#include<stdio.h>
#define N 1000000001

typedef struct Card{
  char pat;
  int num;
  int turn;
}Ca;



int Partition(Ca A[], int p, int r){
  int i, j, x;
  Ca a;
  
  x = A[r].num;
  i = p-1;
  
  for(j = p; j <= r-1; j++){
    
    if(A[j].num<=x){
      i++;
      a = A[i];
      A[i] = A[j];
      A[j] = a; 
    }
    
  }
  
  a = A[i+1];
  A[i+1] = A[r];
  A[r] = a; 
  
  return i+1;
}


void Quicksort(Ca 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);
  }
}



int main(void){
  int i, n, flag =0;
  Ca C[N];
  
  
  scanf("%d", &n);
  for(i=0; i<n; i++){
    scanf("%c%d", &C[i].pat, &C[i].num);
    C[i].turn = i;
  }
  
  Quicksort(C, 0, n-1);
  for(i=0; i<n; i++){
    if(C[i].num == C[i+1].num && C[i].turn > C[i+1].turn){
      printf("Not stable\n");
      flag = 1;
      break;
    }
  }
  
  if(flag == 0) printf("Stable\n");
  for(i=0; i<n; i++) printf("%c %d\n", C[i].pat, C[i].num);
  
  
  return 0;
}