Harmonics with Interference
시간 제한1초메모리 제한1024 MB
최대 16개의 '*' 와일드카드가 있는 비트열 M'과 N'이 주어질 때, 완성된 제어값 N으로 나누어지는 완성된 메시지 M을 찾는다.
문제
The transmission of messages by electromagnetic means presents several challenges, such as interference from other natural or artificial signals that can corrupt a transmission.
A common strategy is to send additional information that allows a received message to be validated. Some more robust protocols even allow for the correction of some errors in the sent message.
Arthur and Bruna are testing a new transmission protocol on a device they have developed. A message , which is a sequence of bits, is sent from Arthur to Bruna, along with a control sequence , also represented as a sequence of bits. By composing the message and choosing the bits from , Arthur ensures that the integer encoded by is divisible by the integer represented by .
For each bit received by Bruna, if the bit was transmitted without problems, the value 0 or 1 will be stored in the receiving device. If there was any interference, the symbol * is stored in place of the bit. The result of the transmission will be stored in the pair .
After the communication, if the message was sent successfully, Bruna can decode the original message (since ). If there was a problem, due to the way the protocol works, it may still be possible to decode the message. If many bits were lost, Bruna simply discards the message. But for transmissions where at most bits of the original pair were lost, Bruna would like to try to recover the message, avoiding retransmissions. She needs your help to recover one of the possible messages encoded by the received pair .
For example, suppose Bruna received 111* and 1*. Two transmissions could have been made:
1111with11. In this case, the numbers and are represented by and , respectively.1110with10. In this case, the numbers and are represented by and , respectively.
Your task is: given the representations of the information received, find a message that could have been sent by Arthur. If more than one message exists, you can print any message that could have been transmitted by Arthur.
입력
The first line of input will contain a sequence of characters representing , with . The second line of input will contain a sequence of characters representing , with . All characters in and will be either 0, 1, or *. In total, there will never be more than * characters in the input. It is guaranteed that always contains at least one bit .
출력
A single line should be printed, containing a message , compatible with the information received by Bruna.