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

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

j = A("j")
e = B("e")
l = A("l")
a = A("a")
m = B("m")

j.w = m
j.p = m
e.y = j
e.o = j
l.w = e
l.p = m
a.w = m
a.p = e
m.y = j
m.o = a
assert e.y.w.o.w.txt == "
class A:
    def __init__(self, txt: str):
        self.w: B = None
        self.p: B = None
        self.txt = txt

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

j = A("j")
e = B("e")
l = A("l")
a = A("a")
m = B("m")

j.w = m
j.p = m
e.y = j
e.o = j
l.w = e
l.p = m
a.w = m
a.p = e
m.y = j
m.o = a
assert e.y.w.o.w.txt == "m"