#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using st = string;
using ch = char;
const ll MOD = 1000000007;
const ll MOD2 = 998244353;
const ld PI = acos(-1);
const ll INF = 1e18;
st abc = "abcdefghijklmnopqrstuvwxyz";
st ABC = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
struct edge {
  ll to, cost;
};
struct edge2 {
  ll from, to, cost;
};
ll gcd(ll a, ll b) {
  if (a % b == 0) {
    return b;
  } else {
    return gcd(b, a % b);
  }
}
ll pow_mod(ll x, ll y) {
  if (y == 0) {
    return 1;
  } else if (y % 2 == 0) {
    ll t = pow_mod(x, y / 2);
    return t * t % MOD;
  } else {
    return pow_mod(x, y - 1) * x % MOD;
  }
}
int main() {
  int N;
  cin >> N;
  vector<ll> A(N), B(N);
  map<pair<ll, ll>, ll> p;
  for (ll i = 0; i < N; i++) {
    ll a, b;
    cin >> a >> b;
    if (a * b == 0) {
      if (a != 0) {
        a = 1;
      } else if (b != 0) {
        b = 1;
      }
    } else {
      ll x = gcd(a, b);
      a /= x;
      b /= x;
      if (a < 0) {
        a *= -1;
        b *= -1;
      }
    }
    A[i] = a;
    B[i] = b;
    p[{a, b}]++;
  }
  ll ans = 1;
  ll Z = 0;
  for (auto t : p) {
    auto key = t.first;
    auto value = t.second;
    ll x0 = key.first, x1 = key.second;
    ll z;
    p[{x0, x1}] = 0;
    if (value <= 0) {
      continue;
    }
    if (!(x0 == x1 && x0 == 0)) {
      if (x0 * x1 != 0) {
        z = p[{abs(x1), -x1 / abs(x1) * x0}];
        p[{abs(x1), -x1 / abs(x1) * x0}] = 0;
      } else if (x0 == 0) {
        z = p[{1, 0}];
        p[{1, 0}] = 0;
      } else {
        z = p[{0, 1}];
        p[{0, 1}] = 0;
      }
      ans = ans * (pow_mod(2, z) + (ll)pow_mod(2, value) - 1) % MOD;
    } else {
      Z = value;
      p[{0, 0}] = 0;
    }
  }
  cout << (ans + Z - 1) % MOD << endl;
}
