Substrings with Shift#2962

Substrings with Shift

ثانيتان
256 ميغابايت
صعب جدًا

You are given texts, all of which have the same length.

Your task is to find a substring with a shift. A substring with shifts a_1, a_2, \ldots, a_K is said to be present in the set of texts T_1, T_2, \ldots, T_K if there exists a number such that for every , \mathrm{LCP}(T_i + a_i + x, S) \geq |S|. Here, is the length of the longest common prefix, T_i + j denotes the -th suffix of string T_i, and is the length of string .

المدخلات

The number is between and , followed by texts (all texts are of the same length, each between and 10^5). Next is (1 \leq M \leq 10^5) — the number of queries, followed by the queries themselves. Each query consists of a string and numbers from -10^9 to 10^9. The total length of all strings in the queries does not exceed 10^5. All strings and texts consist only of lowercase English letters. All strings in the queries are distinct.

المخرجات

For each query, output NO if such a substring cannot be found, or YES x if it can, where is the value that satisfies the condition.

أمثلة

مثال 1

Loading
Loading