#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
struct stu
{
int solve;
string time;
int score;
};
bool cmp(stu a,stu b)
{
if(a.solve==b.solve)
return (a.time).compare(b.time)<0;
return a.solve>b.solve;
}
int main()
{
int n;
int i,j;
int sum[5];
struct stu s[100],temp[100];
int c4,c3,c2,c1;
while(cin>>n&&n>0)
{
for(i=0;i<5;i++)
sum[i]=0;
for(i=0;i<n;i++)
{
cin>>s[i].solve>>s[i].time;
s[i].score=0;
temp[i]=s[i];
}
sort(s,s+n,cmp);
for(i=0;i<n;i++)
{
if(s[i].solve==5)
s[i].score=100;
else if(s[i].solve==4)
sum[4]++;
else if(s[i].solve==3)
sum[3]++;
else if(s[i].solve==2)
sum[2]++;
else if(s[i].solve==1)
sum[1]++;
else
s[i].score=50;
}
c4=c3=c2=c1=0;
for(i=0;i<n;i++)
{
if(s[i].solve==4)
{
if(c4==0)
{
c4=i;
}
if(i<c4+sum[4]/2||sum[4]==1)
{
s[i].score=95;
}
else
s[i].score=90;
}
else if(s[i].solve==3)
{
if(c3==0)
{
c3=i;
}
if(i<c3+sum[3]/2||sum[3]==1)
{
s[i].score=85;
}
else
s[i].score=80;
}
else if(s[i].solve==2)
{
if(c2==0)
{
c2=i;
}
if(i<c2+sum[2]/2||sum[2]==1)
{
s[i].score=75;
}
else
s[i].score=70;
}
else if(s[i].solve==1)
{
if(c1==0)
{
c1=i;
}
if(i<c1+sum[1]/2||sum[1]==1)
{
s[i].score=65;
}
else
s[i].score=60;
}
}
for(i=0;i<n;i++)
{
for(j=0;j<n;j++)
{
if(temp[i].solve==0)
{
temp[i].score=50;
break;
}
if(s[j].time==temp[i].time&&s[j].solve==temp[i].solve)
{
temp[i].score=s[j].score;
break;
}
}
}
for(j=0;j<n;j++)
{
cout<<temp[j].score<<endl;
}
cout<<endl;
}
return 0;
}