#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<queue>
#define N 100010
using namespace std;
struct node
{
int L, R;
} a[N];
char s[N];
int cmp(node p, node q)
{
if(p.L!=q.L)
return p.L<q.L;
return p.R<q.R;
}
int main()
{
char s0[N];
int n,k, Len;
while(scanf("%s", s)!=EOF)
{
memset(a, 0, sizeof(a));
Len=strlen(s);
scanf("%d", &n);
k=1;
for(int i=1; i<=n; i++)
{
scanf("%s", s0);
if(strstr(s, s0)!=NULL)
{
int pos = 0;
int len = 0;
while(strstr(s+pos+len, s0)!=NULL)
{
pos = strstr(s+pos+len, s0)-s;
len = strlen(s0);
a[k].L=pos;
a[k++].R = pos+len-1;
len=1;///查找时要考虑以下数据:回文串;
}
}
}
sort(a+1, a+k, cmp);
a[k].L=0, a[k].R = Len;///防止出现k=1的情况;
int Max=0, Index=-1;
for(int i=2; i<k; i++)
{
int len1=a[i].R-a[i-1].L-1;
int len2=a[i-1].R-a[i].L-1;///如果a[i].R<a[i-1].R;
if(len1>Max)
{
Max = len1;
Index = a[i-1].L+1;
}
if(len2>Max)
{
Max = len2;
Index = a[i].L+1;
}
}
if(a[1].R>=Max)///与开头和结尾的相比较;
{
Max = a[1].R;
Index = 0;
}
if(Len-a[k-1].L-1>Max)
{
Max = Len - a[k-1].L-1;
Index = a[k-1].L+1;
}
printf("%d %d\n", Max, Index);
}
return 0;
}
/*
tstst
1
tst
abcde
1
ac
3 1
5 0
*/