#include <stdio.h>
#define MAX 100000
#define MIHARI 2000000000


struct A{
    char point;
    int value;
};

struct A left[MAX / 2 +2],right[MAX/2 +2];

void merge(struct A M[],int n,int le,int mi,int ri){
    int i,j,k;
    int n1 = mi - le;
    int n2 = ri - mi;
    for(i=0;i<n1;i++) left[i] = M[le + i];
    for(i=0;i<n2;i++) right[i] = M[mi + i];
    left[n1].value = right[n2].value = MIHARI ;
    i=0;
    j=0;
    for(k=le;k<ri;k++){
        if(left[i].value <= right[j].value){
            M[k] = left[i++];
        }else{
            M[k] = right[j++];
        }
    }
}

void mergeS(struct A M[],int n,int le,int ri){
    if(le+1 < ri){
        int mid = (le+ri)/2;
        mergeS(M,n,le,mid);
        mergeS(M,n,mid,ri);
        merge(M,n,le,mid,ri);
    }
}

int par(struct A M[],int n,int p,int r){
    int i,j;
    struct A t,x;
    x = M[r];
    i = p - 1;
    for(j=p;j<r;j++){
        if(M[j].value <= x.value){
            i++;
            t = M[i];
            M[i] = M[j];
            M[j] = t;
        }
    }
    t = M[i+1];
    M[i+1] = M[r];
    M[r] = t;
    return i+1;
}

void quick(struct A M[],int n,int p,int r){
    int q;
    if(p<r){
        q=par(M,n,p,r);
        quick(M,n,p,q-1);
        quick(M,n,q+1,r);
    }
}

int main(){
    int n,i,x;
    struct A M[MAX],Y[MAX];
    char S[10];
    int c = 1;
    
    scanf("%d",&n);
    
    for(i=0;i<n;i++){
        scanf("%s%d",S,&x);
        M[i].point = Y[i].point = S[0];
        M[i].value = Y[i].value = x;
    }
    
    mergeS(M,n,0,n);
    quick(Y,n,0,n-1);
    
    for(i=0;i<n;i++){
        if(M[i].point != Y[i].point) c=0;
    }
    
    if(c==1) printf("Stable\n");
    else printf("Not stable");
    for(i=0;i<n;i++){
        printf("%c %d\n",Y[i].point,Y[i].value);
    }
    return 0;
}







