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

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

b = A("b")
i = B("i")
f = A("f")
d = B("d")
n = A("n")
j = A("j")

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

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

b = A("b")
i = B("i")
f = A("f")
d = B("d")
n = A("n")
j = A("j")

b.s = n
i.w = d
f.s = j
d.w = i
n.s = j
j.s = n
assert i.w.w.w.w.w.w.txt == "i"