You are part of a research team dedicated to deciphering symbols carved into ancient stone tablets. After years of study, you have successfully decrypted certain groups of symbols. Recently, a new set of tablets from the same era has been discovered and handed over to you. Although you haven't yet managed to translate complete sentences in the past, you're confident that these new inscriptions contain larger segments of symbols that can be translated using the groups you've already decrypted.
Your goal is to identify the longest segment of symbols on the new tablets that you can translate based on your existing knowledge.
The first line contains a string representing the text on the tablet, consisting of $$$n$$$ consecutive alphanumeric characters.
The second line contains the integer $$$m$$$.
Each on of the next $$$m$$$ lines contains a group of symbols that you have already decrypted.
The length of the longest segment of the tablet's text that can be fully translated using the decrypted symbol groups.
abafopwewwqeiqioloadaduertwpoeabafad 3 abaf iolo ad
8
Limits
- $$$1 \leq n \leq 1000$$$
- $$$1 \leq m \leq 200$$$
- Each of the $$$m$$$ groups of symbols' length is at most $$$20$$$