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

~/algor $ cat problems/minmax-29-ikki-guruhni-solishtirish

Comparing two groups

Easy 1000 ms 128 MB 22%
Share

A positive integer $N$ and $N$ integers $A_{i}$, and a positive integer $M$ and $M$ integers $B_{j}$ are given. Is every number of the first group strictly less than every number of the second group?

Comparing the largest number of the first group with the smallest number of the second

Input

The first line contains a positive integer $N$, the second — $N$ integers $A_{i}$, the third — a positive integer $M$, the fourth — $M$ integers $B_{j}$.

Output

One line: YES or NO.

Note

$1 \le N, M \le 1000$
$-10^{9} \le A_{i}, B_{j} \le 10^{9}$

Examples

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

Sign in to submit a solution

Signing up is free and takes a minute.