class A:
    def __init__(self, txt: str):
        self.x: C = None
        self.o: 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.w: C = None
        self.u: C = None
        self.q: A = None
        self.txt = txt

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

f.x = i
f.o = m
m.w = l
l.w = i
l.u = i
l.q = f
i.w = l
i.u = l
i.q = f
assert l.u.q.x.q.txt == "
class A:
    def __init__(self, txt: str):
        self.x: C = None
        self.o: 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.w: C = None
        self.u: C = None
        self.q: A = None
        self.txt = txt

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

f.x = i
f.o = m
m.w = l
l.w = i
l.u = i
l.q = f
i.w = l
i.u = l
i.q = f
assert l.u.q.x.q.txt == "f"