#include<stdio.h>
#include<iostream>
#include<algorithm>
using namespace std;
struct Kp{
     char c;
     int n,k;
}card[100000];
bool cmp(Kp x,Kp y){
    return x.n<y.n;
}
int main(){
   int N,i;
   bool flag;
   while(~scanf("%d",&N)){
        flag=false;
        getchar();
    for(i=0;i<N;i++){
        scanf("%c %d",&card[i].c,&card[i].n);
        getchar();
        card[i].k=i;
    }
   sort(card,card+N,cmp);
   for(i=0;i<N;i++){
        for(int j=i+1;j<N;j++){
            if(card[i].c==card[j].c)
                if(card[i].k>card[j].k)
                  flag=true;
        }
   }
   if(flag)
     printf("Not stable\n");
   else
     printf("Stable\n");
   for(i=0;i<N;i++){
        printf("%c %d\n",card[i].c,card[i].n);
   }

  }
}