Finding GCD of each row and column and replacing with each element with maximum of GCD of row or column .
def replacematrix ( mat , n , m ) : NEW_LINE INDENT rgcd = [ 0 ] * R NEW_LINE cgcd = [ 0 ] * C NEW_LINE DEDENT