#include <bits/stdc++.h>
using namespace std;
mt19937 rnd;
const long long mod = 1e9 + 7;
const long long max_n = 1e5 + 3;
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
struct P {
  long long x, y;
  P() {}
  P(long long x, long long y) : x(x), y(y) {}
  P operator-(P a) { return P(x - a.x, y - a.y); }
  long long det(P a) { return x * a.y - y * a.x; }
};
long long n;
P ps[max_n];
long long cnt[64];
long long cnt_bor(P v1, P v2) {
  return gcd(abs(v1.x - v2.x), abs(v1.y - v2.y));
}
long long square(P v1, P v2, P v3) {
  long long res = (v2 - v1).det(v3 - v1);
  return abs(res) % 4;
}
void run() {
  cin >> n;
  for (long long i = 0; i < n; ++i) {
    cin >> ps[i].x >> ps[i].y;
  }
  long long res = 0;
  for (long long st = 0; st < n; ++st) {
    fill(cnt, cnt + 64, 0);
    swap(ps[st], ps[n - 1]);
    for (long long i = 0; i < n - 1; ++i) {
      ++cnt[((ps[i].x & 3) << 4) + ((ps[i].y & 3) << 2) +
            (cnt_bor(ps[i], ps[n - 1]) & 3)];
    }
    for (long long m1 = 0; m1 < 64; ++m1) {
      for (long long m2 = m1; m2 < 64; ++m2) {
        if (!cnt[m1] || !cnt[m2]) continue;
        P p1 = P(m1 >> 4, m1 >> 2 & 3);
        P p2 = P(m2 >> 4, m2 >> 2 & 3);
        long long b1 = m1 & 3, b2 = m2 & 3;
        long long ls = square(p1, p2, ps[n - 1]);
        long long tmp = cnt_bor(p1, p2);
        if (tmp & 1) continue;
        long long rs = (b1 + b2 + tmp) % 4;
        if (ls == rs) {
          long long c =
              (m1 == m2 ? cnt[m1] * (cnt[m1] - 1) / 2 : cnt[m1] * cnt[m2]);
          long long co = (b1 % 2 == 0 ? 1 : 3);
          res += co * c;
        }
      }
    }
    swap(ps[st], ps[n - 1]);
  }
  cout << res / 3 << endl;
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.precision(20);
  long long t = 1;
  while (t--) {
    run();
  }
}
