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

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

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

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

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

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

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

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

f.y = i
f.x = b
i.x = f
i.q = f
b.y = i
b.r = i
assert b.y.q.y.txt == "i"