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

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

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

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

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

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

b.s = m
n.x = h
n.o = h
h.x = n
h.o = n
m.x = h
m.o = n
assert m.o.o.x.txt == "n"