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

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

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

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

class E:
    def __init__(self, txt: str):
        self.o: A = None
        self.q: A = None
        self.x: C = None
        self.p: E = None
        self.z: E = None
        self.txt = txt

m = A("m")
l = B("l")
c = C("c")
g = D("g")
f = E("f")
j = D("j")
b = C("b")
a = D("a")
d = E("d")
h = C("h")

m.t = a
m.q = h
l.q = h
c.s = f
g.t = m
f.o = m
f.q = m
f.x = b
f.p = d
f.z = d
j.t = m
b.s = d
a.t = m
d.o = m
d.q = m
d.x = h
d.p = f
d.z = f
h.s = f
assert b.s.z.x.s.q.txt == "
class A:
    def __init__(self, txt: str):
        self.t: D = None
        self.q: C = None
        self.txt = txt

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

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

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

class E:
    def __init__(self, txt: str):
        self.o: A = None
        self.q: A = None
        self.x: C = None
        self.p: E = None
        self.z: E = None
        self.txt = txt

m = A("m")
l = B("l")
c = C("c")
g = D("g")
f = E("f")
j = D("j")
b = C("b")
a = D("a")
d = E("d")
h = C("h")

m.t = a
m.q = h
l.q = h
c.s = f
g.t = m
f.o = m
f.q = m
f.x = b
f.p = d
f.z = d
j.t = m
b.s = d
a.t = m
d.o = m
d.q = m
d.x = h
d.p = f
d.z = f
h.s = f
assert b.s.z.x.s.q.txt == "m"