def q a,l,r
l<r&&(
i=0
(a.size-1).times{|j|a[j][2,20].to_i<=a[r][2,20].to_i&&(a[i],a[j]=a[j],a[i];i+=1)}
a[i],a[r]=a[r],a[i]
q a,l,i-1
q a,i+1,r
)
end
gets
a=$<.to_a
b=a.dup
q b,n=0,b.size-1
puts b==a.sort_by{|i|[i[2,20].to_i,n+=1]}?:Stable:"Not stable",b