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

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

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

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

l.o = a
a.v = m
k.x = l
g.v = a
c.x = j
j.o = m
b.x = j
m.v = g
f.x = l
e.o = g
assert k.x.o.v.v.v.v.txt == "
class A:
    def __init__(self, txt: str):
        self.o: B = None
        self.txt = txt

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

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

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

l.o = a
a.v = m
k.x = l
g.v = a
c.x = j
j.o = m
b.x = j
m.v = g
f.x = l
e.o = g
assert k.x.o.v.v.v.v.txt == "m"