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

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

i = A("i")
h = B("h")
f = B("f")
e = A("e")
m = B("m")
n = A("n")
l = B("l")
j = B("j")

i.s = m
h.w = j
f.w = l
e.s = h
m.w = j
n.s = m
l.w = m
j.w = l
assert f.w.w.w.w.w.w.txt == "
class A:
    def __init__(self, txt: str):
        self.s: B = None
        self.txt = txt

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

i = A("i")
h = B("h")
f = B("f")
e = A("e")
m = B("m")
n = A("n")
l = B("l")
j = B("j")

i.s = m
h.w = j
f.w = l
e.s = h
m.w = j
n.s = m
l.w = m
j.w = l
assert f.w.w.w.w.w.w.txt == "j"