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

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

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

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

n.z = m
c.u = m
c.y = n
m.o = n
m.t = n
assert c.y.z.o.txt == "
class A:
    def __init__(self, txt: str):
        self.z: C = None
        self.txt = txt

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

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

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

n.z = m
c.u = m
c.y = n
m.o = n
m.t = n
assert c.y.z.o.txt == "n"