#include <stdio.h>
#include <stdlib.h>
#define MAX 100000

int partition(int*,int,int);
void quickSort(int*,int,int);

char C[MAX];

int main(){

  //unsigned short *A;
  int A[MAX];

  int i,k,n;
  int x,p,q,r;
  int SA[100000];

  scanf("%d",&n);

  p=0;
  r=n-1;

  //A=malloc(sizeof(short)*n+1);

  for(i=0;i<n;i++){
    scanf(" %c%d",&C[i],&A[i]);
  }

 for(i=0;i<n;i++){
   SA[i]=A[i];
  }

  quickSort(A,p,r);


  for(i=0;i<n;i++){
    if(SA[i]!=A[i]) k=1; 
  }

  if(k==1) printf("Not stable\n");
  else printf("Stable\n");


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


  return 0;
  
}


int partition(int* A,int p,int r){
  int i,j,x,mv;
  char cmv;
  i=p-1;
  x=A[r];

  for(j=p;j<r;j++){
    if(A[j]<=x){
      i++;
 
      mv=A[i];
      cmv=C[i];
      A[i]=A[j];
      C[i]-C[j];
      A[j]=mv;
      C[j]=cmv;
    }

  }

  mv=A[i+1];
  cmv=C[i+1];
  A[i+1]=A[r];
  C[i+1]=C[r];
  A[r]=mv;
  C[r]=cmv;

  return i+1;
}


void quickSort(int* 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);
  }
}