#P1013. L-K-V-E Base-4 Addition

    ID: 12117 Type: Default 1000ms 256MiB

L-K-V-E Base-4 Addition

L-K-V-E Base-4 Addition

A famous scientist, Lus, devised an addition table using the letters L, K, V, and E to represent digits. The table is given as follows:

$$\def\arraystretch{2} \begin{array}{c||c|c|c|c} \rm + & \kern{.5cm} \rm \mathclap{L} \kern{.5cm} & \kern{.5cm} \rm \mathclap{K} \kern{.5cm} & \kern{.5cm} \rm \mathclap{V} \kern{.5cm} & \kern{.5cm} \rm \mathclap{E} \kern{.5cm} \\ \hline\hline \rm L & \rm L & \rm K & \rm V & \rm E \\ \hline \rm K & \rm K & \rm V & \rm E & \rm \mathclap{KL} \\ \hline \rm V & \rm V & \rm E & \rm \mathclap{KL} & \rm \mathclap{KK} \\ \hline \rm E & \rm E & \rm \mathclap{KL} & \rm \mathclap{KK} & \rm \mathclap{KV} \\ \end{array} $$

This table implies the following rules:

  • $L+L = L$, $L+K = K$, $L+V = V$, $L+E = E$
  • $K+L = K$, $K+K = V$, $K+V = E$, $K+E = KL$
  • ... (and so on)
  • $E+E = KV$

From these rules, we can deduce that:

L=0,K=1,V=2,E=3.L=0, \quad K=1, \quad V=2, \quad E=3.

Moreover, the table represents addition in base-4.

Your task is to perform addition of two numbers given in this unusual representation.

Note: When representing numbers, use the following mapping:

  • L: 0
  • K: 1
  • V: 2
  • E: 3

You must add the two numbers (which are provided in this letter-based notation) as base-4 numbers, and output the result in the same format (with no extra leading L unless the result is zero).

inputFormat

The input consists of two tokens separated by whitespace. Each token is a non-empty string that represents a non-negative base-4 number using the characters L, K, V, and E.

For example:

KV
E

represents the numbers corresponding to 6 (since KV in base-4 is 1*4 + 2 = 6) and 3 respectively.

outputFormat

Output a single token: the sum of the two input numbers, expressed in the same L-K-V-E representation.

sample

K V
E