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

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

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

j.o = a
e.w = n
k.w = n
n.o = e
l.w = j
a.w = d
d.o = a
assert d.o.w.o.w.txt == "
class A:
    def __init__(self, txt: str):
        self.o: B = None
        self.txt = txt

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

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

j.o = a
e.w = n
k.w = n
n.o = e
l.w = j
a.w = d
d.o = a
assert d.o.w.o.w.txt == "d"