class A:
    def __init__(self, txt: str):
        self.s: D = None
        self.o: D = None
        self.q: D = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.p: A = None
        self.q: E = None
        self.u: C = None
        self.s: C = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.t: B = None
        self.x: D = None
        self.y: A = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.y: B = None
        self.o: D = None
        self.z: A = None
        self.t: E = None
        self.x: E = None
        self.txt = txt

class E:
    def __init__(self, txt: str):
        self.u: D = None
        self.txt = txt

n = A("n")
k = B("k")
m = C("m")
b = D("b")
h = E("h")
e = D("e")

n.s = b
n.o = b
n.q = b
k.p = n
k.q = h
k.u = m
k.s = m
m.t = k
m.x = b
m.y = n
b.y = k
b.o = e
b.z = n
b.t = h
b.x = h
h.u = e
e.y = k
e.o = b
e.z = n
e.t = h
e.x = h
assert m.t.q.u.x.txt == "
class A:
    def __init__(self, txt: str):
        self.s: D = None
        self.o: D = None
        self.q: D = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.p: A = None
        self.q: E = None
        self.u: C = None
        self.s: C = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.t: B = None
        self.x: D = None
        self.y: A = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.y: B = None
        self.o: D = None
        self.z: A = None
        self.t: E = None
        self.x: E = None
        self.txt = txt

class E:
    def __init__(self, txt: str):
        self.u: D = None
        self.txt = txt

n = A("n")
k = B("k")
m = C("m")
b = D("b")
h = E("h")
e = D("e")

n.s = b
n.o = b
n.q = b
k.p = n
k.q = h
k.u = m
k.s = m
m.t = k
m.x = b
m.y = n
b.y = k
b.o = e
b.z = n
b.t = h
b.x = h
h.u = e
e.y = k
e.o = b
e.z = n
e.t = h
e.x = h
assert m.t.q.u.x.txt == "h"