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

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

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

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

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

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

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