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

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

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

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

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

d.z = i
d.x = i
h.v = d
h.p = d
h.o = i
i.s = h
k.x = i
k.u = i
k.v = i
k.w = h
assert k.w.o.s.txt == "
class A:
    def __init__(self, txt: str):
        self.z: C = None
        self.x: C = None
        self.txt = txt

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

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

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

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

d.z = i
d.x = i
h.v = d
h.p = d
h.o = i
i.s = h
k.x = i
k.u = i
k.v = i
k.w = h
assert k.w.o.s.txt == "h"