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

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

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

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

n.u = f
n.x = l
a.o = n
k.u = g
b.o = n
f.u = g
c.u = f
m.u = g
g.u = m
l.u = m
l.x = n
assert l.u.u.u.u.u.u.txt == "
class A:
    def __init__(self, txt: str):
        self.u: C = None
        self.x: A = None
        self.txt = txt

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

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

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

n.u = f
n.x = l
a.o = n
k.u = g
b.o = n
f.u = g
c.u = f
m.u = g
g.u = m
l.u = m
l.x = n
assert l.u.u.u.u.u.u.txt == "g"