#include <iostream>
using namespace std;
struct stack
{
int top;
int *s;
};
void Push(stack &x, int i)
{
x.s[++x.top]= i;
}
void Pop(stack &x)
{
int res = x.s[x.top--];
}
int main()
{
stack x;
int n, k, m;
cin >> m >> k >> n;
x.top = -1;
x.s = new int[k];
int *temp = new int[k];
int i;
while (n--)
{
for (i = 0; i < k; i++)
cin >> temp[i];
i = 0;
int j = 1;
x.top = -1;
while (i < k&&x.top<m)
{
if (x.s[x.top] == temp[i])
{
Pop(x);
i++;
}
else
{
Push(x, j);
j++;
}
}
if (i < k)
cout << "NO"<<endl;
else
cout << "YES" << endl;
}
system("pause");
return 0;
}