You are given \(N\) strings and \(Q\) questions. Each question contains two values \(X\) and \(Y\). Print "Yes" if the \(X^{th}\) string is a subsequence of \(Y^{th}\) string or Yth string is a subsequence of Xth string, otherwise,print "No".
A subsequence is a sequence that can be derived from another sequence by deleting some or no elements without changing the order of the remaining elements. Read more about subsequences here.
Input format
- First line: Two space-separated integers \(N\) and \(Q\)
- Next N lines: \(N\) strings
- Next Q lines: Two space-separated integers \(X\) and \(Y\)
Output format
Print the answer to each question in a new line.
Constraints
\(1 \le |S_i| \le 10^6\)
\(1 \le N \le 10^5\)
\(N \le\sum_{i=1}^{n}|S_i|\le 10^6 \)
\(1 \le Q \le 10^5\)
\(1 \le X,Y \le N\)
\(|Si|\) denotes length of ith string
Each string contains only lowercase alphabets.
Please login to use the editor
You need to be logged in to access the code editor
Loading...
Please wait while we load the editor
Login to unlock the editorial