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

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

e = A("e")
c = B("c")
k = B("k")
m = B("m")
i = B("i")
n = A("n")
a = B("a")
b = B("b")

e.o = n
c.y = m
c.w = n
k.y = c
k.w = e
m.y = c
m.w = n
i.y = a
i.w = n
n.o = e
a.y = m
a.w = n
b.y = a
b.w = e
assert i.y.y.w.o.o.o.o.o.txt == "
class A:
    def __init__(self, txt: str):
        self.o: A = None
        self.txt = txt

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

e = A("e")
c = B("c")
k = B("k")
m = B("m")
i = B("i")
n = A("n")
a = B("a")
b = B("b")

e.o = n
c.y = m
c.w = n
k.y = c
k.w = e
m.y = c
m.w = n
i.y = a
i.w = n
n.o = e
a.y = m
a.w = n
b.y = a
b.w = e
assert i.y.y.w.o.o.o.o.o.txt == "e"