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

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

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

g = A("g")
m = B("m")
l = C("l")
k = B("k")
e = C("e")
c = C("c")
n = A("n")

g.r = l
g.y = k
m.o = k
l.q = k
l.z = g
k.o = m
e.q = k
e.z = n
c.q = m
c.z = n
n.r = l
n.y = m
assert c.q.o.o.o.o.o.o.txt == "
class A:
    def __init__(self, txt: str):
        self.r: C = None
        self.y: B = None
        self.txt = txt

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

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

g = A("g")
m = B("m")
l = C("l")
k = B("k")
e = C("e")
c = C("c")
n = A("n")

g.r = l
g.y = k
m.o = k
l.q = k
l.z = g
k.o = m
e.q = k
e.z = n
c.q = m
c.z = n
n.r = l
n.y = m
assert c.q.o.o.o.o.o.o.txt == "m"