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

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

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

a = A("a")
g = B("g")
h = C("h")
k = A("k")
i = B("i")
n = A("n")
m = A("m")
d = A("d")
b = A("b")

a.q = g
g.u = h
g.z = i
h.s = n
k.q = g
i.u = h
i.z = g
n.q = i
m.q = i
d.q = g
b.q = g
assert k.q.z.u.s.q.txt == "
class A:
    def __init__(self, txt: str):
        self.q: B = None
        self.txt = txt

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

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

a = A("a")
g = B("g")
h = C("h")
k = A("k")
i = B("i")
n = A("n")
m = A("m")
d = A("d")
b = A("b")

a.q = g
g.u = h
g.z = i
h.s = n
k.q = g
i.u = h
i.z = g
n.q = i
m.q = i
d.q = g
b.q = g
assert k.q.z.u.s.q.txt == "i"