#include <iostream>
#include <iomanip>
#include <cstring>
#include <cctype>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <stdlib.h>
#include <fstream>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <map>
#include <set>
typedef long long ll;
using namespace std;
int main(int argc, const char * argv[])
{
ios_base::sync_with_stdio(false);
cin.tie(0);
ll n, count = 1;
string reg;
while(cin>>n)
{
count = 1;
map<string ,ll> ar;
while(n--)
{
cin>>reg;
if(ar.count(reg)<=0)
{
ar[reg] = count;
cout<<"New! "<<count<<'\n';
}
else
{
cout<<"Old! "<<ar[reg]<<'\n';
count -= 1;
}
count += 1;
}
}
return 0;
}