import sys, base64, re

def dec_b64(s):
    return base64.b64decode(s, validate=True)

def dec_b85(s):
    return base64.b85decode(s)

def dec_a85(s):
    return base64.a85decode(s)

DECODERS = [('b64', dec_b64), ('b85', dec_b85), ('a85', dec_a85)]

def printable(b):
    try:
        t = b.decode('utf-8')
    except Exception:
        return None
    return t if all(c.isprintable() or c in '\n\r\t' for c in t) else None

def peel(s, depth, path):
    """DFS: peel exactly `depth` layers, return (text, path)."""
    if depth == 0:
        t = printable(s.encode() if isinstance(s, str) else s)
        return (t, path) if t else None
    cur = s if isinstance(s, str) else s.decode('latin-1')
    cur = cur.strip()
    for name, fn in DECODERS:
        try:
            out = fn(cur)
        except Exception:
            continue
        t = printable(out)
        if t is None:
            continue
        r = peel(t, depth - 1, path + [name])
        if r:
            return r
    return None

raw = sys.stdin.read()
sid = re.search(r'Session ID:\s*(\S+)', raw)
prog = re.search(r'Progress:\s*(\S+)', raw)
diff = re.search(r'Difficulty:\s*(\S+)', raw)
q = re.search(r'Question:\s*(\S+)', raw)

if sid: print('SID:', sid.group(1))
if prog: print('PROGRESS:', prog.group(1))
if diff: print('DIFFICULTY:', diff.group(1))

if not q:
    print('--- no question; raw response ---')
    print(raw)
    sys.exit()

for d in (5, 4, 3, 2, 1):
    r = peel(q.group(1), d, [])
    if r:
        print(f'LAYERS({d}):', ' -> '.join(r[1]))
        print('QUESTION:', r[0])
        break
else:
    print('FAILED to peel:', q.group(1)[:120])
