package javaapplication2;
import java.util.*;
import java.io.*;
class DFA
{
public static void main(String args[]) throws IOException
{
int n, m;
Scanner in = new Scanner(System.in);
StringTokenizer st = new StringTokenizer(in.nextLine());
n = Integer.parseInt(st.nextToken());
m = Integer.parseInt(st.nextToken());
while (n != 0)
{
int[][] move = new int[n][m];
for(int i=0; i<n; i++)
{
st = new StringTokenizer(in.nextLine());
for (int j=0; j<m; j++)
move[i][j] = Integer.parseInt(st.nextToken());
}
String[] temp = in.nextLine().split("\s");
int[] accept = new int[temp.length];
for (int i=0; i<accept.length; i++) accept[i] = Integer.parseInt(temp[i]);
String word = in.nextLine();
while (word.compareTo("#") != 0)
{
if (Move.recognizeString(move, accept, word)) System.out.println("YES");
else System.out.println("NO");
word = in.nextLine();
}
st = new StringTokenizer(in.nextLine());
n = Integer.parseInt(st.nextToken());
m = Integer.parseInt(st.nextToken());
}
}
}
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
评论0