def exchange a, i, j
  tmps = a[i][0]
  tmpn = a[i][1]
  tmpid = a[i][2]
  a[i][0] = a[j][0]
  a[i][1] = a[j][1]
  a[i][2] = a[j][2]
  a[j][0] = tmps
  a[j][1] = tmpn
  a[j][2] = tmpid
end

def partition a, p, r
  x = a[r][1]
  i = p - 1
  for j in p..r-1
    if a[j][1] <= x
      i += 1
      exchange a,i,j
    end
  end
  exchange a,i+1,r
  i + 1
end

def quicksort a, p, r
  if p < r
    q = partition(a,p,r)
    quicksort a,p,q-1
    quicksort a,q+1,r
  end
end

def isStable a
  0.step(a.size - 2, 1).each do |i|
    p = a[i]
    n = a[i+1]
    return false if p[1] == n[1] && p[2] > n[2]
  end
  true
end

card = Array.new
$stdin.gets.to_i.times do |i|
  s,n = $stdin.gets.chomp.split(" ")
  card << [s, n.to_i, i]
end
quicksort card,0,card.size-1
puts (isStable(card))? "Stable" : "Not stable"
card.each do |d|
  printf "%s %d\n", d[0], d[1]
end