PROGRAMMING:The validity of stack out sequence
Given a stack with a maximum capacity of $$M $, which number sequences are impossible to get when the number of $$n $$is put into the stack in the order of 1, 2, 3,..., $$n $$, and is allowed to go out of the stack in any order? For example, given $$m = 5 $$, $$n = 7 $$, we may get {1, 2, 3, 4, 5, 6, 7}, but not {3, 2, 1, 7, 5, 6, 4}.
###Input format:
Enter the first line to give three positive integers no more than 1000: $$M $$(maximum stack capacity), $$n $$(number of stack elements), $$k $$(number of stack out sequences to be checked). Finally, $$k $$lines, each line gives the stack sequence of $$n $$numbers. All peer numbers are separated by spaces.
###Output format:
For each row of stack sequence, if it is indeed a possible legal sequence, output 'yes' in one row, otherwise output' no '.
###Input example:
```in
5 7 5
1 2 3 4 5 6 7
3 2 1 7 5 6 4
7 6 5 4 3 2 1
5 6 4 3 7 2 1
1 7 6 5 4 3 2
```
###Output example:
```out
YES
NO
NO
YES
NO
```
answer:If there is no answer, please comment
###Input format:
Enter the first line to give three positive integers no more than 1000: $$M $$(maximum stack capacity), $$n $$(number of stack elements), $$k $$(number of stack out sequences to be checked). Finally, $$k $$lines, each line gives the stack sequence of $$n $$numbers. All peer numbers are separated by spaces.
###Output format:
For each row of stack sequence, if it is indeed a possible legal sequence, output 'yes' in one row, otherwise output' no '.
###Input example:
```in
5 7 5
1 2 3 4 5 6 7
3 2 1 7 5 6 4
7 6 5 4 3 2 1
5 6 4 3 7 2 1
1 7 6 5 4 3 2
```
###Output example:
```out
YES
NO
NO
YES
NO
```
answer:If there is no answer, please comment