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

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

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

k = A("k")
n = B("n")
f = C("f")
m = C("m")
l = A("l")
b = C("b")

k.u = b
k.z = n
n.q = m
n.s = k
n.u = k
f.z = l
m.z = l
l.u = f
l.z = n
b.z = k
assert k.z.s.z.q.z.txt == "
class A:
    def __init__(self, txt: str):
        self.u: C = None
        self.z: B = None
        self.txt = txt

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

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

k = A("k")
n = B("n")
f = C("f")
m = C("m")
l = A("l")
b = C("b")

k.u = b
k.z = n
n.q = m
n.s = k
n.u = k
f.z = l
m.z = l
l.u = f
l.z = n
b.z = k
assert k.z.s.z.q.z.txt == "l"