#include <stdio.h>

struct Card{
  char mark;
  int num;
};

int Partition(struct Card A[], int left, int pivot, int right){
  int i, j;
  struct Card x, temp;
  x = A[right];
  i = pivot-1;
  for(j=pivot; j<right; j++){
    if(A[j].num<=x.num){
      i++;
      temp = A[i];
      A[i] = A[j];
      A[j] = temp;
	}
  }
  temp = A[i+1];
  A[i+1] = A[right];
  A[right] = temp;
  return i+1;
}


void quickSort(struct 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);
  }
}

int main(){
  int n, i, j, v, stable=0;
  char s[10];
  struct Card A[100001], B[100001]; 
  scanf("%d", &n);
  for(i=0; i<n; i++){
    scanf("%s %d", s, &v);
    A[i].mark=s[0];
    B[i].mark=A[i].mark;
    A[i].num=v;
    B[i].num=A[i].num;
  }

  quickSort(B, n, 0, n-1);
  
  for(i=0; i<n; i++){
    if(A[i].mark==B[i].mark && A[i].num==B[i].num)stable++;
  }

  if(stable==n)printf("Stable\n");
  else printf("Not stable\n");
  for(i=0;i<n;i++){
    printf("%c %d\n",B[i].mark, B[i].num);
  }  
  return 0;
}