13537 - Find the pairs   

Description

Several men and women are going to attend the singles mixer (聯誼會) tonight. As the organizer, you have collected the personal score of each participant. Several independent events will occur during the party. Each event has a random lucky value ei. If the sum of the scores of a man and a woman equals ei, they will form a perfect pair and dance together. However, since this is a singles mixer and the events are independent, a specific man/woman may dance with a different woman/man in a different event.

Your staff has shown you the lucky value of each event. To gain more control over the party, you want to calculate whether there is a perfect pair in each event before the singles mixer.

!!WARNING!!

You may get TLE if you use std::set and the compile language C++ is chosen, instead of C++11.

Input

The first line contains 3 positive integers M, W and E, where there're M men, W women and E events.

The second line contains M integers, denoting the personal score of each man.

The third line contains W integers, denoting the personal score of each woman.

Next, followed by E lines, each line has the lucky score ei.

Constraints:

  • Cases 1~2 : either the score of every man or woman is 0
    E=200000; M+W<200000
  • Cases 3~4 : either the score of every man or woman is the same (e.g. all of the men have the score of 87)
    E=200000; M+W<200000
  • Cases 5~8: M+W<200000; min(M, W)*log2(max(MW))*E < 108;

The absolute values of all scores range in [0, 107).

Output

For each event, if there exist at least a perfect pair, print "Yes"  in a line; otherwise, print "No". Remember to add a '\n' at the end.

Sample Input  Download

Sample Output  Download

Tags




Discuss