input: from typing import List
  
  def merge_sort(A: List[int], B: List[int]) -> List[int]:
      """
      Given two sorted lists A and B, merges them into a single sorted list by comparing the first element of each list.
      If the first element of A is smaller, it is added to the result and the pointer of A is moved to the next element.
      If the first element of B is smaller, it is added to the result and the pointer of B is moved to the next element.
      This process continues until one of the lists is exhausted, after which the remaining elements of the other list are appended to the result.
      
      >>> merge_sort([3, 6, 8, 10, 11], [2, 5, 7, 12])
      [2, 3, 5, 6, 7, 8, 10, 11, 12]
      """
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