#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <climits>
#include <iomanip>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
double mod = 1000000007;
long long power(double m,double n){
    double res = 1;
    if(n > 0){
        res = power(m,n / 2);
        if((long long)n % 2 == 0){
            res = (long long)(res * res) % mod;
        }
        else{
            res = (long long)(((long long)(res * res) % mod) * m) % mod;
        }
    }
    return res;
}
int main(){
  double n = 0;
  cin >> n;
  map<double,double> count;
  for(int i = 0;i < n;i++){
    double a,b;
    cin >> a >> b;
    if(b != 0)count[(double)a / b]++;
    else count[0]++;
    //cout << a / b << endl;
  }
  if(n == 1){
    cout << 1 << endl;
    return 0;
  }
  double res = 0;
  res = 1;
  double pair = 0;
  //res = power(2,n) - 1;
  if(res < 0)res += mod;
  for(auto& item:count){
    //cout << item.first << " "<< item.second<< endl;
    if(item.first >= 0)continue;
    double now = 0;
    //now = item.second * count[(double)-1 / item.first];
    //cout << now << endl;
    now += item.second + count[(double)-1 / item.first];
    if(item.second <= 0 || count[(double)-1 / item.first] <= 0)continue;
    pair += now;
    now = pow(2,item.second) - 1 + pow(2,count[(double)-1 / item.first]) - 1;
    now++;
    //ll mai = 0;
    //mai = now * power(2,n - 2);
    //mai %= mod;
    res *= now;
    res %= mod;
    //while(res < 0)res += mod;
    //cout << now << endl;
  }
  //cout << res << endl;
  res *= count[0] + 1;
  pair += count[0];
  //cout << res << endl;
  //cout << "p" << pair << endl;
  //cout << res << endl;
  res *= pow(2,n - pair);
  res %= mod;
  res--;
  if(res < 0)res += mod;
  cout << (ll)res << endl;
}