#include <bits/stdc++.h>
using namespace std;
int p[4][4][4];
int n, x[6005], y[6005];
long long ans1, ans2;
int dr() {
  int xx = 0;
  char ch = getchar();
  while (ch < '0' || ch > '9') ch = getchar();
  while (ch >= '0' && ch <= '9') xx = xx * 10 + ch - '0', ch = getchar();
  return xx;
}
int gcd(const int &x, const int &y) { return y ? gcd(y, x % y) : x; }
int main() {
  n = dr();
  for (int i = 1; i <= n; i++) x[i] = dr(), y[i] = dr();
  for (int i = 1; i <= n; i++) {
    memset(p, 0, sizeof(p));
    for (int j = 1; j <= n; j++)
      if (i != j) {
        int xx = x[j] - x[i], yy = y[j] - y[i];
        ++p[(xx % 4 + 4) % 4][(yy % 4 + 4) % 4][gcd(abs(xx), abs(yy)) % 4];
      }
    for (int t1 = 0; t1 < 4; t1++)
      for (int t2 = 0; t2 < 4; t2++)
        for (int t3 = t1 & 1; t3 < 4; t3 += 2)
          for (int t4 = t2 & 1; t4 < 4; t4 += 2) {
            int s = ((t1 * t4 - t3 * t2) % 4 + 4) % 4;
            int t5 = (t1 - t3 + 4) % 4, t6 = (t2 - t4 + 4) % 4,
                gt = t5 || t6 ? 2 : 0;
            s = (s - gt + 4) % 4;
            if ((t1 & 1) == 0 && (t2 & 1) == 0) {
              for (int t = 0; t < 4; t++) {
                int tt = (s - t + 4) % 4;
                if (t1 == t3 && t2 == t4 && t == tt)
                  ans2 += 1ll * p[t1][t2][t] * (p[t1][t2][t] - 1);
                else
                  ans2 += 1ll * p[t1][t2][t] * p[t3][t4][tt];
              }
            } else {
              for (int t = 0; t < 4; t++) {
                int tt = (s - t + 4) % 4;
                if (t1 == t3 && t2 == t4 && t == tt)
                  ans1 += 1ll * p[t1][t2][t] * (p[t1][t2][t] - 1);
                else
                  ans1 += 1ll * p[t1][t2][t] * p[t3][t4][tt];
              }
            }
          }
  }
  printf("%lld", ans1 / 2 + ans2 / 6);
}
