#include<iostream>
#include<cstring>
#include<cctype>
using namespace std;
int main(){
char a[100000],b[400000];
string sbsb;
int sb=0,sbs=-1,s514=0;
cin.getline(a,100000);
cin.getline(b,400000);
for(int c=0;c<max(strlen(a),strlen(b));c++){
a[c]=tolower(a[c]);
b[c]=tolower(b[c]);
if(b[c]==' '){
if(sbsb==a){
sb++;
if(sbs==-1){
sbs=c;
}
}
sbsb.clear();
}else{
sbsb+=b[c];
}
}
if(sbsb==a){
sb++;
if(sbs==-1){
sbs=strlen(b);
}
}
if(sb==0){
cout<<-1;
}else{
cout<<sb<<" "<<sbs-strlen(a);
}
}