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

class B:
    def __init__(self, txt: str):
        self.s: C = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.w: C = None
        self.p: D = None
        self.q: D = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.w: B = None
        self.z: A = None
        self.o: C = None
        self.u: A = None
        self.txt = txt

n = A("n")
a = B("a")
e = C("e")
g = D("g")
m = C("m")
k = C("k")

n.s = m
n.u = m
a.s = e
e.w = m
e.p = g
e.q = g
g.w = a
g.z = n
g.u = n
g.o = k
m.w = e
m.p = g
m.q = g
k.w = m
k.p = g
k.q = g
assert a.s.p.o.txt == "
class A:
    def __init__(self, txt: str):
        self.s: C = None
        self.u: C = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.s: C = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.w: C = None
        self.p: D = None
        self.q: D = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.w: B = None
        self.z: A = None
        self.o: C = None
        self.u: A = None
        self.txt = txt

n = A("n")
a = B("a")
e = C("e")
g = D("g")
m = C("m")
k = C("k")

n.s = m
n.u = m
a.s = e
e.w = m
e.p = g
e.q = g
g.w = a
g.z = n
g.u = n
g.o = k
m.w = e
m.p = g
m.q = g
k.w = m
k.p = g
k.q = g
assert a.s.p.o.txt == "k"