#include <stdio.h>
#include <stdlib.h>


int main()
{
	
	int i,a,t;
	int flag;
	char c;
	
	scanf("%d",&a);
	
	int *quick_int = (int*)malloc(sizeof(int)*a);
	char *quick_char = (char*)malloc(sizeof(char)*a);
	
	for(i=0;i<a;i++)
	{
		scanf("%s",&quick_char[i]);
		scanf("%d",&quick_int[i]);
	}
	
	
	flag = 1;
	while(flag)
	{
		flag = 0;
		for(i=a-1;i>0;i--)
		{
			if(quick_int[i] < quick_int[i-1])
			{
				 t = quick_int[i];
				 quick_int[i] = quick_int[i-1];
				 quick_int[i-1] = t;
				 c = quick_char[i];
				 quick_char[i] = quick_char[i-1];
				 quick_char[i-1] = c;
				 flag = 1;
			}
		}
	}
	
	printf("Stable\n");
	for(i=0;i<a;i++)
	{
		printf("%c",quick_char[i]);
		printf(" %d",quick_int[i]);
		puts("");
	}
	
	
	
	
	return 0;
	
}