def t(A,p,r):

 x=A[r][1];i=p-1

 for j in range(p,r):

  if A[j][1]<=x:i+=1;A[i],A[j]=A[j],A[i]

 A[i+1],A[r]=A[r],A[i+1]

 return i+1

def k(A,p,r):

 if p<r:q=t(A,p,r);k(A,p,q-1);k(A,q+1,r)

def m(L,R):

 T=[]

 for l in L[::-1]:

  while R and R[-1][1]>=l[1]:T+=[R.pop()]

  T+=[l]

 return R+T[::-1]

def d(A):l=len(A);s=l//2;return m(d(A[:s]),d(A[s:]))if l>1 else A

n=int(eval(input()))

f=lambda x,y:(x,int(y))

A=[f(*input().split())for _ in[0]*n]

B=A[:]

k(A,0,n-1)

print((['Not s','S'][A==d(B)]+'table'))

for e in A:print((*e))

import sys

def t(A,p,r):

 x=A[r][1];i=p-1

 for j in range(p,r):

  if A[j][1]<=x:i+=1;A[i],A[j]=A[j],A[i]

 A[i+1],A[r]=A[r],A[i+1]

 return i+1

def k(A,p,r):

 if p<r:q=t(A,p,r);k(A,p,q-1);k(A,q+1,r)

def m(L,R):

 T=[]

 for l in L[::-1]:

  while R and R[-1][1]>=l[1]:T+=[R.pop()]

  T+=[l]

 return R+T[::-1]

def d(A):l=len(A);s=l//2;return m(d(A[:s]),d(A[s:]))if l>1 else A

n=int(eval(input()))

f=lambda x,y:(x,int(y))

A=[f(*e.split())for e in sys.stdin]

B=A[:]

k(A,0,n-1)

print((['Not s','S'][A==d(B)]+'table'))

for e in A:print((*e))

def t(A, p, r):
    x = A[r][1]
    i = p - 1
    for j in range(p, r):
        if A[j][1] <= x:
            i += 1
            A[i], A[j] = A[j], A[i]
    A[i + 1], A[r] = A[r], A[i + 1]
    return i + 1


def k(A, p, r):
    if p < r:
        q = t(A, p, r)
        k(A, p, q - 1)
        k(A, q + 1, r)


def m(L, R):
    T = []
    for l in L[::-1]:
        while R and R[-1][1] >= l[1]:
            T += [R.pop()]
        T += [l]
    return R + T[::-1]


def d(A):
    l = len(A)
    s = l // 2
    return m(d(A[:s]), d(A[s:])) if l > 1 else A


n = int(eval(input()))
f = lambda x, y: (x, int(y))
A = [f(*input().split()) for _ in [0] * n]
B = A[:]
k(A, 0, n - 1)
print((["Not s", "S"][A == d(B)] + "table"))
for e in A:
    print((*e))

import sys


def t(A, p, r):
    x = A[r][1]
    i = p - 1
    for j in range(p, r):
        if A[j][1] <= x:
            i += 1
            A[i], A[j] = A[j], A[i]
    A[i + 1], A[r] = A[r], A[i + 1]
    return i + 1


def k(A, p, r):
    if p < r:
        q = t(A, p, r)
        k(A, p, q - 1)
        k(A, q + 1, r)


def m(L, R):
    T = []
    for l in L[::-1]:
        while R and R[-1][1] >= l[1]:
            T += [R.pop()]
        T += [l]
    return R + T[::-1]


def d(A):
    l = len(A)
    s = l // 2
    return m(d(A[:s]), d(A[s:])) if l > 1 else A


n = int(eval(input()))
f = lambda x, y: (x, int(y))
A = [f(*e.split()) for e in sys.stdin]
B = A[:]
k(A, 0, n - 1)
print((["Not s", "S"][A == d(B)] + "table"))
for e in A:
    print((*e))

+import sys + + -A = [f(*input().split()) for _ in [0] * n] +A = [f(*e.split()) for e in sys.stdin]