#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
const long long INF = INT64_MAX;
long long euclid(long long x, long long y) {
  long long a = max(x, y);
  long long b = min(x, y);
  if (a % b == 0)
    return b;
  else {
    return euclid(b, a % b);
  }
}
long long ruijou(long long x, long long y) {
  if (y == 0)
    return 1;
  else if (y % 2 == 0)
    return ruijou(x * x % mod, y / 2);
  else
    return x * ruijou(x, y - 1) % mod;
}
long long i, j, k;
int main() {
  long long N;
  cin >> N;
  vector<long long> A(N), B(N);
  for (long long i = 0; i < N; i++) cin >> A[i] >> B[i];
  map<pair<long long, long long>, pair<long long, long long> > kosuu;
  for (long long i = 0; i < N; i++) {
    if (A[i] == 0 && B[i] == 0)
      continue;
    else if (A[i] == 0) {
      if (kosuu.count(pair<long long, long long>(1, 0)))
        kosuu[pair<long long, long long>(1, 0)].first++;
      else {
        kosuu[pair<long long, long long>(1, 0)].first = 1;
        kosuu[pair<long long, long long>(1, 0)].second = 0;
      }
    } else if (B[i] == 0) {
      if (kosuu.count(pair<long long, long long>(1, 0)))
        kosuu[pair<long long, long long>(1, 0)].second++;
      else {
        kosuu[pair<long long, long long>(1, 0)].first = 0;
        kosuu[pair<long long, long long>(1, 0)].second = 1;
      }
    } else {
      if ((A[i] > 0 && B[i] > 0) || (A[i] < 0 && B[i] < 0)) {
        long long a = abs(A[i]);
        long long b = abs(B[i]);
        long long gcd = euclid(a, b);
        if (kosuu.count(pair<long long, long long>(a / gcd, b / gcd)))
          kosuu[pair<long long, long long>(a / gcd, b / gcd)].first++;
        else {
          kosuu[pair<long long, long long>(a / gcd, b / gcd)].first = 1;
          kosuu[pair<long long, long long>(a / gcd, b / gcd)].second = 0;
        }
      } else {
        long long a = abs(A[i]), b = abs(B[i]);
        long long gcd = euclid(a, b);
        if (kosuu.count(pair<long long, long long>(b / gcd, a / gcd)))
          kosuu[pair<long long, long long>(b / gcd, a / gcd)].second++;
        else {
          kosuu[pair<long long, long long>(b / gcd, a / gcd)].first = 0;
          kosuu[pair<long long, long long>(b / gcd, a / gcd)].second = 1;
        }
      }
    }
  }
  long long ans;
  for (auto itr = kosuu.begin(); itr != kosuu.end(); itr++) {
    if (itr == kosuu.begin()) {
      ans = ruijou(2, itr->second.first) + ruijou(2, itr->second.second) - 1;
      ans %= mod;
    } else {
      long long jud =
          (ruijou(2, itr->second.first) + ruijou(2, itr->second.second) - 1);
      jud %= mod;
      ans = (ans * jud) % mod;
    }
  }
  cout << ans - 1 << endl;
}
