input: def merge_sort(A: List[int], B: List[int]) -> List[int]:
      """Merge two sorted lists A and B into a single sorted list by comparing elements
      one by one. If the element from A is greater than the element from B, move to the
      next element in B; otherwise, move to the next element in A. Continue until one
      of the lists is exhausted, then append the remaining elements from the other list.
      >>> merge_sort([3, 6, 8, 10, 11], [2, 5, 7, 12])
      [2, 3, 5, 6, 7, 8, 10, 11, 12]
      >>> merge_sort([1, 3, 5], [2, 4, 6])
      [1, 2, 3, 4, 5, 6]
      """
output:     result = []
      i, j = 0, 0
      while i < len(A) and j < len(B):
          if A[i] < B[j]:
              result.append(A[i])
              i += 1
          else:
              result.append(B[j])
              j += 1
      result.extend(A[i:])
      result.extend(B[j:])
      return result