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

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

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

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

i.q = n
n.u = d
d.y = i
assert i.q.u.y.txt == "
class A:
    def __init__(self, txt: str):
        self.q: B = None
        self.txt = txt

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

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

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

i.q = n
n.u = d
d.y = i
assert i.q.u.y.txt == "i"