14258 - 2024_IDS_Spring_Lab4_Fun With Strings   

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.  For example, if si"star" and sj = "burst", then the concatenation of si and sj will be "starburst".

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 q 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 si and sj are identical, 'N' otherwise.

Sample Input  Download

Sample Output  Download

Tags




Discuss