T = [[, , , , , , , , , , ],
     [,   , , , ,  , , , ,  , ],
     [,  , , , , , , , , , ],
     [,  , , , , , , , , , ]]

def straddle(s):
    return .join(L[0]+T[0][L.index(c)] for c in s.upper() for L in T if c in L)

def unstraddle(s):
    s = iter(s)
    for c in s:
        if c in [T[2][0], T[3][0]]:
            i = [T[2][0], T[3][0]].index(c)
            n = T[2 + i][T[0].index(s.next())]
            yield s.next() if n ==  else n
        else:
            yield T[1][T[0].index(c)]

O = 
print , straddle(O)
print , .join(unstraddle(straddle(O)))