#include <bits/stdc++.h>
#pragma GCC optimize("O2")
#pragma G++ optimize("O2")
#pragma GCC optimize("O3")
#pragma G++ optimize("O3")
using namespace std;
const int N = 1111111;
const int M = 22222;
const int MOD = 1e9 + 7;
const int intINF = 1e9;
const long long llINF = 2e18;
const double pi = acos(-1.0);
const int dx[4] = {-1, 1, 0, 0};
const int dy[4] = {0, 0, -1, 1};
int read() {
  int v = 0, f = 1;
  char c = getchar();
  while (c < 48 || 57 < c) {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (48 <= c && c <= 57) v = (v << 3) + v + v + c - 48, c = getchar();
  return v * f;
}
long long readll() {
  long long v = 0, f = 1;
  char c = getchar();
  while (c < 48 || 57 < c) {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (48 <= c && c <= 57) v = (v << 3) + v + v + c - 48, c = getchar();
  return v * f;
}
unsigned long long readull() {
  long long v = 0, f = 1;
  char c = getchar();
  while (c < 48 || 57 < c) {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (48 <= c && c <= 57) v = (v << 3) + v + v + c - 48, c = getchar();
  return v * f;
}
map<long long, int> mp;
map<pair<int, int>, int> ans;
vector<pair<int, int> > V[1111111];
int n, s;
void predo() {}
void init() { n = read(); }
int getid(long long r) {
  if (!mp[r]) mp[r] = ++s;
  return mp[r];
}
int gcd(int x, int y) {
  if (y == 0) return x;
  return gcd(y, x % y);
}
pair<int, int> calc(int x, int y) {
  int g = gcd(x, y);
  x /= g;
  y /= g;
  return make_pair(x, y);
}
void solve() {
  int cnt = 0;
  s = 0;
  for (int i = (int)1; i <= (int)n; i++) {
    int op = read(), x = read(), y = read();
    long long r = 1ll * x * x + 1ll * y * y;
    int id = getid(r);
    if (op == 1) {
      cnt++;
      for (auto t : V[id]) {
        ans[calc(t.first + x, t.second + y)] += 2;
      }
      ans[calc(x, y)]++;
      V[id].push_back(make_pair(x, y));
    }
    if (op == 2) {
      cnt--;
      for (auto t : V[id]) {
        if (t == make_pair(x, y)) continue;
        ans[calc(t.first + x, t.second + y)] -= 2;
      }
      auto it = V[id].begin();
      while (*it != make_pair(x, y)) it++;
      V[id].erase(it);
      ans[calc(x, y)]--;
    }
    if (op == 3) printf("%d\n", cnt - ans[calc(x * 2, y * 2)]);
  }
}
int main() {
  predo();
  int cas = 1;
  while (cas--) {
    init();
    solve();
  }
  return 0;
}
