#include<stdio.h>
void quickSort(int,int);
int partition(int,int);
int Judge(int);

typedef struct{
  int A;
  char B;
  int No;
}cards;
 
cards card[100000];

int main(void){
  int k,r,mid,p=0;
  int i;
 
  scanf("%d",&k);
 
  for(i=0; i<k; i++){
 
    scanf("%s%d",&card[i].B,&card[i].A);
 
    card[i].No = i;
  }
   
   
  r = k-1;
  quickSort(p, r);
   
  if(Judge(r) == 1)printf("Stable\n");
  else printf("Not stable\n");
 
   
  for(i=0; i<k; i++){
     
    printf("%c %d\n",card[i].B,card[i].A);
  }
   
  return 0;
   
}
 
 void quickSort(int p,int r){
  int q;
  if(p < r){q = partition(p,r);
    quickSort(p,q-1);
    quickSort(q+1,r);
     
  }
}
int partition(int p,int r){
   
  int i=0,j;
  cards temp;
  i = p;
   
  for(j=p; j<r; j++){
    if(card[j].A <= card[r].A){
          i++;
      temp = card[i];
      card[i] = card[j];
      card[j] = temp;
     
    }
  }
  temp = card[r];
  card[r] = card[i];
  card[i] = temp;
  return i;
}
 

int Judge(int r){
  int i;
  for(i=0; i<r; i++){
     
    if(card[i].A == card[i+1].A){     
      if(card[i].No > card[i+1].No)
    {
      return 0;
    }  
    }
  }
 return 1;
}