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

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

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

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

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

j.t = k
j.r = k
j.w = k
d.y = h
d.x = k
d.v = k
h.z = k
k.s = j
k.o = h
k.y = h
assert j.t.o.z.s.txt == "
class A:
    def __init__(self, txt: str):
        self.t: D = None
        self.r: D = None
        self.w: D = None
        self.txt = txt

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

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

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

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

j.t = k
j.r = k
j.w = k
d.y = h
d.x = k
d.v = k
h.z = k
k.s = j
k.o = h
k.y = h
assert j.t.o.z.s.txt == "j"