Under construction

Still being built. Things may change

Matrix Cipher

Time limit2sMemory limit512 MB

Summary
Given the 2x2 matrix formed by reading a bitstring and right-multiplying by one of the two elementary matrices per bit, recover the bitstring.
Level

Medium6 of 10

Topics
Math, Simulation
Solved
No attempts yet

Problem

Alice holds her message to Bob as a bitstring and encodes it into a matrix. She starts from the identity matrix

A=(1001)A = \begin{pmatrix} 1 & 0 \\ 0 & 1 \end{pmatrix}

and reads the bitstring one character at a time, starting from the leftmost bit. For a 0 bit she multiplies AA on the right by

(1011)\begin{pmatrix} 1 & 0 \\ 1 & 1 \end{pmatrix}

that is, A←A⋅(1011)A \leftarrow A \cdot \begin{pmatrix} 1 & 0 \\ 1 & 1 \end{pmatrix}. For a 1 bit she multiplies AA on the right by

(1101)\begin{pmatrix} 1 & 1 \\ 0 & 1 \end{pmatrix}

that is, A←A⋅(1101)A \leftarrow A \cdot \begin{pmatrix} 1 & 1 \\ 0 & 1 \end{pmatrix}. After the last bit she transmits the resulting matrix AA.

Bob deleted the program that decodes a message from Alice. Given the transmitted matrix, recover the original bitstring.

Input

The input consists of two lines. Line ii has two integers ai1a_{i1} and ai2a_{i2} separated by a space (0≤ai1,ai2≤2128−10 \le a_{i1}, a_{i2} \le 2^{128} - 1, 1≤i≤21 \le i \le 2), where

(a11a12a21a22)\begin{pmatrix} a_{11} & a_{12} \\ a_{21} & a_{22} \end{pmatrix}

is the matrix holding the encoded message.

The original bitstring has length 1 to 120, and the input is always the encoding of one such bitstring.

Output

Print the decoded bitstring on one line. The bitstring that satisfies the conditions is unique.

Examples2

  1. Example 1

    Input
    2 1
    3 2
    
    Expected output
    010
    
  2. Example 2

    Input
    18 29
    13 21
    
    Expected output
    10010101