#include <bits/stdc++.h>
using namespace std;
template <typename T>
using minpq = priority_queue<T, vector<T>, greater<T>>;
const long long MOD = 1000000007LL;
int ni() {
  int x;
  cin >> x;
  return x;
}
long long nl() {
  long long x;
  cin >> x;
  return x;
}
double nd() {
  double x;
  cin >> x;
  return x;
}
string next() {
  string x;
  cin >> x;
  return x;
}
long long choose(long long n, long long k) {
  if (n < k) return 0LL;
  if (k == 2)
    return n * (n - 1) / 2;
  else
    return n * (n - 1) * (n - 2) / 6;
}
int boundary(int x1, int y1, int x2, int y2) {
  if (x1 == x2 && y1 == y2)
    return 0;
  else
    return 2;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N = ni();
  long long cnt[2][2];
  for (int i = 0; i < (2); i++)
    for (int j = 0; j < (2); j++) {
      cnt[i][j] = 0LL;
    }
  for (int i = 0; i < (N); i++) {
    int x = ni();
    int y = ni();
    cnt[(x % 4) / 2][(y % 4) / 2] += 1;
  }
  long long ans = 0;
  for (int s1 = 0; s1 < 4; s1++) {
    for (int s2 = s1; s2 < 4; s2++) {
      for (int s3 = s2; s3 < 4; s3++) {
        int x1 = s1 / 2;
        int y1 = s1 % 2;
        int x2 = s2 / 2;
        int y2 = s2 % 2;
        int x3 = s3 / 2;
        int y3 = s3 % 2;
        int b1 = boundary(x1, y1, x2, y2);
        int b2 = boundary(x1, y1, x3, y3);
        int b3 = boundary(x2, y2, x3, y3);
        int B = (b1 + b2 + b3) % 4;
        if (B == 0) {
          if (s1 == s2 && s2 == s3) {
            ans += choose(cnt[x1][y1], 3);
          } else if (s1 == s2) {
            ans += choose(cnt[x1][y1], 2) * cnt[x3][y3];
          } else if (s2 == s3) {
            ans += choose(cnt[x2][y2], 2) * cnt[x1][y1];
          }
        }
      }
    }
  }
  cout << ans << '\n';
}
