Bonus1 Binary Search Tree

Input consists of several test cases. For each test case, the first line
contains two positive integers N (10) and L, which are the total number
of integers in an insertion sequence and the number of sequences to be
tested, respectively. The second line contains N positive integers,
separated by a space, which are the initially inserted numbers. Then L
lines follow, each contains a sequence of N integers to be checked.
For convenience, it is guaranteed that each insertion sequence is a
permutation of integers 1 to N – that is, all the N numbers are distinct
and no greater than N. The input ends with N being 0. That case must NOT
be processed.