#include <bits/stdc++.h>
using namespace std;
template <class T = int>
T in() {
  T x;
  cin >> x;
  return (x);
}
template <class T>
void print(T& x) {
  cout << x << '\n';
}
const int MOD = (int)1e9 + 7;
const int mod = (int)998244353;
const int MAX = 510000;
long long fac[MAX], finv[MAX], inv[MAX];
void COMint() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; i++) {
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}
long long COM(int n, int k) {
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
long long gcd(long long a, long long b) {
  if (b == 0) return a;
  if (a > b) {
    swap(a, b);
  }
  return gcd(a, b % a);
}
long long lcm(long long a, long long b) {
  if (a < 0) a = -a;
  if (b < 0) b = -b;
  long long g;
  g = gcd(a, b);
  return b / g * a;
}
bool compare_by_b(pair<int, int> a, pair<int, int> b) {
  if (a.second != b.second) {
    return a.second < b.second;
  } else {
    return a.first < b.first;
  }
}
bool compare_by_a(pair<int, int> a, pair<int, int> b) {
  if (a.first != b.first) {
    return a.first < b.first;
  } else {
    return a.second < b.second;
  }
}
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
long long RS(long long N, long long pair<int, int>, long long m) {
  if (pair<int, int> == 0) {
    return 1;
  } else {
    if (pair<int, int> % 2 == 0) {
      long long t = RS(N, pair<int, int> / 2, m);
      return t * t % m;
    } else {
      return N * RS(N, pair<int, int> - 1, m) % m;
    }
  }
}
bool greater_pair(pair<long long, long long> a, pair<long long, long long> b) {
  if (a.first != b.first) {
    return a.first > b.first;
  } else {
    return a.second > b.second;
  }
}
struct mint {
  long long x;
  mint(long long x = 0) : x((x % mod + mod) % mod) {}
  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 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;
  }
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x; }
ostream& operator<<(ostream& os, const mint& a) { return os << a.x; }
struct combination {
  vector<mint> fact, ifact;
  combination(int n) : fact(n + 1), ifact(n + 1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i - 1] * i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i - 1] = ifact[i] * i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n] * ifact[k] * ifact[n - k];
  }
} c(2000005);
int main() {
  ios::sync_with_stdio(false);
  long long N;
  cin >> N;
  vector<pair<long long, long long>> vec;
  map<pair<long long, long long>, long long> m;
  long long zero = 0;
  long long a_zero = 0;
  long long b_zero = 0;
  long long ryoukou = 0;
  vector<long long> nakawaru;
  for (int i = 0; i < (N); ++i) {
    long long a, b;
    cin >> a >> b;
    if (a == 0 && b == 0) {
      zero++;
    } else if (a == 0) {
      a_zero++;
    } else if (b == 0) {
      b_zero++;
    } else {
      if (gcd(abs(a), abs(b)) > 1) {
        long long g = gcd(abs(a), abs(b));
        a = a / g;
        b = b / g;
      }
      m[make_pair(a, b)] = m[make_pair(a, b)] + 1;
    }
  }
  for (auto iter = m.begin(); iter != m.end(); iter++) {
    pair<long long, long long> p = iter->first;
    long long a = p.first;
    long long b = p.second;
    long long sei = m[make_pair(a, b)] + m[make_pair(-a, -b)];
    long long fu = m[make_pair(-b, a)] + m[make_pair(b, -a)];
    if (sei == 0) continue;
    if (fu == 0) {
      ryoukou += m[make_pair(a, b)];
    } else {
      long long waru;
      waru = RS(2, sei, MOD);
      waru += RS(2, fu, MOD);
      waru--;
      nakawaru.push_back(waru % MOD);
      m[make_pair(a, b)] = 0;
      m[make_pair(-a, -b)] = 0;
      m[make_pair(-b, a)] = 0;
      m[make_pair(b, -a)] = 0;
    }
  }
  long long ans;
  ans = RS(2, ryoukou, MOD);
  for (int i = 0; i < (nakawaru.size()); ++i) {
    ans *= nakawaru[i];
    ans %= MOD;
  }
  ans *= (RS(2, b_zero, MOD) + RS(2, a_zero, MOD) - 1) % MOD;
  ans %= MOD;
  ans %= MOD;
  ans--;
  cout << ans << endl;
  return 0;
}
