Types: N: int, Q: int, S: List[str], k: List[int], p: List[str]
Ranges: 1 ≤ N, Q ≤ 100000, 1 ≤ |S_i| (1 ≤ i ≤ N), Sum of |S_i| ≤ 400000, 1 ≤ k_i ≤ N
Addtl Info: S_i is a string of lowercase alphabet, and every S_i is unique. p_{i,1}p_{i,2}...p_{i,26} is a permutation of 'abcdefghijklmnopqrstuvwxyz'.