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

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

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

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

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

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

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

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

d.y = n
i.s = d
i.q = d
n.t = d
n.u = d
n.y = k
k.s = d
k.q = d
assert d.y.u.y.txt == "n"