#include <bits/stdc++.h>
using namespace std;
#define int long long
inline int read() {
int x = 0, f = 0; char c = 0;
while (!isdigit(c)) f |= c == '-', c = getchar();
while (isdigit(c)) x = (x << 3) + (x << 1) + (c & 15), c = getchar();
return f ? -x : x;
}
#define PII pair<int, int>
#define fi first
#define se second
#define mp make_pair
#define Q 300010
int q, fa[Q << 1], sz1[Q << 1], sz2[Q << 1], ans = 0, res[Q];
stack<PII > st;
struct node { int t, x, y; }e[Q];
void mem() {
for (int i = 1; i <= 2 * q; i ++) {
fa[i] = i;
sz1[i] = (i <= q);
sz2[i] = (i > q);
}
}
int getF(int x) {
return fa[x] == x ? x : getF(fa[x]);
}
void add(int x, int y) {
int u = getF(x), v = getF(y + q);
if (sz1[u] + sz2[u] > sz1[v] + sz2[v]) swap(u, v);
st.push(mp(u, v));
if (u == v) return;
ans -= sz1[v] * sz2[v];
ans -= sz1[u] * sz2[u];
fa[u] = fa[v];
sz1[v] += sz1[u];
sz2[v] += sz2[u];
ans += sz1[v] * sz2[v];
}
void del() {
int u = st.top().fi, v = st.top().se;
st.pop();
if (u == v) return;
ans -= sz1[v] * sz2[v];
fa[u] = u;
sz1[v] -= sz1[u];
sz2[v] -= sz2[u];
ans += sz1[u] * sz2[u];
ans += sz1[v] * sz2[v];
}
#define lid (id << 1)
#define rid (id << 1 | 1)
struct Segment {
int l, r;
vector<PII > e;
}tr[Q * 4];
void Build(int id, int l, int r) {
tr[id].l = l, tr[id].r = r;
if (tr[id].l == tr[id].r) return;
int mid = tr[id].l + tr[id].r >> 1;
Build(lid, l, mid), Build(rid, mid + 1, r);
}
void Add(int id, int l, int r, int x, int y) {
if (l <= tr[id].l && tr[id].r <= r) {
tr[id].e.emplace_back(x, y);
return;
}
int mid = tr[id].l + tr[id].r >> 1;
if (l <= mid) Add(lid, l, r, x, y);
if (r > mid) Add(rid, l, r, x, y);
}
void dfs(int id) {
for (auto x : tr[id].e) add(x.fi, x.se);
if (tr[id].l == tr[id].r) res[tr[id].l] = ans;
else dfs(lid), dfs(rid);
for (auto x : tr[id].e) del();
}
signed main() {
q = read(), Build(1, 1, q);
for (int i = 1; i <= q; i ++) {
e[i].x = read(), e[i].y = read(), e[i].t = i;
}
sort(e + 1, e + q + 1, [](node a, node b) {
if (a.x != b.x) return a.x < b.x;
if (a.y != b.y) return a.y < b.y;
return a.t < b.t;
});
for (int i = 1, f = 0; i <= q; i ++) {
if (e[i - 1].x == e[i].x && e[i - 1].y == e[i].y && f) { f = 0; continue; }
if (e[i + 1].x == e[i].x && e[i + 1].y == e[i].y) Add(1, e[i].t, e[i + 1].t - 1, e[i].x, e[i].y), f = 1;
else Add(1, e[i].t, q, e[i].x, e[i].y);
}
mem(), dfs(1);
for (int i = 1; i <= q; i ++) printf("%lld ", res[i]);
puts("");
return 0;
}