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

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

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

l = A("l")
h = B("h")
c = C("c")
n = A("n")
g = B("g")
k = B("k")
a = C("a")

l.o = c
h.u = l
h.q = g
h.z = g
c.z = a
n.o = a
g.u = n
g.q = k
g.z = h
k.u = l
k.q = h
k.z = h
a.z = c
assert n.o.z.z.z.z.txt == "
class A:
    def __init__(self, txt: str):
        self.o: C = None
        self.txt = txt

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

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

l = A("l")
h = B("h")
c = C("c")
n = A("n")
g = B("g")
k = B("k")
a = C("a")

l.o = c
h.u = l
h.q = g
h.z = g
c.z = a
n.o = a
g.u = n
g.q = k
g.z = h
k.u = l
k.q = h
k.z = h
a.z = c
assert n.o.z.z.z.z.txt == "a"