#include <bits/stdc++.h>
using namespace std;
const int maxn = 6e5 + 5;
struct DELNode {
  int u, dep, sz1, sz2;
  DELNode(int u = 0, int dep = 0, int sz1 = 0, int sz2 = 0)
      : u(u), dep(dep), sz1(sz1), sz2(sz2) {}
};
int fa[maxn], siz[maxn][2], dep[maxn];
vector<int> wife[maxn << 2];
struct edge {
  int u, v, l, r;
} e[maxn];
int ecnt, n, mx1, mx2;
long long ans;
map<pair<int, int>, int> mp;
stack<DELNode> st;
template <typename T>
inline void read(T &x) {
  char c;
  int f = 1;
  while (!isdigit(c = getchar())) (c == '-') && (f = -1);
  x = c ^ 48;
  while (isdigit(c = getchar())) x = x * 10 + (c ^ 48);
  x *= f;
}
inline int findf(int x) {
  while (x != fa[x]) x = fa[x];
  return x;
}
inline void merge(int u, int v) {
  if (u == v) return;
  if (dep[u] > dep[v]) swap(u, v);
  st.push(DELNode(u, dep[u] == dep[v], siz[u][0], siz[u][1]));
  ans = ans - 1ll * siz[v][0] * siz[v][1] - 1ll * siz[u][0] * siz[u][1];
  fa[u] = v;
  siz[v][0] += siz[u][0];
  siz[v][1] += siz[u][1];
  dep[v] += (dep[u] == dep[v]);
  ans = ans + 1ll * siz[v][0] * siz[v][1];
}
void modify(int u, int l, int r, int x, int y, int id) {
  if (x <= l && r <= y) return void(wife[u].push_back(id));
  int mid = (l + r) >> 1;
  if (x <= mid) modify(u << 1, l, mid, x, y, id);
  if (y > mid) modify(u << 1 | 1, mid + 1, r, x, y, id);
}
void solve(int u, int l, int r) {
  int nowsiz = st.size();
  for (const auto &i : wife[u]) merge(findf(e[i].u), findf(e[i].v + mx1));
  if (l == r)
    printf("%lld ", ans);
  else {
    int mid = (l + r) >> 1;
    solve(u << 1, l, mid);
    solve(u << 1 | 1, mid + 1, r);
  }
  while (st.size() > nowsiz) {
    DELNode x = st.top();
    ans = ans - 1ll * siz[fa[x.u]][0] * siz[fa[x.u]][1];
    dep[fa[x.u]] -= x.dep;
    siz[fa[x.u]][0] -= x.sz1;
    siz[fa[x.u]][1] -= x.sz2;
    ans = ans + 1ll * siz[fa[x.u]][0] * siz[fa[x.u]][1] +
          1ll * siz[x.u][0] * siz[x.u][1];
    fa[x.u] = x.u;
    st.pop();
  }
}
int main() {
  int u, v, m;
  read(m);
  for (int i = 1; i <= m; ++i) {
    read(u);
    read(v);
    mx1 = max(mx1, u);
    mx2 = max(mx2, v);
    if (mp.find(make_pair(u, v)) == mp.end()) {
      mp[make_pair(u, v)] = ++ecnt;
      e[ecnt].u = u;
      e[ecnt].v = v;
      e[ecnt].l = i;
      e[ecnt].r = m;
    } else
      e[mp[make_pair(u, v)]].r = i - 1, mp.erase(make_pair(u, v));
  }
  for (int i = 1; i <= mx1; ++i) fa[i] = i, siz[i][0] = 1;
  for (int i = mx1 + 1; i <= mx1 + mx2; ++i) fa[i] = i, siz[i][1] = 1;
  for (int i = 1; i <= ecnt; ++i) modify(1, 1, m, e[i].l, e[i].r, i);
  solve(1, 1, m);
  return 0;
}
