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

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

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

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

d = A("d")
l = B("l")
e = C("e")
i = D("i")
h = C("h")
c = C("c")

d.x = l
d.v = l
l.t = i
l.z = e
e.w = d
e.r = c
i.s = d
i.u = d
h.w = d
h.r = e
c.w = d
c.r = h
assert d.x.z.w.txt == "
class A:
    def __init__(self, txt: str):
        self.x: B = None
        self.v: B = None
        self.txt = txt

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

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

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

d = A("d")
l = B("l")
e = C("e")
i = D("i")
h = C("h")
c = C("c")

d.x = l
d.v = l
l.t = i
l.z = e
e.w = d
e.r = c
i.s = d
i.u = d
h.w = d
h.r = e
c.w = d
c.r = h
assert d.x.z.w.txt == "d"