#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll INF = 1000000007;
int main() {
  int n;
  cin >> n;
  ll sum = (n * (n - 1) / 2) % INF;
  map<ll, double> mp;
  vector<pair<ll, ll>> pa(n);
  for (int i = 0; i < (n); i++) {
    cin >> pa[i].first >> pa[i].second;
    mp[pa[i].first / pa[i].second]++;
  }
  for (auto it : mp) {
    sum -= ((it.first) * (it.first - 1) / 2) % INF;
  }
  cout << sum % INF;
  return 0;
}
