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

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

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

l.z = c
l.q = g
g.u = m
g.p = i
k.z = c
k.q = n
c.z = l
c.q = n
d.z = l
d.q = g
i.z = c
i.q = m
n.u = g
n.p = d
m.u = n
m.p = d
h.z = i
h.q = g
e.z = h
e.q = n
assert m.p.z.q.u.txt == "
class A:
    def __init__(self, txt: str):
        self.z: A = None
        self.q: B = None
        self.txt = txt

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

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

l.z = c
l.q = g
g.u = m
g.p = i
k.z = c
k.q = n
c.z = l
c.q = n
d.z = l
d.q = g
i.z = c
i.q = m
n.u = g
n.p = d
m.u = n
m.p = d
h.z = i
h.q = g
e.z = h
e.q = n
assert m.p.z.q.u.txt == "m"