x, _, _ = (gets || "").chomp.split.map { |i| i.to_i } AS = (gets || "").chomp.split.map { |i| i.to_i } BS = (gets || "").chomp.split.map { |i| i.to_i } mr_max = AS.includes?(x) max_valu = BS.includes?(x) result = if mr_max && max_valu "MrMaxValu" elsif mr_max "MrMax" elsif max_valu "MaxValu" else -1 end puts result