Skip to main content
Tuesday (24.11.2026) at 20:00: ALGOR Contest: Round #4 (Special Challenge) starts!

~/algor $ cat problems/qidiruv-sonni-topish

Search in a sorted array

Easy 1000 ms 128 MB 20%
Share

$n$ integers sorted in non-decreasing order, $a_{1} \le a_{2} \le \dots \le a_{n}$, and $q$ queries are given. Each query gives an integer $x$: is $x$ in the array?

Cells of the sorted array; the cell where the searched number is found is highlighted

Input

The first line contains two positive integers: $n$ and $q$. The second line contains $n$ integers $a_{i}$ separated by spaces. Each of the next $q$ lines contains one integer $x$.

Output

$q$ lines: for each query YES ($x$ is in the array) or NO (it is not).

Note

$1 \le n, q \le 10^{5}$
$-10^{9} \le a_{i}, x \le 10^{9}$
$a_{1} \le a_{2} \le \dots \le a_{n}$

Examples

Input #1
5 3
1 3 5 7 9
3
4
9
Output #1
YES
NO
YES
Input #2
1 2
10
10
-10
Output #2
YES
NO

Sign in to submit a solution

Signing up is free and takes a minute.