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

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

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

k = A("k")
a = B("a")
c = C("c")
n = C("n")

k.s = a
k.x = a
a.q = k
c.y = n
c.t = k
n.y = c
n.t = k
assert k.x.q.s.q.txt == "
class A:
    def __init__(self, txt: str):
        self.s: B = None
        self.x: B = None
        self.txt = txt

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

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

k = A("k")
a = B("a")
c = C("c")
n = C("n")

k.s = a
k.x = a
a.q = k
c.y = n
c.t = k
n.y = c
n.t = k
assert k.x.q.s.q.txt == "k"