#include <stdio.h>

#define N 100000
#define E 1000000000

int q;
int A[N];
char B[N];
int C[N];


int Partition(int ,int);
void Quicksort(int ,int);
int Judge_stable(int);
void Print(int);

main(){
  int i,n=0,p=0,r=0;

 q = 0;

  scanf("%d",&n);
  
  if(N < n || n < 0) return 0;
  
  r = n-1;
  
  for(i=0;i < n;i++){
    scanf(" %c%d",&B[i],&A[i]);
    C[i] = i;
    if(A[i] < 0 || E < A[i]) return 0;
  }

  Quicksort(p,r);  

  Print(n);
  
  return 0;
}

int Partition(int p,int r){
  int x=0,j;
  x = A[r];
  int i = p-1;
  int tmp=0,tmp2=0;
  char c;
  
  for(j=p;j <= r-1;j++){
    if(A[j] <= x){
      i=i+1;
      tmp = A[j];
      A[j] = A[i];
      A[i] = tmp;
      c = B[j];
      B[j] = B[i];
      B[i] = c;
      tmp2 = C[j];
      C[j] = C[i];
      C[i] = tmp2;
    }
  }
  tmp = 0;
  tmp2 = 0;
  tmp = A[i+1];
  A[i+1] = A[r];
  A[r] = tmp;
  c = B[i+1];
  B[i+1] = B[r];
  B[r] = c;
  tmp2 = C[i+1];
  C[i+1] = C[r];
  C[r] = tmp2;
  
  return i+1;
}

void Quicksort(int p,int r){

  if(p < r){
    q = Partition(p,r);
    Quicksort(p,q-1);
    Quicksort(q+1,r);
  }
}

int Judge_stable(int n){
  int i,j=0;
  
  for(i=0;i < n;i++) {
    if(i == C[i]) j++;
  }

  if(j == n)  return 1;
  else return 0;
}

void Print(int n){
  int i,j=0;

  j = Judge_stable(n);
  if(j == 1) printf("Stable\n");
  else if(j == 0) printf("Not stable\n");

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