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

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

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

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

i.w = a
i.y = f
f.w = i
a.q = i
assert i.w.q.y.txt == "
class A:
    def __init__(self, txt: str):
        self.w: C = None
        self.y: B = None
        self.txt = txt

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

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

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

i.w = a
i.y = f
f.w = i
a.q = i
assert i.w.q.y.txt == "f"