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

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

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

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

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

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

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