#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e18;
long long gcd(long long a, long long b) { return (b == 0) ? a : gcd(b, a % b); }
long long powmod(long long a, long long x) {
  if (x == 0) return 1;
  long long r = powmod(a, x / 2);
  return (x % 2) ? (r * r % MOD) * a % MOD : r * r % MOD;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  long long n;
  cin >> n;
  map<pair<long long, long long>, pair<long long, long long> > mp;
  for (long long i = (0); i < (n); i++) {
    long long a, b;
    cin >> a >> b;
    if (a == 0 && b == 0) continue;
    if (a == 0) {
      if (mp.find(pair<long long, long long>(0, 1)) == mp.end())
        mp[pair<long long, long long>(0, 1)] = pair<long long, long long>(0, 0);
      mp[pair<long long, long long>(0, 1)] = pair<long long, long long>(
          mp[pair<long long, long long>(0, 1)].first + 1,
          mp[pair<long long, long long>(0, 1)].second);
    } else if (b == 0) {
      if (mp.find(pair<long long, long long>(0, 1)) == mp.end())
        mp[pair<long long, long long>(0, 1)] = pair<long long, long long>(0, 0);
      mp[pair<long long, long long>(0, 1)] = pair<long long, long long>(
          mp[pair<long long, long long>(0, 1)].first,
          mp[pair<long long, long long>(0, 1)].second + 1);
    } else {
      if (b < 0) {
        a *= -1;
        b *= -1;
      }
      long long g = gcd(abs(a), abs(b));
      a /= g;
      b /= g;
      if (a > 0) {
        if (mp.find(pair<long long, long long>(a, b)) == mp.end())
          mp[pair<long long, long long>(a, b)] =
              pair<long long, long long>(0, 0);
        mp[pair<long long, long long>(a, b)] = pair<long long, long long>(
            mp[pair<long long, long long>(a, b)].first + 1,
            mp[pair<long long, long long>(a, b)].second);
      } else {
        long long tmp = a;
        a = b;
        b = -tmp;
        if (mp.find(pair<long long, long long>(a, b)) == mp.end())
          mp[pair<long long, long long>(a, b)] =
              pair<long long, long long>(0, 0);
        mp[pair<long long, long long>(a, b)] = pair<long long, long long>(
            mp[pair<long long, long long>(a, b)].first,
            mp[pair<long long, long long>(a, b)].second + 1);
      }
    }
  }
  long long ans = 1;
  for (auto it = mp.begin(); it != mp.end(); it++) {
    auto p = (*it).second;
    long long l = p.first;
    long long r = p.second;
    ans *= ((powmod(2, l) + powmod(2, r)) % MOD + MOD - 1) % MOD;
    ans %= MOD;
  }
  cout << ((ans + MOD - 1) % MOD) << endl;
  return 0;
}
