#include<iostream>
#include<algorithm>
#include<map>
#include<cstdio>
using namespace std;const int N=1e5+10;
int next1[4][2]={1,0,0,1,0,-1,-1,0};
struct st{
int x,y;
int num;st(){
num=0;}};classmp{//map排序规则(没这个会报错) public:
bool operator()(const st &a,const st &b)const{return(a.x<b.x)||(a.x==b.x&&a.y<b.y)||(false);}};/*
4
1 1
0 1
1 0
1 2
*/
int main(){
int n;
int x,y;
int nx,ny,num=0;
st t;
st s[N];
map<st,int,mp>m;scanf("%d",&n);for(int i=0;i<n;i++){scanf("%d%d",&x,&y);
s[i].x=x;
s[i].y=y;
t.x=x;
t.y=y;
m.insert(make_pair(t,1));}for(int i=0;i<n;i++){
x=s[i].x;
y=s[i].y;
nx=ny=0;
num=0;for(int j=0;j<4;j++){
nx=next1[j][0]+x;
ny=next1[j][1]+y;
t.x=nx;
t.y=ny;if(m.find(t)!=m.end()){
num++;}}printf("%d\n",num);}return0;}
unordered_map(AC)
#include<iostream>
#include<cstdio>
#include<tr1/unordered_map>
using std::tr1::unordered_map;
using namespace std;const int N=1e+5+10;
int next1[4][2]={1,0,0,1,0,-1,-1,0};classst{public:
int x,y;
int num;st(){num=0;}}s[N];classhash_v{//哈希函数 public:
size_t operator()(const pair<int,int>&p)const{//这是我自己随便写的;//通过函数给key一个值,然后地址储存 return p.first*111+p.second;}};
struct pair_hash {//哈希函数 //这是百度的,也能用,但是不太理解
template<classt1,classt2>
std::size_t operator()(const std::pair<t1, t2>& p)const{return std::tr1::hash<t1>{}(p.first)^std::tr1::hash<t2>{}(p.second);}};
int read()//输入加速挂 {
char ch=' ';
int ans=0;while(ch<'0'|| ch>'9')
ch=getchar();while(ch<='9'&& ch>='0'){
ans=ans*10+ch-'0';
ch=getchar();}return ans;}voidout(int a)//输出加速挂 {if(a >9){out(a/10);}putchar(a%10+'0');}/*
4
1 1
0 1
1 0
1 2
*/
int main(){
unordered_map<pair<int,int>,int,hash_v>m;//创建一个对象
int n;
int x,y;
int nx,ny,num=0;
pair<int,int>t;
n=read();for(int i=0; i<n; i++){
x=read();
y=read();
s[i].x=x;
s[i].y=y;
t.first=x;
t.second=y;
m.insert(make_pair(t,true));//存入哈希表 }for(int i=0; i<n; i++){
x=s[i].x;
y=s[i].y;
nx=ny=0;
num=0;for(int j=0; j<4; j++)//该点的四个方向 {
nx=next1[j][0]+x;
ny=next1[j][1]+y;
t.first=nx;//t为一个点
t.second=ny;if(m.find(t)!=m.end())//散列查找 {
num++;}}
s[i].num=num;//该点相邻点计数 }for(int i=0; i<n; i++){//输出 //printf输出也行,cout输出会超时 out(s[i].num);printf("\n");}return0;}