#include <stdio.h>
typedef struct{
  char c;
  int num;
} Card;

void quickSort(Card [],int,int);
int partition(Card [],int,int);

int main(){

  int i,j,n,k,l,flag=0;
  Card card[100];
  Card card2[100];

  scanf("%d",&n);

 for(i=0;i<n;i++){
   scanf(" %c %d",&card[i].c, &card[i].num);
   card2[i].c = card[i].c;
   card2[i].num = card[i].num;
 }

 quickSort(card,0,n-1);

 for(i=0;i<n;i++)
    {
      for(j=i+1;j<n;j++)
	{
	  for(k=0;k<n;k++)
	    {
	      for(l=k+1;l<n;l++)
		{
		  if(card[i].num == card[j].num && card[i].c == card2[l].c && card[j].c == card2[k].c)
		    {
		      flag=1;
		    }
		}
	    }
	}
    }
  
  if(flag == 0)
    {
      printf("Stable\n");
    }
  else
    {
     printf("Not stable\n");
    }

 for(i=0;i<n;i++){
   printf("%c %d\n",card[i].c,card[i].num);
 }

 return 0;
}

void quickSort(Card A[],int p,int r){

  int q;

  if(p < r){
    q = partition(A,p,r);
    quickSort(A,p,q-1);
    quickSort(A,q+1,r);
  }
}

int partition(Card A[],int p,int r){

  int  i,j,x;
  Card temp;

  x = A[r].num;
  i = p-1;
  for(j=p;j<r;j++){
    if(A[j].num <= x){
      i = i+1;
      temp = A[i];
      A[i] = A[j];
      A[j] = temp;
    }
  }
  temp = A[i+1];
  A[i+1] = A[r];
  A[r] = temp;
  return i+1;
}