XOR Racer
James is the XOR Racer — the man who flies around space on a motorbike that is powered by integers. Specifically, he feeds integers into his engine, which XORs them together. The engine requires multiple specific types of integer to move, and James is running dangerously low...
James has made a crash landing on a strange planet, where he finds a bunch of random integers. For each of the integers his engine requires, can you tell him if its possible for him to feed some subset of these integers to his engine in order to power it and fly off this planet? In other words, for each query integer, is there some subset of the input integers that XOR together to create the target value?
Input
The first line contains two space-separated integers and
, with
representing the amount of integers found by James and
representing the target integers required by James's engine.
The next line contains space-separated integers
, each of the integers encountered by James. James is a smart fella and he has been attending AUCPL workshops, so he knows the properties of XOR. Thus, James has logged the integers such that each
is unique in the input. These integers form the set
.
The following line contains space-separated integers
, the value of each of the target integers that should be created by XORing together subsets of the input values.
Output
For each , if it is possible to select a subset
with elements
such that
(the elements of subset
all XOR'd together gives
), output "Yeehaw". Otherwise, output "Aw damn".
Clarifications
We define that any subset can produce any of its elements through XOR, i.e., the set can produce
as an output. Although XOR is a binary operation, you can effectively imagine that the unit
is in every set.
Example
Input 1
3 3
1 2 5
4 2 6
Output 1
Yeehaw
Yeehaw
Yeehaw
We can select a subset of the input such that the XOR is . Specifically,
and
are in the input and
.
is present in the input, so it is trivial to select a subset that XORs to it — namely just
itself.
, so it is possible to select a subset that XORs to
.
Input 2
3 2
1 10 5
7 4
Output 2
Aw damn
Yeehaw
There is no subset of the input that XORs to . If we like we can show this by enumerating all possibilities
There is a subset that XORs to - namely
.
Comments