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

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

e = A("e")
f = B("f")
k = A("k")
n = B("n")
d = B("d")
l = A("l")

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

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

e = A("e")
f = B("f")
k = A("k")
n = B("n")
d = B("d")
l = A("l")

e.w = n
f.o = k
f.x = d
k.w = f
n.o = l
n.x = f
d.o = k
d.x = n
l.w = f
assert f.x.x.o.w.x.o.txt == "k"