#include<iostream>
#include<stack>
using namespace std;
int main()
{
int n, m, k, i;
cin >> n >> m >> k;
int s[1050];
while (k--)
{
int x = 1, t = 0;
int f = 0;
for (int i = 1; i <= n; i++)
cin >> s[i];
stack<int>q;
for (int i = 1; i <= n; i++)
{
// if(t)
while (1)
{
if (s[x] == i)
{
x++; break;
}
if (!q.empty())
{
if (q.top() == i)
{
q.pop();
break;
}
}
q.push(s[x]);
x++;
if (x>n||q.size()>m){ t = 1; break; }
}
if (t == 1)break;
}
if (t==0)cout << "YES" << endl;
else cout << "NO" << endl;
}
system("pause");
return 0;
}