
The great Dutch painter Piet Mondriaan (1872–1944) is regarded as one of the first modern painters. Many of his compositions are divided into several rectangular regions. Some regions are filled with a color, while the others are left white.
Mondriaan's colorings usually obey the following rules:
Once a painting has been divided into regions, there are still many ways to fill them with colors. For a given division, determine how many different colorings are possible. For the paintings considered here, this number does not exceed $10^6$.
Two regions that touch only at a corner point are not considered adjacent.
The first line contains a single integer: the number of test cases. Each test case has the following format:
For each test case, output on a single line the number of ways the painting can be colored.