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

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

h = A("h")
e = B("e")
j = A("j")
b = B("b")
l = B("l")
c = B("c")
i = B("i")

h.p = c
e.u = l
j.p = b
b.u = c
l.u = i
c.u = l
i.u = e
assert b.u.u.u.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: B = None
        self.txt = txt

h = A("h")
e = B("e")
j = A("j")
b = B("b")
l = B("l")
c = B("c")
i = B("i")

h.p = c
e.u = l
j.p = b
b.u = c
l.u = i
c.u = l
i.u = e
assert b.u.u.u.u.txt == "e"