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

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

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

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

k.o = n
k.z = n
k.r = n
b.s = k
b.x = n
n.q = k
assert b.s.z.q.txt == "
class A:
    def __init__(self, txt: str):
        self.o: C = None
        self.z: C = None
        self.r: C = None
        self.txt = txt

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

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

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

k.o = n
k.z = n
k.r = n
b.s = k
b.x = n
n.q = k
assert b.s.z.q.txt == "k"