Problem:
Score: 500 points

Problem Statement

We have caught N sardines. The deliciousness and fragrantness of the i-th sardine is A_i and B_i, respectively.

We will choose one or more of these sardines and put them into a cooler. However, two sardines on bad terms cannot be chosen at the same time.

The i-th and j-th sardines (i \neq j) are on bad terms if and only if A_i \cdot A_j + B_i \cdot B_j = 0.

In how many ways can we choose the set of sardines to put into the cooler? Since the count can be enormous, print it modulo 1000000007.

Constraints

All values in input are integers.

1 \leq N \leq 2 \times 10^5

-10^{18} \leq A_i, B_i \leq 10^{18}

Input

Input is given from Standard Input in the following format:

N
A_1 B_1
:
A_N B_N

Output

Print the count modulo 1000000007.

Sample Input 1

3
1 2
-1 1
2 -1

Sample Output 1

5

There are five ways to choose the set of sardines, as follows:

The 1-st

The 1-st and 2-nd

The 2-nd

The 2-nd and 3-rd

The 3-rd

Sample Input 2

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

Sample Output 2

479

Solution in C++ (Clang 10.0.0) (judge verdict: Accepted)

/*  -*- coding: utf-8 -*-
 *
 * e.cc: E - ∙ (Bullet)
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 200000;
const int MOD = 1000000007;

/* typedef */

typedef long long ll;
typedef pair<ll,ll> pll;
typedef map<pll,int> mpli;

/* global variables */

mpli ms;

/* subroutines */

template <typename T>
T gcd(T m, T n) {  // m > 0, n > 0
  if (m < n) swap(m, n);
  while (n > 0) {
    T r = m % n;
    m = n;
    n = r;
  }
  return m;
}

int powmod(int a, int n) {  // a^n % MOD
  int pm = 1;
  while (n > 0) {
    if (n & 1) pm = (ll)pm * a % MOD;
    a = (ll)a * a % MOD;
    n >>= 1;
  }
  return pm;
}

/* main */

int main() {
  int n;
  scanf("%d", &n);

  int zn = 0;
  for (int i = 0; i < n; i++) {
    ll a, b;
    scanf("%lld%lld", &a, &b);

    if (a == 0) {
      if (b == 0) zn++;
      else ms[pll(0, 1)]++;
    }
    else {
      if (b == 0) ms[pll(1, 0)]++;
      else {
	if (a < 0) a = -a, b = -b;
	ll g = gcd<ll>(a, abs(b));
	a /= g, b /= g;
	ms[pll(a, b)]++;
      }
    }
  }

  int p = 1;
  for (mpli::iterator mit = ms.begin(); mit != ms.end(); mit++)
    if (mit->second > 0) {
      int pp = powmod(2, mit->second);

      ll a = mit->first.first, b = mit->first.second;
      ll a0, b0;
      if (a == 0) a0 = 1, b0 = 0;
      else if (b == 0) a0 = 0, b0 = 1;
      else {
	a0 = b, b0 = -a;
	if (a0 < 0) a0 = -a0, b0 = -b0;
      }

      mpli::iterator mit0 = ms.find(pll(a0, b0));
      if (mit0 != ms.end() && mit0->second > 0) {
	pp = (pp + (powmod(2, mit0->second) + MOD - 1) % MOD) % MOD;
	mit0->second = 0;
      }

      p = (ll)p * pp % MOD;
    }

  int sum = (zn + (p + MOD - 1) % MOD) % MOD;
  printf("%d\n", sum);
  return 0;
}