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

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

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

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

i.q = a
i.y = a
n.r = i
n.y = a
a.q = i
a.z = i
a.r = i
assert i.y.r.q.txt == "
class A:
    def __init__(self, txt: str):
        self.q: C = None
        self.y: C = None
        self.txt = txt

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

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

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

i.q = a
i.y = a
n.r = i
n.y = a
a.q = i
a.z = i
a.r = i
assert i.y.r.q.txt == "a"