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

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

c = A("c")
j = B("j")
l = B("l")
m = A("m")
k = B("k")
b = A("b")
e = B("e")
a = A("a")
n = B("n")

c.x = n
c.o = e
j.q = c
l.q = c
m.x = k
m.o = l
k.q = c
b.x = k
b.o = k
e.q = a
a.x = k
a.o = n
n.q = m
assert m.o.q.x.q.x.q.o.txt == "
class A:
    def __init__(self, txt: str):
        self.x: B = None
        self.o: B = None
        self.txt = txt

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

c = A("c")
j = B("j")
l = B("l")
m = A("m")
k = B("k")
b = A("b")
e = B("e")
a = A("a")
n = B("n")

c.x = n
c.o = e
j.q = c
l.q = c
m.x = k
m.o = l
k.q = c
b.x = k
b.o = k
e.q = a
a.x = k
a.o = n
n.q = m
assert m.o.q.x.q.x.q.o.txt == "e"