#include <bits/stdc++.h>
using namespace std;
inline char gc() {
  static char buf[100000], *p1 = buf, *p2 = buf;
  return p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 100000, stdin), p1 == p2)
             ? EOF
             : *p1++;
}
inline int read() {
  int x = 0;
  char ch = getchar();
  bool positive = 1;
  for (; !isdigit(ch); ch = getchar())
    if (ch == '-') positive = 0;
  for (; isdigit(ch); ch = getchar()) x = x * 10 + ch - '0';
  return positive ? x : -x;
}
inline void write(long long x) {
  if (x < 0) x = -x, putchar('-');
  if (x > 9) write(x / 10);
  putchar(x % 10 + '0');
}
inline void writeln(long long x) {
  write(x);
  puts("");
}
struct Node {
  int x, y, w;
} a, b, c, g[6005];
int n, x, y, S, m[5][5], f[5][5][5];
long long now1, now2, ans1, ans2, ans3;
inline int gcd(int x, int y) { return x % y ? gcd(y, x % y) : y; }
int main() {
  n = read();
  for (int i = 1; i <= n; i++) {
    g[i].x = read();
    g[i].y = read();
  }
  for (int i = 1; i <= n; i++) {
    memset(f, 0, sizeof f);
    a.x = (g[i].x + 3) % 4 + 1;
    a.y = (g[i].y + 3) % 4 + 1;
    for (int j = 1; j <= n; j++) {
      if (i != j) {
        if (abs(g[i].x - g[j].x) * abs(g[i].y - g[j].y)) {
          f[(g[j].x + 3) % 4 + 1][(g[j].y + 3) % 4 + 1]
           [(gcd(abs(g[i].x - g[j].x), abs(g[i].y - g[j].y)) + 3) % 4 + 1]++;
        } else {
          f[(g[j].x + 3) % 4 + 1][(g[j].y + 3) % 4 + 1]
           [(abs(g[i].x - g[j].x) + abs(g[i].y - g[j].y) + 3) % 4 + 1]++;
        }
      }
    }
    for (int j = 0; j < 16; j++) {
      b.x = j / 4 + 1;
      b.y = j % 4 + 1;
      for (b.w = 1; b.w <= 4; b.w++) {
        now1 = f[b.x][b.y][b.w];
        f[b.x][b.y][b.w]--;
        for (int k = 0; k < 16; k++) {
          c.x = k / 4 + 1;
          c.y = k % 4 + 1;
          S = a.x * (b.y - c.y) + b.x * (c.y - a.y) + c.x * (a.y - b.y);
          if (S & 1) continue;
          S /= 2;
          for (c.w = (b.w + 1) % 2 + 1; c.w <= 4; c.w += 2) {
            now2 = now1 * f[c.x][c.y][c.w];
            a.w = gcd(abs(b.x - c.x) + 4, abs(b.y - c.y) + 4);
            if ((S + (a.w + b.w + c.w) / 2) & 1) continue;
            if (b.w % 2 + c.w % 2) {
              ans1 += now2;
            } else {
              ans2 += now2;
            }
          }
        }
        f[b.x][b.y][b.w]++;
      }
    }
  }
  writeln(ans1 / 2 + ans2 / 6);
  return 0;
}
