#include <bits/stdc++.h>
namespace {
using LL = long long;
int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); }
struct Solver {
  int n;
  std::vector<int> xs, ys;
  static int mod4(int x) { return x >= 0 ? (x & 3) : ((x % 4 + 4) & 3); }
  static int mod2(int x) { return std::abs(x) & 1; }
  void solve(int ca, std::istream& reader) {
    reader >> n;
    xs.resize(n);
    ys.resize(n);
    for (int i = 0; i < n; ++i) {
      reader >> xs[i] >> ys[i];
    }
    int A_table[4][4][4][4] = {};
    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) {
            A_table[x1][y1][x2][y2] = std::abs(x1 * y2 - x2 * y1) & 3;
          }
        }
      }
    }
    int g3_table[4][4][4][4] = {};
    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) {
            g3_table[x1][y1][x2][y2] =
                gcd(std::abs(x1 - x2), std::abs(y1 - y2)) & 3;
          }
        }
      }
    }
    int g2_table[4][4][4] = {};
    for (int A = 0; A < 4; ++A) {
      for (int g1 = 0; g1 < 4; ++g1) {
        for (int g3 = 0; g3 < 4; ++g3) {
          g2_table[A][g1][g3] = mod4(A - g1 - g3);
        }
      }
    }
    LL EEE = 0, OOE = 0;
    for (int i = 0; i < n; ++i) {
      int cnt[4][4][4] = {};
      std::vector<int> g1_table(n);
      for (int j = 0; j < n; ++j)
        if (i != j) {
          int x1 = xs[j] - xs[i];
          int y1 = ys[j] - ys[i];
          g1_table[j] = gcd(std::abs(x1), std::abs(y1)) & 3;
          int g1 = g1_table[j];
          x1 = mod4(x1);
          y1 = mod4(y1);
          cnt[x1][y1][g1]++;
        }
      for (int j = 0; j < n; ++j)
        if (i != j) {
          int x1 = xs[j] - xs[i];
          int y1 = ys[j] - ys[i];
          int g1 = g1_table[j];
          x1 = mod4(x1);
          y1 = mod4(y1);
          cnt[x1][y1][g1]--;
          LL& recv = (g1 & 1) ? OOE : EEE;
          for (int x2 = x1 & 1; x2 < 4; x2 += 2) {
            for (int y2 = y1 & 1; y2 < 4; y2 += 2) {
              int g3 = g3_table[x1][y1][x2][y2];
              int A = A_table[x1][y1][x2][y2];
              int g2 = g2_table[A][g1][g3];
              recv += cnt[x2][y2][g2];
            }
          }
          cnt[x1][y1][g1]++;
        }
    }
    printf("%lld\n", EEE / 6 + OOE / 2);
  }
};
}  // namespace
int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  std::istream& reader = std::cin;
  int cas = 1;
  for (int ca = 1; ca <= cas; ++ca) {
    Solver().solve(ca, reader);
  }
}
