input: Write a python function to solve the Traveling Salesman Problem (TSP) using dynamic programming.
  assert solveTSP([[0, 10, 15, 20], [10, 0, 35, 25], [15, 35, 0, 30], [20, 25, 30, 0]]) == 80
  assert solveTSP([[0, 29, 20, 21], [29, 0, 15, 17], [20, 15, 0, 28], [21, 17, 28, 0]]) == 69
  assert solveTSP([[0, 5, 10], [5, 0, 15], [10, 15, 0]]) == 30
output: def solveTSP(distances):
      n = len(distances)
      memo = [[None] * (1 << n) for _ in range(n)]
  
      def dp(i, mask):
          if mask == (1 << n) - 1:
              return distances[i][0]
          if memo[i][mask] is not None:
              return memo[i][mask]
          min_cost = float('inf')
          for j in range(n):
              if mask & (1 << j) == 0:
                  cost = distances[i][j] + dp(j, mask | (1 << j))
                  if cost < min_cost:
                      min_cost = cost
          memo[i][mask] = min_cost
          return min_cost
  
      return dp(0, 1)