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

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

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

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

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

d = A("d")
j = B("j")
m = C("m")
l = D("l")
f = E("f")
a = C("a")

d.z = a
j.y = a
j.p = l
j.z = m
j.u = d
j.x = d
m.o = a
l.t = j
f.t = d
f.p = d
f.z = l
a.o = m
assert l.t.z.o.o.o.o.txt == "
class A:
    def __init__(self, txt: str):
        self.z: C = None
        self.txt = txt

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

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

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

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

d = A("d")
j = B("j")
m = C("m")
l = D("l")
f = E("f")
a = C("a")

d.z = a
j.y = a
j.p = l
j.z = m
j.u = d
j.x = d
m.o = a
l.t = j
f.t = d
f.p = d
f.z = l
a.o = m
assert l.t.z.o.o.o.o.txt == "m"