a=raw_input().split() b=raw_input().split() if int(a[1])==int(b[1]): print -1 else: print[a,b][int(a[1])