#include <bits/stdc++.h>
using namespace std;
template <typename T>
void chkmax(T& x, T y) {
  if (x < y) x = y;
}
template <typename T>
void chkmin(T& x, T y) {
  if (x > y) x = y;
}
inline int read() {
  int x = 0;
  char c = getchar();
  bool f = 0;
  while (c < 48) f |= c == '-', c = getchar();
  while (c > 47) x = x * 10 + (c ^ 48), c = getchar();
  return f ? -x : x;
}
const int maxn = 6e5 + 10;
int n = 3e5, q;
map<pair<int, int>, int> mp;
int par[maxn], sz1[maxn], sz2[maxn];
int top, st[maxn];
long long as;
int find(int x) {
  while (x != par[x]) x = par[x];
  return x;
}
void unite(int x, int y) {
  if ((x = find(x)) != (y = find(y))) {
    if (sz1[x] + sz2[x] < sz1[y] + sz2[y]) swap(x, y);
    par[y] = x, as -= 1ll * sz1[x] * sz2[x], as -= 1ll * sz1[y] * sz2[y],
    sz1[x] += sz1[y], sz2[x] += sz2[y], as += 1ll * sz1[x] * sz2[x],
    st[++top] = y;
  }
}
void revert(int k) {
  while (top > k) {
    int u = st[top--];
    sz1[par[u]] -= sz1[u], sz2[par[u]] -= sz2[u], par[u] = u;
  }
}
vector<pair<int, int> > vec[maxn << 2];
void add(int k, int l, int r, int ql, int qr, pair<int, int> e) {
  if (ql <= l && r <= qr) return vec[k].push_back(e), void();
  if (ql <= ((l + r) >> 1)) add(k << 1, l, ((l + r) >> 1), ql, qr, e);
  if (qr > ((l + r) >> 1)) add(k << 1 | 1, ((l + r) >> 1) + 1, r, ql, qr, e);
}
void divide(int k, int l, int r) {
  int tp = top;
  long long TAS = as;
  for (pair<int, int> p : vec[k]) {
    unite(p.first, p.second);
  }
  if (l == r)
    printf("%I64d ", as);
  else
    divide(k << 1, l, ((l + r) >> 1)),
        divide(k << 1 | 1, ((l + r) >> 1) + 1, r);
  revert(tp), as = TAS;
}
void solve() {
  cin >> q;
  for (int i = (1), iend = (n); i <= iend; ++i)
    par[i] = i, sz1[i] = 1, par[n + i] = n + i, sz2[n + i] = 1;
  for (int i = (1), iend = (q); i <= iend; ++i) {
    int u = read(), v = n + read(), x = mp[{u, v}];
    if (x) {
      add(1, 1, q, x, i - 1, {u, v}), mp.erase({u, v});
    } else {
      mp[{u, v}] = i;
    }
  }
  for (auto p : mp) {
    add(1, 1, q, p.second, q, p.first);
  }
  divide(1, 1, q);
}
signed main() {
  solve();
  return 0;
}
