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

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

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

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

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

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

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

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

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

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

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

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

m.o = k
m.p = k
m.q = k
m.t = e
c.r = e
e.t = c
e.s = c
k.r = m
b.y = c
b.z = c
b.p = e
assert b.z.r.s.r.s.txt == "c"