#include <bits/stdc++.h>
using namespace std;
const long long inf = 1e16;
const int mod = 1e9 + 7;
int gcd(int a, int b) {
  a = abs(a);
  b = abs(b);
  while (b) {
    a %= b;
    swap(a, b);
  }
  return a;
}
int f(int x1, int y1, int x2, int y2) { return gcd(x1 - x2, y1 - y2); }
long long cnk(int k, int n) {
  if (k == 1) return n;
  if (k == 2) return (long long)n * (n - 1) / 2;
  if (k == 3) return (long long)n * (n - 1) * (n - 2) / 6;
  return 0;
}
void solve() {
  int n;
  cin >> n;
  vector<vector<int>> c(4, vector<int>(4, 0));
  int x, y;
  for (int i = 0; i < n; i++) {
    cin >> x >> y;
    c[x % 4][y % 4]++;
  }
  long long ans = 0;
  for (int i = 0; i < 16; i += 2) {
    for (int j = i; j < 16; j += 2) {
      for (int k = j; k < 16; k += 2) {
        int x1 = i / 4;
        int y1 = i % 4;
        int x2 = j / 4;
        int y2 = j % 4;
        int x3 = k / 4;
        int y3 = k % 4;
        int yasuo = f(x1, y1, x2, y2) + f(x2, y2, x3, y3) + f(x3, y3, x1, y1);
        if (yasuo % 4 == 0) {
          if (i == j && i == k)
            ans += cnk(3, c[x1][y1]);
          else if (i == j)
            ans += cnk(2, c[x1][y1]) * c[x3][y3];
          else if (i == k)
            ans += cnk(2, c[x1][y1]) * c[x2][y2];
          else if (j == k)
            ans += cnk(2, c[x2][y2]) * c[x1][y1];
          else
            ans += c[x1][y1] * c[x2][y2] * c[x3][y3];
        }
      }
    }
  }
  cout << ans << "\n";
  return;
}
int main(int argc, const char* argv[]) {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int test_cnt = 1;
  for (int test = 1; test <= test_cnt; test++) {
    solve();
  }
  return 0;
}
