#include <bits/stdc++.h>
using namespace std;
int gcd(int a, int b) { return !b ? a : gcd(b, a % b); }
unordered_map<long long, set<pair<int, int>>> mp;
unordered_map<int, unordered_map<int, int>> ans, online;
int q, n, t, x, y;
void fix(int val) {
  long long dis = x * 1LL * x + y * 1LL * y;
  if (val == -1) mp[dis].erase({x, y});
  for (auto i : mp[dis]) {
    ;
    int a = x + i.first, b = y + i.second;
    int c = gcd(a, b);
    a /= c;
    b /= c;
    ans[a][b] += val;
  }
  int c = gcd(x, y);
  online[x / c][y / c] += val;
  if (val == 1) mp[dis].insert({x, y});
  n += val;
}
int main() {
  scanf("%d", &q);
  while (q--) {
    scanf("%d%d%d", &t, &x, &y);
    if (t == 1)
      fix(1);
    else if (t == 2)
      fix(-1);
    else {
      int c = gcd(x, y);
      x /= c;
      y /= c;
      printf("%d\n", n - 2 * ans[x][y] - online[x][y]);
    }
  }
}
