Codeforces Beta Round 71
C
Beaver
Codeforces
1800
原题
← BD →
翻译中…

After Fox Ciel got off a bus, she found that the bus she was on was a wrong bus and she lost her way in a strange town. However, she fortunately met her friend Beaver Taro and asked which way to go to her castle. Taro's response to her was a string $*s*$, and she tried to remember the string $*s*$ correctly.

翻译中…

However, Ciel feels $*n*$ strings $*b*_{1}, *b*_{2}, ... , *b*_{*n*}$ are really boring, and unfortunately she dislikes to remember a string that contains a boring substring. To make the thing worse, what she can remember is only the contiguous substring of $*s*$.

翻译中…

Determine the longest contiguous substring of $*s*$ that does not contain any boring string, so that she can remember the longest part of Taro's response.

翻译中…

Input

翻译中…

In the first line there is a string $*s*$. The length of $*s*$ will be between $1$ and $10^{5}$, inclusive.

翻译中…

In the second line there is a single integer $*n*$ ($1 ≤ *n* ≤ 10$). Next $*n*$ lines, there is a string $*b*_{*i*}$ ($1 ≤ *i* ≤ *n*$). Each length of $*b*_{*i*}$ will be between $1$ and $10$, inclusive.

翻译中…

Each character of the given strings will be either a English alphabet (both lowercase and uppercase) or a underscore ('_') or a digit. Assume that these strings are case-sensitive.

翻译中…

Output

翻译中…

Output in the first line two space-separated integers $*len*$ and $*pos*$: the length of the longest contiguous substring of $*s*$ that does not contain any $*b*_{*i*}$, and the first position of the substring (0-indexed). The position $*pos*$ must be between $0$ and $|*s*| - *len*$ inclusive, where $|*s*|$ is the length of string $*s*$.

翻译中…

If there are several solutions, output any.

翻译中…

Note

翻译中…

In the first sample, the solution is traight_alon.

翻译中…

In the second sample, the solution is an empty string, so the output can be «0 0», «0 1», «0 2», and so on.

翻译中…

In the third sample, the solution is either nagio or oisii.

翻译中…

样例

Input #1
Go_straight_along_this_street
5
str
long
tree
biginteger
ellipse
Output #1
12 4
InputCopy OutputCopy
Input #2
IhaveNoIdea
9
I
h
a
v
e
N
o
I
d
Output #2
0 0
InputCopy OutputCopy
Input #3
unagioisii
2
ioi
unagi
Output #3
5 5
InputCopy OutputCopy
题目信息
题号
79C
时间限制
2 s
内存限制
256 MB
标签
数据结构
动态规划
贪心
哈希
字符串
双指针

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。