D. Treasure
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

Alice the Fox and Basil the Cat ran away from Pinocchio but left him a cube. They said that it has written on it where the treasure is buried. Of course, he believed them.

A digit was burned on each face of the cube.

Pinocchio was told that he needs to move along the faces of the cube, transitioning to a neighboring face each time and recording the digits that are drawn on them. He can enter each face only once.

The largest number that can be collected in this way will indicate where the treasure is buried. The first three digits represent steps to the north from the old mill, and the rest represent steps to the east.

Help Pinocchio find the largest number that can be obtained in the specified way. After all, he wants to check if what he was told is true.

Input

The first line contains $$$6$$$ integers $$$d_1, \ldots, d_6$$$ $$$(0 \le d_i \le 9)$$$ — the digits burned on the top, bottom, left, right, front, and back faces of the cube, respectively.

It is guaranteed that at least one of the digits $$$d_i$$$ is different from $$$0$$$.

Output

In the first line, output a single integer $$$X$$$ $$$(10^5 \le X \lt 10^6)$$$ — the largest number that can be obtained in the way described by Pinocchio.

Example
Input
2 3 1 4 5 6
Output
645312
Note

First test example

The maximum number $$$645312$$$ can be obtained by traversing the faces of the cube in the following order:

  • back;
  • right;
  • front;
  • bottom;
  • left;
  • top.

Note that the following numbers cannot be obtained:

  • $$$654312$$$ cannot be obtained, as you cannot move from the back face directly to the front;
  • $$$645321$$$ cannot be obtained, as you cannot move from the bottom face directly to the top.