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

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

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

h = A("h")
a = B("a")
i = C("i")
m = A("m")

h.p = a
h.u = a
h.y = i
a.r = h
i.w = m
m.p = a
m.u = a
m.y = i
assert a.r.u.r.p.txt == "
class A:
    def __init__(self, txt: str):
        self.p: B = None
        self.u: B = None
        self.y: C = None
        self.txt = txt

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

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

h = A("h")
a = B("a")
i = C("i")
m = A("m")

h.p = a
h.u = a
h.y = i
a.r = h
i.w = m
m.p = a
m.u = a
m.y = i
assert a.r.u.r.p.txt == "a"