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

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

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

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

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

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

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

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

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