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

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

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

k = A("k")
e = B("e")
h = C("h")
g = B("g")
m = A("m")
i = B("i")
l = C("l")
f = A("f")
b = A("b")
n = A("n")

k.r = h
k.q = m
e.v = b
h.v = e
h.o = e
h.x = l
g.v = b
m.r = l
m.q = n
i.v = b
l.v = i
l.o = i
l.x = h
f.r = l
f.q = m
b.r = h
b.q = f
n.r = h
n.q = f
assert m.q.r.v.v.q.q.txt == "
class A:
    def __init__(self, txt: str):
        self.r: C = None
        self.q: A = None
        self.txt = txt

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

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

k = A("k")
e = B("e")
h = C("h")
g = B("g")
m = A("m")
i = B("i")
l = C("l")
f = A("f")
b = A("b")
n = A("n")

k.r = h
k.q = m
e.v = b
h.v = e
h.o = e
h.x = l
g.v = b
m.r = l
m.q = n
i.v = b
l.v = i
l.o = i
l.x = h
f.r = l
f.q = m
b.r = h
b.q = f
n.r = h
n.q = f
assert m.q.r.v.v.q.q.txt == "m"