PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN

#GL0000362. Chọn cá không xung đột (Bullet)

HỌC THEO LỘ TRÌNH

Bài tập thuộc lộ trình

1 lộ trình

Chọn cá không xung đột (Bullet)

Bullet

Source: AtCoder

Version: Phuoc Hung OJ Extended

Problem Statement

There are NN distinguishable fish. Fish ii has integer attributes (Ai,Bi)(A_i,B_i). Choose a nonempty subset of fish. Order does not matter, and distinct indices remain distinguishable even if their attributes match.

Two fish i≠ji\ne j cannot both be selected if

AiAj+BiBj=0.A_iA_j+B_iB_j=0.

Count all valid nonempty subsets modulo 109+710^9+7. The zero vector (0,0)(0,0) is allowed and has dot product zero with every vector, including another zero vector.

Input

  • First line: integer NN.
  • Next NN lines: integers Ai,BiA_i,B_i.

Output

Print the valid subset count modulo 109+710^9+7.

Subtasks

  • Subtask 1 (20 points): 1<=N<=12;−20<=Ai,Bi<=201 <= N <= 12; -20 <= A_i,B_i <= 20.
  • Subtask 2 (30 points): 1<=N<=5000;−109<=Ai,Bi<=1091 <= N <= 5000; -10^9 <= A_i,B_i <= 10^9.
  • Subtask 3 (50 points): 1<=N<=200000;−1018<=Ai,Bi<=10181 <= N <= 200000; -10^18 <= A_i,B_i <= 10^18.

Examples

Example 1

Input

3
1 2
-1 1
2 -1

Output

5

Explanation

There are 5 valid nonempty subsets: {1}, {2}, {3}, {1,2}, {2,3}. Fish 1 and 3 are perpendicular.

Example 2

Input

10
3 2
3 2
-1 1
2 -1
-3 -9
-8 12
7 7
8 1
8 2
8 4

Output

479

Explanation

After grouping vectors by normalized directions and their perpendicular partners, multiply (2^u+2^v-1) over all groups and subtract the empty subset.