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

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

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

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

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

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

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

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

d.u = i
i.t = d
n.p = i
n.u = i
n.y = i
assert n.y.t.u.txt == "i"