ni, nj should be integers