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

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

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

class D:
    def __init__(self, txt: str):
        self.w: B = None
        self.r: A = None
        self.z: C = None
        self.t: A = None
        self.txt = txt

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

e.w = a
a.x = e
a.y = c
k.v = e
c.w = a
c.r = e
c.t = e
c.z = k
m.v = e
assert c.z.v.w.txt == "
class A:
    def __init__(self, txt: str):
        self.w: B = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.w: B = None
        self.r: A = None
        self.z: C = None
        self.t: A = None
        self.txt = txt

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

e.w = a
a.x = e
a.y = c
k.v = e
c.w = a
c.r = e
c.t = e
c.z = k
m.v = e
assert c.z.v.w.txt == "a"