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

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

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

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

i.o = m
i.w = m
i.v = l
l.o = i
l.q = i
l.p = i
m.q = i
m.x = i
m.o = i
assert l.o.v.o.txt == "
class A:
    def __init__(self, txt: str):
        self.o: C = None
        self.v: B = None
        self.w: C = None
        self.txt = txt

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

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

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

i.o = m
i.w = m
i.v = l
l.o = i
l.q = i
l.p = i
m.q = i
m.x = i
m.o = i
assert l.o.v.o.txt == "i"