Firstly, I don't understand the point of having both $m$ and $n.$ Since only their product appears, call it $k.$ You are then trying to find the smallest prime congruent to $1$ modulo $k.$ The bound for such is a highly nontrivial matter, see (eg)
http://en.wikipedia.org/wiki/Linnik%27s_theorem
EDIT It is believed that you don't have to examine more than $\log^2 k$ multiples to find the first prime in a progression of your type.

