#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define fi first
#define sc second
#define pb push_back
#define INF 100000000
int n;
char s[100005];
vector<int>vec[26];
int main(){
scanf("%s",s);
scanf("%d",&n);
int x = strlen(s);
rep(i,x){
vec[s[i]-'a'].pb(i);
}
rep(i,n){
string str;cin>>str;
int B=str[0]-'a';
if(vec[B].empty()){
cout<<-1<<endl; continue;
}
int beg = vec[B][0];
{
for(int i=1;i<str.size();i++){
int x = upper_bound(vec[str[i]-'a'].begin(),vec[str[i]-'a'].end(),beg)-vec[str[i]-'a'].begin();
if(x==vec[str[i]-'a'].size()){
puts("-1"); goto bad;
}
beg = vec[str[i]-'a'][x];
}
int R = beg;
for(int i=str.size()-2;i>=0;i--){
int x = lower_bound(vec[str[i]-'a'].begin(),vec[str[i]-'a'].end(),beg)-vec[str[i]-'a'].begin();
if(x==0){
puts("-1"); goto bad;
}
beg = vec[str[i]-'a'][x-1];
}
printf("%d %d\n",beg+1,R+1);
}
bad:;
}
}
./Main.cpp: In function ‘int main()’:
./Main.cpp:14:15: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%s",s);
^
./Main.cpp:15:16: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d",&n);
^