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

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

n = A("n")
k = B("k")
j = A("j")
d = B("d")
a = A("a")
e = A("e")
i = B("i")

n.s = k
k.w = n
j.s = k
d.w = a
a.s = i
e.s = k
i.w = n
assert d.w.s.w.s.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: A = None
        self.txt = txt

n = A("n")
k = B("k")
j = A("j")
d = B("d")
a = A("a")
e = A("e")
i = B("i")

n.s = k
k.w = n
j.s = k
d.w = a
a.s = i
e.s = k
i.w = n
assert d.w.s.w.s.w.txt == "n"