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

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

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

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

h = A("h")
i = B("i")
g = C("g")
l = D("l")
a = A("a")

h.z = l
h.r = l
i.y = l
g.t = i
g.u = h
l.w = i
a.z = l
a.r = l
assert i.y.w.y.w.y.txt == "
class A:
    def __init__(self, txt: str):
        self.z: D = None
        self.r: D = None
        self.txt = txt

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

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

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

h = A("h")
i = B("i")
g = C("g")
l = D("l")
a = A("a")

h.z = l
h.r = l
i.y = l
g.t = i
g.u = h
l.w = i
a.z = l
a.r = l
assert i.y.w.y.w.y.txt == "l"