Please forgive us, we could'nt come up with any story.Just solve this Boring Question to get 100 points :).
There is a N X M array of switches controlling N X M matrix of bulbs .
Initially, all the bulbs are in OFF state, You just have to turn all the bulbs ON, but there is a defect in the switch system.
If any one of the switches is toggled(OFF to ON and vice versa) all the switches of adjacent bulbs also gets toggled(including the bulbs which are diagonal to it) thereby turning them ON also
So, it becomes an easy task now, tell us the number of minimum toggles required to turn all the bulbs ON.
First Line of each test case tells the total number of cases T. The next T lines gives the value of N X M
Print the minimum number of toggels required to turn all the lights ON. Changing line after every Case.
1 <= T <= 1000000
0<= N <= 10^9
0<= M <= 10^9
All the cases are Obvious except the 4th. For the 4th you will require minimum 2 toggles to turn all the bulbs ON. (solution is to toggle the first and the last bulb).