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

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

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

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

n.r = a
a.w = i
i.o = a
i.t = a
i.r = n
assert a.w.o.w.txt == "
class A:
    def __init__(self, txt: str):
        self.r: B = None
        self.txt = txt

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

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

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

n.r = a
a.w = i
i.o = a
i.t = a
i.r = n
assert a.w.o.w.txt == "i"