#include <bits/stdc++.h>
using namespace std;
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
map<long long, set<pair<int, int> > > s;
map<pair<int, int>, int> num;
int n, sz;
pair<int, int> reduce(int first, int second) {
  int g = gcd(first, second);
  if (g) first /= g, second /= g;
  return pair<int, int>(first, second);
}
void add(set<pair<int, int> > &a, int first, int second, int v) {
  sz += v;
  num[reduce(first, second)] += v;
  for (auto &u : a) num[reduce(u.first + first, u.second + second)] += v * 2;
}
int main() {
  scanf("%d", &n);
  while (n--) {
    int t, first, second;
    scanf("%d%d%d", &t, &first, &second);
    long long d = (long long)first * first + (long long)second * second;
    if (t == 1)
      add(s[d], first, second, 1), s[d].insert(pair<int, int>(first, second));
    else if (t == 2)
      s[d].erase(pair<int, int>(first, second)), add(s[d], first, second, -1);
    else
      printf("%d\n", sz - num[reduce(first, second)]);
  }
}
