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

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

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

k = A("k")
a = B("a")
l = C("l")
n = A("n")
m = A("m")
c = B("c")
d = A("d")

k.z = d
k.s = l
a.s = l
l.q = c
n.z = m
n.s = l
m.z = n
m.s = l
c.s = l
d.z = m
d.s = l
assert n.z.z.z.s.q.txt == "
class A:
    def __init__(self, txt: str):
        self.z: A = None
        self.s: C = None
        self.txt = txt

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

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

k = A("k")
a = B("a")
l = C("l")
n = A("n")
m = A("m")
c = B("c")
d = A("d")

k.z = d
k.s = l
a.s = l
l.q = c
n.z = m
n.s = l
m.z = n
m.s = l
c.s = l
d.z = m
d.s = l
assert n.z.z.z.s.q.txt == "c"