You have a sequence $$$a_1, a_2, \ldots, a_n$$$ of length $$$n$$$, each element of which is either $$$0$$$ or $$$1$$$, and a sequence $$$b$$$, which is initially empty.
You are going to perform $$$n$$$ operations. On each of them you will increase the length of $$$b$$$ by $$$1$$$.
- On the $$$i$$$-th operation you choose an integer $$$p$$$ between $$$0$$$ and $$$i-1$$$. You insert $$$0$$$ in the sequence $$$b$$$ on position $$$p+1$$$ (after the first $$$p$$$ elements), and then you invert the first $$$p$$$ elements of $$$b$$$.
- More formally: let's denote the sequence $$$b$$$ before the $$$i$$$-th ($$$1 \le i \le n$$$) operation as $$$b_1, b_2, \ldots, b_{i-1}$$$. On the $$$i$$$-th operation you choose an integer $$$p$$$ between $$$0$$$ and $$$i-1$$$ and replace $$$b$$$ with $$$\overline{b_1}, \overline{b_2}, \ldots, \overline{b_{p}}, 0, b_{p+1}, b_{p+2}, \ldots, b_{i-1}$$$. Here, $$$\overline{x}$$$ denotes the binary inversion. Hence, $$$\overline{0} = 1$$$ and $$$\overline{1} = 0$$$.
You can find examples of operations in the Notes section.
Determine if there exists a sequence of operations that makes $$$b$$$ equal to $$$a$$$. If such sequence of operations exists, find it.
Note
In the first test case,
- Before the first operation, $$$b = [\,]$$$. You choose $$$p = 0$$$ and replace $$$b$$$ with $$$[\, \underline{0} \,]$$$
- On the second operation you choose $$$p = 0$$$ and replace $$$b$$$ with $$$[\, \underline{0}, 0 \,]$$$.
- On the third operation you choose $$$p = 2$$$ and replace $$$b$$$ with $$$[\, 1, 1, \underline{0} \,]$$$.
- On the fourth operation you choose $$$p = 1$$$ and replace $$$b$$$ with $$$[\, 0, \underline{0}, 1, 0 \,]$$$.
- On the fifth operation you choose $$$p = 3$$$ and replace $$$b$$$ with $$$[\, 1, 1, 0, \underline{0}, 0 \,]$$$.
Hence, sequence $$$b$$$ changes in the following way: $$$[\,]$$$ $$$\xrightarrow{p \, = \, 0}$$$ $$$[\, \underline{0} \,]$$$ $$$\xrightarrow{p \, = \, 0}$$$ $$$[\, \underline{0}, 0 \,]$$$ $$$\xrightarrow{p \, = \, 2}$$$ $$$[\, 1, 1, \underline{0} \,]$$$ $$$\xrightarrow{p \, = \, 1}$$$ $$$[\, 0, \underline{0}, 1, 0 \,]$$$ $$$\xrightarrow{p \, = \, 3}$$$ $$$[\, 1, 1, 0, \underline{0}, 0 \,]$$$. In the end the sequence $$$b$$$ is equal to the sequence $$$a$$$, so this way to perform operations is one of the correct answers.
In the second test case, $$$n = 1$$$ and the only achiveable sequence $$$b$$$ is $$$[\, 0 \, ]$$$.
In the third test case, there are six possible sequences of operations:
- $$$[\,]$$$ $$$\xrightarrow{p \, = \, 0}$$$ $$$[\, \underline{0} \,]$$$ $$$\xrightarrow{p \, = \, 0}$$$ $$$[\, \underline{0}, 0 \,]$$$ $$$\xrightarrow{p \, = \, 0}$$$ $$$[\, \underline{0}, 0, 0 \,]$$$.
- $$$[\,]$$$ $$$\xrightarrow{p \, = \, 0}$$$ $$$[\, \underline{0} \,]$$$ $$$\xrightarrow{p \, = \, 0}$$$ $$$[\, \underline{0}, 0 \,]$$$ $$$\xrightarrow{p \, = \, 1}$$$ $$$[\, 1, \underline{0}, 0 \,]$$$.
- $$$[\,]$$$ $$$\xrightarrow{p \, = \, 0}$$$ $$$[\, \underline{0} \,]$$$ $$$\xrightarrow{p \, = \, 0}$$$ $$$[\, \underline{0}, 0 \,]$$$ $$$\xrightarrow{p \, = \, 2}$$$ $$$[\, 1, 1, \underline{0} \,]$$$.
- $$$[\,]$$$ $$$\xrightarrow{p \, = \, 0}$$$ $$$[\, \underline{0} \,]$$$ $$$\xrightarrow{p \, = \, 1}$$$ $$$[\, 1, \underline{0} \,]$$$ $$$\xrightarrow{p \, = \, 0}$$$ $$$[\, \underline{0}, 1, 0 \,]$$$.
- $$$[\,]$$$ $$$\xrightarrow{p \, = \, 0}$$$ $$$[\, \underline{0} \,]$$$ $$$\xrightarrow{p \, = \, 1}$$$ $$$[\, 1, \underline{0} \,]$$$ $$$\xrightarrow{p \, = \, 1}$$$ $$$[\, 0, \underline{0}, 0 \,]$$$.
- $$$[\,]$$$ $$$\xrightarrow{p \, = \, 0}$$$ $$$[\, \underline{0} \,]$$$ $$$\xrightarrow{p \, = \, 1}$$$ $$$[\, 1, \underline{0} \,]$$$ $$$\xrightarrow{p \, = \, 2}$$$ $$$[\, 0, 1, \underline{0} \,]$$$.
None of them makes $$$b$$$ equal to $$$[\, 0, 1, 1 \,]$$$, so the answer is "NO".