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

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

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

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

a = A("a")
j = B("j")
k = C("k")
h = D("h")
i = A("i")
m = B("m")

a.s = k
j.s = h
j.y = h
j.z = m
j.w = i
k.t = h
h.s = m
h.u = k
i.s = k
m.s = h
m.y = h
m.z = j
m.w = i
assert h.u.t.s.w.s.t.txt == "
class A:
    def __init__(self, txt: str):
        self.s: C = None
        self.txt = txt

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

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

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

a = A("a")
j = B("j")
k = C("k")
h = D("h")
i = A("i")
m = B("m")

a.s = k
j.s = h
j.y = h
j.z = m
j.w = i
k.t = h
h.s = m
h.u = k
i.s = k
m.s = h
m.y = h
m.z = j
m.w = i
assert h.u.t.s.w.s.t.txt == "h"