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

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

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

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

i.x = l
f.s = l
f.o = i
l.o = f
l.v = i
assert f.s.v.x.txt == "
class A:
    def __init__(self, txt: str):
        self.x: C = None
        self.txt = txt

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

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

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

i.x = l
f.s = l
f.o = i
l.o = f
l.v = i
assert f.s.v.x.txt == "l"