#include<stdio.h>

#define MAX 100000
 
struct Cards {
	char pattern[2];
	int num;
};
int flag=0;

void exchange( struct Cards *pa, struct Cards *pb )
{
	struct Cards t;
	
	t=*pa;
	*pa=*pb;
	*pb=t;

	return;
}

int Partition( struct Cards A[], int p, int r )
{
	struct Cards x;
	int i,j;
	
	x=A[r];
	i=p-1;
	for( j=p; j<r; j++ ) {
		if( A[j].num < x.num ) {
			flag=1;	
			i++;
			exchange( &A[i], &A[j] );
		}
	}
	exchange( &A[i+1], &A[r] );

	return i+1;
}
void QuickSort( struct Cards 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 );
	}
	return;
}


int main( void ) 
{	
	int n,i;
	struct Cards A[MAX+1];
		
    scanf( "%d", &n );
	for( i=0; i<n; i++ ) {
		scanf( "%s%d", A[i].pattern, &A[i].num );
	}
	QuickSort( A, 0, n-1 );
	if( flag ) {
		printf( "Not stable\n" );
	} else {
		printf( "Stable\n" );
	}
	for( i=0; i<n; i++ ) {
		printf( "%s %d\n", A[i].pattern, A[i].num );
	}

    return 0;
}