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

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

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

n = A("n")
m = B("m")
i = C("i")

n.y = m
m.t = i
m.s = i
m.x = n
i.z = n
assert n.y.t.z.txt == "
class A:
    def __init__(self, txt: str):
        self.y: B = None
        self.txt = txt

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

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

n = A("n")
m = B("m")
i = C("i")

n.y = m
m.t = i
m.s = i
m.x = n
i.z = n
assert n.y.t.z.txt == "n"