#include<stdio.h>
#define MAX 100000
typedef struct{
  char design;
  int value;
}card;
int Partition(card A[],int,int,int);
void quickSort(card A[],int,int,int);
void mergeSort(card A[],int ,int );
void merge(card A[],int ,int ,int );
int Partition(card A[],int n,int p,int r){
  int x=A[r].value;
  int i=p-1,j;
  card k;
  for(j=p;j<r;j++){
    if(A[j].value<=x){
      i++;
      k=A[i];
      A[i]=A[j];
      A[j]=k;

    }
  }
  k=A[i+1];
  A[i+1]=A[r];
  A[r]=k;
return  i+1;
}
void quickSort(card A[],int n,int p,int r){
  int q;
  if(p<r){
    q=Partition(A,n,p,r);
    quickSort(A,n,p,q-1);
    quickSort(A,n,q+1,r);
  }
}
void mergeSort(card A[],int Left,int Right){

  if(Left+1<Right){
      int Mid=(Left+Right)/2;
  mergeSort(A,Left,Mid);
  mergeSort(A,Mid,Right);
merge(A,Left,Mid,Right);

}
}
void merge(card A[],int Left,int Mid,int Right){
  int i,j,l1,l2,k;
l1=Mid-Left;
  l2=Right-Mid;

  for(i=0;i<l1;i++){
    L[i]=A[Left+i];
  }
  for(j=0;j<l2;j++){
    R[j]=A[Mid+j];
  }
  L[l1]=1000000000;
  R[l2]=1000000000;
  i=0;
  j=0;
  for(k=Left;k<Right;k++)
  if(L[i]<=R[j]){
    A[k]=L[i];
    i++;
    c++;

  }
  else{
    A[k]=R[j];
    j++;
    c++;

  }
}
int main(){
int i,n;
char s[5];
card A[MAX],B[MAX];
scanf("%d",&n);
for (i=0;i<n;i++) {
  scanf("%s %d",s,&A[i].value);
  A[i].design=s[0];
  B[i]=A[i];
  }
  quickSort(A,n,0,n-1);
  mergeSort(B,0,n);
  printf("Not stable\n");
  for(i=0;i<n;i++){


  printf("%c %d\n",A[i].design,A[i].value);
}
printf("\n");
return 0;
}

