#include<bits/stdc++.h>
using namespace std;
int gs,cs=-1;
string s,s1,s2;
int main(){
getline(cin,s);
getline(cin,s1);
for(int i=0;i<s1.size();i++){
if(s1[i]!=' '){
s2+=s1[i];
}
else{
int f=0;
for(int j=0;j<s.size();j++){
if(s[j]+'a'-'A'==s2[j]){
}
else if(s[j]+'A'-'a'==s2[j]){
}
else if(s[j]==s2[j]){
}
else{
f=1;
break;
}
}
if(f==0){
gs++;
if(cs==-1){
cs=i-s.size();
}
}
s2="";
}
}
int f=0;
for(int j=0;j<s.size();j++){
if(s[j]+'a'-'A'==s2[j]){
}
else if(s[j]-'a'+'A'==s2[j]){
}
else if(s[j]==s2[j]){
}
else{
f=1;
break;
}
}
if(f==0){
gs++;
if(cs==-1){
cs=s1.size()-s.size();
}
}
if(cs==-1){
cout<<-1;
return 0;
}
cout<<gs<<" "<<cs<<endl;
return 0;
}