#include <bits/stdc++.h>
using namespace std;
static const long MM = 1000000007;
map<pair<long, long>, long> S;
long power2(long n) {
  long res = 1;
  if (n > 0) {
    res = power2(n / 2);
    if (n % 2 == 0)
      res = (res * res) % MM;
    else
      res = (((res * res) % MM) * 2) % MM;
  }
  return res;
}
long ABO = 0, AO = 0, BO = 0;
pair<long, long> getV(pair<int, int> P) {
  if (P.second < 0)
    return make_pair(-1 * P.second, P.first);
  else
    return make_pair(P.second, -1 * P.first);
}
long getans(map<pair<long, long>, long> *S) {
  if ((*S).empty()) return 1;
  long a = (*S).begin()->second;
  pair<long, long> P = (*S).begin()->first;
  pair<long, long> Q = getV(P);
  long b;
  if ((*S).find(Q) == (*S).end())
    b = 0;
  else {
    b = (*S)[Q];
    (*S).erase(Q);
  }
  (*S).erase(P);
  return ((power2(a) + power2(b) - 1) % MM) * getans(S) % MM;
}
long gcd(long x, long y) {
  x = abs(x);
  y = abs(y);
  long r;
  if (x < y) swap(x, y);
  while (y > 0) {
    r = x % y;
    x = y;
    y = r;
  }
  return x;
}
pair<long, long> getg(long n, long m) {
  if (n > 0) {
    if (m > 0) {
      long g = gcd(n, m);
      return make_pair(n / g, m / g);
    } else {
      long g = gcd(n, m);
      return make_pair(n / g, -1 * (abs(m) / g));
    }
  } else {
    if (m > 0) {
      long g = gcd(n, m);
      return make_pair((abs(n) / g), -1 * (m / g));
    } else {
      long g = gcd(n, m);
      return make_pair((abs(n) / g), (abs(m) / g));
    }
  }
}
int main() {
  long N;
  cin >> N;
  for (int i = 0; i < N; i++) {
    long A, B;
    cin >> A >> B;
    if (A == 0) {
      if (B == 0)
        ABO++;
      else
        AO++;
    } else {
      if (B == 0) BO++;
      pair<long, long> P = getg(A, B);
      if (S.find(P) != S.end())
        S[P]++;
      else
        S.insert(make_pair(P, 1));
    }
  }
  if (AO + BO == 0)
    cout << (ABO + getans(&S) - 1) % MM << endl;
  else
    cout << (((ABO + ((power2(AO) + power2(BO)) % MM)) % MM) + getans(&S)) % MM
         << endl;
  return 0;
}
