#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
long long gcd(long long a, long long b) {
  if (a >= b) {
    if (b == 0) {
      return a;
    } else {
      return gcd(a % b, b);
    }
  } else {
    if (a == 0) {
      return b;
    } else {
      return gcd(a, b % a);
    }
  }
}
int main() {
  int n;
  cin >> n;
  map<pair<long long, long long>, int> p;
  long long ret = 1;
  for (int i = 1; i <= n; i++) {
    long long a, b;
    cin >> a >> b;
    a = a / gcd(a, b);
    b = b / gcd(a, b);
    if (a < 0) {
      a = a * (-1);
      b = b * (-1);
    }
    if ((p[pair<long long, long long>(a, b)] != 0) &&
        (p[pair<long long, long long>(b, a)] != 0)) {
      ret = (ret * 2) % mod;
    }
    p[pair<long long, long long>(a, b)]++;
    p[pair<long long, long long>(b, a)]++;
  }
  cout << ret - 1;
  return 0;
}
