SA, PA, XA = map(int, input().split()) SB, PB, XB = map(int, input().split()) if PA > PB: print(SA) elif PA < PB: print(SB) elif PA == PB: print(-1)