def decideHost(i, j, n):
    """
    i: Row index on the original matrix.
    j: Column index on the original matrix.
    n: Target size of the new matrix.
    Returns the sub-matrix and new row/column index.
    """
    h = 2 if i >= n else 0
    h = h+1 if j >= n else h
    ni = abs(n - i) if i >= n else i
    nj = abs(n - j) if j >= n else j
    return (ni, nj, h)