flag = false
l = gets.to_i.times.map{ gets.chomp }
gets.to_i.times do
  if l.include?( name = gets.chomp )
    if flag then puts "Closed by #{name}"
    else puts "Opened by #{name}"
    end
    flag = !flag
  else puts "Unknown #{name}"
  end
end