from collections import namedtuple



Card = namedtuple('Card', ['suit', 'value', 'init'])



def QuickSort(A, begin, end):

    if end - begin <= 1:

        return



    piv = A[end - 1].value

    left, right = begin, begin



    for i in range(begin, end - 1):

        if A[i].value <= piv:

            if i - left > 0:

                A[left], A[i] = A[i], A[left]

            left += 1



    A[left], A[end - 1] = A[end - 1], A[left]



    QuickSort(A, begin, left)

    QuickSort(A, left + 1, end)



n = int(eval(input()))



A = []



for i in range(n):

    suit, value = input().split()

    value = int(value)

    A.append(Card(suit, value, i))



QuickSort(A, 0, n)



for i in range(n - 1):

    if A[i].value == A[i + 1].value and A[i].init > A[i + 1].init:

        print('Not stable')

        break

else:

    print('Stable')



for a in A:

    print((a.suit, a.value))
from sys import stdin

from collections import namedtuple



Card = namedtuple('Card', ['suit', 'value', 'init'])



def QuickSort(A, begin, end):

    if end - begin <= 1:

        return



    piv = A[end - 1].value

    left, right = begin, begin



    for i in range(begin, end - 1):

        if A[i].value <= piv:

            if i - left > 0:

                A[left], A[i] = A[i], A[left]

            left += 1



    A[left], A[end - 1] = A[end - 1], A[left]



    QuickSort(A, begin, left)

    QuickSort(A, left + 1, end)



n = int(stdin.readline())

A = [None] * n



for i in range(n):

    suit, value = stdin.readline().split()

    A[i] = Card(suit, int(value), i)



QuickSort(A, 0, n)



for i in range(n - 1):

    if A[i].value == A[i + 1].value and A[i].init > A[i + 1].init:

        print('Not stable')

        break

else:

    print('Stable')



for a in A:

    print((a.suit, a.value))
from collections import namedtuple

Card = namedtuple("Card", ["suit", "value", "init"])


def QuickSort(A, begin, end):
    if end - begin <= 1:
        return
    piv = A[end - 1].value
    left, right = begin, begin
    for i in range(begin, end - 1):
        if A[i].value <= piv:
            if i - left > 0:
                A[left], A[i] = A[i], A[left]
            left += 1
    A[left], A[end - 1] = A[end - 1], A[left]
    QuickSort(A, begin, left)
    QuickSort(A, left + 1, end)


n = int(eval(input()))
A = []
for i in range(n):
    suit, value = input().split()
    value = int(value)
    A.append(Card(suit, value, i))
QuickSort(A, 0, n)
for i in range(n - 1):
    if A[i].value == A[i + 1].value and A[i].init > A[i + 1].init:
        print("Not stable")
        break
else:
    print("Stable")
for a in A:
    print((a.suit, a.value))

from sys import stdin
from collections import namedtuple

Card = namedtuple("Card", ["suit", "value", "init"])


def QuickSort(A, begin, end):
    if end - begin <= 1:
        return
    piv = A[end - 1].value
    left, right = begin, begin
    for i in range(begin, end - 1):
        if A[i].value <= piv:
            if i - left > 0:
                A[left], A[i] = A[i], A[left]
            left += 1
    A[left], A[end - 1] = A[end - 1], A[left]
    QuickSort(A, begin, left)
    QuickSort(A, left + 1, end)


n = int(stdin.readline())
A = [None] * n
for i in range(n):
    suit, value = stdin.readline().split()
    A[i] = Card(suit, int(value), i)
QuickSort(A, 0, n)
for i in range(n - 1):
    if A[i].value == A[i + 1].value and A[i].init > A[i + 1].init:
        print("Not stable")
        break
else:
    print("Stable")
for a in A:
    print((a.suit, a.value))

+from sys import stdin -n = int(eval(input())) -A = [] +n = int(stdin.readline()) +A = [None] * n -    suit, value = input().split() -    value = int(value) -    A.append(Card(suit, value, i)) +    suit, value = stdin.readline().split() +    A[i] = Card(suit, int(value), i)