#include <bits/stdc++.h>
using namespace std;
const int INF = 1 << 30;
const long long int MAX = 1e9 + 7;
void array_show(int *array, int array_n, char middle = ' ') {
  for (int i = 0; i < array_n; i++)
    printf("%d%c", array[i], (i != array_n - 1 ? middle : '\n'));
}
void array_show(long long int *array, int array_n, char middle = ' ') {
  for (int i = 0; i < array_n; i++)
    printf("%lld%c", array[i], (i != array_n - 1 ? middle : '\n'));
}
void array_show(vector<int> &vec_s, int vec_n = -1, char middle = ' ') {
  if (vec_n == -1) vec_n = vec_s.size();
  for (int i = 0; i < vec_n; i++)
    printf("%d%c", vec_s[i], (i != vec_n - 1 ? middle : '\n'));
}
void array_show(vector<long long int> &vec_s, int vec_n = -1,
                char middle = ' ') {
  if (vec_n == -1) vec_n = vec_s.size();
  for (int i = 0; i < vec_n; i++)
    printf("%lld%c", vec_s[i], (i != vec_n - 1 ? middle : '\n'));
}
map<pair<long long int, long long int>, int> m1;
long long int gcd(long long int a, long long int b) {
  if (a < 0) a = -a;
  if (b < 0) b = -b;
  if (a < b) swap(a, b);
  if (b == 0) return a;
  return gcd(b, a % b);
}
long long int pow_mod(long long int p_a, long long int p_n,
                      long long int p_p = 1e9 + 7) {
  long long int p_b = 1, p_t = 1;
  for (; p_b <= p_n; p_b <<= 1)
    ;
  for (p_b >>= 1; p_b > 0; p_b >>= 1) {
    p_t *= p_t;
    if (p_t >= p_p) p_t %= p_p;
    if (p_n & p_b) p_t *= p_a;
    if (p_t >= p_p) p_t %= p_p;
  }
  return p_t;
}
int main() {
  int n, m;
  int i, j, k;
  long long int a, b, c, d;
  long long int s = 1;
  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> a >> b;
    c = gcd(a, b);
    a /= c, b /= c;
    if (a < 0 || (a == 0 && b < 0)) a = -a, b = -b;
    cout << a << " " << b << endl;
    m1[make_pair(a, b)]++;
  }
  for (auto &node : m1) {
    a = node.first.first, b = node.first.second;
    if (a == 0 && b == 0) continue;
    c = pow_mod(2, node.second) - 1;
    swap(a, b);
    b = -b;
    if (a < 0 || (a == 0 && b < 0)) a = -a, b = -b;
    if (m1.find(make_pair(a, b)) != m1.end()) {
      d = m1[make_pair(a, b)];
      if (d == -1) continue;
    } else
      d = 0;
    c += pow_mod(2, d);
    c %= MAX;
    s *= c;
    s %= MAX;
    node.second = -1;
  }
  s--;
  if (s < 0) s += MAX;
  cout << s << endl;
}
