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

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

h = A("h")
e = B("e")
c = B("c")
i = A("i")
l = B("l")
d = B("d")

h.o = d
e.p = h
e.u = i
c.p = h
c.u = i
i.o = d
l.p = h
l.u = h
d.p = h
d.u = i
assert c.p.o.u.o.u.txt == "
class A:
    def __init__(self, txt: str):
        self.o: B = None
        self.txt = txt

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

h = A("h")
e = B("e")
c = B("c")
i = A("i")
l = B("l")
d = B("d")

h.o = d
e.p = h
e.u = i
c.p = h
c.u = i
i.o = d
l.p = h
l.u = h
d.p = h
d.u = i
assert c.p.o.u.o.u.txt == "i"