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

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

b = A("b")
h = B("h")
l = B("l")
e = B("e")
n = A("n")
i = B("i")

b.p = n
h.o = e
h.r = n
l.o = h
l.r = b
e.o = i
e.r = b
n.p = b
i.o = h
i.r = n
assert l.o.r.p.p.p.txt == "
class A:
    def __init__(self, txt: str):
        self.p: A = None
        self.txt = txt

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

b = A("b")
h = B("h")
l = B("l")
e = B("e")
n = A("n")
i = B("i")

b.p = n
h.o = e
h.r = n
l.o = h
l.r = b
e.o = i
e.r = b
n.p = b
i.o = h
i.r = n
assert l.o.r.p.p.p.txt == "b"