import java.util.*;
import java.lang.*;

class Main
{
	static class Person {
		private String first;
		private String last;
		public String getFirst() {return first;}
		public String getLast() {return last;}
		public Person(String f, String l) {
			first = f;
			last = l;
		}
		public String toString() {
			return first+" "+last;
		}
	}
	public static void main (String[] args) throws java.lang.Exception
	{
		List<Person> people = new ArrayList<Person>();
		people.add(new Person("John", "Smith"));
		people.add(new Person("John", "Scott"));
		people.add(new Person("Jack", "First"));
		people.add(new Person("John", "Walker"));
		people.add(new Person("Jack", "Black"));
		Set<Object> seen = new HashSet<Object>();
		for (Person p : people) {
			final Person thisPerson = p;
			class Wrap {
				public int hashCode() { return thisPerson.getFirst().hashCode(); }
				public boolean equals(Object o) {
					Wrap other = (Wrap)o;
					return other.wrapped().getFirst().equals(thisPerson.getFirst());
				}
				public Person wrapped() { return thisPerson; }
			};
			Wrap wrap = new Wrap();
			if (seen.add(wrap)) {
				System.out.println(p + " is new");
			} else {
				System.out.println(p + " is a duplicate");
			}
		}
	}
}