#include <bits/stdc++.h>
using namespace std;
const int N = 1e4 + 10;
const long long mod = 1e9 + 7;
inline long long gcd(long long a, long long b) {
  return !b ? a : gcd(b, a % b);
}
inline long long q_pow(long long a, long long x) {
  long long ans = 1, tmp = a;
  while (x) {
    if (x & 1) (ans *= tmp) %= mod;
    (tmp *= tmp) %= mod;
    x >>= 1;
  }
  return ans;
}
template <typename T>
inline void re(T &N) {
  int f = 1;
  char c;
  while ((c = getchar()) < '0' || c > '9')
    if (c == '-') f = -1;
  N = c - '0';
  while ((c = getchar()) >= '0' && c <= '9') N = N * 10 + c - '0';
  N *= f;
}
template <class T, class... T_>
inline void re(T &x, T_ &...y) {
  re(x), re(y...);
}
int m, n, t = 1, st, en;
const int eps = 1e-9;
const int PI = 3.14159265358979323846;
int sign(int a) { return a < -eps ? -1 : a > eps; }
int cmp(int a, int b) { return sign(a - b); }
int zero(int a) { return -eps < a && a < eps; }
struct L;
struct S;
struct Po;
struct C;
struct P {
  int x, y;
  P() {}
  P(int _x, int _y) : x(_x), y(_y) {}
  P operator+(P p) { return P(x + p.x, y + p.y); }
  P operator-(P p) { return P(x - p.x, y - p.y); }
  P operator*(int d) { return P(x * d, y * d); }
  P operator/(int d) { return P(x / d, y / d); }
  int operator^(P p) { return x * p.y - y * p.x; }
  bool operator||(P o) { return zero(det(o)); }
  bool operator<(P o) { return x < o.x || (x == o.x && y < o.y); }
  bool operator==(P o) { return zero(x - o.x) && zero(y - o.y); }
  int len() { return sqrt(x * x + y * y); }
  int dot(P p) { return x * p.x + y * p.y; }
  int det(P p) { return x * p.y - y * p.x; }
  int ang(P p) { return acos((x * p.x + y * p.y) / len() / p.len()); }
  int quad() { return sign(y) == 1 || (sign(y) == 0 && sign(x) >= 0); }
  P rot(int rad) {
    return P(x * cos(rad) - y * sin(rad), x * sin(rad) + y * cos(rad));
  }
  P Nol() {
    int l = len();
    return P(x / l, y / l);
  }
  friend ostream &operator<<(ostream &o, P p) { return o << p.x << ' ' << p.y; }
};
P a[N];
int f[N][4][4][4];
int main() {
  re(n);
  for (int i = 1; i <= n; i++) re(a[i].x, a[i].y);
  for (int i = 1; i <= n; i++)
    for (int j = i + 1; j <= n; j++) {
      int dx = ((a[j].x - a[i].x) % 4 + 4) % 4;
      int dy = ((a[j].y - a[i].y) % 4 + 4) % 4;
      int b = gcd(abs(a[i].x - a[j].x), abs(a[i].y - a[j].y)) % 4;
      f[i][dx][dy][b]++;
      f[j][(4 - dx) % 4][(4 - dy) % 4][b]++;
    }
  long long sum[2][2] = {};
  for (int x1 = 0; x1 < 4; x1++)
    for (int y1 = 0; y1 < 4; y1++)
      for (int x2 = 0; x2 < 4; x2++)
        for (int y2 = 0; y2 < 4; y2++) {
          if (x1 % 2 != x2 % 2 || y1 % 2 != y2 % 2) continue;
          int b3 = (x1 == x2 && y1 == y2) ? 0 : 2;
          int S = ((x1 * y2 - x2 * y1) % 4 + 4) % 4;
          for (int b1 = 0; b1 < 4; b1++) {
            int b2 = (S - b3 - b1 + 8) % 4;
            if (b1 & 1) {
              if (x1 == x2 && y1 == y2 && b1 == b2) {
                for (int i = 1; i <= n; i++)
                  sum[0][1] +=
                      1ll * f[i][x1][y1][b1] * (f[i][x1][y1][b1] - 1) / 2;
              } else {
                for (int i = 1; i <= n; i++)
                  sum[0][0] += 1ll * f[i][x1][y1][b1] * f[i][x2][y2][b2];
              }
            } else {
              if (x1 == x2 && y1 == y2 && b1 == b2) {
                for (int i = 1; i <= n; i++)
                  sum[1][1] +=
                      1ll * f[i][x1][y1][b1] * (f[i][x1][y1][b1] - 1) / 2;
              } else {
                for (int i = 1; i <= n; i++)
                  sum[1][0] += 1ll * f[i][x1][y1][b1] * f[i][x2][y2][b2];
              }
            }
          }
        }
  assert(!(sum[0][0] % 2));
  assert(!(sum[1][0] % 2));
  assert(!((sum[1][0] / 2 + sum[1][1]) % 3));
  printf("%lld\n", sum[0][0] / 2 + sum[0][1] + (sum[1][0] / 2 + sum[1][1]) / 3);
}
