310625: CF1862A. Gift Carpet

Memory Limit:256 MB Time Limit:1 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

A. Gift Carpettime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard output

Recently, Tema and Vika celebrated Family Day. Their friend Arina gave them a carpet, which can be represented as an $n \cdot m$ table of lowercase Latin letters.

Vika hasn't seen the gift yet, but Tema knows what kind of carpets she likes. Vika will like the carpet if she can read her name on. She reads column by column from left to right and chooses one or zero letters from current column.

Formally, the girl will like the carpet if it is possible to select four distinct columns in order from left to right such that the first column contains "v", the second one contains "i", the third one contains "k", and the fourth one contains "a".

Help Tema understand in advance whether Vika will like Arina's gift.

Input

Each test consists of multiple test cases. The first line of input contains a single integer $t$ ($1 \le t \le 100$) — the number of test cases. Then follows the description of the test cases.

The first line of each test case contains two integers $n$, $m$ ($1 \le n, m \le 20$) — the sizes of the carpet.

The next $n$ lines contain $m$ lowercase Latin letters each, describing the given carpet.

Output

For each set of input data, output "YES" if Vika will like the carpet, otherwise output "NO".

You can output each letter in any case (lowercase or uppercase). For example, the strings "yEs", "yes", "Yes", and "YES" will be accepted as a positive answer.

ExampleInput
5
1 4
vika
3 3
bad
car
pet
4 4
vvvv
iiii
kkkk
aaaa
4 4
vkak
iiai
avvk
viaa
4 7
vbickda
vbickda
vbickda
vbickda
Output
YES
NO
YES
NO
YES
Note

In the first sample, Vika can read her name from left to right.

In the second sample, Vika cannot read the character "v", so she will not like the carpet.

Output

题目大意:
Tema和Vika庆祝家庭日,他们的朋友Arina送他们一块地毯,可以表示为一个小写拉丁字母的n*m表格。Vika喜欢能够按列从左到右读取她名字的地毯。具体来说,如果地毯上存在这样的四列,从左到右按顺序分别包含“v”、“i”、“k”、“a”,则Vika喜欢这块地毯。现在需要判断Vika是否会喜欢Arina的礼物。

输入数据格式:
第一行包含一个整数t(1≤t≤100),表示测试用例的数量。接下来是t个测试用例的描述。
每个测试用例的第一行包含两个整数n、m(1≤n,m≤20),表示地毯的大小。
接下来的n行,每行包含m个小写拉丁字母,描述给定的地毯。

输出数据格式:
对于每组输入数据,如果Vika会喜欢地毯,输出“YES”,否则输出“NO”。
输出每个字母时可以使用任何大小写。例如,“yEs”、“yes”、“Yes”和“YES”都可以作为肯定答案。

注意:
在第一个示例中,Vika可以从左到右读取她的名字。
在第二个示例中,Vika无法读取字符“v”,因此她不会喜欢这块地毯。题目大意: Tema和Vika庆祝家庭日,他们的朋友Arina送他们一块地毯,可以表示为一个小写拉丁字母的n*m表格。Vika喜欢能够按列从左到右读取她名字的地毯。具体来说,如果地毯上存在这样的四列,从左到右按顺序分别包含“v”、“i”、“k”、“a”,则Vika喜欢这块地毯。现在需要判断Vika是否会喜欢Arina的礼物。 输入数据格式: 第一行包含一个整数t(1≤t≤100),表示测试用例的数量。接下来是t个测试用例的描述。 每个测试用例的第一行包含两个整数n、m(1≤n,m≤20),表示地毯的大小。 接下来的n行,每行包含m个小写拉丁字母,描述给定的地毯。 输出数据格式: 对于每组输入数据,如果Vika会喜欢地毯,输出“YES”,否则输出“NO”。 输出每个字母时可以使用任何大小写。例如,“yEs”、“yes”、“Yes”和“YES”都可以作为肯定答案。 注意: 在第一个示例中,Vika可以从左到右读取她的名字。 在第二个示例中,Vika无法读取字符“v”,因此她不会喜欢这块地毯。

加入题单

上一题 下一题 算法标签: