#C10607. Taco Subsequence Validation

    ID: 39831 Type: Default 1000ms 256MiB

Taco Subsequence Validation

Taco Subsequence Validation

Given an array \(A\) of \(n\) integers and another array \(B\) of \(m\) integers, determine whether \(B\) is a subsequence of \(A\). A subsequence of \(A\) is formed by deleting zero or more elements from \(A\) without changing the order of the remaining elements. In other words, there exist indices \(i_1, i_2, \ldots, i_m\) such that \(0 \le i_1 < i_2 < \cdots < i_m < n\) and \(A[i_j] = B[j]\) for every \(1 \le j \le m\).

Your task is to read the input from standard input and output either True or False to standard output depending on whether \(B\) is a valid subsequence of \(A\).

inputFormat

The first line contains an integer n, the number of elements in the array \(A\). The second line contains n space-separated integers representing the array \(A\). The third line contains an integer m, the number of elements in the subsequence candidate \(B\). The fourth line contains m space-separated integers representing the subsequence candidate \(B\).

outputFormat

Output a single line to the standard output: True if \(B\) is a subsequence of \(A\), and False otherwise.

## sample
8
5 1 22 25 6 -1 8 10
4
1 6 -1 10
True