
#include <stdio.h>
#include <stdlib.h>

void quick_sort(int *,int,int,char *);

int main()
{
  int n; //?????°??£?¨?
  int i;


  scanf("%d",&n);//?????????????????°n???????????????

  char *quick_char = (char*)malloc(sizeof(char)*n);//?????????????????????????¬??????????
  int *quick_int = (int*)malloc(sizeof(int)*n);//??????????????°??????????¬??????????

  for(i=0;i<n;i++)
  {
    scanf("%s",&quick_char[i]);
    scanf("%d",&quick_int[i]);
  }

  quick_sort(&quick_int[0],0,n-1,&quick_char[0]);

  printf("Not stable\n");
  for(i=0;i<n;i++)
  {
    printf("%c",quick_char[i]);
    printf(" %d",quick_int[i]);
    puts("");
  }

  return 0;
} 

//quicksort??¢??°

void quick_sort(int *quick_int,int left,int right,char *quick_char)
{
  int s,t,i,j;
  char c,ca;

  if(left < right)
  {
    s = quick_int[left];
    ca = quick_char[left];
    i = left;
    j = right + 1;

    while(1)