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

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

d = A("d")
g = B("g")
n = B("n")
k = A("k")
c = A("c")
l = B("l")
i = A("i")
m = A("m")
b = B("b")

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

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

d = A("d")
g = B("g")
n = B("n")
k = A("k")
c = A("c")
l = B("l")
i = A("i")
m = A("m")
b = B("b")

d.u = b
d.x = g
g.o = n
g.q = l
n.o = l
n.q = g
k.u = b
k.x = l
c.u = b
c.x = g
l.o = g
l.q = g
i.u = l
i.x = b
m.u = n
m.x = n
b.o = g
b.q = l
assert m.x.o.q.txt == "g"