  Lin and Lin have recently shown how starting with a classical query algorithm
(decision tree) for a function, we may find upper bounds on its quantum query
complexity. More precisely, they have shown that given a decision tree for a
function $f:\{0,1\}^n\to[m]$ whose input can be accessed via queries to its
bits, and a guessing algorithm that predicts answers to the queries, there is a
quantum query algorithm for $f$ which makes at most $O(\sqrt{GT})$ quantum
queries where $T$ is the depth of the decision tree and $G$ is the maximum
number of mistakes of the guessing algorithm. In this paper we give a simple
proof of and generalize this result for functions $f:[\ell]^n \to [m]$ with
non-binary input as well as output alphabets. Our main tool for this
generalization is non-binary span program which has recently been developed for
non-binary functions, and the dual adversary bound. As applications of our main
result we present several quantum query upper bounds, some of which are new. In
particular, we show that topological sorting of vertices of a directed graph
$\mathcal{G}$ can be done with $O(n^{3/2})$ quantum queries in the adjacency
matrix model. Also, we show that the quantum query complexity of the maximum
bipartite matching is upper bounded by $O(n^{3/4}\sqrt m + n)$ in the adjacency
list model.
