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

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

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

k = A("k")
a = B("a")
g = C("g")
m = A("m")
b = A("b")
i = B("i")
l = A("l")
f = C("f")

k.u = a
a.s = l
a.y = k
g.o = f
m.u = i
b.u = i
i.s = m
i.y = k
l.u = a
f.o = g
assert m.u.y.u.y.u.y.u.s.txt == "
class A:
    def __init__(self, txt: str):
        self.u: B = None
        self.txt = txt

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

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

k = A("k")
a = B("a")
g = C("g")
m = A("m")
b = A("b")
i = B("i")
l = A("l")
f = C("f")

k.u = a
a.s = l
a.y = k
g.o = f
m.u = i
b.u = i
i.s = m
i.y = k
l.u = a
f.o = g
assert m.u.y.u.y.u.y.u.s.txt == "l"