output_description: In the first line, print the stability ("Stable" or "Not stable") of this
  output.
  
  In the following lines, print the arranged cards in the same manner of that of
  the input.
input_description: The first line contains an integer _n_ , the number of cards.
  
  _n_ cards are given in the following lines. Each card is given in a line and
  represented by a pair of a character and an integer separated by a single
  space.
attempt: if __name__ == "__main__":
      import sys
  
      input = sys.stdin.readline
  
      MAX = 100000
      SENTINEL = 2000000000
  
      class Card:
          def __init__(self, suit, value):
              self.suit = suit
              self.value = value
  
      def merge(A, n, left, mid, right):
          n1 = mid - left
          n2 = right - mid
          L = [Card(None, None) for _ in range(n1 + 1)]
          R = [Card(None, None) for _ in range(n2 + 1)]
          for i in range(n1):
              L[i] = A[left + i]
          for i in range(n2):
              R[i] = A[mid + i]
          L[n1].value = SENTINEL
          R[n2].value = SENTINEL
          i, j = 0, 0
          for k in range(left, right):
              if L[i].value <= R[j].value:
                  A[k] = L[i]
                  i += 1
              else:
                  A[k] = R[j]
                  j += 1
  
      def mergeSort(A, n, left, right):
          if left + 1 < right:
              mid = (left + right) // 2
              mergeSort(A, n, left, mid)
              mergeSort(A, n, mid, right)
              merge(A, n, left, mid, right)
  
      def swap(a, i, j):
          # list aのi番目の要素とj番目の要素を交換する関数
          k = a[j]
          a[j] = a[i]
          a[i] = k
  
      def partition(A, p, r):
          x = A[r]
          i = p - 1
          for j in range(p, r):
              if A[j].value <= x.value:
                  i += 1
                  swap(A, i, j)
          swap(A, i + 1, r)
          return i + 1
  
      def quickSort(A, p, r):
          if p < r:
              q = partition(A, p, r)
              quickSort(A, p, q - 1)
              quickSort(A, q + 1, r)
  
      n = int(input())
  
      A = [Card(None, None) for _ in range(n)]
      B = [Card(None, None) for _ in range(n)]
  
      for i in range(n):
          suit, value = input().split()
          A[i].suit = suit
          B[i].suit = suit
          A[i].value = int(value)
          B[i].value = int(value)
  
      mergeSort(A, n, 0, n)
      quickSort(B, 0, n - 1)
  
      for i in range(n):
          if A[i].suit != B[i].suit:
              print("Not stable")
              break
      else:
          print("Stable")
  
      for b in B:
          print(b.suit, b.value)
  
problem_description: Quick Sort
  
  Let's arrange a deck of cards. Your task is to sort totally n cards. A card
  consists of a part of a suit (S, H, C or D) and an number. Write a program
  which sorts such cards based on the following pseudocode:
  
      
      
      Partition(A, p, r)
      1 x = A[r]
      2 i = p-1
      3 for j = p to r-1
      4     do if A[j] <= x
      5        then i = i+1
      6            exchange A[i] and A[j] 
      7 exchange A[i+1] and A[r]
      8 return i+1
      
      
      Quicksort(A, p, r)
      1 if p < r
      2    then q = Partition(A, p, r)
      3        run Quicksort(A, p, q-1)
      4        run Quicksort(A, q+1, r)
      
  
  Here, A is an array which represents a deck of cards and comparison operations
  are performed based on the numbers.
  
  Your program should also report the stability of the output for the given
  input (instance). Here, 'stability of the output' means that: cards with the
  same value appear in the output in the same order as they do in the input
  (instance).
samples: [{"input": "6\n    D 3\n    H 2\n    D 1\n    S 3\n    D 2\n    C 1", "output": "Not stable\n    D 1\n    C 1\n    D 2\n    H 2\n    D 3\n    S 3"}, {"input": "2\n    S 1\n    H 1", "output": "Stable\n    S 1\n    H 1"}]