P27915 [洛谷] [Language Month Competition 202402] Number String
普及
题目描述

Problem Description

bj12z_jiasiyuan has $n + 1$ sequences of infinite length, each following a specific pattern:

  • The first sequence is $\texttt{11111111111111\dots}$, starting with $1$ and the distance between adjacent $1$s is $0$.
  • The second sequence is $\texttt{10101010101010\dots}$, starting with $1$ and the distance between adjacent $1$s is $1$.
  • The third sequence is $\texttt{10010010010010\dots}$, starting with $1$ and the distance between adjacent $1$s is $2$.
  • $\cdots$
  • The $(n + 1)$-th sequence starts with $1$ and the distance between adjacent $1$s is $n$.

bj12z_jiasiyuan gives you a $01$ number string $s$ of length $m$ and asks you to determine if this string could be a substring extracted from one of the $n + 1$ sequences.

bj12z_jiasiyuan will ask you multiple times, each time providing a new set of $n, m, s$. Please help answer these queries.

Input Format

This problem contains multiple sets of test data within a single test case.

The first line contains an integer $t$, representing the number of test data sets.
Lines $2$ to $t + 1$ each contain two integers $n, m$ and a $01$ number string $s$ of length $m$.

Output Format

Output $t$ lines, each containing a string Yes or No, representing the answer to each query. Output Yes if it is possible, otherwise output No.

Sample Input and Output

Input Sample #1

1
5 5 10010

Output Sample #1

Yes

Input Sample #2

1
5 12 000001000010

Output Sample #2

No

Notes

Data Size and Constraints

  • For $30\%$ of the data, $t = 1$, $1 \leq n \leq 10$, $1 \leq m \leq 10$;
  • For $50\%$ of the data, $1 \leq t \leq 20$, $1 \leq n \leq 10^3$, $1 \leq m \leq 10^3$;
  • For $100\%$ of the data, $1 \leq t \leq 20$, $1 \leq n \leq 10^5$, $1 \leq m \leq 10^5$.
输入格式

见题面 Input 部分

输出格式

见题面 Output 部分

样例输入
1 5 5 10010
样例输出
Yes