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

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

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

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

e = A("e")
d = B("d")
k = C("k")
h = D("h")
m = D("m")

e.z = k
d.y = h
d.z = k
k.q = e
k.s = m
k.v = d
h.u = e
h.s = d
m.u = e
m.s = d
assert e.z.v.y.s.txt == "
class A:
    def __init__(self, txt: str):
        self.z: C = None
        self.txt = txt

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

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

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

e = A("e")
d = B("d")
k = C("k")
h = D("h")
m = D("m")

e.z = k
d.y = h
d.z = k
k.q = e
k.s = m
k.v = d
h.u = e
h.s = d
m.u = e
m.s = d
assert e.z.v.y.s.txt == "d"