#include <bits/stdc++.h>
using namespace std;
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
const int MOD = 1000000007;
struct mint {
  long long x;
  mint(long long 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 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 gcd(const long long sx, const long long sy) {
  long long x = min(sx, sy);
  long long y = max(sx, sy);
  long long tmp;
  while (x > 0) {
    tmp = y;
    y = x;
    x = tmp % x;
  }
  return y;
}
vector<long long> as;
vector<long long> bs;
map<pair<long long, long long>, set<int>> ms;
vector<pair<long long, long long>> ps;
int group_no;
vector<int> groups;
map<int, int> opposite_group;
map<int, int> group_size;
mint solve(const int group_no_pairs, const int group_no_any, const int N) {
  mint ans(1);
  vector<bool> used(group_no_pairs, false);
  for (int i = 0; i < group_no_pairs; i++) {
    if (used[i]) continue;
    mint acc(1);
    acc += mint(2).pow(group_size[i]) - 1;
    acc += mint(2).pow(group_size[opposite_group[i]]) - 1;
    ans *= acc;
    used[i] = true;
    used[opposite_group[i]] = true;
  }
  ans *= mint(2).pow(group_size[group_no_any]);
  ans -= 1;
  return ans;
}
int main(void) {
  int N;
  cin >> N;
  as.resize(N);
  bs.resize(N);
  for (int i = 0; i < N; i++) {
    cin >> as[i] >> bs[i];
  }
  ps.resize(N);
  for (int i = 0; i < N; i++) {
    long long g = gcd(abs(as[i]), abs(bs[i]));
    if (g == 0) g = 1;
    long long bunshi = as[i] / g;
    long long bunbo = bs[i] / g;
    if (bunbo == 0 && bunshi != 0) {
      bunshi = 1;
    } else if (bunbo != 0 && bunshi == 0) {
      bunbo = 1;
    }
    if ((bunshi < 0 && bunbo > 0) || (bunshi > 0 && bunbo < 0)) {
      bunshi = -1 * abs(bunshi);
      bunbo = abs(bunbo);
    }
    ps[i] = {bunshi, bunbo};
    ms[ps[i]].insert(i);
  }
  groups.resize(N, -1);
  for (int i = 0; i < N; i++) {
    long long my_bunshi = ps[i].first;
    long long my_bunbo = ps[i].second;
    long long other_bunshi = my_bunbo;
    long long other_bunbo = my_bunshi;
    if (other_bunbo > 0) {
      other_bunshi *= -1;
    } else {
      other_bunbo *= -1;
    }
    int other_group = -1;
    if (groups[i] >= 0 || (my_bunshi == 0 && my_bunbo == 0)) {
      continue;
    }
    for (auto& other_ind : ms[{other_bunshi, other_bunbo}]) {
      if (groups[i] < 0 && groups[other_ind] < 0) {
        int my_group = group_no++;
        groups[i] = my_group;
        other_group = group_no++;
        groups[other_ind] = other_group;
        opposite_group[my_group] = other_group;
        opposite_group[other_group] = my_group;
      } else if (groups[i] < 0 && groups[other_ind] >= 0) {
        other_group = groups[other_ind];
        int my_group = opposite_group[other_group];
        groups[i] = my_group;
      } else if (groups[i] >= 0 && groups[other_ind] < 0) {
        int my_group = groups[i];
        other_group = opposite_group[my_group];
        groups[other_ind] = other_group;
      } else {
      }
    }
    for (auto& same_ind : ms[{my_bunshi, my_bunbo}]) {
      groups[same_ind] = groups[i];
    }
  }
  int group_no_pairs = group_no - 1;
  int group_no_zero = group_no++;
  opposite_group[group_no_zero] = -1;
  for (int i = 0; i < N; i++) {
    long long my_bunshi = ps[i].first;
    long long my_bunbo = ps[i].second;
    if (my_bunshi == 0 && my_bunbo == 0) {
      groups[i] = group_no_zero;
    }
  }
  int group_no_any = group_no++;
  opposite_group[group_no_any] = -1;
  for (int i = 0; i < N; i++) {
    if (groups[i] < 0) {
      groups[i] = group_no_any;
    }
  }
  for (int i = 0; i < N; i++) {
    group_size[groups[i]]++;
  }
  mint ans = solve(group_no_pairs, group_no_any, N);
  ans += group_size[group_no_zero];
  cout << ans.x << endl;
  return 0;
}
