# include <stdio.h>

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

void merge(card[] ,int,int,int);
void mergeSort(card[] ,int,int);
int part ( card [],int ,int);
void quickSort( card [],int ,int);

#define INF 100000005

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;
  }  

mergeSort(arr,0,n);
  quickSort(input, 0,n-1);


   int 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 mergeSort(card A[], int left, int right){
  if (left+1 < right){
    int mid = (left + right)/2;
    mergeSort(A, left, mid);
    mergeSort(A, mid, right);
    merge(A, left, mid, right);
  }
}
void merge( card A[] , int left ,int mid ,int right)
        {
            int n1 = mid - left;
            int n2 = right - mid;
            card L [n1];
            card R [n2] ;
            int i = 0;
            for ( i= 0; i < n1; i++)
            {
                L[i].value = A[left + i].value;
				L[i].mark  = A[left + i].mark;
            }
            for ( i = 0; i < n2; i++)
            {
				R[i].value = A[mid + i].value;
				R[i].mark  = A[mid + i].mark;
            }

            L[n1].value = INF;
            R[n2].value = INF;

            i = 0; int j = 0;
			int k;
            for ( k= left; k < right; k++)
            {
                if (L[i].value <= R[j].value)
                {
                    A[k].value = L[i].value;
					A[k].mark  = L[i].mark;
                    i++;
                }
                else
                {
                    A[k].value = R[j].value;
					A[k].mark  = R[j].mark;
                    j++;
                }
            }
		}
