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

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

d = A("d")
f = B("f")
l = A("l")
m = A("m")
g = B("g")
i = B("i")
j = A("j")
e = A("e")
b = A("b")
k = B("k")

d.o = f
d.w = k
f.t = b
l.o = k
l.w = k
m.o = f
m.w = g
g.t = j
i.t = j
j.o = i
j.w = g
e.o = k
e.w = g
b.o = g
b.w = i
k.t = d
assert m.w.t.o.t.w.t.w.t.txt == "
class A:
    def __init__(self, txt: str):
        self.o: B = None
        self.w: B = None
        self.txt = txt

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

d = A("d")
f = B("f")
l = A("l")
m = A("m")
g = B("g")
i = B("i")
j = A("j")
e = A("e")
b = A("b")
k = B("k")

d.o = f
d.w = k
f.t = b
l.o = k
l.w = k
m.o = f
m.w = g
g.t = j
i.t = j
j.o = i
j.w = g
e.o = k
e.w = g
b.o = g
b.w = i
k.t = d
assert m.w.t.o.t.w.t.w.t.txt == "j"