For the first sample, there’re 4 possible situations:
All the switches is off, no light is bright, X^3 = 0.
Only the first switch is on, the first light is bright, X^3 = 1.
Only the second switch is on, all the lights are bright, X^3 = 8.
All the switches is on, the second lights are bright, X^3 = 1.
Therefore, the answer is E[X^3] × 2^2 mod (10^9 + 7) = 10.
For the second sample, there’re 2 possible situations:
The switches is off, no light is bright, X^3 = 0.
The switches is on, all the lights are bright, X^3 = 27.
Therefore, the answer is E[X^3] × 2^1 mod (10^9 + 7) = 27.