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

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

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

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

i = A("i")
h = B("h")
g = C("g")
b = D("b")
e = D("e")
k = A("k")
c = C("c")
l = A("l")
m = B("m")
a = D("a")

i.u = b
i.s = l
i.o = e
h.x = m
g.s = h
b.y = c
b.w = a
e.y = c
e.w = a
k.u = e
k.o = e
k.s = l
c.s = h
l.u = a
l.o = a
l.s = k
m.x = h
a.y = g
a.w = e
assert h.x.x.x.txt == "
class A:
    def __init__(self, txt: str):
        self.u: D = None
        self.s: A = None
        self.o: D = None
        self.txt = txt

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

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

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

i = A("i")
h = B("h")
g = C("g")
b = D("b")
e = D("e")
k = A("k")
c = C("c")
l = A("l")
m = B("m")
a = D("a")

i.u = b
i.s = l
i.o = e
h.x = m
g.s = h
b.y = c
b.w = a
e.y = c
e.w = a
k.u = e
k.o = e
k.s = l
c.s = h
l.u = a
l.o = a
l.s = k
m.x = h
a.y = g
a.w = e
assert h.x.x.x.txt == "m"