Chance! 2
Time limit2sMemory limit1024 MB
Check, for each allowed spell count K, whether complex a can reach complex b using exactly K moves of +1, doubling, or multiplying by i.
Problem
The informatics teachers at Daegu Science High School decided that starting in the second semester of , test scores will be complex numbers, which have no order, to prevent excessive competition among students. On the data structures exam, Eunseong scored and Sanghun scored . Both and are complex numbers. Eunseong admires Sanghun greatly and wants to make his score the same as Sanghun's. So Eunseong learned a spell that changes his score and can now use three spells:
- Give water: the number increases by .
- Give rice: the number doubles.
- Chance!: shout Chance! at the number, and it is multiplied by ().
For example, if and , Eunseong can use the give water, give rice, and Chance! spells in that order to change his score to , then , then . There is no limit on how many times the spells are used, but after each spell, the real part and the imaginary part of Eunseong's score must each have absolute value at most . Eunseong loves the positive integers , so he wants the number of spells used to be one of them. For each , determine whether Eunseong can turn his score into using exactly spells in total across all three spells.
Input
The first line contains the real part and the imaginary part of Eunseong's score , separated by a space. The second line contains the real part and the imaginary part of Sanghun's score , separated by a space. The third line contains the number of positive integers that Eunseong likes. The fourth line contains the positive integers that Eunseong likes, separated by spaces, in ascending order.
Output
Print lines. On line , print YES if Eunseong can change into using exactly spells, and NO otherwise.
Constraints
- The real part and the imaginary part of each have absolute value at most .
- The real part and the imaginary part of each have absolute value at most .
- All given numbers are integers.