input: def matrix_operations(mat1, mat2, op):
      """ Performs various matrix operations like addition, subtraction, multiplication and transpose.
      mat1 and mat2 are instances of the Matrix class, and op is a string indicating the operation to be performed.
      If op is 'add', it will add mat2 to mat1.
      If op is 'sub', it will subtract mat2 from mat1.
      If op is 'mul', it will multiply mat1 by mat2.
      If op is 'transpose', it will transpose mat1.
      Returns the resultant matrix after performing the specified operation.
      Example:
      >>> mat1 = Matrix(2, 2, [1, 2, 3, 4])
      >>> mat2 = Matrix(2, 2, [5, 6, 7, 8])
      >>> matrix_operations(mat1, mat2, 'add')
      '6 8 \n10 12 \n'
      """
output:     if op == 'add':
          return mat1 + mat2
      elif op == 'sub':
          return mat1 - mat2
      elif op == 'mul':
          return mat1 * mat2
      elif op == 'transpose':
          return mat1.transpose()
      else:
          raise ValueError("Invalid operation")