class A:
    def __init__(self, txt: str):
        self.y: B = None
        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")
j = B("j")
c = B("c")
n = B("n")

e.y = n
e.w = j
j.o = e
j.x = c
c.o = e
c.x = n
n.o = e
n.x = j
assert j.x.x.x.o.txt == "
class A:
    def __init__(self, txt: str):
        self.y: B = None
        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")
j = B("j")
c = B("c")
n = B("n")

e.y = n
e.w = j
j.o = e
j.x = c
c.o = e
c.x = n
n.o = e
n.x = j
assert j.x.x.x.o.txt == "e"