#include<stdio.h>
#include<stdlib.h>

typedef struct{
  char c;
  int num;
} Card;

int flug=1;

int partition(Card *, int, int);
void quicksort(Card *, int, int);


int main(){

  int n,r,i,p;
  Card A[100000];
  char tmp;

  scanf("%d",&n);

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


  quicksort(A, 0, n-1);

  if(n == 2) flug=1;

  if(flug==0) printf("Not stable\n");
  if(flug==1) printf("Stable\n");

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

  return 0;

}


int partition(Card *A, int p, int r){

  int x,i,j;
  Card tmp;

  x = A[r].num;
  i = p-1;

  for(j = p ; j <= r-1 ; j++){
    if(A[j].num <= x){
      if(A[j].num == x) flug=0;
      i++;
      tmp = A[i];
      A[i] = A[j];
      A[j] = tmp;
    }
  }
    tmp = A[i+1];
    A[i+1] = A[r];
    A[r] = tmp;

    return i+1;

}


void quicksort(Card *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);

      }
}