s=input().upper() z=input().upper() z=z.split() i,j,flag,l=0,0,True,0 if s in z: for u in z: if u==s and flag: i=l flag=False if u==s: j+=1 l+=1 print(j,i) else: print(-1)