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

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

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

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

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

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

j.z = f
j.p = m
f.t = c
c.p = f
c.u = m
m.w = f
i.p = m
i.r = m
i.z = j
k.p = m
k.r = m
k.z = j
assert k.z.z.t.p.t.txt == "
class A:
    def __init__(self, txt: str):
        self.z: B = None
        self.p: D = None
        self.txt = txt

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

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

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

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

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

j.z = f
j.p = m
f.t = c
c.p = f
c.u = m
m.w = f
i.p = m
i.r = m
i.z = j
k.p = m
k.r = m
k.z = j
assert k.z.z.t.p.t.txt == "c"