class A:
    def __init__(self, txt: str):
        self.s: D = None
        self.y: 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.r: B = None
        self.o: D = None
        self.txt = txt

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

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

h.s = i
h.y = i
b.y = a
l.r = b
l.o = i
i.w = l
a.w = l
assert b.y.w.o.w.o.txt == "
class A:
    def __init__(self, txt: str):
        self.s: D = None
        self.y: 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.r: B = None
        self.o: D = None
        self.txt = txt

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

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

h.s = i
h.y = i
b.y = a
l.r = b
l.o = i
i.w = l
a.w = l
assert b.y.w.o.w.o.txt == "i"