input: Write a python function to implement the simplex algorithm and solve a linear programming problem.
  assert simplex([[2, 4], [1, 2, 14], [3, -4, 18]]) == "Objective function on the optimal solution:  0"
  assert simplex([[3, 2, 1], [2, 1, 0, 10], [1, 2, 3, 20], [0, 0, 1, 30]]) == "Objective function on the optimal solution:  60"
  assert simplex([[1, 1, 1], [2, 3, 1, 10], [4, 1, 2, 20]]) == "Objective function on the optimal solution:  40"
output: def simplex(tableau):
      from fractions import Fraction
  
      # Convert all elements to Fraction to avoid floating point issues
      tableau = [[Fraction(x) for x in row] for row in tableau]
  
      def pivot_index():
          # Find the column with the most negative value in the last row
          col = min(range(len(tableau[0]) - 1), key=lambda c: tableau[-1][c])
          if tableau[-1][col] >= 0:
              return None  # optimal solution found
          # Find the row with the smallest positive ratio in the pivot column
          ratios = [(row[-1] / row[col], i) for i, row in enumerate(tableau[:-1]) if row[col] > 0]
          if not ratios:
              raise ValueError("The problem is unbounded.")
          _, row = min(ratios)
          return row, col
  
      while True:
          pivot = pivot_index()
          if pivot is None:
              break
          row, col = pivot
          pivot_val = tableau[row][col]
          tableau[row] = [x / pivot_val for x in tableau[row]]
          for i, row_val in enumerate(tableau):
              if i != row:
                  row_factor = tableau[i][col]
                  tableau[i] = [row_val - row_factor * tableau[row][j] for j, row_val in enumerate(tableau[i])]
  
      return f"Objective function on the optimal solution:  {tableau[-1][-1]}"