#include <bits/stdc++.h>
#pragma GCC optimize("-O3")
using namespace std;
void _main();
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  _main();
}
const int inf = INT_MAX / 2;
const long long infl = 1LL << 60;
template <class T>
bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
int gcd(int a, int b) { return a ? gcd(b % a, a) : b; }
int Q;
void _main() {
  int cnt = 0;
  map<long long, set<pair<int, int>>> P;
  map<pair<int, int>, int> pairs;
  map<pair<int, int>, int> on;
  cin >> Q;
  for (int _ = 0; _ < Q; _++) {
    int t, x, y;
    cin >> t >> x >> y;
    long long c = 1LL * x * x + 1LL * y * y;
    if (t == 1) {
      cnt++;
      for (auto &p : P[c]) {
        int px, py;
        tie(px, py) = p;
        int xx = x + px;
        int yy = y + py;
        int g = gcd(xx, yy);
        xx /= g;
        yy /= g;
        pairs[{xx, yy}]++;
      }
      P[c].insert({x, y});
      int gg = gcd(x, y);
      on[{x / gg, y / gg}]++;
    } else if (t == 2) {
      cnt--;
      P[c].erase({x, y});
      for (auto &p : P[c]) {
        int px, py;
        tie(px, py) = p;
        int xx = x + px;
        int yy = y + py;
        int g = gcd(xx, yy);
        xx /= g;
        yy /= g;
        pairs[{xx, yy}]--;
      }
      int gg = gcd(x, y);
      on[{x / gg, y / gg}]--;
    } else {
      int g = gcd(x, y);
      int ans = cnt - 2 * pairs[{x / g, y / g}] - on[{x / g, y / g}];
      printf("%d\n", ans);
    }
  }
}
