line1 = gets.chomp! abort "line1" unless line1 =~ /^[0-9]+$/ n = line1.to_i abort "n" unless 1 <= n && n <= 20000 hh = {} n.times do |i| line = gets.chomp! abort "no.#{i}" unless line =~ /^[A-Za-z]+ [A-Za-z]+$/ a, b = line.split abort "twice badman" if hh[a] hh[a] = true end abort "EOF" if gets puts 'AC!'