inquiry is depicted by a couple of integers li, ri (1≤li
Correct answer will be upvoted else Multiple Downvoted. Computer science.
inquiry is depicted by a couple of integers li, ri (1≤li<ri≤n).
For each question, he needs to decide if there exists a decent aftereffect in s that is equivalent to the substring s[li… ri].
A substring s[i… j] of a string s is the string shaped by characters sisi+1… sj.
String an is supposed to be an aftereffect of string b if a can be gotten from b by erasing a few characters without changing the request for the excess characters.
An aftereffect is supposed to be acceptable in case it isn't coterminous and has length ≥2. For instance, in the event that s is "1100110", the aftereffects s1s2s4 ("1100110") and s1s5s7 ("1100110") are acceptable, while s1s2s3 ("1100110") isn't acceptable.
Would you be able to help Hr0d1y answer each question?
Input
The primary line of the input contains a solitary integer t (1≤t≤100) — the number of experiments. The portrayal of each experiment is as per the following.
The principal line contains two integers n (2≤n≤100) and q (1≤q≤100) — the length of the string and the number of questions.
The subsequent line contains the string s.
The I-th of the following q lines contains two integers li and ri (1≤li<ri≤n).
Output
For each experiment, output q lines. The I-th line of the output of each experiment ought to contain "YES" if there exists a decent aftereffect equivalent to the substring s[li...ri], and "NO" in any case.
You might print each letter regardless (upper or lower).
Step by step
Solved in 4 steps with 1 images