#include<bits/stdc++.h>
using namespace std;
string word;
int sum=0,sot;
char wos[10000050];
char wcp[10000050];
bool deng() {
for(int i=0; i<strlen(wcp); i++) {
if(wcp[i]!=word[i])return false;
}
if(strlen(wcp)>word.size()||strlen(wcp)<word.size()) return false;
else return true;
}
bool copy() {
for(int i=0; i<strlen(wcp); i++) {
if(wcp[i]>='A'&&wcp[i]<='Z')
wcp[i]+=32;
}
bool bz=deng ();
if(bz==true) {
sum++;
if(sum==1)return true;
}
return false;
}
int main() {
cin>>word;
for(int i=0; i<word.size(); i++) {
if(word[i]>='A'&&word[i]<='Z')
word[i]+=32;
}
int er=0,f=1;
getchar();
do {
char rt=getchar();
if(rt=='\n')f=0;
else {
wos[er]=rt;
er++;
}
} while(f);
int qum=0,ant=0;
wos[strlen(wos)]=' ';
for(int i=0; i<=strlen(wos); i++) {
if(wos[i]==' ') {
int y=i;
for(int j=y-qum; j<=y-1; j++) {
wcp[ant]=wos[j];
ant++;
}
ant=0;
bool s=copy();
if(s==true) {
sot=y-qum;
}
memset(wcp,0,sizeof(wcp));
qum=0;
} else {
qum++;
}
}
if(sum!=0)cout<<sum<<" "<<sot;
else cout<<"-1";
}