#include <bits/stdc++.h>
using namespace std;
mt19937 mt_rand(chrono::system_clock::now().time_since_epoch().count());
template <typename T1, typename T2>
inline bool upmax(T1& a, T2 b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename T1, typename T2>
inline bool upmin(T1& a, T2 b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
const int maxn = (int)200500;
const int base = (int)1e9 + 7;
const long double eps = (long double)1e-7;
const long double PI = acos(-1.);
const int pp = 41;
int q;
map<long long, set<pair<int, int>>> pts;
map<pair<int, int>, pair<int, int>> cnt;
template <typename T>
T gcd(T a, T b) {
  while (b) {
    a %= b;
    swap(a, b);
  }
  return a + b;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin >> q;
  int ptCnt = 0;
  while (q--) {
    int tp;
    long long x, y;
    cin >> tp >> x >> y;
    long long rast = ((x) * (x)) + ((y) * (y));
    if (tp == 1) {
      for (auto& pt : pts[rast]) {
        int mx = pt.first + x;
        int my = pt.second + y;
        int mg = gcd(mx, my);
        mx /= mg;
        my /= mg;
        cnt[{mx, my}].first++;
      }
      pts[rast].emplace(x, y);
      int g = gcd(x, y);
      cnt[{x / g, y / g}].second++;
      ptCnt++;
    } else if (tp == 2) {
      pts[rast].erase({x, y});
      for (auto& pt : pts[rast]) {
        int mx = pt.first + x;
        int my = pt.second + y;
        int mg = gcd(mx, my);
        mx /= mg;
        my /= mg;
        cnt[{mx, my}].first--;
      }
      int g = gcd(x, y);
      cnt[{x / g, y / g}].second--;
      ptCnt--;
    } else {
      int g = gcd(x, y);
      auto& t = cnt[{x / g, y / g}];
      int ans = ptCnt - t.second - t.first * 2;
      cout << ans << "\n";
    }
  }
  return 0;
}
