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

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

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

n = A("n")
k = B("k")
b = C("b")

n.q = k
n.w = b
k.y = n
b.t = k
b.z = n
assert b.z.w.t.txt == "
class A:
    def __init__(self, txt: str):
        self.q: B = None
        self.w: C = None
        self.txt = txt

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

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

n = A("n")
k = B("k")
b = C("b")

n.q = k
n.w = b
k.y = n
b.t = k
b.z = n
assert b.z.w.t.txt == "k"