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

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

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

k = A("k")
e = B("e")
a = C("a")
d = A("d")
g = B("g")
i = B("i")
b = B("b")
j = A("j")
f = A("f")

k.q = a
e.x = k
e.z = g
a.s = i
d.q = a
g.x = k
g.z = e
i.x = f
i.z = b
b.x = k
b.z = e
j.q = a
f.q = a
assert k.q.s.x.q.s.x.q.s.txt == "
class A:
    def __init__(self, txt: str):
        self.q: C = None
        self.txt = txt

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

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

k = A("k")
e = B("e")
a = C("a")
d = A("d")
g = B("g")
i = B("i")
b = B("b")
j = A("j")
f = A("f")

k.q = a
e.x = k
e.z = g
a.s = i
d.q = a
g.x = k
g.z = e
i.x = f
i.z = b
b.x = k
b.z = e
j.q = a
f.q = a
assert k.q.s.x.q.s.x.q.s.txt == "i"