14358 - 2024_IDS_Summer_Lab8_String Hashing   

Description

You have n strings s1, s2, ..., sn, where the strings are combination of lower case characters.  You are going to perform q operations.  Each operation is in the following format:

1. E i j: Check if si and sj are identical?
2. C i j: Update si to be the concatenation of si and sj.

Input

The first line contains integer n and q.

The following n lines are the strings, with the i-th line containing si.

The following lines are the queries described in the problem description.

Constraints

  •  1 <= n, q <=100
  • Length sum of all strings <= 5000 
  • Length of each string after concatenation <= 5000

Output

For each operation E i j, please output 'Y' if $s_i$ and $s_j$ are identical, 'N' otherwise.

Sample Input  Download

Sample Output  Download

Tags




Discuss