Fredo has got two strings s and t. Playing around with them, he came up with the following question:
Will string t be a subsequence of string s if he removes substring \([s_i,s_{i+1},....,s_{j-1},s_j]\) from string s ?
Given q queries, each query consists of indices i and j, you have to answer "Yes" if string t is a subsequence of remaining string s else answer "No".
Note:
Each query is independent of each other.
Input Format:
First line of input consists of string s.
Next line consists of string t.
Next line consists of two integers q 2 (q denoting number of queries and second integer always having value 2).
Each of following q lines consists of two integers i and j, denoting starting and ending indices of substring to be deleted from string s.
Output Format:
For each query , output "Yes" if t is a subsequence of remaining string s, else output "No".
Answer for each query should come in a new line.
Input Constraints:
\(1 \le |s| \le 10^5\)
\(1 \le |t| \le |s|\)
\(1 \le q \le 10^5\)
\(1 \le i \le j \le |s|\)
Both strings s and t contain lowercase English 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