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

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

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

l = A("l")
i = B("i")
g = C("g")

l.o = g
i.t = l
g.t = l
assert i.t.o.t.txt == "
class A:
    def __init__(self, txt: str):
        self.o: C = None
        self.txt = txt

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

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

l = A("l")
i = B("i")
g = C("g")

l.o = g
i.t = l
g.t = l
assert i.t.o.t.txt == "l"