var m,index;

function partition(a,p,r){
    var x = a[r];
    var i = p - 1;
    for(var j = p;j < r;j++){
        if(a[j] <= x){
            i++;
            var b = a[i];
            a[i] = a[j];
            a[j] = b;
            var b = m[i];
            m[i] = m[j];
            m[j] = b;
            var b = index[i];
            index[i] = index[j];
            index[j] = b;            
        }
    }
    b = a[i + 1];
    a[i + 1] = a[r];
    a[r] = b;
    b = m[i + 1];
    m[i + 1] = m[r];
    m[r] = b;
    b = index[i + 1];
    index[i + 1] = index[r];
    index[r] = b;
    return i + 1;
}

function qsort(a,p,r){
    if(p < r){
        var q = partition(a,p,r);
        qsort(a,p,q - 1);
        qsort(a,q + 1,r);
    }
}

function Main(input){
    input = input.split("\n");
    var n = parseInt(input[0],10);
    for(var i = 1;i <= n;i++)
        input[i] = input[i].split(" ");
    var a = new Array(n);m = new Array(n);index = new Array(n);
    for(var i = 0;i < n;i++){
        m[i] = input[i + 1][0];
        a[i] = parseInt(input[i + 1][1],10);
        index[i] = i;
    }

    var j = qsort(a,0,n - 1);var k = true;
    for(var i = 0;i < n - 1;i++)
        if(a[i] == a[i + 1] && index[i] > index[i + 1]){
            k = false;break;
        }
    if(k)
        console.log("Stable");
    else
        console.log("Not stable");
    for(var i = 0;i < n;i++)
        console.log(m[i] + a[i]);
}

Main(require("fs").readFileSync("/dev/stdin","utf8"));