# include <stdio.h>

typedef struct {
  int value;
  char mark;
}card;

int part ( card [],int ,int);
void quickSort( card [],int ,int);
int main(){
  int n,i ,t;char tc;
  scanf("%d\n" , &n);
  card arr[n] ,input[n];
  for ( i = 0; i < n; i++){
    if ( i == n-1 ) { scanf("%c %d",&arr[i].mark,&arr[i].value);
  
    }else{
      scanf("%c %d ",&arr[i].mark,&arr[i].value);
    }
    input[i].mark = arr[i].mark;
    input[i].value = arr[i].value;
    
  }

  margeSort(arr,0,n);

  quickSort(input, 0,n-1);


   flag = 1;
  for ( i = 0; i < n; i++){
    if( input[i].mark != arr[i].mark){
      flag =0;break;
    }
  }
  if (flag == 1){printf("Stable\n");}
  else if ( flag == 0)  { printf("Not stable\n");}
  
    for ( i = 0; i < n; i++){
      printf("%c %d\n",input[i].mark,input[i].value);
    }
  
  return 0;
}


void quickSort( card a[],int p,int r){
  if ( p < r){
    int q = part(a , p ,r);
    quickSort(a,p,q-1);
    quickSort(a,p+1,r);
  }
}

int  part (card a[] ,int p ,int r){
  int x = a[r].value ,t ,k;char tc;
  int j, i = p-1;
  for ( j = p ; j < r ; j++ ){
    if ( a[j].value  <= x){
      i++;
      t = a[i].value; a[i].value = a[j].value; a[j].value =t;
      tc = a[i].mark; a[i].mark = a[j].mark; a[j].mark =tc;
    }
  }
  t = a[i+1].value; a[i+1].value = a[r].value ; a[r].value=t;
  tc = a[i+1].mark; a[i+1].mark = a[r].mark ; a[r].mark=tc;
  return i+1;
}


void merge (   long   int a[] ,   unsigned int lef ,   unsigned int mid ,  unsigned int rig){
  unsigned int k,none = mid - lef,i,j,ntwo = rig - mid;

  for (i = 0; i <  none;i++ ){
    l[i] = a[lef+ i];
  }
  for ( i = 0; i < ntwo ; i++){
    r[i] = a[mid + i];
  }l[none] = 2500000000;r[ntwo]= 2500000000; i= 0;j= 0;
  for (k = lef ;k < rig ;k++ ){
    c++;
    if (l[i] <= r[j]){
      a[k] = l[i];
      i = i + 1;
    }else{ 
      a[k] = r[j];
      j = j + 1;
    }
  }
}

