#include<bits/stdc++.h>
#include <stdio.h>
#include <string.h>
using namespace std;
string a,b;
bool tf=true;
long long s,k,l1,l2,i=1,e,x;
int main(){
cin >> a;
getline(cin,b);
l1=a.length();
l2=b.length();
while(b[i]==' '){
i++;
x++;
}
if(x!=0){
x++;
}
while(i<l2){
for(int j=0;j<l1;j++){
if(a[j]>='a'){
a[j]=a[j]-32;
}
if(b[i]>='a'){
b[i]=b[i]-32;
}
if(a[j]!=b[i]){
tf=false;
break;
}
i++;
}
while(b[i]!=' '){
i++;
}
i++;
if(tf==true){
if(s==0){
e=s+x;
}
s++;
}
tf=true;
i++;
}
if(s==0){
cout << -1;
}
else{
cout << s << ' ' << e;
}
return 0;
}