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

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

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

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

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

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

d.z = m
d.s = j
f.w = d
m.z = k
j.v = k
j.r = d
j.t = d
j.u = d
k.v = j
k.r = d
k.s = m
assert d.z.z.r.txt == "
class A:
    def __init__(self, txt: str):
        self.z: C = None
        self.s: D = None
        self.txt = txt

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

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

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

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

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

d.z = m
d.s = j
f.w = d
m.z = k
j.v = k
j.r = d
j.t = d
j.u = d
k.v = j
k.r = d
k.s = m
assert d.z.z.r.txt == "d"