#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int x = 0, fu = 0;
  char ch = getchar();
  for (; ch < 48 || ch > 57; ch = getchar()) fu |= (ch == '-');
  for (; ch > 47 && ch < 58; ch = getchar()) x = x * 10 + ch - '0';
  return fu ? -x : x;
}
int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); }
long long dis(long long x, long long y) { return x * x + y * y; }
map<long long, int> mp;
int Cnt, point;
int find(long long x) {
  if (!mp.count(x)) return mp[x] = ++Cnt;
  return mp[x];
}
vector<pair<int, int> > v[200005];
vector<pair<int, int> >::iterator it;
map<pair<int, int>, int> ans;
int main() {
  for (int Q = read(), op, x, y, id, tmp, t1, t2; Q--;) {
    op = read(), x = read(), y = read(), id = find(dis(x, y));
    if (op == 1) {
      for (it = v[id].begin(); it != v[id].end(); it++) {
        t1 = (*it).first + x, t2 = (*it).second + y, tmp = gcd(t1, t2);
        ans[make_pair(t1 / tmp, t2 / tmp)] += 2;
      }
      point++, v[id].push_back(make_pair(x, y));
      tmp = gcd(x, y), ans[make_pair(x / tmp, y / tmp)]++;
    } else if (op == 2) {
      for (it = v[id].begin(); it != v[id].end(); it++)
        if ((*it) == make_pair(x, y)) {
          v[id].erase(it);
          break;
        }
      for (it = v[id].begin(); it != v[id].end(); it++) {
        t1 = (*it).first + x, t2 = (*it).second + y, tmp = gcd(t1, t2);
        ans[make_pair(t1 / tmp, t2 / tmp)] -= 2;
      }
      point--, tmp = gcd(x, y), ans[make_pair(x / tmp, y / tmp)]--;
    } else {
      tmp = gcd(x, y), x /= tmp, y /= tmp;
      printf("%d\n", point - ans[make_pair(x, y)]);
    }
  }
}
