시간 제한 메모리 제한 제출 정답 맞은 사람 정답 비율
1 초 128 MB 2 2 2 100.000%

문제

Being a farmer in Ardenia is a tough job. We do not mean only the dry and hostile environment where they have to pasture sheep. The government (or actually the king himself) wants his people to invade foreign lands rather than to harvest theirs, and thus tries to make the lives of poor farmers as hard as possible. All difficulties start with a seemingly simple task: purchasing a piece of land, called farming parcel.

The whole farming territory is a huge rectangular grid consisting of square fields; a farming parcel consists of some of these fields. At the beginning a farmer buys an initial set of fields; his parcel consists initially just of these fields. However, the actual farming parcel is determined with the help of string and poles, by repeating the following steps.

  1. Stick a pole into the middle of each field from the farming parcel.
  2. Surround the poles with a string, creating the smallest region enclosing all the poles.
  3. The new farming parcel is the set of all fields having a non-empty intersection with this region. A field sharing just the edge or a corner with the region does not count.

Of course, the parcel may only increase by implementing the operation above, so each farmer makes sure these steps are repeated till the farming parcel does not change; we call such a parcel final. An example is depicted below. The initial farming parcel consists of four fields (figure A), after one iteration it grows (figure B), and after another one it becomes final (figure C).

It appears, however, that the final farming parcel would sometimes be the same even if the farmer did not buy all the initial fields but just a subset of them. A subset of this property is called valid. The farmer wants to know in how many ways he may choose a valid subset of initial fields.

The input contains several test cases. The first line of the input contains a positive integer Z ≤ 50, denoting the number of test cases. Then Z test cases follow, each conforming to the format described in section Input. For each test case, your program has to write an output conforming to the format described in section Output.

입력

The first line of the input instance contains a positive integer n ≤ 106, being the number of initial fields of the parcel. Each of the following n lines contain two integers xi, yi ∈ [−109, 109], being the coordinates of these fields. All initial fields are different.

출력

Let k be the number of valid subsets of the initial fields. You should output a line containing the number k mod (109 + 7).

예제 입력

2
4
0 0
0 1
0 2
0 3
5
0 0
-1 0
1 0
0 -1
0 1

예제 출력

4
2

힌트