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

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

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

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

h = A("h")
l = B("l")
e = C("e")
i = D("i")

h.y = l
h.o = i
l.x = i
l.w = e
e.o = l
i.y = l
i.x = l
assert e.o.w.o.txt == "
class A:
    def __init__(self, txt: str):
        self.y: B = None
        self.o: D = None
        self.txt = txt

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

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

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

h = A("h")
l = B("l")
e = C("e")
i = D("i")

h.y = l
h.o = i
l.x = i
l.w = e
e.o = l
i.y = l
i.x = l
assert e.o.w.o.txt == "l"