input: def Matrix(m: int, n: int, lst: list) -> object:
      """
      Develop a class in Python to perform various matrix operations like addition, subtraction, multiplication and transpose.
      >>> mat1 = Matrix(2, 2, [1, 2, 3, 4])
      >>> print(mat1)
      1 2 
      3 4 
      >>> mat2 = Matrix(2, 2, [5, 6, 7, 8])
      >>> mat1.add(mat2)
      >>> print(mat1)
      6 8 
      10 12 
      >>> mat1.sub(mat2)
      >>> print(mat1)
      1 2 
      3 4 
      >>> mat1.mul(mat2)
      >>> print(mat1)
      19 22 
      43 50 
      >>> mat1.transpose()
      >>> print(mat1)
      19 43 
      22 50 
      """
output:     
      class Matrix:
          def __init__(self, m: int, n: int, lst: list):
              self.rows = m
              self.cols = n
              self.data = lst
          
          def __str__(self):
              result = []
              for i in range(self.rows):
                  result.append(' '.join(map(str, self.data[i*self.cols:(i+1)*self.cols])))
              return '\n'.join(result)
          
          def add(self, other):
              if self.rows != other.rows or self.cols != other.cols:
                  raise ValueError("Matrices must have the same dimensions for addition")
              for i in range(self.rows * self.cols):
                  self.data[i] += other.data[i]
          
          def sub(self, other):
              if self.rows != other.rows or self.cols != other.cols:
                  raise ValueError("Matrices must have the same dimensions for subtraction")
              for i in range(self.rows * self.cols):
                  self.data[i] -= other.data[i]
          
          def mul(self, other):
              if self.cols != other.rows:
                  raise ValueError("Number of columns in the first matrix must be equal to the number of rows in the second matrix")
              result = [0] * (self.rows * other.cols)
              for i in range(self.rows):
                  for j in range(other.cols):
                      for k in range(self.cols):
                          result[i*other.cols + j] += self.data[i*self.cols + k] * other.data[k*other.cols + j]
              self.data = result
              self.cols = other.cols
          
          def transpose(self):
              result = [0] * (self.rows * self.cols)
              for i in range(self.rows):
                  for j in range(self.cols):
                      result[j*self.rows + i] = self.data[i*self.cols + j]
              self.data = result
              self.rows, self.cols = self.cols, self.rows
  