#include<iostream>
#include<cstring>
using namespace std;
const int maxn = 1e6 + 10;
int pos = -1, cnt, timer;
char word[maxn], s[maxn];
int main() {
gets(word);
gets(s);
strcat(word, " ");
strcat(s, " ");
for (int i = 0; i < strlen(word); i++) {
if (word[i] >= 'A' && word[i] <= 'Z') word[i] = word[i] - 'A' + 'a';
}
for (int i = 0; i < strlen(s); i++) {
if (s[i] >= 'A' && s[i] <= 'Z') s[i] = s[i] - 'A' + 'a';
}
int wordst = 0, pw, ps;
for (int i = 0; i < strlen(s); i++) {
if (s[i] != ' ') continue;
bool f = true;
for (pw = 0, ps = wordst; ps <= i; pw++, ps++) {
if (word[pw] != s[ps]) {
f = false;
break;
}
}
if (f == true) {
if (pos == -1) pos = wordst;
cnt++;
}
wordst = i + 1;
}
if (pos == -1) cout << -1 << endl;
else cout << cnt << " " << pos << endl;
return 0;
}