#include <bits/stdc++.h>
using namespace std;
long long gi() {
  char cc = getchar();
  long long cn = 0, flus = 1;
  while (cc < '0' || cc > '9') {
    if (cc == '-') flus = -flus;
    cc = getchar();
  }
  while (cc >= '0' && cc <= '9') cn = cn * 10 + cc - '0', cc = getchar();
  return cn * flus;
}
const long long N = 6e5 + 5;
long long n, Ans, maxn, sz[N], cntx[N], cnty[N], fa[N], ans[N];
struct node {
  long long x, y;
};
struct Tr {
  vector<node> S;
} tr[N << 2];
map<pair<long long, long long>, long long> S;
void insert(long long x, long long l, long long r, long long ql, long long qr,
            node k) {
  if (ql <= l && r <= qr) return tr[x].S.push_back(k), void();
  if (qr < l || r < ql) return;
  long long mid = (l + r) >> 1;
  insert((x << 1), l, mid, ql, qr, k),
      insert((x << 1 | 1), mid + 1, r, ql, qr, k);
}
vector<node> q;
long long fd(long long x) { return (fa[x] == x) ? x : fd(fa[x]); }
void merge(long long x, long long y) {
  long long u = fd(x), v = fd(y);
  if (u == v) return;
  if (sz[u] > sz[v]) swap(u, v);
  Ans -= cntx[u] * cnty[u], Ans -= cntx[v] * cnty[v],
      fa[u] = v, cntx[v] += cntx[u], cnty[v] += cnty[u],
      Ans += cntx[v] * cnty[v], sz[v] += sz[u], q.push_back((node){u, v});
}
void solve(long long x, long long l, long long r) {
  if (l == r) {
    long long lsz = q.size();
    for (node v : tr[x].S) merge(v.x, v.y + maxn);
    ans[l] = Ans;
    long long siz = q.size();
    for (long long i = siz - 1; i >= lsz; --i) {
      long long u = q[i].x, v = q[i].y;
      Ans -= cntx[v] * cnty[v], fa[u] = u, cntx[v] -= cntx[u],
                                cnty[v] -= cnty[u], sz[v] -= sz[u];
      Ans += cntx[u] * cnty[u], Ans += cntx[v] * cnty[v];
    }
    while (q.size() > lsz) q.pop_back();
    return;
  }
  long long mid = (l + r) >> 1, lsz = q.size();
  for (node v : tr[x].S) merge(v.x, v.y + maxn);
  solve((x << 1), l, mid), solve((x << 1 | 1), mid + 1, r);
  long long siz = q.size();
  for (long long i = siz - 1; i >= lsz; --i) {
    long long u = q[i].x, v = q[i].y;
    Ans -= cntx[v] * cnty[v], fa[u] = u, cntx[v] -= cntx[u], cnty[v] -= cnty[u],
                              sz[v] -= sz[u];
    Ans += cntx[u] * cnty[u], Ans += cntx[v] * cnty[v];
  }
  while (q.size() > lsz) q.pop_back();
}
signed main() {
  n = gi();
  long long x, y;
  for (register long long i = (1); i <= (n); ++i) {
    x = gi(), y = gi(), maxn = max(max(x, y), maxn);
    if (S[make_pair(x, y)]) {
      node opt = (node){x, y};
      insert(1, 1, n, S[make_pair(x, y)], i - 1, opt), S[make_pair(x, y)] = 0;
    } else
      S[make_pair(x, y)] = i;
  }
  for (auto z : S)
    if (z.second)
      insert(1, 1, n, z.second, n, (node){z.first.first, z.first.second});
  for (register long long i = (1); i <= ((maxn * 2)); ++i) sz[i] = 1, fa[i] = i;
  for (register long long i = (1); i <= (maxn); ++i)
    cntx[i] = 1, cnty[i + maxn] = 1;
  solve(1, 1, n);
  for (register long long i = (1); i <= (n); ++i) printf("%lld ", ans[i]);
  return 0;
}
