#include<stdio.h>

typedef struct card{
 char mark;
 int num;
}card;


int part(card A[],int p,int r){
int i,j;
card temp;

i=p-1;
for(j=p;j<r;j++){
 if(A[j].num<=A[r].num){
  i++;
  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;
}



void quicksort(card A[],int p,int r){
int q;
 if(p<r){
  q=part(A,p,r);
  quicksort(A,p,q-1);
  quicksort(A,q+1,r);
 }

}


int stable(card T[],card U[],int n){
int i;
int count=0;
for(i=0;i<n;i++){
if( (T[i].num==U[i].num)&&(T[i].mark==U[i].mark) ){count++;}
}
if(count==n){return 1;}

}



void bubble(card U[],int n){
 int k,l;
 card temp;

for(k=0;k<n-1;k++){
 for(l=n-1;l>=k+1;l--){
  if(U[l].num<U[l-1].num){ temp=U[l]; U[l]=U[l-1]; U[l-1]=temp; }
 }
}

}


int main(){
int i,n,x;
card A[100001];
card B[100001];

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

quicksort(A,0,n-1);
x=stable(A,B,n);
if(x==1){printf("Stable\n");}
else{printf("Not stable\n");}




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



return 0;
}