FOLDCUBE - Fold the cube

Folding

In order to represent a 3 dimensional cube in 2 dimensions it needs to be unfolded. We will always unfold cubes to look like this:

    -----
    | 1 |
-------------
| 2 | 3 | 4 |
-------------
    | 5 |
    -----
    | 6 |
    -----

We don't know what orientation the cube was before it was unfolded. Based on the 2D representations of the cubes, we want to know if the cubes could have been the same in 3D after refolding and rotations.

Note that when refolding, we can fold the edges up or down. For example, if you fold the edges up, face 3 would be on the bottom, but if you folded the edges down 3 would be on the top.

Input

Each test case consists of two flatten cubes separated by an empty line. Each face of a cube is represented with a single lowercase letter. A cube can have multiple identical faces.

Output

Output same if they are the same, and different if they are different.

Examples

Input:
 b
aba
 b
 b

 b
bab
 b
 a

Output:
same
Input:
 b
adc
 e
 f

 a
adc
 e
 f

Output:
different
Input:
 a
bcd
 e
 f

 a
bfd
 e
 c

Output:
same

Added by:BYU Admin
Date:2015-11-04
Time limit:1s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: ASM64 MAWK BC NCSHARP COFFEE DART FORTH GOSU JS-MONKEY JULIA KTLN OCT PROLOG PYPY3 R RACKET SQLITE SWIFT UNLAMBDA
Resource:hackthe.computer

© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.