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

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

b = A("b")
h = B("h")
m = A("m")
i = B("i")
a = A("a")
c = B("c")
n = A("n")

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

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

b = A("b")
h = B("h")
m = A("m")
i = B("i")
a = A("a")
c = B("c")
n = A("n")

b.y = c
h.p = c
h.u = i
m.y = h
i.p = h
i.u = h
a.y = i
c.p = i
c.u = i
n.y = i
assert h.p.u.u.txt == "h"