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

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

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

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

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

h.y = a
a.u = h
a.o = h
a.w = h
e.r = m
m.z = a
m.y = a
m.s = h
i.r = m
assert e.r.s.y.txt == "
class A:
    def __init__(self, txt: str):
        self.y: B = None
        self.txt = txt

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

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

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

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

h.y = a
a.u = h
a.o = h
a.w = h
e.r = m
m.z = a
m.y = a
m.s = h
i.r = m
assert e.r.s.y.txt == "a"