#include <bits/stdc++.h>
using namespace std;
void Ans(bool x) {
  if (x)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}
const long long int INF = 1001001001;
const long long int mod = 1000000007;
struct mint {
  long long int x;
  mint(long long int x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod - a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res -= a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res *= a;
  }
  mint pow(long long int t) const {
    if (!t) return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1) a *= *this;
    return a;
  }
  mint inv() const { return pow(mod - 2); }
  mint& operator/=(const mint a) { return (*this) *= a.inv(); }
  mint operator/(const mint a) const {
    mint res(*this);
    return res /= a;
  }
};
long long int gcd(long long int a, long long int b) {
  if (a < 0) return gcd((-1) * a, b);
  if (b < 0) return gcd(a, (-1) * b);
  if (b < a) return gcd(b, a);
  if (b % a == 0) return a;
  return gcd(b % a, a);
}
int main() {
  long long int n;
  cin >> n;
  long long int a, b;
  pair<int, int> v[n];
  vector<pair<int, int> > vc;
  map<pair<int, int>, int> mp;
  for (int i = 0; i < (int)(n); i++) {
    cin >> a >> b;
    int ch = 0;
    long long int g = gcd(a, b);
    v[i] = pair<int, int>(a / g, b / g);
    if (mp[pair<int, int>(a / g, b / g)] == 0 &&
        mp[pair<int, int>((-1) * a / g, (-1) * b / g)] == 0 &&
        mp[pair<int, int>((-1) * b / g, a / g)] == 0 &&
        mp[pair<int, int>(b / g, (-1) * a / g)] == 0) {
      ch++;
    }
    if (a > 0 && b > 0) {
      mp[pair<int, int>(a / g, b / g)]++;
      if (ch != 0) vc.push_back(pair<int, int>(a / g, b / g));
    } else if (a < 0 && b < 0) {
      mp[pair<int, int>((-1) * a / g, (-1) * b / g)]++;
      if (ch != 0) vc.push_back(pair<int, int>((-1) * a / g, (-1) * b / g));
    } else if (a > 0 && b < 0) {
      mp[pair<int, int>(a / g, b / g)]++;
      if (ch != 0) vc.push_back(pair<int, int>(a / g, b / g));
    } else if (a < 0 && b > 0) {
      mp[pair<int, int>((-1) * a / g, (-1) * b / g)]++;
      if (ch != 0) vc.push_back(pair<int, int>((-1) * a / g, (-1) * b / g));
    }
  }
  mint ans = 1;
  mint d = 2;
  for (auto p : vc) {
    long long int j = mp[p];
    long long int k = max(mp[pair<int, int>(p.second, (-1) * p.first)],
                          mp[pair<int, int>((-1) * p.second, p.first)]);
    ans *= (d.pow(j) + d.pow(k) - 1);
  }
  ans -= 1;
  cout << ans.x << endl;
}
