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

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

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

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

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

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

h.s = e
d.w = h
e.s = h
b.w = h
i.s = h
n.w = i
assert h.s.s.s.s.txt == "h"