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

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

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

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

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

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

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

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

n.y = h
a.p = n
a.t = n
h.t = a
assert h.t.p.y.txt == "h"