class A:
    def __init__(self, txt: str):
        self.u: B = None
        self.t: 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.p: A = None
        self.txt = txt

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

f.u = d
f.t = d
d.u = n
n.p = f
assert f.u.u.p.txt == "
class A:
    def __init__(self, txt: str):
        self.u: B = None
        self.t: 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.p: A = None
        self.txt = txt

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

f.u = d
f.t = d
d.u = n
n.p = f
assert f.u.u.p.txt == "f"