#include<cstdio> #include<stdlib.h> #include<string.h> #include<string> #include<cmath> #include<iostream> #include <queue> #include <stack> #include<algorithm> #include<set> #include<map> using namespace std; #define inf 100000 #define INF -0x3f3f3f3f #define eps 1e-8 #define ll long long #define N 2002 #define M 50005 struct node1 { char name[50]; int num; int no; } now[30]; struct node2 { char name[50]; int num; int no; }last[300]; int cmp(node1 a,node1 b) { return a.num>b.num; } int cmp2(node2 a,node2 b) { return a.num>b.num; } int main() { int n,i,w=0,num=0,j; while(scanf("%d",&n)&&n) { for(i = 0; i<n; i++) scanf("%s %d",now[i].name,&now[i].num); sort(now,now+n,cmp); for(i = 0; i<n; i++) now[i].no = i+1; printf("----------------WEEK %d----------------\n",++w); if(w==1) { for(i = 0; i<5; i++) { printf("%d.*NEW* %s\n",now[i].no,now[i].name); } } else if(w) { for(i = 0; i<5; i++) { for(j = 0; j<num; j++) { if(!strcmp(now[i].name,last[j].name)) { if(now[i].no>last[j].no) printf("%d.*DOWN* %s\n",now[i].no,now[i].name); else if(now[i].no==last[j].no) printf("%d.*STAY* %s\n",now[i].no,now[i].name); else if(now[i].no<last[j].no) printf("%d.*UP* %s\n",now[i].no,now[i].name); break; } } if(j>=num) printf("%d.*NEW* %s\n",now[i].no,now[i].name); } } for(i = 0; i<n; i++) { for(j = 0;j<num;j++) { if(!strcmp(last[j].name,now[i].name)) { last[j].num = now[i].num; break; } } if(j>=num||num==0) { strcpy(last[num].name,now[i].name); last[num].num = now[i].num; num++; } } for(j = 0;j<num;j++) { for(i = 0;i<5;i++) { if(!strcmp(last[j].name,now[i].name)) { last[j].no = now[i].no; break; } } if(i>=5) { last[j].no = inf; } } } return 0; }