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

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

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

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

i = A("i")
a = B("a")
c = C("c")
h = D("h")

i.z = c
i.t = a
a.w = h
a.q = h
c.u = i
h.s = c
h.x = c
h.w = c
h.z = i
assert h.z.t.w.txt == "
class A:
    def __init__(self, txt: str):
        self.z: C = None
        self.t: B = None
        self.txt = txt

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

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

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

i = A("i")
a = B("a")
c = C("c")
h = D("h")

i.z = c
i.t = a
a.w = h
a.q = h
c.u = i
h.s = c
h.x = c
h.w = c
h.z = i
assert h.z.t.w.txt == "h"