#include <bits/stdc++.h>
const int N = 600010;
int n, from[N], to[N], st[N], ed[N], m, p[N], U[N], V[N], top;
int dep[N], fa[N], sz0[N], sz1[N];
long long res;
std::pair<int, int> stk[N];
std::vector<std::pair<int, int> > e[N << 2];
void modify(int rt, int L, int R, int l, int r, int u, int v) {
  if (l <= L && R <= r) {
    e[rt].push_back(std::make_pair(u, v));
    return;
  }
  int mid = (L + R) >> 1;
  if (l <= mid) modify(rt << 1, L, mid, l, r, u, v);
  if (r > mid) modify(rt << 1 | 1, mid + 1, R, l, r, u, v);
  return;
}
int Find(int x) {
  while (fa[x] != x) x = fa[x];
  return x;
}
void Merge(int u, int v) {
  if (dep[u] > dep[v]) std::swap(u, v);
  stk[++top].first = u;
  stk[top].second = (dep[u] == dep[v]);
  fa[u] = v;
  dep[v] += (dep[u] == dep[v]);
  res += 1LL * sz0[u] * sz1[v] + 1LL * sz1[u] * sz0[v];
  sz0[v] += sz0[u];
  sz1[v] += sz1[u];
}
void dfs(int rt, int l, int r) {
  int btop = top;
  for (int i = 0; i < e[rt].size(); i++) {
    int u = e[rt][i].first, v = e[rt][i].second;
    if (Find(u) != Find(v)) {
      Merge(Find(u), Find(v));
    }
  }
  if (l < r) {
    int mid = (l + r) >> 1;
    dfs(rt << 1, l, mid);
    dfs(rt << 1 | 1, mid + 1, r);
  } else
    printf("%lld ", res);
  while (top > btop) {
    int u = stk[top].first, f = fa[u];
    fa[u] = u;
    dep[f] -= stk[top].second;
    sz0[f] -= sz0[u];
    sz1[f] -= sz1[u];
    res -= (1LL * sz0[u] * sz1[f] + 1LL * sz0[f] * sz1[u]);
    top--;
  }
}
std::map<std::pair<int, int>, int> mp;
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d%d", &from[i], &to[i]);
    to[i] += 300000;
    if (mp[std::make_pair(from[i], to[i])]) {
      st[++m] = mp[std::make_pair(from[i], to[i])];
      ed[m] = i;
      mp[std::make_pair(from[i], to[i])] = 0;
      p[st[m]] = p[ed[m]] = 1;
      U[m] = from[i];
      V[m] = to[i];
    } else
      mp[std::make_pair(from[i], to[i])] = i;
  }
  for (int i = 1; i <= n; i++) {
    if (!p[i]) {
      st[++m] = i;
      ed[m] = n + 1;
      U[m] = from[i];
      V[m] = to[i];
    }
  }
  for (int i = 1; i <= m; i++) {
    modify(1, 1, n, st[i], ed[i] - 1, U[i], V[i]);
  }
  for (int i = 1; i <= N - 10; i++) {
    fa[i] = i, dep[i] = 1;
    sz0[i] = (i <= 300000);
    sz1[i] = (i > 300000);
  }
  dfs(1, 1, n);
  return 0;
}
