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

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

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

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

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

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

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

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

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

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

b.v = k
b.t = i
h.y = k
h.q = k
h.s = k
k.x = i
k.w = h
k.s = h
k.r = b
i.z = h
assert h.y.w.s.txt == "k"