#include <iostream>

using namespace std;

int main() {
  int N;
  cin >> N;

  int count = 0;
  for (int i = 1; i <= N; i++) {
    int x, y;
    cin >> x >> y;
    if (x != 0 && y != 0) {
      count++;
    }
  }

  if (count == 0) {
    cout << 0 << endl;
  } else {
    cout << (count * (count - 1) / 2) % (1000000007) << endl;
  }

  return 0;
}