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

class B:
    def __init__(self, txt: str):
        self.u: E = None
        self.w: A = None
        self.t: A = None
        self.y: C = None
        self.txt = txt

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

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

class E:
    def __init__(self, txt: str):
        self.z: B = None
        self.r: B = None
        self.txt = txt

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

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

class B:
    def __init__(self, txt: str):
        self.u: E = None
        self.w: A = None
        self.t: A = None
        self.y: C = None
        self.txt = txt

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

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

class E:
    def __init__(self, txt: str):
        self.z: B = None
        self.r: B = None
        self.txt = txt

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

m.o = j
c.u = d
c.w = m
c.t = m
c.y = j
j.t = d
f.t = d
f.p = c
f.z = j
f.x = m
f.s = m
d.z = c
d.r = c
assert c.y.t.z.y.txt == "j"