#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<queue>
#include<cstdio>
#define lowbit(x) -x&x
#define LL long long
using namespace std;
const int N = 32010;
int ans[N], tr[N];
int n;
void add(int i, int z){
for (; i < N; i += lowbit(i))
tr[i] += z;
}
int ask(int i){
int res = 0;
for (; i; i -= lowbit(i))
res += tr[i];
return res;
}
int main(){
scanf("%d", &n);
for (int i = 1; i <= n; i ++ ){
int x, y;
scanf("%d%d", &x, &y);
x ++ ;
ans[ask(x)] ++ ;
add(x, 1);
}
for (int i = 0; i < n; i ++ )
printf("%d\n", ans[i]);
return 0;
}
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<queue>
#include<cstdio>
#define lowbit(x) -x&x
#define LL long long
using namespace std;
const int N = 1010;
int tr[N];
int n, m, k, casei;
LL ans;
struct Node{
int x, y;
bool operator<(const Node& t)const{
return x < t.x || (x == t.x && y < t.y);
}
}p[1000010];
void add(int i, int z){
for (; i < N; i += lowbit(i))
tr[i] += z;
}
int ask(int i){
int res = 0;
for (; i; i -= lowbit(i))
res += tr[i];
return res;
}
int main(){
int T;
scanf("%d", &T);
while (T -- ){
scanf("%d%d%d", &n, &m, &k);
for (int i = 1; i <= k; i ++ )
scanf("%d%d", &p[i].x, &p[i].y);
sort(p + 1, p + 1 + k);
ans = 0;
memset(tr, 0, sizeof tr);
for (int i = 1; i <= k; i ++ ){
ans += i - 1 - ask(p[i].y);
add(p[i].y, 1);
}
printf("Test case %d: %lld\n", ++ casei, ans);
}
return 0;
}