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

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

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

n = A("n")
h = B("h")
k = C("k")

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

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

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

n = A("n")
h = B("h")
k = C("k")

n.p = h
h.u = n
k.y = h
k.t = n
k.u = n
assert h.u.p.u.txt == "n"