You are playing a very popular computer game. The next level consists of $$$n$$$ consecutive locations, numbered from $$$1$$$ to $$$n$$$, each of them containing either land or water. It is known that the first and last locations contain land, and for completing the level you have to move from the first location to the last. Also, if you become inside a location with water, you will die, so you can only move between locations with land.You can jump between adjacent locations for free, as well as no more than once jump from any location with land $$$i$$$ to any location with land $$$i + x$$$, spending $$$x$$$ coins ($$$x \geq 0$$$).Your task is to spend the minimum possible number of coins to move from the first location to the last one.Note that this is always possible since both the first and last locations are the land locations.

There are several test cases in the input data. The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 100$$$) — the number of test cases. This is followed by the test cases description. The first line of each test case contains one integer $$$n$$$ ($$$2 \leq n \leq 100$$$) — the number of locations. The second line of the test case contains a sequence of integers $$$a_1, a_2, \ldots, a_n$$$ ($$$0 \leq a_i \leq 1$$$), where $$$a_i = 1$$$ means that the $$$i$$$-th location is the location with land, and $$$a_i = 0$$$ means that the $$$i$$$-th location is the location with water. It is guaranteed that $$$a_1 = 1$$$ and $$$a_n = 1$$$.

For each test case print a single integer — the answer to the problem.

NoteIn the first test case, it is enough to make one free jump from the first location to the second one, which is also the last one, so the answer is $$$0$$$.In the second test case, the only way to move from the first location to the last one is to jump between them, which will cost $$$4$$$ coins.In the third test case, you can jump from the first location to the third for $$$2$$$ coins, and then jump to the fourth location for free, so the answer is $$$2$$$. It can be shown that this is the optimal way.

let stop = '';
process.stdin.on('data', c => stop += c);
process.stdin.on('end', () => {
    const {EOL} = require('os');
    const lines = stop.split(EOL);
    var t = lines[0];
    var n = 0;
    for(i = 1; i <= t * 2; i++){
        if(i % 2 == 1){
            n = lines[i];
        }else{
            var k = lines[i].split(' ').map(Number);
            var ans = 0;
            var left = 0, right = n - 1;
            while(left + 1 < n && k[left + 1] == 1){
                left++;
            }
            while(right > 0 && k[right - 1] == 1){
                right--;
            }
            var a = right - left;
            console.log(a > 0 ? a : 0);
        }
    }

});

let stop = '';
process.stdin.on('data', c => stop += c);
process.stdin.on('end', () => {
    const {EOL} = require('os');
    const lines = stop.split(EOL);
    var t = lines[0];
    var n = 0;
    for(i = 1; i <= t * 2; i++){
        if(i % 2 == 1){
            n = lines[i];
        }else{
            var k = lines[i].split(' ').map(Number);
            var ans = 0;
            var left = 0, right = n - 1;
            while(left + 1 < n && k[left + 1] == 1){
                left++;
            }
            while(right > 0 && k[right - 1] == 1){
                right--;
            }
            ans = right - left;
            console.log(ans > 0 ? ans : 0);
        }
    }

});

'use strict';

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';
let currentLine = 0;

process.stdin.on('data', stdin => inputString += stdin);

process.stdin.on('end', _ => {
    inputString = inputString.trim().split('\n').map(s => s.trim());
    main();
});

function readline() {
    return inputString[currentLine++];
}

function output(x) {
    if (typeof x !== 'string') {
        x = x.toString();
    }
    //process.stdout.write(x);   // without auto '\n' (newline)
    console.log(x);  // with auto '\n' (newline)
}

function main() {
    let N = readline();

    for (let test = 0; test < N; test++) {
        let n = parseInt(readline(), 10);
        let arr = readline().split(' ').map(Number);

        let l = 0;
        let r = n - 1;

        while (l < n) {
            if (arr[l] === 0) {
                break;
            } else {
                l++
            }
        }
        if (l === n) {
            output(0);
            continue;
        }

        while (r >= 0) {
            if (arr[r] === 0) {
                break;
            } else {
                r--
            }
        }

        output(r - l + 2);
    }
}

//Don't have to see. start------------------------------------------
var read = require('readline').createInterface({
	input: process.stdin, output: process.stdout
});
var obj; var inLine = []; var outputList = [];var retcode = new Set();
read.on('line', function(input){
	var tmp = input.split(' ');
	for(var i = 0; i < tmp.length; i++){
		inLine.push(tmp[i]);
		if(i == tmp.length - 1){
			retcode.add(inLine.length);
		}
	}
});
read.on('close', function(){
	obj = init(inLine);
	console.error('\n↑入力 ↓出力');
	Main();
	console.log(myconv(outputList, 9));
});
function makeClone(obj){return (obj instanceof Set) ? new Set(Array.from(obj)) : JSON.parse(JSON.stringify(obj));}
function nextArray(size, code){
	var ret = new Array(size);
	for(var i = 0; i < size; i++){
		if(code == 'int'){
			ret[i] = nextInt();
		}else if(code == 'long'){
			ret[i] = nextLong();
		}else if(code == 'double'){
			ret[i] = nextDouble();
		}else{
			ret[i] = next();
		}
	}
	return ret;
}
function nextIntArray(size){return nextArray(size, 'int');} function nextStrArray(size){return nextArray(size, 'str');} function nextLongArray(size){return nextArray(size, 'long');} function nextDoubleArray(size){return nextArray(size, 'double');}
function nextCharArray(){return myconv(next(),6);}
function next(){return obj.next();} function hasNext(){return obj.hasNext();} function nextInt(){return myconv(next(),1);} function nextLong(){return BigInt(next());} function nextDouble(){return parseFloat(next());}
function getCountMap(list){
	var map = {};
	for(var i = 0; i < list.length; i++){
		if(map[list[i]] == null){
			map[list[i]] = 0;
		}
		map[list[i]]++;
	}
	return map;
}
function init(input){
	return {
		list : input, index : 0, max : input.length,
		hasNext : function(){return (this.index < this.max);},
		next : function(){if(this.hasNext()){return this.list[this.index++];}else{throw 'ArrayIndexOutOfBoundsException ‚There is no more input';}},
		isReturn : function(){return retcode.has(this.index);}
	};
}
function myout(s){outputList.push(s);}
function myerr(s){console.error('debug:' + require('util').inspect(s,false,null));}
function isReturn(){return obj.isReturn();}
//param "no" is
//unknown or outlier : return i. 1: parseInt.
//2: split space. 4: split space and parseInt.
//6: split 1 character. 7: split 1 character and parseInt.
//8: join space. 9: join nextline. 0: join no character.
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(' ');case 4:return i.split(' ').map(Number);case 6:return i.split('');case 7:return i.split('').map(Number);case 8:return i.join(' ');case 9:return i.join('\n');case 0:return i.join('');default:return i;}}catch(e){return i;}}

//Don't have to see. end------------------------------------------
function Main(){
	var t = nextInt();
	while(hasNext()){
		var N = nextInt();
		var list = nextIntArray(N);
		var output = 0;
		var L = 0;
		var R = N - 1;
		for(var i = 0; i < N; i++){
			if(list[i] == 1){
				L++;
			}else{
				L--;
				break;
			}
		}
		for(var i = N - 1; i >= 0; i--){
			if(list[i] == 1){
				R--;
			}else{
				R++;
				break;
			}
		}
		output = Math.max(0, R - L);
		myout(output);
	}
}

var readline = require('readline');
var rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
});

let ls = [];

function solve(){
    let i = 1;
    while (i < ls.length){
        const len = ls[i++];
        const arr = ls[i++].split(' ');
        const fi = arr.indexOf('0');
        const li = arr.lastIndexOf('0');
        if (fi == -1){
            console.log('0');
            continue;
        }
        console.log(li - fi + 2);
    }
}

rl.on('line', (l) => ls.push(l));
rl.on('close', () => solve());

process.stdin.resume();
process.stdin.setEncoding("utf-8");

let inputString = "";
let currentLine = 0;

process.stdin.on("data", (inputStdin) => {
  inputString += inputStdin;
});

process.stdin.on("end", (_) => {
  inputString = inputString
    .trim()
    .split("\n")
    .map((string) => {
      return string.trim();
    });

  main();
});

function readline() {
  return inputString[currentLine++];
}

function main() {
  const testCases = readline();

  for (let i = 0; i < testCases; i++) {
    let size = readline();
    let arr = readline();

    let firstZero = null;
    let lastZero = null;

    for (let i = 0; i < arr.length; i++) {
      if (arr[i] === "0") {
        lastZero = i;
        if (firstZero === null) {
          firstZero = i;
        }
      }
    }
    if (firstZero) {
      // console.log(lastZero, firstZero);
      console.log((lastZero + 1) / 2 - (firstZero + 1) / 2 + 2);
    } else {
      console.log(0);
    }
  }
}

function solve() {
   const n = Number(read());
   const arr = readArray(Number);
   let firstZeroIndex;
   let lastZeroIndex;
   for (let i = 0; i < n; i++) {
      const x = arr[i];
      if (x !== 0) {
         continue;
      }
      if (typeof firstZeroIndex === 'undefined') {
         firstZeroIndex = i;
      }
      lastZeroIndex = i;
   }
   if (typeof firstZeroIndex === 'undefined') {
      write(0);
      return;
   }
   write(lastZeroIndex - firstZeroIndex + 2);
}

function sortF(a, b) {
   if (a < b) {
      return -1;
   }
   if (a > b) {
      return 1;
   }
   return 0;
}

function pDivCount(n) {
   let ans = 0;
   let i = 1;
   while(n > 1) {
      i++;
      while(n % i === 0) {
         ans++;
         n = Math.floor(n / i);
      }
   }
   return ans;
}

function gcd(a, b) {
   if (a === 0) {
      return b;
   }
   return gcd(b % a, a);
}

function lcm(a, b) {
   return Math.floor(a / gcd(a, b)) * b;
}

function init() {
   try {
      var T;
      T = 1;
      T = Number(read());
      for (var t = 0; t < T; t++) {
         solve();
      }
   } catch (e) {
      write(e);
   }
}

function readArray(mapF) {
   var res = read().split(' ');
   if (mapF) {
      res = res.map(mapF);
   }
   return res;
}

var isNode = typeof console !== 'undefined';
var MEMORY = [];
var MEMORY_INDEX = 0;
if (isNode) {
   var fs = require('fs');

   var inTextName;
   var outTextName;
   if (process.argv.length === 5) {
      inTextName = process.argv[3];
      outTextName = process.argv[4];
   }
   MEMORY = fs.readFileSync(inTextName ? require('path').join(__dirname, inTextName) : 0, 'utf8').split('\r\n');
}
init();

function write(value) {
   isNode ? console.log('' + value) : print('' + value);
}
function read() {
   return isNode ? MEMORY[MEMORY_INDEX++] : readline();
}
function readAll() {
   if (isNode) {
      return MEMORY;
   }
   var res = [];
   var x;
   while (x = read()) {
      res.push(x);
   }
   return res;
}

var t= parseInt(readline());
while(t--)
{
    var n=parseInt(readline());
    var arr=readline().split(' ').map(x=>parseInt(x));
    var sum=0;
    for(var i=0; i<n; i++) sum+=arr[i];
    if(sum==n) print(0);
    else
    {
        var f=0, l=n-1;
        while(arr[f]==1) f++;
        f--;
        while(arr[l]) l--;
        l++;

        print(l-f);
    }
}

var t = parseInt(readline())

while(t--){
    var n = parseInt(readline())
    var arr = readline().split(' ').map(x => parseInt(x))

    var start = 0
    var end = n-1
    for(var i = 0;i<n;i++){
        if(arr[i] == 0){
            start = i;
            break;
        }
    }

    for(var j = n-1; j>=0;j--){
        if(arr[j] == 0){
            end = j;
            break;
        }
    }

    if((end - start) == (n-1))
        print(0)
    else
        print(end-start+2)

}

var t = +readline();
while (t-->0){
    var n = +readline();
    var ar = readline().split(' ').map(Number);
    var first = 0, last = -2;
    for (var i=1;i<n;i++){
        if (ar[i] === 0 && first === 0){
            first = i;
        }
        if (ar[n-1-i] === 0 && last === -2){
            last = n - 1 - i;
        }
    }
    print(last + 2 - first);
}

let i = '';
process.stdin.on('data', c => i += c);
process.stdin.on('end', () => {
    const {EOL} = require('os');
    const lines = i.split(EOL);
    var n = lines[0];
    var e = 0;
    for(i = 1; i <= n * 2; i++){
        if(i % 2 == 1){
            e = lines[i];
        }else{
            var k = lines[i].split(' ').map(Number);
            var o = 0;
            var z = 0;
            for(j = 0; j < e; j++){
                if(k[j] == 1){
                    o++;
                }else{
                    z++;
                }
            }
            console.log(z * 2);
        }
    }
});

'use strict';

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';
let currentLine = 0;

process.stdin.on('data', stdin => inputString += stdin);

process.stdin.on('end', _ => {
    inputString = inputString.trim().split('\n').map(s => s.trim());
    main();
});

function readline() {
    return inputString[currentLine++];
}

function output(x) {
    if (typeof x !== 'string') {
        x = x.toString();
    }
    //process.stdout.write(x);   // without auto '\n' (newline)
    console.log(x);  // with auto '\n' (newline)
}

function main() {
    let N = readline();

    for (let test = 0; test < N; test++) {
        let n = parseInt(readline(), 10);
        let arr = readline().split(' ').map(Number);

        let onWater = false;
        let water = 0;
        let total = 0;
        for (let i = 0; i < arr.length; i++) {
            if (arr[i] === 0) {
                onWater = true;
                water++;
            } else if (onWater) {
                onWater = false;
                total += water + 1;
                water = 0;
            }
        }

        output(total);
    }
}

//Don't have to see. start------------------------------------------
var read = require('readline').createInterface({
	input: process.stdin, output: process.stdout
});
var obj; var inLine = []; var outputList = [];var retcode = new Set();
read.on('line', function(input){
	var tmp = input.split(' ');
	for(var i = 0; i < tmp.length; i++){
		inLine.push(tmp[i]);
		if(i == tmp.length - 1){
			retcode.add(inLine.length);
		}
	}
});
read.on('close', function(){
	obj = init(inLine);
	console.error('\n↑入力 ↓出力');
	Main();
	console.log(myconv(outputList, 9));
});
function makeClone(obj){return (obj instanceof Set) ? new Set(Array.from(obj)) : JSON.parse(JSON.stringify(obj));}
function nextArray(size, code){
	var ret = new Array(size);
	for(var i = 0; i < size; i++){
		if(code == 'int'){
			ret[i] = nextInt();
		}else if(code == 'long'){
			ret[i] = nextLong();
		}else if(code == 'double'){
			ret[i] = nextDouble();
		}else{
			ret[i] = next();
		}
	}
	return ret;
}
function nextIntArray(size){return nextArray(size, 'int');} function nextStrArray(size){return nextArray(size, 'str');} function nextLongArray(size){return nextArray(size, 'long');} function nextDoubleArray(size){return nextArray(size, 'double');}
function nextCharArray(){return myconv(next(),6);}
function next(){return obj.next();} function hasNext(){return obj.hasNext();} function nextInt(){return myconv(next(),1);} function nextLong(){return BigInt(next());} function nextDouble(){return parseFloat(next());}
function getCountMap(list){
	var map = {};
	for(var i = 0; i < list.length; i++){
		if(map[list[i]] == null){
			map[list[i]] = 0;
		}
		map[list[i]]++;
	}
	return map;
}
function init(input){
	return {
		list : input, index : 0, max : input.length,
		hasNext : function(){return (this.index < this.max);},
		next : function(){if(this.hasNext()){return this.list[this.index++];}else{throw 'ArrayIndexOutOfBoundsException ‚There is no more input';}},
		isReturn : function(){return retcode.has(this.index);}
	};
}
function myout(s){outputList.push(s);}
function myerr(s){console.error('debug:' + require('util').inspect(s,false,null));}
function isReturn(){return obj.isReturn();}
//param "no" is
//unknown or outlier : return i. 1: parseInt.
//2: split space. 4: split space and parseInt.
//6: split 1 character. 7: split 1 character and parseInt.
//8: join space. 9: join nextline. 0: join no character.
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(' ');case 4:return i.split(' ').map(Number);case 6:return i.split('');case 7:return i.split('').map(Number);case 8:return i.join(' ');case 9:return i.join('\n');case 0:return i.join('');default:return i;}}catch(e){return i;}}

//Don't have to see. end------------------------------------------
function Main(){
	var t = nextInt();
	while(hasNext()){
		var N = nextInt();
		var list = nextIntArray(N);
		var output = 0;
		var cost = 1;
		for(var i = 0; i < N; i++){
			if(list[i] == 0){
				cost++;
			}else{
				if(list[i - 1] == 0){
					output += cost;
					cost = 1;
				}
			}
		}
		myout(output);
	}
}

var t= readline();
while(t--)
{
    var n=readline();
    var arr=readline().split(' ');
    var sum=0;
    for(var i=0; i<n; i++) sum+=arr[i];
    if(sum==n) print(0);
    else
    {
        var f=0, l=n-1;
        while(arr[f]==1) f++;
        f--;
        while(arr[l]) l--;
        l++;

        print(l-f);
    }
}

var t= parseInt(readline());
while(t--)
{
    var n=parseInt(readline());
    var arr=readline().split(' ').map(x=>parseInt(x));
    var sum=0;
    for(var i=0; i<n; i++) sum+=arr[i];
    if(sum==0) print(0);
    else
    {
        var f=0, l=n-1;
        while(arr[f]==1) f++;
        f--;
        while(arr[l]) l--;
        l++;

        print(l-f);
    }
}


You are given a matrix consisting of $$$n$$$ rows and $$$m$$$ columns. Each cell of this matrix contains $$$0$$$ or $$$1$$$.Let's call a square of size $$$2 \times 2$$$ without one corner cell an L-shape figure. In one operation you can take one L-shape figure, with at least one cell containing $$$1$$$ and replace all numbers in it with zeroes.Find the maximum number of operations that you can do with the given matrix.

The first line contains one integer $$$t$$$ ($$$1 \leq t \leq 500$$$) — the number of test cases. Then follow the descriptions of each test case. The first line of each test case contains two integers $$$n$$$ and $$$m$$$ ($$$2 \leq n, m \leq 500$$$) — the size of the matrix. Each of the following $$$n$$$ lines contains a binary string of length $$$m$$$ — the description of the matrix. It is guaranteed that the sum of $$$n$$$ and the sum of $$$m$$$ over all test cases does not exceed $$$1000$$$.

For each test case output the maximum number of operations you can do with the given matrix.

NoteIn the first testcase one of the optimal sequences of operations is the following (bold font shows l-shape figure on which operation was performed):   Matrix before any operation was performed:  101111011110  Matrix after $$$1$$$ operation was performed:  100101011110  Matrix after $$$2$$$ operations were performed:  100100011110  Matrix after $$$3$$$ operations were performed:  100100010110  Matrix after $$$4$$$ operations were performed:  100000010110  Matrix after $$$5$$$ operations were performed:  100000010100  Matrix after $$$6$$$ operations were performed:  100000000100  Matrix after $$$7$$$ operations were performed:  000000000100  Matrix after $$$8$$$ operations were performed:  000000000000 In the third testcase from the sample we can not perform any operation because the matrix doesn't contain any ones.In the fourth testcase it does not matter which L-shape figure we pick in our first operation. We will always be left with single one. So we will perform $$$2$$$ operations.

const fs = require("fs");

const input = fs.readFileSync(0, "utf8").trim().split("\n");

const testCases = [];
let T;

function parseInput() {
  T = parseInt(input[0]);
  let index = 0;

  for (let i = 0; i < T; i++) {
    index++;
    const [n, m] = input[index].split(" ").map((item) => parseInt(item));
    const testCase = {
      n,
      m,
      grid: [],
    };
    for (let j = 0; j < n; j++) {
      index++;
      const line = input[index].split("").map((item) => parseInt(item));
      testCase.grid.push(line);
    }
    testCases.push(testCase);
  }
}

function solution(testCase) {
  const { n, m, grid } = testCase;
  // console.log(n, m, grid);

  let nb1s = 0;
  const indexesOf1s = new Set();
  grid.forEach((line, i) =>
    line.forEach((cell, j) => {
      if (cell == 1) {
        nb1s++;
        indexesOf1s.add(`${i},${j}`);
      }
    })
  );

  let mini1s = Infinity;
  let mini1sIndexes;

  const check = ([i1, j1], [i2, j2], [i3, j3]) => {
    if (
      i1 < 0 ||
      i2 < 0 ||
      i3 < 0 ||
      i1 >= n ||
      i2 >= n ||
      i3 >= n ||
      j1 < 0 ||
      j2 < 0 ||
      j3 < 0 ||
      j1 >= m ||
      j2 >= m ||
      j3 >= m
    )
      return;
    // console.log("check", [i1, j1], [i2, j2], [i3, j3]);
    const v = [grid[i1][j1], grid[i2][j2], grid[i3][j3]].filter(
      (v) => v == 1
    ).length;
    if (v < mini1s && v > 0) {
      mini1s = v;
      mini1sIndexes = [
        [i1, j1],
        [i2, j2],
        [i3, j3],
      ];
    }
  };

  for (let i = 0; i < n; i++) {
    for (let j = 0; j < m - 1; j++) {
      check([i, j], [i, j + 1], [i - 1, j]);
      check([i, j], [i, j + 1], [i + 1, j]);
      check([i, j], [i, j + 1], [i - 1, j + 1]);
      check([i, j], [i, j + 1], [i - 1, j + 1]);
    }
  }

  console.log(nb1s - (mini1s == Infinity ? 0 : mini1s - 1));
}

parseInput();

testCases.forEach(solution);

//Don't have to see. start------------------------------------------
var read = require('readline').createInterface({
	input: process.stdin, output: process.stdout
});
var obj; var inLine = []; var outputList = [];var retcode = new Set();
read.on('line', function(input){
	var tmp = input.split(' ');
	for(var i = 0; i < tmp.length; i++){
		inLine.push(tmp[i]);
		if(i == tmp.length - 1){
			retcode.add(inLine.length);
		}
	}
});
read.on('close', function(){
	obj = init(inLine);
	console.error('\n↑入力 ↓出力');
	Main();
	console.log(myconv(outputList, 9));
});
function makeClone(obj){return (obj instanceof Set) ? new Set(Array.from(obj)) : JSON.parse(JSON.stringify(obj));}
function nextArray(size, code){
	var ret = new Array(size);
	for(var i = 0; i < size; i++){
		if(code == 'int'){
			ret[i] = nextInt();
		}else if(code == 'long'){
			ret[i] = nextLong();
		}else if(code == 'double'){
			ret[i] = nextDouble();
		}else{
			ret[i] = next();
		}
	}
	return ret;
}
function nextIntArray(size){return nextArray(size, 'int');} function nextStrArray(size){return nextArray(size, 'str');} function nextLongArray(size){return nextArray(size, 'long');} function nextDoubleArray(size){return nextArray(size, 'double');}
function nextCharArray(){return myconv(next(),6);}
function next(){return obj.next();} function hasNext(){return obj.hasNext();} function nextInt(){return myconv(next(),1);} function nextLong(){return BigInt(next());} function nextDouble(){return parseFloat(next());}
function getCountMap(list){
	var map = {};
	for(var i = 0; i < list.length; i++){
		if(map[list[i]] == null){
			map[list[i]] = 0;
		}
		map[list[i]]++;
	}
	return map;
}
function init(input){
	return {
		list : input, index : 0, max : input.length,
		hasNext : function(){return (this.index < this.max);},
		next : function(){if(this.hasNext()){return this.list[this.index++];}else{throw 'ArrayIndexOutOfBoundsException ‚There is no more input';}},
		isReturn : function(){return retcode.has(this.index);}
	};
}
function myout(s){outputList.push(s);}
function myerr(s){console.error('debug:' + require('util').inspect(s,false,null));}
function isReturn(){return obj.isReturn();}
//param "no" is
//unknown or outlier : return i. 1: parseInt.
//2: split space. 4: split space and parseInt.
//6: split 1 character. 7: split 1 character and parseInt.
//8: join space. 9: join nextline. 0: join no character.
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(' ');case 4:return i.split(' ').map(Number);case 6:return i.split('');case 7:return i.split('').map(Number);case 8:return i.join(' ');case 9:return i.join('\n');case 0:return i.join('');default:return i;}}catch(e){return i;}}

//Don't have to see. end------------------------------------------
function Main(){
	var t = nextInt();
	while(hasNext()){
		var N = nextInt();
		var M = nextInt();
		var list = nextStrArray(N);
		var one = 0;
		for(var i = 0; i < N; i++){
			for(var j = 0; j < M; j++){
				if(list[i][j] == "1"){
					one++;
				}
			}
		}
		var output = one - 2;
		var ok = false;
		for(var i = 0; i < N - 1; i++){
			for(var j = 0; j < M - 1; j++){
				if(ok){
					break;
				}
				var c = 0;
				c += (list[i][j] == "0") ? 1 : 0;
				c += (list[i][j + 1] == "0") ? 1 : 0;
				c += (list[i + 1][j] == "0") ? 1 : 0;
				c += (list[i + 1][j + 1] == "0") ? 1 : 0;
				if(c >= 2 && !ok){
					output = one;
					ok = true;
				}else if(c == 1){
					output = one - 1;
				}
			}
		}
		myout(output);
	}
}

var n, m, mat;

    var tests = parseInt(readline());
    for (var t=0; t<tests;t++) {
        var nm = readline().split(' ').map(x=>parseInt(x));
        n = nm[0];
        m = nm[1];
        mat = [];
        for (var i = 0; i < n; i++) {
            var a = readline().split('').map(x=>parseInt(x));
            mat.push(a);
        }
        var ones = 0;
        for (var i = 0; i < n; i++) {
            for (var j = 0; j < m; j++) {
                ones += mat[i][j];
            }
        }
        if (ones == n * m || ones == n * m - 1 ) {
            print(n * m - 2);
            continue;
        }
        var ans = ones;
        var diff = 1;
        for (var i = 0; i < n; i++) {
            for (var j = 0; j < m; j++) {
                if (!mat[i][j]) {
                    if (i != n-1 && !mat[i+1][j]) {
                        diff = 0;
                        break;
                    }
                    if (j != m-1 && !mat[i][j+1]) {
                        diff = 0;
                        break;
                    }
                    if (j != m-1 && i != n-1 && !mat[i+1][j+1]) {
                        diff = 0;
                        break;
                    }
                    if (j != 0 && i != n-1 && !mat[i+1][j-1]) {
                        diff = 0;
                        break;
                    }
                }
            }
            if (!diff) {
                break;
            }
        }
        print(ans - diff);
    }

//Don't have to see. start------------------------------------------
var read = require('readline').createInterface({
	input: process.stdin, output: process.stdout
});
var obj; var inLine = []; var outputList = [];var retcode = new Set();
read.on('line', function(input){
	var tmp = input.split(' ');
	for(var i = 0; i < tmp.length; i++){
		inLine.push(tmp[i]);
		if(i == tmp.length - 1){
			retcode.add(inLine.length);
		}
	}
});
read.on('close', function(){
	obj = init(inLine);
	console.error('\n↑入力 ↓出力');
	Main();
	console.log(myconv(outputList, 9));
});
function makeClone(obj){return (obj instanceof Set) ? new Set(Array.from(obj)) : JSON.parse(JSON.stringify(obj));}
function nextArray(size, code){
	var ret = new Array(size);
	for(var i = 0; i < size; i++){
		if(code == 'int'){
			ret[i] = nextInt();
		}else if(code == 'long'){
			ret[i] = nextLong();
		}else if(code == 'double'){
			ret[i] = nextDouble();
		}else{
			ret[i] = next();
		}
	}
	return ret;
}
function nextIntArray(size){return nextArray(size, 'int');} function nextStrArray(size){return nextArray(size, 'str');} function nextLongArray(size){return nextArray(size, 'long');} function nextDoubleArray(size){return nextArray(size, 'double');}
function nextCharArray(){return myconv(next(),6);}
function next(){return obj.next();} function hasNext(){return obj.hasNext();} function nextInt(){return myconv(next(),1);} function nextLong(){return BigInt(next());} function nextDouble(){return parseFloat(next());}
function getCountMap(list){
	var map = {};
	for(var i = 0; i < list.length; i++){
		if(map[list[i]] == null){
			map[list[i]] = 0;
		}
		map[list[i]]++;
	}
	return map;
}
function init(input){
	return {
		list : input, index : 0, max : input.length,
		hasNext : function(){return (this.index < this.max);},
		next : function(){if(this.hasNext()){return this.list[this.index++];}else{throw 'ArrayIndexOutOfBoundsException ‚There is no more input';}},
		isReturn : function(){return retcode.has(this.index);}
	};
}
function myout(s){outputList.push(s);}
function myerr(s){console.error('debug:' + require('util').inspect(s,false,null));}
function isReturn(){return obj.isReturn();}
//param "no" is
//unknown or outlier : return i. 1: parseInt.
//2: split space. 4: split space and parseInt.
//6: split 1 character. 7: split 1 character and parseInt.
//8: join space. 9: join nextline. 0: join no character.
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(' ');case 4:return i.split(' ').map(Number);case 6:return i.split('');case 7:return i.split('').map(Number);case 8:return i.join(' ');case 9:return i.join('\n');case 0:return i.join('');default:return i;}}catch(e){return i;}}

//Don't have to see. end------------------------------------------
function Main(){
	var t = nextInt();
	while(hasNext()){
		var N = nextInt();
		var M = nextInt();
		var list = nextStrArray(N);
		var one = 0;
		for(var i = 0; i < N; i++){
			for(var j = 0; j < M; j++){
				if(list[i][j] == "1"){
					one++;
				}
			}
		}
		var output = one - 2;
		var ok = false;
		for(var i = 0; i < N - 1; i++){
			for(var j = 0; j < M - 1; j++){
				var c = 0;
				c += (list[i][j] == "0") ? 1 : 0;
				c += (list[i][j + 1] == "0") ? 1 : 0;
				c += (list[i + 1][j] == "0") ? 1 : 0;
				c += (list[i + 1][j + 1] == "0") ? 1 : 0;
				if(c >= 2 && !ok){
					output = one;
					ok = true;
				}else if(c == 1){
					output = one - 1;
				}
			}
		}
		myout(output);
	}
}

var n, m, mat;

    var tests = parseInt(readline());
    for (var t=0; t<tests;t++) {
        var nm = readline().split(' ').map(x=>parseInt(x));
        n = nm[0];
        m = nm[1];
        mat = [];
        for (var i = 0; i < n; i++) {
            var a = readline().split('').map(x=>parseInt(x));
            mat.push(a);
        }
        var ones = 0;
        for (var i = 0; i < n; i++) {
            for (var j = 0; j < m; j++) {
                ones += mat[i][j];
            }
        }
        if (ones == n * m || ones == n * m - 1 ) {
            print(n * m - 2);
            continue;
        }
        var ans = ones;
        var diff = 1;
        for (var i = 0; i < n; i++) {
            for (var j = 0; j < m; j++) {
                if (!mat[i][j]) {
                    if (i != n-1 && !mat[i+1][j]) {
                        diff = 0;
                        break;
                    }
                    if (j != m-1 && !mat[i][j+1]) {
                        diff = 0;
                        break;
                    }
                    if (j != m-1 && i != n-1 && !mat[i+1][j+1]) {
                        diff = 0;
                        break;
                    }
                }
            }
            if (!diff) {
                break;
            }
        }
        print(ans - diff);
    }

var n, m, mat;

    var tests = parseInt(readline());
    for (var t=0; t<tests;t++) {
        var nm = readline().split(' ').map(x=>parseInt(x));
        n = nm[0];
        m = nm[1];
        mat = [];
        for (var i = 0; i < n; i++) {
            var a = readline().split('').map(x=>parseInt(x));
            mat.push(a);
        }
        var ones = 0;
        for (var i = 0; i < n; i++) {
            for (var j = 0; j < m; j++) {
                ones += mat[i][j];
            }
        }
        if (ones == n * m || ones == n * m - 1 ) {
            print(n * m - 2);
            continue;
        }
        var ans = ones;
        var diff = 1;
        for (var i = 0; i < n; i++) {
            for (var j = 0; j < m; j++) {
                if (!mat[i][j]) {
                    if (i != n-1 && !mat[i+1][j]) {
                        diff = 0;
                        break;
                    }
                    if (j != m-1 && !mat[i][j+1]) {
                        diff = 0;
                        break;
                    }
                }
            }
            if (!diff) {
                break;
            }
        }
        print(ans - diff);
    }


Limak is a little polar bear. He likes nice strings — strings of length n, consisting of lowercase English letters only.The distance between two letters is defined as the difference between their positions in the alphabet. For example, , and .Also, the distance between two nice strings is defined as the sum of distances of corresponding letters. For example, , and .Limak gives you a nice string s and an integer k. He challenges you to find any nice string s' that . Find any s' satisfying the given conditions, or print "-1" if it's impossible to do so.As input/output can reach huge size it is recommended to use fast input/output methods: for example, prefer to use gets/scanf/printf instead of getline/cin/cout in C++, prefer to use BufferedReader/PrintWriter instead of Scanner/System.out in Java.

The first line contains two integers n and k (1 ≤ n ≤ 105, 0 ≤ k ≤ 106). The second line contains a string s of length n, consisting of lowercase English letters.

If there is no string satisfying the given conditions then print "-1" (without the quotes). Otherwise, print any nice string s' that .

/* TEST CASE
input
4 26
bear
output
roar
input
2 7
af
output
db
input
3 1000
hey
output
-1 */
function main() {
	var splitted = readline().split(" ");
	var n = parseInt(splitted[0]);
	var k = parseInt(splitted[1]);
	var s = readline();
	var r = "";
	for (var i = 0; i < n; i++) {
		var c = s.charCodeAt(i)
		var distToZ = 0x7A - c
		var distToA = c - (0x7A - 25);
		if (distToZ >= distToA) {
			if (distToZ <= k) {
				r += 'z';
				k -= distToZ;
			} else {
				r += String.fromCharCode(c + k);
				k = 0;
			}
		} else {
			if (distToA <= k) {
				r += 'a';
				k -= distToA;
			} else {
				r += String.fromCharCode(c - k);
				k = 0;
			}
		}
	}

	if (k > 0)
		r = "-1";

	print(r);
}

main();

var str = readline().split(" ", 2);
var k = Number(str[1]);
var str = readline();

function getChar(str, n) {
    var table = "abcdefghijklmnopqrstuvwxyz";
    var index = table.indexOf(str);
    return table[index + n];
}

var ans = "";
for (var i = 0; i < str.length; ++i) {
    if (k === 0) {
        ans += str.slice(i);
        break;
    }
    var dis;
    if (str[i] <= "m") {
        dis = "z".charCodeAt(0) - str[i].charCodeAt(0);
        if (dis >= k) {
            ans += getChar(str[i], k);
            k = 0;
        } else {
            ans += getChar(str[i], dis);
            k -= dis;
        }
    } else {
        dis = str[i].charCodeAt(0) - "a".charCodeAt(0);
        if (dis >= k) {
            ans += getChar(str[i], -k);
            k = 0;
        } else {
            ans += getChar(str[i], -dis);
            k -= dis;
        }
    }
}

if (k !== 0) {
    print(-1);
} else {
    print(ans);
}

/* TEST CASE
input
4 26
bear
output
roar
input
2 7
af
output
db
input
3 1000
hey
output
-1 */
function main() {
	var splitted = readline().split(" ");
	var n = parseInt(splitted[0]);
	var k = parseInt(splitted[1]);
	var s = readline();
	var r = "";
	for (var i = 0; i < n; i++) {
		var c = s.charCodeAt(i)
		var distToZ = 0x7A - c
		var distToA = c - (0x7A - 25);
		if (distToZ >= distToA) {
			if (distToZ <= k) {
				r += 'z';
				k -= distToZ;
			} else {
				r += String.fromCharCode(c + k);
				k = 0;
			}
		} else {
			if (distToA <= k) {
				r += 'a';
				k -= distToA;
			} else {
				r += String.fromCharCode(c + k);
				k = 0;
			}
		}
	}

	if (k > 0)
		r = "-1";

	print(r);
}

main();

/* TEST CASE
input
5 2 3
output
20 15
input
8 2 4
output
35 32
 */
function main() {
	var splitted = readline().split(" ");
	var n = parseInt(splitted[0]);
	var k = parseInt(splitted[1]);
	var s = readline();
	var r = "";
	for (var i = 0; i < n; i++) {
		var c = s.charCodeAt(i)

		if (0x7A - c <= k) {
			r += 'z';
			k -= 0x7A - c;
		} else {
			r += String.fromCharCode(c + k);
			k = 0;
		}
	}

	if (k > 0)
		r = "-1";

	print(r);
}

main();

/* TEST CASE
input
5 2 3
output
20 15
input
8 2 4
output
35 32
 */
function main() {
	var splitted = readline().split(" ");
	var n = parseInt(splitted[0]);
	var k = parseInt(splitted[1]);
	var s = readline();
	var r = "";
	for (var i = 0; i < n; i++) {
		var c = s.charCodeAt(i)

		if (0x7A - c <= k) {
			r += 'z';
			k -= 0x7A - c;
		} else {
			r += String.fromCharCode(c + k);
			k = 0;
		}
	}

	print(r);
}

main();

var str = readline().split(" ", 2);
var k = Number(str[1]);
var str = readline();

function getChar(str, n) {
    var table = "abcdefghijklmnopqrstuvwxyz";
    var index = table.indexOf(str);
    return table[index + n];
}

var ans = "";
for (var i = 0; i < str.length; ++i) {
    if (k === 0) {
        ans += str.slice(i);
        break;
    }
    var dis;
    if (str[i] <= "m") {
        dis = "z".charCodeAt(0) - str[i].charCodeAt(0);
        if (dis >= k) {
            k = 0;
            ans += getChar(str[i], k);
        } else {
            k -= dis;
            ans += getChar(str[i], dis);
        }
    } else {
        dis = str[i].charCodeAt(0) - "a".charCodeAt(0);
        if (dis >= k) {
            k = 0;
            ans += getChar(str[i], -k);
        } else {
            k -= dis;
            ans += getChar(str[i], -dis);
        }
    }
}

if (k !== 0) {
    print(-1);
} else {
    print(ans);
}


Igor has fallen in love with Tanya. Now Igor wants to show his feelings and write a number on the fence opposite to Tanya's house. Igor thinks that the larger the number is, the more chance to win Tanya's heart he has. Unfortunately, Igor could only get v liters of paint. He did the math and concluded that digit d requires ad liters of paint. Besides, Igor heard that Tanya doesn't like zeroes. That's why Igor won't use them in his number.Help Igor find the maximum number he can write on the fence.

The first line contains a positive integer v (0 ≤ v ≤ 106). The second line contains nine positive integers a1, a2, ..., a9 (1 ≤ ai ≤ 105).

Print the maximum number Igor can write on the fence. If he has too little paint for any digit (so, he cannot write anything), print -1.

print(function(v, a) {

	var min = 1e5 + 1;
	var x = 0;
	for (var i = 1; i <= 9; i++)
		if (a[i] <= min) {
			x = i.toString();
			min = a[i];
		}

	var ans = [];

	var t = Math.floor(v / min);

	for (var i = t - 1; i >= 0; i--) {
		var num = x;
		for (var j = 9; j > x; j--) {
			if ((v - a[j]) / min >= i) {
				num = j;
				break
			}
		}
		v = v - a[num];
		ans.push(num);
	}

	return ans.length === 0 ? -1 : ans.join('');

}(+readline(), ('0 ' + readline()).split(' ').map(Number)));

print(function(v, a) {

	var min = Math.min.apply(0, a);
	a = a.map(function(v) {
		return v - min;
	});

	var t = Math.floor(v / min);
	var ans = [];

	v = v % min;

	for (var i = 0; i < t; i++)
		for (var j = 8; j >= 0; j--)
			if (v - a[j] >= 0) {
				v -= a[j];
				ans.push(j + 1);
				break;
			}

	return ans.length === 0 ? -1 : ans.join('');

}(+readline(), readline().split(' ').map(Number)));

print(function(v, a) {
	var i, j, t, ans = [],
		min = Math.min.apply(0, a);
	a = a.map(function(v) {
		return v - min;
	});
	t = ~~ (v / min);
	v = v % min;
	for (i = 0; i < t; i++)
		for (j = 8; j >= 0; j--)
			if (v - a[j] >= 0) {
				v -= a[j];
				ans.push(j + 1);
				break;
			}
	return ans.length === 0 ? -1 : ans.join('');
}(+readline(), readline().split(' ').map(Number)));

function trim(s) {
	return s.replace(/^\s+|\s+$/gm, '');
}

function tokenize(s) {
	return trim(s).split(/\s+/);
}

function tokenizeIntegers(s) {
	var tokens = tokenize(s);
	for (var i = 0; i < tokens.length; i += 1) {
		tokens[i] = parseInt(tokens[i], 10);
	};
	return tokens;
}

function main() {
	var cash = parseInt(readline()),
		costs = tokenizeIntegers(readline()),
		digitCost = {}, minCost = costs[0];
	for (var d = 1; d <= 9; ++d) {
		var cost = costs[d-1];
		minCost = Math.min(minCost, cost);
		digitCost[d] = cost;
	}
	var length = Math.floor(cash / minCost),
		result = new Array(length);
	if (length == 0) {
		print(-1);
		return;
	}
	cash -= length*minCost;
	for (var d = 1; d <= 9; ++d) {
		digitCost[d] -= minCost;
	}
	for (var i = 0; i <  length; ++i) {
		for (var d = 9; d >= 1; --d) {
			if (digitCost[d] <= cash) {
				break;
			}
		}
		if (d == 0) {
			break;
		}
		result[i] = d;
		cash -= digitCost[d];
	}
	print(result.join(''));
}

main();

print(function(v, a) {

	var min = 1e5 + 1;
	var x = 0;
	for (var i = 1; i <= 9; i++)
		if (a[i] <= min) {
			x = i.toString();
			min = a[i];
		}

	var ans = '';
	var t = Math.floor(v / min);
	for (var i = 0; i < t; i++)
		ans += x;

	return ans.length === 0 ? -1 : ans;

}(+readline(), ('0 ' + readline()).split(' ').map(Number)));

print(function(v, a) {

	var min = 1e5 + 1;
	var x = 0;
	for (var i = 1; i <= 9; i++)
		if (a[i] <= min) {
			x = i.toString();
			min = a[i];
		}

	var ans = [];
	var t = Math.floor(v / min);
	for (var i = t - 1; i >= 0; i--){
		var num = x;
		for (var j = 9; j > x; j--) {
			if( (v-a[j])/min >= i ){
				num = j;
				v = v-a[j];
				break
			}
		}
		ans.push(num);
	}

	return ans.length === 0 ? -1 : ans.join('');

}(+readline(), ('0 ' + readline()).split(' ').map(Number)));

function trim(s) {
	return s.replace(/^\s+|\s+$/gm, '');
}

function tokenize(s) {
	return trim(s).split(/\s+/);
}

function tokenizeIntegers(s) {
	var tokens = tokenize(s);
	for (var i = 0; i < tokens.length; i += 1) {
		tokens[i] = parseInt(tokens[i], 10);
	};
	return tokens;
}

function main() {
	var cash = parseInt(readline()),
		digitValues = tokenizeIntegers(readline()),
		digits = [];
	for (var d = 1; d <= 9; ++d) {
		digits.push({ digit: d, cost: digitValues[d-1] });
	}
	digits.sort(function (a, b) {
		if (a.cost != b.cost) {
			return a.cost - b.cost;
		} else {
			return a.digit - b.digit;
		}
	});
	var cheap = digits[0].cost,
		length = Math.floor(cash / cheap),
		result = new Array(length),
		resultPos = 0, digitPos = 8;
	if (length == 0) {
		print(-1);
		return;
	}
	cash -= length*cheap;
	while (resultPos < length) {
		while (digitPos >= 0 && digits[digitPos].cost - cheap > cash) {
			--digitPos;
		}
		if (digitPos == -1) {
			break;
		}
		result[resultPos++] = digits[digitPos].digit;
		cash -= digits[digitPos].cost - cheap;
	}
	print(result.join(''));
}

main();


You are given a string $$$s$$$ consisting of $$$n$$$ lowercase Latin letters.You have to remove at most one (i.e. zero or one) character of this string in such a way that the string you obtain will be lexicographically smallest among all strings that can be obtained using this operation.String $$$s = s_1 s_2 \dots s_n$$$ is lexicographically smaller than string $$$t = t_1 t_2 \dots t_m$$$ if $$$n < m$$$ and $$$s_1 = t_1, s_2 = t_2, \dots, s_n = t_n$$$ or there exists a number $$$p$$$ such that $$$p \le min(n, m)$$$ and $$$s_1 = t_1, s_2 = t_2, \dots, s_{p-1} = t_{p-1}$$$ and $$$s_p < t_p$$$.For example, "aaa" is smaller than "aaaa", "abb" is smaller than "abc", "pqr" is smaller than "z".

The first line of the input contains one integer $$$n$$$ ($$$2 \le n \le 2 \cdot 10^5$$$) — the length of $$$s$$$. The second line of the input contains exactly $$$n$$$ lowercase Latin letters — the string $$$s$$$.

Print one string — the smallest possible lexicographically string that can be obtained by removing at most one character from the string $$$s$$$.

NoteIn the first example you can remove any character of $$$s$$$ to obtain the string "aa".In the second example "abca" < "abcd" < "abcda" < "abda" < "acda" < "bcda".

const readline = require('readline');
const rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
});

let l = 0;
rl.on('line', (input) => {
    if (l === 0) { l++ }
    else {
        rl.close();
        let max = 1
        let arr = input.split('')
        let curr=0
        let res=''
        let isRem = false
        for (let i = 0; i < arr.length-1;i++) {
             if(arr[i]>arr[i+1]&&!isRem){
                isRem= true
             } else {
                 res+=arr[i]
             }
        }
        res+=arr[arr.length-1]
        if(arr.length===res.length)
        {
            res=res.slice(0,res.length-1)
        }
        console.log(res)
        return 0;
    }
});

const readline = require('readline');
const rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
});

let l = 0;
rl.on('line', (input) => {
    if (l === 0) { l++ }
    else {
        rl.close();
        let max = 1
        let arr = input.split('')
        let curr=0
        let res=''
        let rem = true
        for (let i = 0; i < arr.length-1;i++) {
             if(arr[i]>arr[i+1]&&rem){
                    rem= false
             } else {
                 res+=arr[i]
             }
        }
        res+=arr[arr.length-1]
        if(arr.length===res.length)
        {
            res=res.slice(0,res.length-1)
        }
        console.log(res)
        return 0;
    }
});

const readline = require('readline');

const rl = readline.createInterface({
  input: process.stdin,
  output: process.stdout
});

var counter=0, N;
rl.on('line', (input) => {
    if(counter==0){
        N=parseInt(input);
        counter++;
    }
    else
    {
        if(N != 1){
            let ind = N-1;
            for(let i=0; i<N-1; i++){
                if(input[i]>input[i+1]){
                ind=i;
                break;
                }
            }
            input = input.substring(0, ind) + input.substring(ind + 1);

        }
        console.log(input);
        rl.close();
    }

  });

  /*

  input = "abcdefghi"
  input = "aaaaaaaaa"
  */

var length = parseInt(readline());

var string = readline().split('');

var removePos = length-1;

for(var i = 0; i< length-1; i++){
    if(string[i]>string[i+1]){
        removePos = i;
        break;
    }
}

string.splice(removePos,1)
print(string.join(''))

var cnt = parseInt(readline());
var line = readline();
for (var i = 1; i < cnt; i++) {
	if (line[i-1] > line[i]) {
		break;
    }
}
print(line.slice(0,i-1) + line.slice(i,line.length));

function solve(n, s) {
    for (var i=1; i<n; i++) {
        if (s.charCodeAt(i) < s.charCodeAt(i-1)) {
            return s.substring(0, i-1) + s.substring(i, n);
        }
    }

    return s.substring(0, n-1)
}

write(solve(+readline(), readline()))

readline();
var str = readline();
var res;
for(var i = 1; i < str.length; i++) {
	if(str[i] < str[i - 1]) {
		res = str.substr(0, i - 1) + str.substr(i);
		break;
	}
}

if(!res) res = str.substr(0, str.length - 1);

print(res);

function minString(str) {
    var len = str.length;
    var removeIndex = len-1;
    for (var i = 0; i < len-1; i++) {
        if (str[i] > str[i+1]) {
            removeIndex = i;
            break;
        }
    }
    return str.slice(0, removeIndex) + str.slice(removeIndex +1);
}

const len = Number(readline());
const str = readline();
print(minString(str));

const readline = require('readline');
const rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
});

let l = 0;
rl.on('line', (input) => {
    if (l === 0) { l++ }
    else {
        rl.close();
        let max = 1
        let arr = input.split('')
        let curr=0
        let res=''
        let rem = true
        for (let i = 0; i < arr.length-1;i++) {
             if(arr[i]>arr[i+1]&&rem){
                    rem= false
             } else {
                 res+=arr[i]
             }
        }
        res+=arr[arr.length-1]
        if(arr.length===res.length)
        {
            res=res.slice(1)
        }
        console.log(res)
        return 0;
    }
});

var length = parseInt(readline());

var string = readline().split('');

if(string[length -1] =='a'){
    string.splice(-1,1);
    length = string.length;
}

string[length - 1] = 'a';

print(string.join(''))

function minString(str) {
    var len = str.length;
    var removeIndex = len-1;
    for (var i = 0; i < len-1; i++) {
        if (str[i] > str[i+1]) {
            removeIndex = i;
        }
    }
    return str.slice(0, removeIndex) + str.slice(removeIndex +1);
}

const len = Number(readline());
const str = readline();
print(minString(str));


A kindergarten teacher Natalia Pavlovna has invented a new ball game. This game not only develops the children's physique, but also teaches them how to count. The game goes as follows. Kids stand in circle. Let's agree to think of the children as numbered with numbers from 1 to n clockwise and the child number 1 is holding the ball. First the first child throws the ball to the next one clockwise, i.e. to the child number 2. Then the child number 2 throws the ball to the next but one child, i.e. to the child number 4, then the fourth child throws the ball to the child that stands two children away from him, i.e. to the child number 7, then the ball is thrown to the child who stands 3 children away from the child number 7, then the ball is thrown to the child who stands 4 children away from the last one, and so on. It should be mentioned that when a ball is thrown it may pass the beginning of the circle. For example, if n = 5, then after the third throw the child number 2 has the ball again. Overall, n - 1 throws are made, and the game ends.The problem is that not all the children get the ball during the game. If a child doesn't get the ball, he gets very upset and cries until Natalia Pavlovna gives him a candy. That's why Natalia Pavlovna asks you to help her to identify the numbers of the children who will get the ball after each throw.

The first line contains integer n (2 ≤ n ≤ 100) which indicates the number of kids in the circle.

In the single line print n - 1 numbers which are the numbers of children who will get the ball after each throw. Separate the numbers by spaces.

print(function(n) {
	var x = 2;
	var ans = [];
	for (var i = 1; i < n; i++) {
		ans.push(x);
		x = x + i + 1;
		if(x>n){
			x = x-n;
		}
	}
	return ans.join(' ');
}(readline()));

;(function () {

	print(function (n) {

		var q = 1, p = [], t = 1, r = n;
		while (--n) {
			p.push(((q += t++) % r) || r);
		}

		return p.join(' ');

	}(+readline()));

}.call(this));

'use strict'

let N = +readline()

let i = 0
let c = 1
let n = N
let r = []
while (--n) {
  i++
  c += i
  c = c % N
  r.push(c)
}

print(r.map(v => v || N).join(' '))

var readline = require('readline'),
    rl = readline.createInterface(process.stdin, process.stdout);

var n;

rl.on('line', function (line) {
   n = parseInt(line);

   let limit = n - 1, ind = 0, skip = 0, pos = 1;
   while (ind < limit)
   {
       pos += skip + 1;
       if (pos > n)
           pos = pos % n;

       process.stdout.write(pos + " ");
      // Console.Write("{0} ", pos);

       skip++;
       ind++;

   }
  rl.close();

}).on('close', function () {

    process.exit(0);
});

const readline = require('readline');
const rl = readline.createInterface({
  input: process.stdin,
  output: process.stdout,
  terminal: false
});

rl.on('line', (d) => {
  const n = +d;
  const ans = [2];
  let inc = 1;

  while(ans.length < n - 1) {
    inc++;
    const v = (ans[ans.length - 1] + inc) % n;
    ans.push(v === 0 ? n : v);
  }

  console.log(ans.join(' '));
});

const readline = require('readline');
const rl = readline.createInterface({
  input: process.stdin,
  output: process.stdout,
  terminal: false
});

rl.on('line', (d) => {
  const n = +d;
  let curr = 0;
  let step = 1;
  let ans = '';

  for (let i = 0; i < n - 1; i++) {
    curr = (curr + step) % n;
    step++;
    ans += curr + 1 + ' ';
  }

  console.log(ans);

  // const ans = [2];
  // let inc = 1;

  // while(ans.length < n - 1) {
  //   inc++;
  //   const v = (ans[ans.length - 1] + inc) % n;
  //   ans.push(v === 0 ? n : v);
  // }

  // console.log(ans.join(' '));
});

print(function(n) {
	var x = 2;
	var ans = [];
	for (var i = 1; i < n; i++) {
		ans.push(x);
		x = (x + i + 1) % n || n;
	}
	return ans.join(' ');
}(readline()));

'use strict'

let N = +readline()

let i = 0
let c = 1
let n = N
let r = []
while (--n) {
  i++
  c += i
  c = c % N
  r.push(c)
}

print(r.join(' '))

const readline = require('readline');
const rl = readline.createInterface({
  input: process.stdin,
  output: process.stdout,
  terminal: false
});

rl.on('line', (d) => {
  const n = +d;
  let curr = 0;
  let step = 1;
  let ans = '';

  for (let i = 0; i < n - 1; i++) {
    curr = (curr + step) % n;
    ans += curr + 1 + ' ';
  }

  console.log(ans);

  // const ans = [2];
  // let inc = 1;

  // while(ans.length < n - 1) {
  //   inc++;
  //   const v = (ans[ans.length - 1] + inc) % n;
  //   ans.push(v === 0 ? n : v);
  // }

  // console.log(ans.join(' '));
});

const readline = require('readline');
const rl = readline.createInterface({
  input: process.stdin,
  output: process.stdout,
  terminal: false
});

rl.on('line', (d) => {
  const n = +d;
  const ans = [2];
  let inc = 1;

  while(ans.length < n - 1) {
    inc++;
    const v = (ans[ans.length - 1] + inc) % n;
    ans.push(v);
  }

  console.log(ans.join(' '));
});


During the lunch break all n Berland State University students lined up in the food court. However, it turned out that the food court, too, has a lunch break and it temporarily stopped working.Standing in a queue that isn't being served is so boring! So, each of the students wrote down the number of the student ID of the student that stands in line directly in front of him, and the student that stands in line directly behind him. If no one stands before or after a student (that is, he is the first one or the last one), then he writes down number 0 instead (in Berland State University student IDs are numerated from 1).After that, all the students went about their business. When they returned, they found out that restoring the queue is not such an easy task.Help the students to restore the state of the queue by the numbers of the student ID's of their neighbors in the queue.

The first line contains integer n (2 ≤ n ≤ 2·105) — the number of students in the queue.  Then n lines follow, i-th line contains the pair of integers ai, bi (0 ≤ ai, bi ≤ 106), where ai is the ID number of a person in front of a student and bi is the ID number of a person behind a student. The lines are given in the arbitrary order. Value 0 is given instead of a neighbor's ID number if the neighbor doesn't exist. The ID numbers of all students are distinct. It is guaranteed that the records correspond too the queue where all the students stand in some order.

Print a sequence of n integers x1, x2, ..., xn — the sequence of ID numbers of all the students in the order they go in the queue from the first student to the last one.

NoteThe picture illustrates the queue for the first sample.

var n = parseInt(readline().trim())
var x;
var ans= []
var g = {}
var _g={}
for(var i=0;i<n;i++){
    x = readline().trim().split(' ').map((_x)=>parseInt(_x))
    g[x[0]]=x[1];
    _g[x[1]]=x[0];
}
var y = 0
do{

    if(g[y]==undefined)
        break;
    y=g[y];
    ans.push(-1);
    if(y==0)
    break;
    ans.push(y);
}while(y!=0)

var y,i
if(n%2==0){
    y=_g[0]
    i=n-2;
}else{
    for(var i in g){
        if(g[g[i]]==undefined){
            y=g[i]
            break
        }
    }
    i=n-1
}

do{
    ans[i]=y
    i-=2
    if(_g[y]==undefined)
        break;
    y=_g[y];

}while(y!=0)

print(ans.join(' '))


A teacher decides to give toffees to his students. He asks n students to stand in a queue. Since the teacher is very partial, he follows the following rule to distribute toffees.He looks at the first two students and gives more toffees to the student having higher marks than the other one. If they have the same marks they get the same number of toffees. The same procedure is followed for each pair of adjacent students starting from the first one to the last one.It is given that each student receives at least one toffee. You have to find the number of toffees given to each student by the teacher such that the total number of toffees is minimum.

The first line of input contains the number of students n (2 ≤ n ≤ 1000). The second line gives (n - 1) characters consisting of "L", "R" and "=". For each pair of adjacent students "L" means that the left student has higher marks, "R" means that the right student has higher marks and "=" means that both have equal marks.

Output consists of n integers separated by a space representing the number of toffees each student receives in the queue starting from the first one to the last one.

/* TEST CASE
input
5
LRLR
output
2 1 2 1 2
input
5
=RRR
output
1 1 2 3 4
 */
function main() {
	var n = parseInt(readline());
	var answer = new Array(n);
	var adjacentPairMarks = readline();
	var c = adjacentPairMarks[0];

	answer[0] = (c == 'L' ? 2 : 1);
	answer[1] = (c == 'R' ? 2 : 1);

	for (var i = 1; i < n - 1; i++) {
		c = adjacentPairMarks[i];

		if (c == '=') {
			answer[i + 1] = answer[i];
		} else if (c == 'L') {
			answer[i + 1] = 1;
			for (var j = i; j >= 0; j--) {
				if (adjacentPairMarks[j] == 'L'	&& answer[j] <= answer[j + 1]
				   || adjacentPairMarks[j] == '=' && answer[j] < answer[j + 1]) {
					answer[j]++;
				} else {
					break;
				}
			}
		} else if (c == 'R') {
			answer[i + 1] = answer[i] + 1;
		}
	}

	print(answer.join(' '));
}

main();

/* TEST CASE
input
5
LRLR
output
2 1 2 1 2
input
5
=RRR
output
1 1 2 3 4
 */
function main() {
	var n = parseInt(readline());
	var answer = new Array(n);
	var adjacentPairMarks = readline();
	var c = adjacentPairMarks[0];

	answer[0] = (c == 'L' ? 2 : 1);
	answer[1] = (c == 'R' ? 2 : 1);

	for (var i = 1; i < n - 1; i++) {
		c = adjacentPairMarks[i];

		if (c == '=') {
			answer[i + 1] = answer[i];
		} else if (c == 'L') {
			answer[i + 1] = answer[i] - 1;
			if (answer[i + 1] == 0) {
				for (var j = i; j >= 0; j--) {
					answer[j]++;
				}
			}
			answer[i + 1] = 1;
		} else if (c == 'R') {
			answer[i + 1] = answer[i] + 1;
		}
	}

	print(answer.join(' '));
}

main();

/* TEST CASE
input
5
LRLR
output
2 1 2 1 2
input
5
=RRR
output
1 1 2 3 4
 */
function main() {
	var n = parseInt(readline());
	var answer = new Array(n);
	var adjacentPairMarks = readline();
	var c = adjacentPairMarks[0];

	answer[0] = (c == 'L' ? 2 : 1);
	answer[1] = (c == 'R' ? 2 : 1);

	for (var i = 1; i < n - 1; i++) {
		c = adjacentPairMarks[i];

		if (c == '=') {
			answer[i + 1] = answer[i];
		} else if (c == 'L') {
			answer[i + 1] = answer[i] - 1;
			if (answer[i + 1] == 0) {
				for (var j = i + 1; j >= 0; j--) {
					answer[j]++;
				}
			}
		} else if (c == 'R') {
			answer[i + 1] = answer[i] + 1;
		}
	}

	print(answer.join(' '));
}

main();

/* TEST CASE
input
5
LRLR
output
2 1 2 1 2
input
5
=RRR
output
1 1 2 3 4
 */
function main() {
	var n = parseInt(readline());
	var answer = new Array(n);
	var adjacentPairMarks = readline();
	var i;
	var prev = 1, current;
	var c = adjacentPairMarks[0];

	answer[0] = (c == 'L' ? 2 : 1);
	answer[1] = (c == 'R' ? 2 : 1);

	for (i = 1; i < n - 1; i++) {
		c = adjacentPairMarks[i];

		if (c == '=') {
			answer[i + 1] = answer[i];
		} else if (c == 'L') {
			answer[i + 1] = answer[i] - 1;
			if (answer[i + 1] == 0) {
				for (var j = i + 1; j >= 0; j--) {
					answer[j]++;
				}
			}
		} else if (c == 'R') {
			answer[i + 1] = answer[i] + 1;
		}
	}

	print(answer.join(' '));
}

main();

/* TEST CASE
input
5
LRLR
output
2 1 2 1 2
input
5
=RRR
output
1 1 2 3 4
 */
function main() {
	var n = parseInt(readline());
	var answer = new Array(n);
	var adjacentPairMarks = readline();
	var c = adjacentPairMarks[0];

	answer[0] = (c == 'L' ? 2 : 1);
	answer[1] = (c == 'R' ? 2 : 1);

	for (var i = 1; i < n - 1; i++) {
		c = adjacentPairMarks[i];

		if (c == '=') {
			answer[i + 1] = answer[i];
		} else if (c == 'L') {
			answer[i + 1] = 1;
			for (var j = i; j >= 0; j--) {
				if (adjacentPairMarks[j] == 'L'	&& answer[j] <= answer[j + 1]
				   || adjacentPairMarks[j] == '=' && answer[j] < answer[j + 1]) {
					answer[j] = answer[j + 1] + 1;
				}			}
		} else if (c == 'R') {
			answer[i + 1] = answer[i] + 1;
		}
	}

	print(answer.join(' '));
}

main();

/* TEST CASE
input
5
LRLR
output
2 1 2 1 2
input
5
=RRR
output
1 1 2 3 4
 */
function main() {
	var n = parseInt(readline());
	var answer = new Array(n);
	var adjacentPairMarks = readline();
	var c = adjacentPairMarks[0];

	answer[0] = (c == 'L' ? 2 : 1);
	answer[1] = (c == 'R' ? 2 : 1);

	for (var i = 1; i < n - 1; i++) {
		c = adjacentPairMarks[i];

		if (c == '=') {
			answer[i + 1] = answer[i];
		} else if (c == 'L') {
			answer[i + 1] = 1;
			for (var j = i; j >= 0; j--) {
				if (adjacentPairMarks[j] == 'L'	&& answer[j] <= answer[j + 1]
				   || adjacentPairMarks[j] == '=' && answer[j] < answer[j + 1]) {
					answer[j] = answer[j + 1] + 1;
				} else {
					break;
				}
			}
		} else if (c == 'R') {
			answer[i + 1] = answer[i] + 1;
		}
	}

	print(answer.join(' '));
}

main();


They say "years are like dominoes, tumbling one after the other". But would a year fit into a grid? I don't think so.Limak is a little polar bear who loves to play. He has recently got a rectangular grid with h rows and w columns. Each cell is a square, either empty (denoted by '.') or forbidden (denoted by '#'). Rows are numbered 1 through h from top to bottom. Columns are numbered 1 through w from left to right.Also, Limak has a single domino. He wants to put it somewhere in a grid. A domino will occupy exactly two adjacent cells, located either in one row or in one column. Both adjacent cells must be empty and must be inside a grid.Limak needs more fun and thus he is going to consider some queries. In each query he chooses some rectangle and wonders, how many way are there to put a single domino inside of the chosen rectangle?

The first line of the input contains two integers h and w (1 ≤ h, w ≤ 500) – the number of rows and the number of columns, respectively. The next h lines describe a grid. Each line contains a string of the length w. Each character is either '.' or '#' — denoting an empty or forbidden cell, respectively. The next line contains a single integer q (1 ≤ q ≤ 100 000) — the number of queries. Each of the next q lines contains four integers r1i, c1i, r2i, c2i (1 ≤ r1i ≤ r2i ≤ h, 1 ≤ c1i ≤ c2i ≤ w) — the i-th query. Numbers r1i and c1i denote the row and the column (respectively) of the upper left cell of the rectangle. Numbers r2i and c2i denote the row and the column (respectively) of the bottom right cell of the rectangle.

Print q integers, i-th should be equal to the number of ways to put a single domino inside the i-th rectangle.

NoteA red frame below corresponds to the first query of the first sample. A domino can be placed in 4 possible ways.

// problem name: New Year and Domino
// problem link: https://codeforces.com/problemset/problem/611/C
// contest link: https://codeforces.com/contest/611
// author: reyad
// time: (?)

'use strict';

function main() {
	let h = nextInt();
	let w = nextInt();
	let a = [];
	let u = [];
	let l = [];
	for(let i=0; i<h; i++) {
		a.push([]);
		u.push([]);
		l.push([]);
		let b = nextLine().split('');
		for(let j=0; j<w; j++) {
			let x = (b[j] === '.') ? 0 : 1;
			a[i].push(x);
			u[i].push(0);
			l[i].push(0);
		}
	}

	// for(let i=0; i<h; i++) {
	// 	let b = '';
	// 	for(let j=0; j<w; j++) {
	// 		b += a[i][j] + ' ';
	// 	}
	// 	console.log(b);
	// }
	// console.log('');

	for(let i=0; i<h; i++) {
		for(let j=1; j<w; j++) {
			if(a[i][j] == 0 && a[i][j-1] == 0) l[i][j] = l[i][j-1] + 1;
			else l[i][j] = l[i][j-1];
		}
	}
	for(let i=1; i<h; i++) {
		for(let j=0; j<w; j++) {
			if(a[i][j] == 0 && a[i-1][j] == 0) u[i][j] = u[i-1][j] + 1;
			else u[i][j] = u[i-1][j];
		}
	}

	// for(let i=0; i<h; i++) {
	// 	let b = '';
	// 	for(let j=0; j<w; j++) {
	// 		b += l[i][j] + ' ';
	// 	}
	// 	console.log(b);
	// }
	// console.log('');

	// for(let i=0; i<h; i++) {
	// 	let b = '';
	// 	for(let j=0; j<w; j++) {
	// 		b += u[i][j] + ' ';
	// 	}
	// 	console.log(b);
	// }
	// console.log('');

	let n = nextInt();
	for(let i=0; i<n; i++) {
		let x = nextInt() - 1;
		let y = nextInt() - 1;
		let x2 = nextInt() - 1;
		let y2 = nextInt() - 1;

		let ans = 0;
		for(let i=y; i<=y2; i++) {
			ans += u[x2][i] - u[x][i];
		}
		for(let i=x; i<=x2; i++) {
			ans += l[i][y2] - l[i][y];
		}
		console.log(ans);
	}
}

// reader and main caller

let readline = require('readline');

let rl = readline.createInterface({
	input: process.stdin,
	output: process.stdout,
	terminal: false
});

let inputBuf = [];
let inputBufCnt = 0;
let tk = []
let tkCnt = 0;

function nextLine() {
	return inputBuf[inputBufCnt++];
}
function next() {
	if(tkCnt == tk.length) {
		tk = inputBuf[inputBufCnt++].split(' ');
		tkCnt = 0;
	}
	return tk[tkCnt++];
}
function nextInt() {
	return parseInt(next());
}
function nextDouble() {
	return parseFloat(next());
}

rl.on('line', (line) => {
	inputBuf.push(line);
}).on('close', () => {
	main();
});


The Little Elephant loves Ukraine very much. Most of all he loves town Rozdol (ukr. "Rozdil").However, Rozdil is dangerous to settle, so the Little Elephant wants to go to some other town. The Little Elephant doesn't like to spend much time on travelling, so for his journey he will choose a town that needs minimum time to travel to. If there are multiple such cities, then the Little Elephant won't go anywhere.For each town except for Rozdil you know the time needed to travel to this town. Find the town the Little Elephant will go to or print "Still Rozdil", if he stays in Rozdil.

The first line contains a single integer n (1 ≤ n ≤ 105) — the number of cities. The next line contains n integers, separated by single spaces: the i-th integer represents the time needed to go from town Rozdil to the i-th town. The time values are positive integers, not exceeding 109. You can consider the cities numbered from 1 to n, inclusive. Rozdil is not among the numbered cities.

Print the answer on a single line — the number of the town the Little Elephant will go to. If there are multiple cities with minimum travel time, print "Still Rozdil" (without the quotes).

NoteIn the first sample there are only two cities where the Little Elephant can go. The travel time for the first town equals 7, to the second one — 4. The town which is closest to Rodzil (the only one) is the second one, so the answer is 2.In the second sample the closest cities are cities two and five, the travelling time to both of them equals 4, so the answer is "Still Rozdil".

print(function(n) {
	var a = readline().split(' ').map(Number),
		min = Math.min.apply(0, a),
		i = a.indexOf(min),
		ii = a.indexOf(min, i+1);

	return ii > -1 ? 'Still Rozdil' : i + 1;

}(+readline()));

;(function () {

	var n = +readline();
	var a = readline().split(' ').map(Number);
	var m = Math.min.apply(0, a);
	var p = a.indexOf(m);

	print( p === a.lastIndexOf(m) ? p + 1 : 'Still Rozdil' );

}).call(this);

var n = readline();
var cnt = 0;
var j = 0;
var mn = 1000000000

var array = readline().split(" ").map((item)=>{return parseInt(item)});

array.forEach((item,idx)=>{
    if(item <= mn) {
        mn = item;
        j = idx;
    }
});

for (i = 0; i < n; i++) {
    if (array[i] == mn)
        cnt++;
}
if (cnt > 1) {
    print("Still Rozdil");
} else
    print(j + 1);

let inputString = "";
let currentLine = 0;
process.stdin.on("data", (data) => {
  inputString += data;
});
process.stdin.on("end", function () {
  inputString = inputString
    .trim()
    .split("\n")
    .map((str) => str.trim());
  main();
});
function readLine() {
  return inputString[currentLine++];
}
function main() {
  const len = +readLine();
  const arr = readLine()
    .split(" ")
    .map((n) => parseInt(n));
  let [min, minIndex, minCount] = [Number.MAX_SAFE_INTEGER, -1, 0];

  for (let i = 0; i < len; i++) {
    const num = arr[i];
    if (num <= min) {
      if (num === min) minCount++;
      else minCount = 0;
      min = num;
      minIndex = i + 1;
    }
  }
  minCount === 0 ? console.log(minIndex) : console.log("Still Rozdil");
}

const readline = require('readline');
const rl = readline.createInterface({
  input: process.stdin,
  output: process.stdout,
  terminal: false
});
let c = 0;

rl.on('line', (d) => {
  if (c === 0) {
    c++;
    return;
  }

  const arr = d.split(' ').map(Number);
  let min = Infinity;
  let minIdx = Infinity;
  const obj = {};

  for (let i = 0; i < arr.length; i++) {
    if (min > arr[i]) {
      min = arr[i];
      minIdx = i + 1;
    }

    if (obj.hasOwnProperty(arr[i])) {
      obj[arr[i]]++;
    }
    else {
      obj[arr[i]] = 1;
    }
  }

  if (obj[min] === 1) {
    console.log(minIdx);
  }
  else {
    console.log('Still Rozdil');
  }

  c++;
});

let inputString = '';
let currentLine = 0;
process.stdin.on('data', data => {
	inputString += data;
});
process.stdin.on('end', function () {
	inputString = inputString
		.trim()
		.split('\n')
		.map(str => str.trim());
	main();
});

function readLine() {
	return inputString[currentLine++];
}

function multiply(a, b) {
	a = a.toString(10).split('').reverse();
	b = b.toString(10).split('').reverse();

	if (a.length < b.length) {
		[a, b] = [b, a];
	}

	let res = Array(a.length + b.length).fill(0);
	for (let i = 0, lb = b.length; i < lb; ++i) {
		let carry = 0;
		let scarry = 0;
		for (let j = 0, la = a.length; j < la; ++j) {
			let m = b[i] * a[j];
			m += carry;

			if (m > 9) {
				let [c, d] = m.toString(10).split('');
				res[i + j] += (scarry >> 0) + (d >> 0);
				carry = c >> 0;
			} else {
				res[i + j] += (scarry >> 0) + m;
				carry = 0;
			}

			if (res[i + j] > 9) {
				let [c, d] = res[i + j].toString(10).split('');
				res[i + j] = d >> 0;
				scarry = c;
			} else {
				scarry = 0;
			}
		}
		if (carry > 0) res[a.length + i] = carry;
		if (scarry > 0) res[a.length + i] = scarry;
	}

	res.reverse();
	let mulVal = '';
	let flag = false;
	res.forEach(d => {
		if (!flag && d !== 0) flag = true;
		if (flag) mulVal += d;
	});
	return mulVal;
}

function main() {
	let n = readLine() >> 0;
	let c = readLine()
		.split(' ')
		.map(x => x >> 0);

	let m = Math.min(...c);
	let d = 0;
	let p = 0;
	for (let i = 0; i < n; i++) {
		if (c[i] === m) {
			d++;
			p = i + 1;
		}
	}

	if (d > 1) console.log('Still Rozdil');
	else console.log(p);
}

process.stdin.resume();
process.stdin.setEncoding('utf-8');
let inputString = '';
let currentLine = 0;
process.stdin.on('data', (inputStd) => {
    inputString += inputStd;
});
process.stdin.on('end', function () {
    inputString = inputString
        .trim()
        .split('\n')
        .map((str) => {
            return str.trim();
        });
    main();
});
function readLine() {
    return inputString[currentLine++];
}
function main() {
    let n = parseInt(readLine());
    let distances = readLine().split(' ').map(Number);
    let lowest = Math.min(...distances);
    // for (let i = 0; i < n; i++) {
    //     if (
    //         distances.indexOf(distances[i]) !==
    //         distances.lastIndexOf(distances[i])
    //     ) {
    //         console.log('Still Rozdil');
    //         return;
    //     }
    // }
    if (distances.indexOf(lowest) !== distances.lastIndexOf(lowest)) {
        console.log('Still Rozdil');
        return;
    }

    console.log(distances.indexOf(lowest) + 1);
}

print(function(n) {
	var a = readline().split(' ').map(Number),
		min = Math.min.apply(0, a),
		i = a.indexOf(min),
		ii = a.indexOf(min, i);

	return ii > -1 ? 'Still Rozdil' : i + 1;

}(+readline()));

var n = readline();
var cnt = 0;
var j = 0;
var mn = 1000000000

var array = readline().split(" ").map((item)=>{return item});

array.forEach((item,idx)=>{
    if(item <= mn) {
        mn = item;
        j = idx;
    }
});

for (i = 0; i < n; i++) {
    if (array[i] == mn)
        cnt++;
}
if (cnt > 1) {
    print("Still Rozdil");
} else
    print(j + 1);

var n = readline();
var cnt = 0;
var j = 0;
var array = readline().split(" ");

var mn = array[0];
for (i = 1; i < n; i++) {
    if (array[i] <= mn) {
        mn = array[i];
        j = i;
    }
}
for (i = 1; i < n; i++) {
    if (array[i] == mn)
        cnt++;
}
if (cnt > 1) {
    print("Still Rozdil");
} else
    print(j + 1);

var n = readline();
var cnt = 0;
var j = 0;
var array = [];
for (i = 0; i < n; i++)
    array[i] = readline();
var mn = array[0];
for (i = 1; i < n; i++) {
    if (array[i] <= mn) {
        mn = array[i];
        j = i;
    }
}
for (i = 1; i < n; i++) {
    if (array[i] == mn)
        cnt++;
}
if (cnt > 1) {
    print("Still Rozdil");
} else
    print(j + 1);

process.stdin.resume();
process.stdin.setEncoding('utf-8');
let inputString = '';
let currentLine = 0;
process.stdin.on('data', (inputStd) => {
    inputString += inputStd;
});
process.stdin.on('end', function () {
    inputString = inputString
        .trim()
        .split('\n')
        .map((str) => {
            return str.trim();
        });
    main();
});
function readLine() {
    return inputString[currentLine++];
}
function main() {
    let n = parseInt(readLine());
    let distances = readLine().split(' ').map(Number);
    for (let i = 0; i < n; i++) {
        if (
            distances.indexOf(distances[i]) !==
            distances.lastIndexOf(distances[i])
        ) {
            console.log('Still Rozdil');
            return;
        }
    }

    let lowest = Math.min(...distances);
    console.log(distances.indexOf(lowest) + 1);
}

process.stdin.resume();
process.stdin.setEncoding('utf-8');
let inputString = '';
let currentLine = 0;
process.stdin.on('data', (inputStd) => {
    inputString += inputStd;
});
process.stdin.on('end', function () {
    inputString = inputString
        .trim()
        .split('\n')
        .map((str) => {
            return str.trim();
        });
    main();
});
function readLine() {
    return inputString[currentLine++];
}
function main() {
    let n = parseInt(readLine());
    let distances = readLine().split(' ').map(Number);
    for (let i = 0; i < n; i++) {
        if (
            distances.indexOf(distances[i]) !==
            distances.lastIndexOf(distances[i])
        ) {
            console.log('Still Rozdil');
            return;
        }
    }

    let lowest = Math.min(...distances);
    console.log(distances.indexOf(lowest));
}