Invoker (Hard)

You are an Arch-Magus Invoker, one of the strongest sorcerers that is able to command sources of magic.

The difference between an Arch-Magus Invoker and a regular Invoker is that an Arch-Magus holds an advanced degree or is pursuing a post-doc in mathemagical studies at the Institute of Arcane Studies.

Magical Training

There are two sources of magic available to invokers to control, $\mathbb {R}$eagus and $\mathbb {I}$magus. Each source has a potency coefficient in front of it. This potency is a real number at most $10^6$ in absolute value.

As an invoker you have the choice of combining two sources of magic (denoted $\oplus $), or casting one on to another (denoted $\otimes $).

The rules for combining sources is as follows:

  • Combining a source of Reagus or Imagus with another source of equal type creates the same type but you add the potencies.

    • $x\mathbb {R}\oplus y\mathbb {R}=(x+y)\mathbb {R}$

    • $x\mathbb {I}\oplus y\mathbb {I}=(x+y)\mathbb {I}$

  • Combining a source of Reagus and Imagus together creates a new complex form of magic.

    • $x\mathbb {R}\oplus y\mathbb {I} \in \mathbb {C}_{\mathbb {M}}$

Casting sources of magic has some different laws:

  • Casting Reagus on to Reagus creates a source of Reagus whose potency is the product of the previous sources.

    • $x\mathbb {R}\otimes y\mathbb {R} = (x\cdot y)\mathbb {R}$

  • Casting Imagus on to another source of Imagus creates anti-Reagus (negative potency) with a potency of the product of the two sources.

    • $x\mathbb {I}\otimes y\mathbb {I} = -(x\cdot y)\mathbb {R}$

  • Casting Reagus on Imagus or Imagus on Reagus creates Imagus with a potency of the product of the two sources.

    • $x\mathbb {R}\otimes y\mathbb {I} = (x\cdot y)\mathbb {I}$

Additionally, every magic source $s$ has a magic complement $s^\dagger $ such that:

\[ \begin{aligned} s=x\mathbb {R}& \rightarrow s^\dagger =s\\ s=y\mathbb {I}& \rightarrow s^\dagger =-s\\ s=x\mathbb {R}\oplus y\mathbb {I}& \rightarrow s+s^\dagger =2x\mathbb {R} \end{aligned} \]

Casting a complex magic source on its complement (or visa versa), generates a non-negative number known as the potency norm of the source.

\[ s\otimes s^\dagger = |s|^2 \]

Advanced Mathemagic!!

As an Arch-Magus you are well studied in an additional source of magic: $\mathbb {J}$ae.

Jae acts like Imagus when near the presence of Reagus. However, when Jae is cast on Imagus it can form a $4$th form of magic: $\mathbb {K}$aos!!

Casting either form of Imagus, Jae, or Kaos on itself creates anti-Reagus.

\[ \mathbb {I}\otimes \mathbb {I} = \mathbb {J}\otimes \mathbb {J} = \mathbb {K}\otimes \mathbb {K} = -\mathbb {R} \]

Casting Imagus on to Jae actually creates anti-Kaos however $-\mathbb {K}$.

The complete casting table between the four elements is as follows:

\[ \begin{array}{l|rrrr} \bigotimes & \mathbb {R} & \mathbb {I} & \mathbb {J} & \mathbb {K} \\ \hline \mathbb {R} & \mathbb {R} & \mathbb {I} & \mathbb {J} & \mathbb {K} \\ \mathbb {I} & \mathbb {I} & -\mathbb {R} & \mathbb {K} & -\mathbb {J} \\ \mathbb {J} & \mathbb {J} & -\mathbb {K} & -\mathbb {R} & \mathbb {I} \\ \mathbb {K} & \mathbb {K} & \mathbb {J} & -\mathbb {I} & -\mathbb {R} \end{array} \]

The same rules for combination exist for Jae and Kaos as they do for Imagus.

If you haven’t noticed, this means that casting is non-commutative. That is:

\[ a\otimes b \neq b\otimes a \]

where $a\otimes b$ is called a right cast from $b$ to $a$, and $b\otimes a$ is called a left cast from $b$ to $a$.

Complex combinations and castings are allowed such as:

\[ \left(a\mathbb {R}\oplus b\mathbb {K}\right)\otimes \left(c\mathbb {I}\oplus d\mathbb {J}\oplus e\mathbb {K}\right) \]

Casting is distributive, which means $s\otimes (a\oplus b) = (s\otimes a) \oplus (s\otimes b)$.

For every source there is also guaranteed to exist an inverse source that when cast will neutralize the magical energies.

\[ \forall s\in \mathbb {M}~ \exists s^{-1}\in \mathbb {M} : s\otimes s^{-1} = \epsilon \]

where $\mathbb {M}$ is the set of non-zero magical sources and $\epsilon $ is the neutral source, or $1\mathbb {R}$.

Complements for Jae and Kaos work the same way they do for Imagus.

Problem

You are currently locked in battle against an equally powerful foe. You recognize that you can defeat them by neutralizing their source of magic. That is, you cast a spell on them that will turn their source into the neutral source $\epsilon = 1\mathbb {R}$.

However, magic is not without its consequences. Any source you cast on your opponent will also be cast on you as well, changing your current magical source.

When you cast a spell on your opponent (and simultaneously on yourself) the magical cast is a right cast (described above), that is:

\[ x\otimes y \]

where $x$ is the initial source and $y$ is the source you have cast.

When the dust settles and you are declared victorious, what is your new magical source?

Input

The inputs are two magical sources separated by new lines.

The first line contains your source: $a\mathbb {R}\oplus b\mathbb {I}\oplus c\mathbb {J}\oplus d\mathbb {K}$. The second line contains your opponent’s source: $e\mathbb {R}\oplus f\mathbb {I}\oplus g\mathbb {J}\oplus h\mathbb {K}$.

All sources are integers in the range $-10^6 \le a,b,c,d,e,f,g,h \le 10^6$, and neither source has all four potencies equal to zero.

Output

Output your resulting source after you have annihilated your opponent. The output should be four space separated values $x,y,z,w$. $x$ is the potency of Reagus, $y$ the potency of Imagus, $z$ the potency of Jae, and $w$ the potency of Kaos present in your final source.

Your answers will be accepted if they have an absolute or relative error of at most $10^{-5}$.

Sample Input 1 Sample Output 1
1 2 3 4
1 2 3 4
1.0 0.0 0.0 0.0
Sample Input 2 Sample Output 2
0 1 0 0
0 0 1 0
0.0 0.0 0.0 -1.0