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.q: A = None
        self.txt = txt

n = A("n")
i = B("i")
e = B("e")
g = B("g")
c = B("c")
k = B("k")
m = B("m")

n.o = m
i.w = n
i.q = n
e.w = n
e.q = n
g.w = n
g.q = n
c.w = n
c.q = n
k.w = n
k.q = n
m.w = n
m.q = n
assert e.q.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.q: A = None
        self.txt = txt

n = A("n")
i = B("i")
e = B("e")
g = B("g")
c = B("c")
k = B("k")
m = B("m")

n.o = m
i.w = n
i.q = n
e.w = n
e.q = n
g.w = n
g.q = n
c.w = n
c.q = n
k.w = n
k.q = n
m.w = n
m.q = n
assert e.q.o.w.txt == "n"