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

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

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

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

i = A("i")
h = B("h")
b = C("b")
d = D("d")

i.v = d
i.x = b
h.w = b
h.u = b
h.s = d
h.q = i
b.y = d
d.w = b
d.z = h
assert h.u.y.z.txt == "
class A:
    def __init__(self, txt: str):
        self.v: D = None
        self.x: C = None
        self.txt = txt

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

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

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

i = A("i")
h = B("h")
b = C("b")
d = D("d")

i.v = d
i.x = b
h.w = b
h.u = b
h.s = d
h.q = i
b.y = d
d.w = b
d.z = h
assert h.u.y.z.txt == "h"