// Arup Guha
// 2/9/2022
// Solution to COP 3503 Exam #1 Question #1

import java.util.*;

public class personlist {

	public static void main(String[] args) {
	
		// Read in the number of entries and set up the Hash Map.
		Scanner stdin = new Scanner(System.in);
		int n = stdin.nextInt();
		HashMap<String,Integer> map = new HashMap<String,Integer>();
		int id = 1;
		
		// Go through each entry.
		for (int i=0; i<n; i++) {
		
			// Read in this name.
			String name = stdin.next();
			
			// We've seen this name before, print its ID.
			if (map.containsKey(name))
				System.out.println("Person with id number "+map.get(name)+" visits again.");
			
			// Otherwise, give this person an ID, store it and increment our counter.
			// Note: On the exam id++ was a separate statement. This is logically equivalent.
			else {
				System.out.println("Giving "+name+" id number "+id); 
				map.put(name, id++);
			}
		}
	
	}
}