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

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

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

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

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

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

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

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

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

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

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

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

i.s = n
n.w = h
h.t = i
h.x = a
h.y = a
a.y = n
m.u = h
m.o = n
m.s = n
m.z = a
assert m.o.w.t.txt == "i"