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

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

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

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

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

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

n.z = a
n.x = k
i.q = c
c.z = j
c.x = d
j.z = e
j.x = i
b.z = n
b.x = i
d.q = c
m.z = n
m.x = i
a.z = n
a.x = i
e.z = c
e.x = i
k.q = j
assert c.z.x.q.x.q.z.z.x.q.txt == "c"