#include <stdio.h>

int counter = 0;
char B[100000];
int partition(int *, int, int);
void quickSort(int *, int, int);
int main()
{
  int n, i, A[100000];
  char dummy;
  
  scanf("%d", &n);
  for(i = 0; i < n; i++)
    {
      scanf("%c", &dummy);
      scanf("%c%d", &B[i], &A[i]);
    }

  quickSort(A, 0, n-1);

  if(counter > 2) printf("Not stable\n");
  else printf("Stable\n");
  for(i = 0; i < n; i++)
      printf("%c %d\n", B[i], A[i]);
      
  return 0;
}
  
int partition(int *A, int p, int r)
{
  int x, i, j, tmp, TMP;

  x = A[r];
  i = p-1;
  for(j = p; j < r; j++)
    {
      if(A[j] <= x)
	{
	  i = i+1;
	  tmp = A[i];
	  TMP = B[i];
	  A[i] = A[j];
	  B[i] = B[j];
	  A[j] = tmp;
	  B[j] = TMP;
	}
    }
  tmp = A[i+1];
  TMP = B[i+1];
  A[i+1] = A[r];
  B[i+1] = B[r];
  A[r] = tmp;
  B[r] = TMP;
  return i+1;
}

void quickSort(int *A, int p, int r)
{
  int q;
  if(p < r)
    {
      q = partition(A, p, r);
      counter++;
      quickSort(A, p, q-1);
      quickSort(A, q+1, r);
    }
}