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

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

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

g = A("g")
m = B("m")
b = C("b")
l = A("l")
d = B("d")
f = B("f")
c = B("c")
a = B("a")
n = C("n")
i = C("i")

g.u = c
g.o = i
m.s = n
b.w = g
l.u = m
l.o = n
d.s = n
f.s = b
c.s = n
a.s = n
n.w = g
i.w = g
assert d.s.w.u.s.w.o.w.u.s.txt == "
class A:
    def __init__(self, txt: str):
        self.u: B = None
        self.o: C = None
        self.txt = txt

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

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

g = A("g")
m = B("m")
b = C("b")
l = A("l")
d = B("d")
f = B("f")
c = B("c")
a = B("a")
n = C("n")
i = C("i")

g.u = c
g.o = i
m.s = n
b.w = g
l.u = m
l.o = n
d.s = n
f.s = b
c.s = n
a.s = n
n.w = g
i.w = g
assert d.s.w.u.s.w.o.w.u.s.txt == "n"