#include <bits/stdc++.h>
using namespace std;
const int SZ = 6e5 + 10;
const int mod = 998244353;
const int INF = 1e9 + 10;
const long double eps = 1e-8;
long long read() {
  long long n = 0;
  char a = getchar();
  bool flag = 0;
  while (a > '9' || a < '0') {
    if (a == '-') flag = 1;
    a = getchar();
  }
  while (a <= '9' && a >= '0') {
    n = n * 10 + a - '0', a = getchar();
  }
  if (flag) n = -n;
  return n;
}
struct segment {
  int l, r;
  vector<pair<int, int> > v;
  vector<bool> b;
} tree[SZ * 4];
void build(int p, int l, int r) {
  tree[p].l = l;
  tree[p].r = r;
  if (l == r) return;
  int mid = l + r >> 1;
  build(p << 1, l, mid);
  build(p << 1 | 1, mid + 1, r);
}
void add(int p, int l, int r, pair<int, int> x) {
  if (l <= tree[p].l && tree[p].r <= r) {
    tree[p].v.push_back(x);
    return;
  }
  int mid = tree[p].l + tree[p].r >> 1;
  if (l <= mid) add(p << 1, l, r, x);
  if (mid < r) add(p << 1 | 1, l, r, x);
}
long long fa[SZ], sz[SZ][2];
int find(int x) { return x == fa[x] ? x : find(fa[x]); }
long long get_sz(int x) { return sz[x][0] + sz[x][1]; }
long long get_ans(int x) { return sz[x][0] * sz[x][1]; }
stack<pair<int, int> > S;
long long ans = 0;
bool add(pair<int, int> v) {
  int x = find(v.first), y = find(v.second);
  if (x == y) return false;
  if (get_sz(x) < get_sz(y)) swap(x, y);
  ans -= get_ans(x);
  ans -= get_ans(y);
  fa[y] = x;
  sz[x][0] += sz[y][0];
  sz[x][1] += sz[y][1];
  ans += get_ans(x);
  S.push(make_pair(x, y));
  return true;
}
void del() {
  if (!S.size()) return;
  pair<int, int> p = S.top();
  S.pop();
  int x = p.first, y = p.second;
  ans -= get_ans(x);
  sz[x][0] -= sz[y][0];
  sz[x][1] -= sz[y][1];
  ans += get_ans(x);
  ans += get_ans(y);
  fa[x] = x;
  fa[y] = y;
}
long long Ans[SZ];
void dfs(int p) {
  tree[p].b.resize(tree[p].v.size());
  for (int i = 0; i < tree[p].v.size(); i++) tree[p].b[i] = add(tree[p].v[i]);
  if (tree[p].l == tree[p].r)
    Ans[tree[p].l] = ans;
  else
    dfs(p << 1), dfs(p << 1 | 1);
  for (int i = tree[p].v.size() - 1; i >= 0; i--)
    if (tree[p].b[i]) del();
}
pair<int, int> a[SZ];
map<pair<int, int>, int> mp;
int main() {
  int n = read();
  for (int i = 1; i <= n; i++) {
    int x = read(), y = read();
    a[i] = make_pair(x, y + 3e5);
  }
  build(1, 1, n);
  for (int i = 1; i <= n; i++) {
    pair<int, int> p = a[i];
    if (mp.count(p))
      add(1, mp[p], i - 1, p), mp.erase(p);
    else
      mp[p] = i;
  }
  for (auto it = mp.begin(); it != mp.end(); it++)
    add(1, it->second, n, it->first);
  for (int i = 1; i <= 6e5; i++) fa[i] = i, sz[i][i <= 3e5] = 1;
  dfs(1);
  for (int i = 1; i <= n; i++) printf("%I64d ", Ans[i]);
  return 0;
}
