Untitled

mail@pastecode.io avatar
unknown
plain_text
7 months ago
524 B
5
Indexable
Never
check='vika'
t=int(input())
while t!=0:
    j=0
    flag=0
    [n,m]=list(map(int,input().split()))
    present=n
    while n!=0:
        s=input()
        for i in range(len(s)):
            if len(set(s))==1 and j!=4 and s[i]==check[j] :
                j+=1
                present-=1
                break
            elif j!=4 and s[i]==check[j] and present==n:
                j+=1
        if j==4:
            flag=1
            break
        n-=1
    print("YES" if flag==1 else "NO")
    t-=1
Leave a Comment