Masala #7DYXTGXX9D

Xotira 32 MB Vaqt 1000 ms Qiyinchiligi 1 %
14

  

G.O.A.T.

Elchinbek the G.O.A.T does love number \(x\), that's why the number \(x\) is G.O.A.T.ed too. Shohjahon also wants to become a legend like Elchinbek. He has 2 arrays \(a\) and \(b\), size of array \(a\) is \(n\) and size of array \(b\) is \(m\). He needs to choose 1 element from array \(a\) and another element from array \(b\) such that their sum is equal to \(x\). Is it possible to do so?


Kiruvchi ma'lumotlar:

First line contains number \(x\) (1 ≤ \(x\) ≤ \(10^9\)).

Second line contains number \(n\) (1 ≤ \(n\) ≤ \(10^3\)).

Third line contains number \(m\) (1 ≤ \(m\) ≤ \(10^3\)).

Next \(n\) lines contain a number \(a_i\) each (1 ≤ \(a_i\) ≤ \(10^9\)).

Next \(m\) lines contain a number \(b_i\) each (1 ≤ \(b_i\) ≤ \(10^9\)).


Chiquvchi ma'lumotlar:

If it is possible to choose 2 numbers, one from \(a\) and another from \(b\), such that their sum is equal to \(x\), then print "Yes" (without quotes), otherwise print "No" (without quotes).

Note that "yes" or "YES" won't be accepted as the checker is case sensitive.


Misollar
# input.txt output.txt
1
5
2
3
1
2
3
4
5
Yes
2
1
1
1
2
20
No
Izoh:

In the first case \(a\) = \([1, 2]\) and \(b\) = \([3, 4, 5]\), we can choose number 1 from \(a\) and number 4 from \(b\), 1 + 4 = 5 = \(x\).

In the second case only possible option is to choose 2 from \(a\) and 20 from \(b\), 2 + 20 = 22, which is not equal to 1.

Yechimini yuborish
Bu amalni bajarish uchun tizimga kiring, agar profilingiz bo'lmasa istalgan payt ro'yxatdan o'tishingiz mumkin