#include<stdio.h>
#include<stdlib.h>
char B1[100000], B2[1000000];
void quickSort(int *, int, int);
int partition(int *, int, int);
int Stable(int *, int *, int);
main(){
  int n, i;
  int *A, *A2;
  scanf("%d", &n);
  A = (int *)malloc(sizeof(int)*n);
  if(A == NULL) exit(1);
  A2 = (int *)malloc(sizeof(int)*n);
  if(A2 == NULL) exit(1);
  for(i = 0; i < n; i++){
    scanf(" %c %d", &B1[i], &A[i]);
    A2[i] = A[i];
    B2[i] = B1[i];
  }
  quickSort(A, 0, n);
  if     (Stable(A, A2, n) == 1) printf("Stable\n");
  else if(Stable(A, A2, n) == 0) printf("Not stable\n");
  for(i = 0; i < n; i++){
    printf("%c %d\n",B1[i], A[i]);
  }
  free(A);
  return 0;
}


void quickSort(int *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 partition(int *A, int p, int r){
  int i, j, x, a;
  char b;
  x = A[r-1];
  i = p-1;
  for(j = p; j < r-1; j++){
    if(A[j] <= x){
      i += 1;
      a = A[i];
      A[i] = A[j];
      A[j] = a;
      b = B1[i];
      B1[i] = B1[j];
      B1[j] = b;
    }
  }
  a = A[i+1];
  A[i+1] = A[r-1];
  A[r-1] = a;
  b = B1[i+1];
  B1[i+1] = B1[r-1];
  B1[r-1] = b;
  return i+1;
}


int Stable(int *A1, int *A2, int n){
  int i, j, a, b;
  for(i = 0; i < n; i++){
    for(j = i+1; j < n; j++){
      for(a = 0; a < n; a++){
	for(b = a+1; b < n; b++){
    if(A1[i] == A1[j] && A1[i] == A2[b] && B1[i] == B2[b] && A1[j] == A2[a] && B1[j] == B2[a]) return 0;
	}
      }
    }
  }
  return 1;
}