Mirko is building a simple logic circuit in his workshop. The circuit consists of starting wires denoted
with
and
logic elements OR denoted with
. Each element has exactly two
inputs and one output. Each of the inputs is connected to either a starting wire
or to the output of
another element
. Of course, there are no cycles in a logic circuit and, moreover, it holds that the input
of
can be connected to the output of
only when it holds
.
Each starting wire in the circuit can be set to value or
, and the value of the output of each element is
the logic OR operation of its inputs — the value is
if the values of both inputs are
, otherwise it is
.
Mirko does not know the initial values of the starting wires, but with careful measurements, he has determined the values of the output of some elements. Find the remaining values of the outputs that can be unambiguously determined based on the measurements.
Input Specification
The first line of input contains the positive integers and
— the number of starting wires and the
number of elements in the circuit. The following line contains a string of exactly
characters that
describes the measured value of the output of the element
, or is equal to
?
if Mirko did not perform
this measurement. The of the following
lines contains labels of two inputs of the circuit
, each
label being either a label of the starting wire in the form of
xi
where it holds , or a label of
the element
ci
where it holds . The two inputs of the element
may be the same. You can
assume that the measured values are mutually consistent.
Output Specification
The first line of output must contain a string of characters — the
character in the string must
correspond to the value of the output of
or be
?
if that value cannot be unambiguously determined.
Constraints
Subtask | Score | Constraints |
---|---|---|
Sample Input 1
4 4
10??
x1 x2
x2 x3
x3 x4
x1 c3
Sample Output 1
10?1
Explanation for Sample Output 1
Sample Input 2
4 5
11???
x1 x2
x3 x4
x1 x3
x2 x4
c3 c4
Sample Output 2
11??1
Comments