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

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

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

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

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

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

e.q = a
e.u = j
m.x = g
l.x = g
g.q = a
g.u = d
a.x = n
d.q = l
d.u = g
k.x = g
b.q = a
b.u = j
j.q = m
j.u = d
n.q = a
n.u = b
assert l.x.q.x.q.x.q.txt == "a"