King's Cup


Submit solution

Points: 1
Time limit: 3.5s
Python 6.5s
Memory limit: 256M

Author:
Problem type
Allowed languages
C++, Java, Python

Congratulations! Your team has just won AUCPL Season 1, walking away with the prize money and bragging rights that will last a lifetime. Naturally, you decide to celebrate at the Adelaide Unibar.

After a few rounds in, the brews are hitting hard, and the bar menu is starting to get a bit slurred. You can no longer distinguish between the drink names; it all looks like one big string of characters. You can choose any contiguous subset of characters from this menu to order, and the bartender will guess what you mean, and whip you up a tasty drink. However, some words are considered "forbidden" at the Unibar, and saying them will get you kicked out of the bar, so be careful what you say!

Being the last AUCPL, and determined to go out in style, you decide you want the lexicographically largest drink you can order without accidentally saying a forbidden word. In other words, out of all the possibilities, pick the latest one in alphabetical order that keeps your team safe from the bartender's wrath.

What do you say?

Input

The first line contains two integers n (1 \leq n \leq 10^5) and m (0 \leq m \leq 10^5), the number of characters on the drinks menu, and the number of forbidden words the Unibar has.

The next line contains a string S (|S| = n), the menu as your drunken self perceives it.

The next m lines contain L_i and T_i, where:

  • L_i (1 \leq L_i \leq 10^5) is the length of the ith forbidden word.
  • T_i (|T_i| = L_i) is the forbidden word itself.

It is guaranteed that the sum of L_i is no greater than 10^5.

Output

Output the lexicographically largest substring on the menu that does not contain any forbidden words. If you can't say anything without saying a forbidden word, output "Silence".

Clarifications

  • You might need to select pypy3 if you want to solve this using Python.

Example

Input 1
17 6
GRASSHOPPERMIMOSA
3 ASS
2 SS
3 SSH
3 HOP
4 PERM
4 FUCK
Output 1
SHO

Out of all the substrings you could choose to speak, "SHO" is the 25th lexicographically largest one, but all the lexicographically largest one that does not contain a forbidden word.

Input 2
15 3
ALLHAILTHEKINGS
4 HAIL
3 AIL
2 LL
Output 2
THEKINGS
Input 3
25 4
ABCABABCBBCBABBCCABBCBCAA
3 CBC
3 CBB
2 CC
7 ABACABA
Output 3
CBABBC

Comments

There are no comments at the moment.