Refactor to make more concise
Rename of n and q to dRow and dCol