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

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

h = A("h")
l = B("l")
e = B("e")
a = B("a")

h.o = l
l.o = a
l.r = a
e.o = a
e.r = a
a.o = l
a.r = l
assert l.o.r.o.o.txt == "
class A:
    def __init__(self, txt: str):
        self.o: B = None
        self.txt = txt

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

h = A("h")
l = B("l")
e = B("e")
a = B("a")

h.o = l
l.o = a
l.r = a
e.o = a
e.r = a
a.o = l
a.r = l
assert l.o.r.o.o.txt == "l"