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

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

f = A("f")
b = B("b")
m = A("m")
j = A("j")
k = A("k")
e = A("e")

f.w = b
b.s = k
m.w = b
j.w = b
k.w = b
e.w = b
assert j.w.s.w.s.w.s.txt == "
class A:
    def __init__(self, txt: str):
        self.w: B = None
        self.txt = txt

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

f = A("f")
b = B("b")
m = A("m")
j = A("j")
k = A("k")
e = A("e")

f.w = b
b.s = k
m.w = b
j.w = b
k.w = b
e.w = b
assert j.w.s.w.s.w.s.txt == "k"