#include <bits/stdc++.h>
using namespace std;
map<long long, vector<pair<int, int> > > mp;
map<pair<int, int>, int> ans;
int n, cnt;
long long gcd(long long x, long long y) { return y ? gcd(y, x % y) : x; }
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    int tp, x, y;
    scanf("%d%d%d", &tp, &x, &y);
    if (tp == 1) {
      cnt++;
      vector<pair<int, int> >& v = mp[1ll * x * x + 1ll * y * y];
      for (auto t : v) {
        long long X = t.first + x, Y = t.second + y;
        long long G = gcd(X, Y);
        ans[pair<int, int>(X / G, Y / G)] += 2;
      }
      long long G = gcd(x, y);
      ans[pair<int, int>(x / G, y / G)]++;
      v.push_back(pair<int, int>(x, y));
    } else if (tp == 2) {
      cnt--;
      vector<pair<int, int> >& v = mp[1ll * x * x + 1ll * y * y];
      vector<pair<int, int> > nv;
      for (auto t : v)
        if (t.first != x || t.second != y) {
          long long X = t.first + x, Y = t.second + y;
          long long G = gcd(X, Y);
          ans[pair<int, int>(X / G, Y / G)] -= 2;
          nv.push_back(t);
        }
      long long G = gcd(x, y);
      ans[pair<int, int>(x / G, y / G)]--;
      mp[1ll * x * x + 1ll * y * y] = nv;
    } else {
      int G = gcd(x, y);
      x /= G;
      y /= G;
      printf("%d\n", cnt - ans[pair<int, int>(x, y)]);
    }
  }
}
