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

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

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

i = A("i")
f = B("f")
n = C("n")
l = A("l")

i.o = f
i.t = l
f.z = n
n.t = f
l.o = f
l.t = i
assert n.t.z.t.txt == "
class A:
    def __init__(self, txt: str):
        self.o: B = None
        self.t: A = None
        self.txt = txt

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

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

i = A("i")
f = B("f")
n = C("n")
l = A("l")

i.o = f
i.t = l
f.z = n
n.t = f
l.o = f
l.t = i
assert n.t.z.t.txt == "f"