will not work for negative elements , so . . adding this
if ( matrix [ 0 ] [ 0 ] < 0 ) : NEW_LINE INDENT mod = k - ( abs ( matrix [ 0 ] [ 0 ] ) % k ) NEW_LINE DEDENT else : NEW_LINE INDENT mod = matrix [ 0 ] [ 0 ] % k NEW_LINE DEDENT for i in range ( n ) : NEW_LINE INDENT for j in range ( m ) : NEW_LINE INDENT arr . append ( matrix [ i ] [ j ] ) NEW_LINE DEDENT DEDENT