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

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

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

n.o = b
n.s = h
i.t = n
h.o = n
h.s = n
b.o = h
b.s = n
assert b.s.s.o.s.txt == "
class A:
    def __init__(self, txt: str):
        self.o: A = None
        self.s: A = None
        self.txt = txt

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

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

n.o = b
n.s = h
i.t = n
h.o = n
h.s = n
b.o = h
b.s = n
assert b.s.s.o.s.txt == "h"