#include <bits/stdc++.h>
using namespace std;
map<int, map<int, int> > mp;
int n;
struct Seg {
  int l, r;
  vector<pair<int, int> > v;
} C[1200005];
void build(int o, int l, int r) {
  C[o].l = l;
  C[o].r = r;
  if (l >= r) return;
  build(o * 2, l, ((C[o].l + C[o].r) / 2));
  build(o * 2 + 1, ((C[o].l + C[o].r) / 2) + 1, r);
}
void update(int o, int l, int r, pair<int, int> v) {
  if (C[o].l >= l && C[o].r <= r) {
    C[o].v.push_back(v);
    return;
  }
  if (l <= ((C[o].l + C[o].r) / 2)) update(o * 2, l, r, v);
  if (r > ((C[o].l + C[o].r) / 2)) update(o * 2 + 1, l, r, v);
}
struct State {
  long long typ, u, v, s, t;
};
stack<State> sta;
int mk[300005], f[300005];
long long s[300005], t[300005];
int find(int p) { return f[p] == p ? p : find(f[p]); }
long long res, ans[300005];
void Resolve(int o) {
  int siz = sta.size();
  long long _rev = res;
  for (int i = 0, u, v; i < C[o].v.size(); i++) {
    u = C[o].v[i].first;
    v = C[o].v[i].second;
    if (mk[v] == 0) {
      mk[v] = u;
      u = find(u);
      t[u]++;
      res += s[u];
      sta.push({0, u, v, 0, 1});
    } else if (find(mk[v]) != find(u)) {
      u = find(u);
      v = find(mk[v]);
      if (s[u] > s[v]) swap(u, v);
      res += (s[u] + s[v]) * (t[u] + t[v]) - s[u] * t[u] - s[v] * t[v];
      sta.push({1, u, v, s[u], t[u]});
      s[v] += s[u];
      t[v] += t[u];
      f[u] = v;
    }
  }
  if (C[o].l >= C[o].r) {
    ans[C[o].l] = res;
    goto Karkov;
  }
  Resolve(o * 2);
  Resolve(o * 2 + 1);
Karkov:;
  while (sta.size() > siz) {
    State u = sta.top();
    if (u.typ == 0) {
      t[u.u] -= u.t;
      mk[u.v] = 0;
    }
    if (u.typ == 1) {
      s[u.v] -= u.s;
      t[u.v] -= u.t;
      f[u.u] = u.u;
    }
    sta.pop();
  }
  res = _rev;
}
int main() {
  scanf("%d", &n);
  build(1, 1, n);
  for (int i = 1, u, v; i <= n; i++) {
    scanf("%d%d", &u, &v);
    if (mp[u][v] == 0)
      mp[u][v] = i;
    else {
      update(1, mp[u][v], i - 1, make_pair(u, v));
      mp[u][v] = 0;
    }
  }
  for (auto s : mp)
    for (auto t : s.second)
      if (t.second) {
        update(1, t.second, n, make_pair(s.first, t.first));
      }
  for (int i = 1; i <= n; i++) {
    f[i] = i;
    s[i] = 1;
  }
  Resolve(1);
  for (int i = 1; i <= n; i++) printf("%lld ", ans[i]);
}
