char a[101],b[10001],c[101],d[10001];main(x){scanf("%s%s%*s%s%s%*s",a,b,c,d);x=strlen(b)-strlen(d);x=x?x:strcmp(b,d);x=!printf("%s",x?x>0?a:c:"-1");}