Note that the only difference between String Transformation 1 and String Transformation 2 is in the move Koa does. In this version the letter $$$y$$$ Koa selects must be strictly greater alphabetically than $$$x$$$ (read statement for better understanding). You can make hacks in these problems independently.Koa the Koala has two strings $$$A$$$ and $$$B$$$ of the same length $$$n$$$ ($$$|A|=|B|=n$$$) consisting of the first $$$20$$$ lowercase English alphabet letters (ie. from a to t).In one move Koa:  selects some subset of positions $$$p_1, p_2, \ldots, p_k$$$ ($$$k \ge 1; 1 \le p_i \le n; p_i \neq p_j$$$ if $$$i \neq j$$$) of $$$A$$$ such that $$$A_{p_1} = A_{p_2} = \ldots = A_{p_k} = x$$$ (ie. all letters on this positions are equal to some letter $$$x$$$).  selects a letter $$$y$$$ (from the first $$$20$$$ lowercase letters in English alphabet) such that $$$y>x$$$ (ie. letter $$$y$$$ is strictly greater alphabetically than $$$x$$$).  sets each letter in positions $$$p_1, p_2, \ldots, p_k$$$ to letter $$$y$$$. More formally: for each $$$i$$$ ($$$1 \le i \le k$$$) Koa sets $$$A_{p_i} = y$$$. Note that you can only modify letters in string $$$A$$$.Koa wants to know the smallest number of moves she has to do to make strings equal to each other ($$$A = B$$$) or to determine that there is no way to make them equal. Help her!

Each test contains multiple test cases. The first line contains $$$t$$$ ($$$1 \le t \le 10$$$) — the number of test cases. Description of the test cases follows. The first line of each test case contains one integer $$$n$$$ ($$$1 \le n \le 10^5$$$) — the length of strings $$$A$$$ and $$$B$$$. The second line of each test case contains string $$$A$$$ ($$$|A|=n$$$). The third line of each test case contains string $$$B$$$ ($$$|B|=n$$$). Both strings consists of the first $$$20$$$ lowercase English alphabet letters (ie. from a to t). It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$10^5$$$.

For each test case: Print on a single line the smallest number of moves she has to do to make strings equal to each other ($$$A = B$$$) or $$$-1$$$ if there is no way to make them equal.

5
3
aab
bcc
4
cabc
abcb
3
abc
tsr
4
aabd
cccd
5
abcbd
bcdda

Note  In the $$$1$$$-st test case Koa:   selects positions $$$1$$$ and $$$2$$$ and sets $$$A_1 = A_2 = $$$ b ($$$\color{red}{aa}b \rightarrow \color{blue}{bb}b$$$).  selects positions $$$2$$$ and $$$3$$$ and sets $$$A_2 = A_3 = $$$ c ($$$b\color{red}{bb} \rightarrow b\color{blue}{cc}$$$).   In the $$$2$$$-nd test case Koa has no way to make string $$$A$$$ equal $$$B$$$.  In the $$$3$$$-rd test case Koa:   selects position $$$1$$$ and sets $$$A_1 = $$$ t ($$$\color{red}{a}bc \rightarrow \color{blue}{t}bc$$$).  selects position $$$2$$$ and sets $$$A_2 = $$$ s ($$$t\color{red}{b}c \rightarrow t\color{blue}{s}c$$$).  selects position $$$3$$$ and sets $$$A_3 = $$$ r ($$$ts\color{red}{c} \rightarrow ts\color{blue}{r}$$$).

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 t = Number(readLine())
    for (let _i = 0; _i < t; _i++) {
      const n = Number(readLine())
      const a = Array.from(readLine()).map(s => s.charCodeAt(0) - 97)
      const b = Array.from(readLine()).map(s => s.charCodeAt(0) - 97)
      const ab = Array(26).fill(0).map(() => [])
      let result = 0
      for (let i = 0; i < n; i++) {
        if (a[i] > b[i]) {
          result = -1
        }
        if (a[i] === b[i]) {
          continue
        }
        ab[a[i]][b[i]] = true
      }
      if (result === 0) {
        for (let i = 0; i < 26; i++) {
        	for (let j = i + 1; j < 26; j++) {
          		if (ab[i][j]) {
                  result += 1
                  for (let k = j + 1; k < 26; k++) {
                    if (ab[i][k]) {
                      ab[j][k] = true
                    }
                  }
                  break
                }
        	}
        }
      }
      console.log(result)
    }
}


It is the easy version of the problem. The only difference is that in this version $$$n = 1$$$.In the cinema seats can be represented as the table with $$$n$$$ rows and $$$m$$$ columns. The rows are numbered with integers from $$$1$$$ to $$$n$$$. The seats in each row are numbered with consecutive integers from left to right: in the $$$k$$$-th row from $$$m (k - 1) + 1$$$ to $$$m k$$$ for all rows $$$1 \le k \le n$$$. $$$1$$$$$$2$$$$$$\cdots$$$$$$m - 1$$$$$$m$$$$$$m + 1$$$$$$m + 2$$$$$$\cdots$$$$$$2 m - 1$$$$$$2 m$$$$$$2m + 1$$$$$$2m + 2$$$$$$\cdots$$$$$$3 m - 1$$$$$$3 m$$$$$$\vdots$$$$$$\vdots$$$$$$\ddots$$$$$$\vdots$$$$$$\vdots$$$$$$m (n - 1) + 1$$$$$$m (n - 1) + 2$$$$$$\cdots$$$$$$n m - 1$$$$$$n m$$$ The table with seats indices There are $$$nm$$$ people who want to go to the cinema to watch a new film. They are numbered with integers from $$$1$$$ to $$$nm$$$. You should give exactly one seat to each person.It is known, that in this cinema as lower seat index you have as better you can see everything happening on the screen. $$$i$$$-th person has the level of sight $$$a_i$$$. Let's define $$$s_i$$$ as the seat index, that will be given to $$$i$$$-th person. You want to give better places for people with lower sight levels, so for any two people $$$i$$$, $$$j$$$ such that $$$a_i < a_j$$$ it should be satisfied that $$$s_i < s_j$$$.After you will give seats to all people they will start coming to their seats. In the order from $$$1$$$ to $$$nm$$$, each person will enter the hall and sit in their seat. To get to their place, the person will go to their seat's row and start moving from the first seat in this row to theirs from left to right. While moving some places will be free, some will be occupied with people already seated. The inconvenience of the person is equal to the number of occupied seats he or she will go through.Let's consider an example: $$$m = 5$$$, the person has the seat $$$4$$$ in the first row, the seats $$$1$$$, $$$3$$$, $$$5$$$ in the first row are already occupied, the seats $$$2$$$ and $$$4$$$ are free. The inconvenience of this person will be $$$2$$$, because he will go through occupied seats $$$1$$$ and $$$3$$$.Find the minimal total inconvenience (the sum of inconveniences of all people), that is possible to have by giving places for all people (all conditions should be satisfied).

The input consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. Description of the test cases follows. The first line of each test case contains two integers $$$n$$$ and $$$m$$$ ($$$n = 1$$$, $$$1 \le m \le 300$$$) — the number of rows and places in each row respectively. The second line of each test case contains $$$n \cdot m$$$ integers $$$a_1, a_2, \ldots, a_{n \cdot m}$$$ ($$$1 \le a_i \le 10^9$$$), where $$$a_i$$$ is the sight level of $$$i$$$-th person. It's guaranteed that the sum of $$$n \cdot m$$$ over all test cases does not exceed $$$10^5$$$.

For each test case print a single integer — the minimal total inconvenience that can be achieved.

NoteIn the first test case, there is a single way to arrange people, because all sight levels are distinct. The first person will sit on the first seat, the second person will sit on the second place, the third person will sit on the third place. So inconvenience of the first person will be $$$0$$$, inconvenience of the second person will be $$$1$$$ and inconvenience of the third person will be $$$2$$$. The total inconvenience is $$$0 + 1 + 2 = 3$$$.In the second test case, people should sit as follows: $$$s_1 = 2$$$, $$$s_2 = 1$$$, $$$s_3 = 5$$$, $$$s_4 = 4$$$, $$$s_5 = 3$$$. The total inconvenience will be $$$6$$$.

"use strict";
const fs = require("fs");
//let filename = "0.txt";
let filename = 0;
const input = fs.readFileSync(filename, "utf8").trim().split("\n");
let line = 0;
function readline() {
  return input[line++];
}

const solve = () => {
  let t = parseInt(readline());
  while (t--) {
    let [m, n] = readline()
      .trim()
      .split(" ")
      .map((cur) => parseInt(cur));
    let arr = readline()
      .trim()
      .split(" ")
      .map((cur) => parseInt(cur));
    let cnt = 0;
    for (let i = 0; i < n; i++) {
      for (let j = 0; j < i; j++) {
        if (arr[j] < arr[i]) cnt++;
      }
    }
    console.log(cnt);
  }
};
solve();

process.stdin.resume();
process.stdin.setEncoding('utf8');
let standardInputString = '';
let curLine = 0;

const readLine = () => {
  return standardInputString[curLine++];
};

process.stdin.on('data', rawData => {
  standardInputString += rawData;
});

process.stdin.on('end', _ => {
  standardInputString = standardInputString
    .trim()
    .split('\n')
    .map(line => {
      return line.trim();
    });

  main();
});

/**
 *
 */
// https://codeforces.com/contest/1566/problem/D1

// Return right boundary.
const binSearchR = (num, arr) => {
    let l = -1;
    let r = arr.length;

    while (r - l > 1) {
        const mid = Math.floor(
            (r + l) / 2,
        );

        if (arr[mid] > num) {
            r = mid;
        } else {
            l = mid;
        }
    }

    return r;
};

const main = () => {
    const t = +readLine();

    for (let testCaseIx = 0; testCaseIx < t; testCaseIx += 1) {
        const [, m] = readLine()
            .split(' ')
            .map(item => +item);

        const eyeLvlsInOrder = readLine()
            .split(' ')
            .map(eyeLvl => +eyeLvl);
        const peoplePos = eyeLvlsInOrder
            .slice()
            .sort(
                (a, b) => a - b,
            );

        const wasEyeLvl = new Map();

        const inconvIfSitTo = {};

        let inconvenience = 0;
        for (const eyeLvl of eyeLvlsInOrder) {
            let pos = binSearchR(eyeLvl, peoplePos) - 1;

            const wasEyeLvlOld = wasEyeLvl.get(eyeLvl) || 0;
            pos -= wasEyeLvlOld;
            wasEyeLvl.set(eyeLvl, wasEyeLvlOld + 1);

            const inconvIfSitToOld = inconvIfSitTo[pos] || 0;
            inconvenience += inconvIfSitToOld;

            while (pos < 300) {
                inconvIfSitTo[pos] = (inconvIfSitTo[pos] || 0) + 1;

                pos += 1;
            }
        }

        console.log(inconvenience);
    }
};


Sonya decided that having her own hotel business is the best way of earning money because she can profit and rest wherever she wants.The country where Sonya lives is an endless line. There is a city in each integer coordinate on this line. She has $$$n$$$ hotels, where the $$$i$$$-th hotel is located in the city with coordinate $$$x_i$$$. Sonya is a smart girl, so she does not open two or more hotels in the same city.Sonya understands that her business needs to be expanded by opening new hotels, so she decides to build one more. She wants to make the minimum distance from this hotel to all others to be equal to $$$d$$$. The girl understands that there are many possible locations to construct such a hotel. Thus she wants to know the number of possible coordinates of the cities where she can build a new hotel. Because Sonya is lounging in a jacuzzi in one of her hotels, she is asking you to find the number of cities where she can build a new hotel so that the minimum distance from the original $$$n$$$ hotels to the new one is equal to $$$d$$$.

The first line contains two integers $$$n$$$ and $$$d$$$ ($$$1\leq n\leq 100$$$, $$$1\leq d\leq 10^9$$$) — the number of Sonya's hotels and the needed minimum distance from a new hotel to all others. The second line contains $$$n$$$ different integers in strictly increasing order $$$x_1, x_2, \ldots, x_n$$$ ($$$-10^9\leq x_i\leq 10^9$$$) — coordinates of Sonya's hotels.

Print the number of cities where Sonya can build a new hotel so that the minimum distance from this hotel to all others is equal to $$$d$$$.

NoteIn the first example, there are $$$6$$$ possible cities where Sonya can build a hotel. These cities have coordinates $$$-6$$$, $$$5$$$, $$$6$$$, $$$12$$$, $$$13$$$, and $$$19$$$.In the second example, there are $$$5$$$ possible cities where Sonya can build a hotel. These cities have coordinates $$$2$$$, $$$6$$$, $$$13$$$, $$$16$$$, and $$$21$$$.

const numbers = readline().split(' ').map(function(v){return +v;});
const n = numbers[0];
const b = numbers[1];
const arr = readline().split(' ').map(function(v){return +v;});

var count = 2;
var result = [arr[0]-b, arr[n-1]+b];

function first() {
    if(arr[0]+b+b<=arr[1]) result.push(arr[0]+b)
    if(arr[n-1]-b-b>=arr[n-2]) result.push(arr[n-1]-b)

    for (var i=1; i<n-1; i++) {
        if(arr[i]+b+b<=arr[i+1]) {
            result.push(arr[i]+b)
        }
        if(arr[i]-b-b>=arr[i-1]) {
            result.push(arr[i]-b)
        }
    }
}

first();

uniqueArray = result.filter(function(item, pos) {
    return result.indexOf(item) == pos;
})

print(uniqueArray.length);

var a = [];
var io;
var ans,n,d;
io = readline().split(" ").map(function(x) { return parseInt(x); });
n = io[0]; d = io[1]*2;
io = readline().split(" ").map(function(x) { return parseInt(x); });
a = io;
ans = 0;
for (var i=0;i<n-1;i++){
    if (Math.abs(a[i]-a[i+1])>d){
        ans+=2;
    } else
    if (Math.abs(a[i]-a[i+1])==d){
        ans++;
    }
}
ans+=2;
print(ans);

var l = readline().split(' ').map(v => parseInt(v, 10));
var n = l[0];
var d = l[1];
var a = readline().split(' ').map(v => parseInt(v, 10));

var ans = 2;

for (var i = 0; i < n - 1; i ++) {
    var q = a[i + 1] - a[i];
    if (q > 2 * d) {
        ans+=2;
    } else if (q === 2 * d) {
        ans++;
    }
}
print(ans);

var main=function(){

    var first_line = readline().split(' ').map(Number);

    var n = parseInt(first_line[0]);
    var d = parseInt(first_line[1]);

    var x = readline().split(' ').map(Number);
    var cnt = 2;
    for (var i=0; i<x.length-1; i++){
    	if(x[i]+d <= x[i+1]-d){
    		cnt++;
    		var csr = x[i]+d;
    		if(csr<x[i+1]-d){
    			cnt++;
    		}
    	}
    }

    print(cnt);

};

/// IO ///
if(typeof process!=='undefined'){
	//node.js
	var print=function(x){
		console.log(x);
	}
	var readline=(function(){
		var T=[],cnt=0;
		var stdin = process.openStdin();
		stdin.setEncoding('utf8');

		var input_fragment="";
		stdin.on('data', function(input) {
			var ref=(input_fragment+input).split("\n");
			input_fragment=ref.pop();
			for(var i=0;i<ref.length;i++){
				if(ref[i]=='')continue;
				T.push(ref[i]);
			}
		});
		stdin.on('end', function(z) {
			if(input_fragment){
				var ref=(input_fragment+"\n").split("\n");
				input_fragment=ref.pop();
				for(var i=0;i<ref.length;i++){
					if(ref[i]=='')continue;
					T.push(ref[i]);
				}
			}
			main();
		});

		return function(){
			if(T.length<=cnt)return null;
			return T[cnt++];
		};
	})();
}else{
	//v8
	main();
}

const numbers = readline().split(' ').map(function(v){return +v;});
const n = numbers[0];
const b = numbers[1];
const arr = readline().split(' ').map(function(v){return +v;});

var count = 2;
var result = [arr[0]-b, arr[n-1]+b];

if(arr[0]+b+b<=arr[1]) result.push(arr[0]+b)
if(arr[n-1]-b-b>=arr[n-2]) result.push(arr[n-1]-b)

for (var i=1; i<n-1; i++) {
    if(arr[i]+b+b<=arr[i+1]) {
        result.push(arr[i]+b)
    }
    if(arr[i]-b-b>=arr[i-1]) {
        result.push(arr[i]-b)
    }
}

uniqueArray = result.filter(function(item, pos) {
    return result.indexOf(item) == pos;
})

print(uniqueArray.length);

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

var arr = ''
process.stdin.on('data', (i) => {
  arr += i
})

process.stdin.on('end', () => {
  arr = arr.split('\n')
  const in1 = arr.shift().split(' ')
  const a = arr.shift().split(' ')
  const n = parseInt(in1[0])
  const d = parseInt(in1[1])

  var c = 2
  for(let i = 1; i < n; i ++) {
    if((a[i] - a[i - 1]) > 2 * d){
      // console.log(a[i], a[i - 1])
      c += 2
    }
    else if((a[i] - a[i - 1]) == 2 * d) {
      c ++
    }
  }
  console.log(c)
})

var main=function(){
	var a=readline().split(' ').map(Number);
	print(a[0]+a[1]+' '+readline());
};

/// IO ///
if(typeof process!=='undefined'){
	//node.js
	var print=function(x){
		console.log(x);
	}
	var readline=(function(){
		var T=[],cnt=0;
		var stdin = process.openStdin();
		stdin.setEncoding('utf8');

		var input_fragment="";
		stdin.on('data', function(input) {
			var ref=(input_fragment+input).split("\n");
			input_fragment=ref.pop();
			for(var i=0;i<ref.length;i++){
				if(ref[i]=='')continue;
				T.push(ref[i]);
			}
		});
		stdin.on('end', function(z) {
			if(input_fragment){
				var ref=(input_fragment+"\n").split("\n");
				input_fragment=ref.pop();
				for(var i=0;i<ref.length;i++){
					if(ref[i]=='')continue;
					T.push(ref[i]);
				}
			}
			main();
		});

		return function(){
			if(T.length<=cnt)return null;
			return T[cnt++];
		};
	})();
}else{
	//v8
	main();
}

/**

function Main(input) {
    var data = input.split("\n");

    var first_line = data[0].split(" ");

    var n = parseInt(first_line[0]);
    var d = parseInt(fisrt_line[1]);

    var x = data[1].split(" ");
    var cnt = 2;
    for (var i=0; i<x.length-1; i++){
    	if(x[i]+d < x[i+1]-d){
    		var csr = x[i]+d;
    		while(csr<=x[i+1]-d){
    			cnt++;
    			csr++;
    		}
    	}
    }

    console.log(cnt);
    console.log("\n");
}

Main(require("fs").readFileSync("/dev/stdin").toString);
*/

function Main(input) {
    // inputにはすべての入力の文字列が与えられるので必要に応じて input.split("\n") などで分割する。

    var data = input.split("\n");

    var first_line = data[0].split(" ");

    var n = parseInt(first_line[0]);
    var d = parseInt(fisrt_line[1]);

    var x = data[1].split(" ");
    var cnt = 2;
    for (var i=0; i<x.length-1; i++){
    	if(x[i]+d < x[i+1]-d){
    		var csr = x[i]+d;
    		while(csr<=x[i+1]-d){
    			cnt++;
    			csr++;
    		}
    	}
    }

    console.log(cnt);
    console.log("\n");
}

var main=function(){

    var first_line = readline().split(' ').map(Number);

    var n = parseInt(first_line[0]);
    var d = parseInt(first_line[1]);

    var x = readline().split(' ').map(Number);
    var cnt = 2;
    for (var i=0; i<x.length-1; i++){
    	if(x[i]+d < x[i+1]-d){
    		var csr = x[i]+d;
    		while(csr<=x[i+1]-d){
    			cnt++;
    			csr++;
    		}
    	}
    }

    print(cnt);

};

/// IO ///
if(typeof process!=='undefined'){
	//node.js
	var print=function(x){
		console.log(x);
	}
	var readline=(function(){
		var T=[],cnt=0;
		var stdin = process.openStdin();
		stdin.setEncoding('utf8');

		var input_fragment="";
		stdin.on('data', function(input) {
			var ref=(input_fragment+input).split("\n");
			input_fragment=ref.pop();
			for(var i=0;i<ref.length;i++){
				if(ref[i]=='')continue;
				T.push(ref[i]);
			}
		});
		stdin.on('end', function(z) {
			if(input_fragment){
				var ref=(input_fragment+"\n").split("\n");
				input_fragment=ref.pop();
				for(var i=0;i<ref.length;i++){
					if(ref[i]=='')continue;
					T.push(ref[i]);
				}
			}
			main();
		});

		return function(){
			if(T.length<=cnt)return null;
			return T[cnt++];
		};
	})();
}else{
	//v8
	main();
}

const numbers = readline().split(' ').map(function(v){return +v;});
const n = numbers[0];
const b = numbers[1];
const arr = readline().split(' ').map(function(v){return +v;});

var count = 2;

if(arr[0]+b+3<arr[1]) count++
if(arr[n-1]-b-3>arr[n-2]) count++

for (var i=1; i<n-1; i++) {
    if(arr[i]+b+b<=arr[i+1]) {
        count++
    }
    if(arr[i]-b-b>=arr[i-1]) {
        count++
    }
}

print(count);

const numbers = readline().split(' ').map(function(v){return +v;});
const n = numbers[0];
const b = numbers[1];
const arr = readline().split(' ').map(function(v){return +v;});

var count = 2;

if(arr[0]+b+b<arr[1]) count++
if(arr[n-1]-b-b>arr[n-2]) count++

for (var i=1; i<n-1; i++) {
    if(arr[i]+b+b<=arr[i+1]) {
        count++
    }
    if(arr[i]-b-b>=arr[i-1]) {
        count++
    }
}

print(count);

const numbers = readline().split(' ').map(function(v){return +v;});
const n = numbers[0];
const b = numbers[1];
const arr = readline().split(' ').map(function(v){return +v;});

var count = 2;

if(arr[0]+b+b<=arr[1]) count++
if(arr[n-1]-b-b>=arr[n-2]) count++

for (var i=1; i<n-1; i++) {
    if(arr[i]+b+b<=arr[i+1]) {
        count++
    }
    if(arr[i]-b-b>=arr[i-1]) {
        count++
    }
}

print(count);


Little girl Tanya climbs the stairs inside a multi-storey building. Every time Tanya climbs a stairway, she starts counting steps from $$$1$$$ to the number of steps in this stairway. She speaks every number aloud. For example, if she climbs two stairways, the first of which contains $$$3$$$ steps, and the second contains $$$4$$$ steps, she will pronounce the numbers $$$1, 2, 3, 1, 2, 3, 4$$$.You are given all the numbers pronounced by Tanya. How many stairways did she climb? Also, output the number of steps in each stairway.The given sequence will be a valid sequence that Tanya could have pronounced when climbing one or more stairways.

The first line contains $$$n$$$ ($$$1 \le n \le 1000$$$) — the total number of numbers pronounced by Tanya. The second line contains integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 1000$$$) — all the numbers Tanya pronounced while climbing the stairs, in order from the first to the last pronounced number. Passing a stairway with $$$x$$$ steps, she will pronounce the numbers $$$1, 2, \dots, x$$$ in that order. The given sequence will be a valid sequence that Tanya could have pronounced when climbing one or more stairways.

In the first line, output $$$t$$$ — the number of stairways that Tanya climbed. In the second line, output $$$t$$$ numbers — the number of steps in each stairway she climbed. Write the numbers in the correct order of passage of the stairways.

var firstLine = +readline();
var secondLine = readline().split(' ').map(function(v){return +v;});

var stairsCount = firstLine;
var strairs = secondLine;
var result = [];
var temp = 0;

for (var i = 1; i < stairsCount; i++) {
    if (strairs[i] === 1) {
        if (result.length > 0) {
            result.push(i - temp);
        } else {
            result.push(i);
        }
        temp = i;
    }
}

result.push(stairsCount - temp);

print(result.length);
print(result.join(' '));

var numbers = +readline();
var steps = readline().split(' ').map(Number);

if (numbers === 1) {
    print(1);
    print(1);
} else {
    var stepsStairway = [];
    for (var i = 1; i < numbers; i++) {
        if (steps[i] === 1) {
            stepsStairway.push(steps[i - 1]);
        }
    }

    stepsStairway.push(steps.pop());
    print(stepsStairway.length);
    print(stepsStairway.join(' '));
}

var n = readline();
var arr = readline().split(' ').map(Number);
var start = 0;
var count = 0;
var result = [];

for (var i=1; i<n; i++) {
    if (arr[i] <= arr[i-1]) {
        count++;
        result.push(i - start);
        start = i;
    }
}
count++;
result.push(n - start);
print(count);
print(result.join(" ")); //readline()

/*
n = +readline();
a = readline().split(" ").map(Number);
var res = 0 , add = 0;
for (i = 0 ; i < n ; i ++){
    a[i] -= add;
    add += a[i];
    res += Math.abs(a[i]);

}

write(res);
*/
n = +readline();
a = readline().split(' ').map(Number);
var res = 0;
for (var i = 0 ; i < n ; i ++)
{
    if (a[i] == 1){
        res ++;
    }
}
write(res);
write("\n");
var lengthes = new Array(4);
var cur = 0;
for (var i = 0 ; i < n ; i ++)
{
    if (a[i] == 1){
        var j = i ;
        while (j < n && a[j] - a[i] == j - i){
            j ++;
        }
        lengthes[cur ] = j - i;
        i = j - 1;
        cur += 1;
    }
}
for (var i = 0 ; i < res ; i ++)
{
    write(lengthes[i]);
    write(" ");
}

const n = readline();
var arr = readline().split(' ').map(function(v){return +v;});

var start = 0;
var count = 0;
var result = [];

for (var i=1; i<n; i++) {
    if (arr[i] <= arr[i-1]) {
        count++;
        result.push(i - start);
        start = i;
    }
}
count++;
result.push(n - start);

print(count);
print(result.join(' '));

var last = 1,
    floor = [];

var total = +readline();
if (total == 1) {
    write(1 + '\n' + 1);
} else {
    readline().split(' ').forEach((step, index) => {
        if( index ) {
        if(parseInt(step) == 1) floor.push(last);
        if( index == total - 1) floor.push(step)
        last = parseInt(step); }
    });
    write(floor.length + '\n' + floor.join(' '));
}

var n = +readline();
var a = readline().split(' ').map(Number);
var les = 0;
var j = -1;
var b = [];

for (var i=0; i<n; i++){
	if (a[i] == 1) {
		les++;
		j++;
		b[j] = 1;
	} else b[j]++;

}

print (les);
print (b.join(' '));

var line1 = readline().split(" ").map(function (x) { return parseInt(x); });
var line2 = readline().split(" ").map(function (x) { return parseInt(x); });

var stairs = [];
var stairsIndex = -1;
for (index = 0; index < line2.length; index++) {
    var line_2number = line2[index];
    if (line_2number == "1") {
        stairs.push(1);
        stairsIndex++;
    } else {
        stairs[stairsIndex]++;
    }
}
print(stairs.length);
print(stairs.join(' '));

var g = readline();
var k = readline().split(" ");

var lens_arr = [1];

var len_count = 1;
for(i=1,b=0;i<k.length;i++){
    if(k[i]==1){
        len_count++;
        b++;
        lens_arr[b] = 1;
    }else{
            lens_arr[b]++;
    }
}
print(len_count);
print(lens_arr.join(" "));

function main() {
  const is = new Scanner();
  const n = is.nextInt();
  const numbers = is.nextArray().map(Number);
  numbers.push(0);
  const steps = [];
  let stairways = 0;
  for (let i = 0; i < n; i++)
    if (numbers[i] >= numbers[i + 1]) {
      stairways++;
      steps.push(numbers[i]);
    }

  console.log(stairways);
  console.log(steps.join(' '));
}

/*
 *  api stdin
 */

class Scanner {
  constructor() {
    this.index = 0;
    this.lines = stdinInput.trim().split('\n');
  }

  nextLine() {
    return this.lines[this.index++];
  }

  nextInt() {
    return parseInt(this.nextLine(), 10);
  }

  nextDouble() {
    return parseFloat(this.nextLine());
  }

  nextArray() {
    return this.nextLine().split(' ');
  }

  hasNext() {
    return this.index < this.lines.length;
  }
}

let stdinInput = '';
process.stdin.resume();
process.stdin.setEncoding('utf-8');
process.stdin.on('data', input => { stdinInput += input; });
process.stdin.on('end', () => { main(); });

function main() {
    // write code here:
    const n = Number(stdin[0]);
    var arr = stdin[1].split(' ').map(Number);
    var obj1 = {1: 0};
    var newArr = [];
    for (let i = 0; i < n; i++) {
        if (arr[i] === 1) {
            obj1[1]++;
            if (i !== 0) {
                newArr.push(arr[i - 1]);
            }
        }
    }
    newArr.push(arr[n - 1]);
    console.log(obj1[1] + '\n' + newArr.join(' '));
}

const readline = require('readline');
const rl = readline.createInterface({input: process.stdin});
var stdin = [];
rl.on('line', function (line) {
    stdin.push(line);
});
rl.on('close', main);

//Don't have to see. start------------------------------------------
var read = require('readline').createInterface({
  input: process.stdin, output: process.stdout
});
var obj; var inLine = [];
read.on('line', function(input){inLine.push(input);});
read.on('close', function(){
  obj = init(inLine);
  console.error('\n↑入力 ↓出力');
  Main();
});
function makeClone(obj){return (obj instanceof Set) ? new Set(Array.from(obj)) : JSON.parse(JSON.stringify(obj));}
function nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}
function nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}
function next(){return obj.next();} function hasNext(){return obj.hasNext();}
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';}}
  };
}
function myout(s){console.log(s);}
function myerr(s){console.error('debug:' + require('util').inspect(s,false,null));}
//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 N = nextInt();
  var list = nextIntArray();
  var output = [0];
  for(var i = 0; i < N; i++){
    if(output[output.length - 1] < list[i]){
      output[output.length - 1] = list[i];
    }else{
      output.push(list[i]);
    }
  }
  myout(output.length);
  myout(myconv(output, 8));
}

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 stairs = 1;
  let ans = [];

  for (let i = 1; i < arr.length; i++) {
    if (arr[i - 1] >= arr[i]) {
      stairs++;
      ans.push(arr[i - 1]);
    }
  }

  ans.push(arr[arr.length - 1]);

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

  c++;
});

let input = [];

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

RL.on('line', (line) => {
    input.push(line);
});

RL.on('close', () => {
    let flag = false, count = 0, answer = [], len = 0;
    let n = parseInt(input[0]);
    let num = []; input[1].split(' ').forEach(i => num.push(parseInt(i)));
    for (let i = 0; i < n; i++){
        len++;
        if(num[i] === 1 && !flag){
            flag = true;
        } else if(num[i] === 1 && flag) {
            answer.push(len-1);
            len = 1;
        }
    }
    answer.push(len);

    console.log(answer.length);
    let answer_string = ''; answer.forEach(i => answer_string+= `${i} `)
    console.log(answer_string);
});

const process = require('process');

let inp = "";
process.stdin.on('data', chunk => inp += chunk);
process.stdin.on('end', () => {
    inp = inp.split('\n');
    const n = +inp[0];
    const a = inp[1].split(' ').map(s => +s);
    const ans = [];
    for (let i = 0; i < n; ++i) {
        if (i === n - 1 || a[i + 1] === 1)
            ans.push(a[i]);
    }
    console.log(ans.length);
    console.log(ans.join(' '));
});

n=+readline()
a=readline().split(' ').map(function(x){return +x;})
a.push(1)
res=''
m=0
for (i=0;i<n;i++)
{
    if (a[i+1]==1)
    {
        ++m
        res+=a[i]
        res+=' '
    }
}
print(m)
print(res)

var firstLine = +readline();
var secondLine = readline().split(' ').map(function(v){return +v;});

var stairsCount = firstLine;
var strairs = secondLine;
var result = [];
var temp = 0;

for (var i = 1; i < stairsCount; i++) {
    if (strairs[i] === 1) {
        if (result.length > 0) {
            result.push(i - temp);
        } else {
            result.push(i);
        }
        temp = i;
    }
}

result.push(stairsCount - temp);

print(result.length);
print(result);

var n = +readline();
var str = readline().split(' ').map(Number);
var res = 1;
var mas = [];
var temp = 0;
for (var i = 1; i < n; i++)
{
	temp++;
	if (str[i]==1)
	{
		res++;
		mas.push(temp);
		temp = 0;
	}
	else if (i+1==n)
		mas.push(temp+1);
	//else if (i==str.length[)
}
print(res);
print(mas.join(' '));

var n = +readline();
var str = readline().split(' ').map(Number);
var res = 1;
var mas = [];
var temp = 0;
for (var i = 1; i < n; i++)
{
	temp++;
	if (str[i]==1)
	{
		res++;
		mas.push(temp);
		temp = 0;
	}
	else if (i+1==n)
		mas.push(temp+1);
	//else if (i==str.length[)
}
print(res);
print(mas);

var last = 1,
    floor = [];

var total = +readline();
readline().split(' ').forEach((step, index) => {
    if( index ) {
    if(parseInt(step) == 1) floor.push(last);
    if( index == total - 1) floor.push(step)
    last = parseInt(step); }
});

write(floor.length + '\n' + floor.join(' '));

var last = 0,
    floor = [];

var total = +readline();
readline().split(' ').forEach((step, index) => {
    if( index ) {
    if(parseInt(step) == 1) floor.push(last);
    if( index == total - 1) floor.push(step)
    last = parseInt(step); }
});

write(floor.length + '\n' + floor.join(' '));

var numbers = readline().split(" ").map(function(x) { return parseInt(x); });
var numbers2 = readline().split(" ").map(function(x) { return parseInt(x); });
print(numbers);
print(numbers2);

var numbers = readline().split(" ").map(function(x) { return parseInt(x); });
print(numbers);


Olya has an array of integers $$$a_1, a_2, \ldots, a_n$$$. She wants to split it into tandem repeats. Since it's rarely possible, before that she wants to perform the following operation several (possibly, zero) number of times: insert a pair of equal numbers into an arbitrary position. Help her!More formally:  A tandem repeat is a sequence $$$x$$$ of even length $$$2k$$$ such that for each $$$1 \le i \le k$$$ the condition $$$x_i = x_{i + k}$$$ is satisfied.  An array $$$a$$$ could be split into tandem repeats if you can split it into several parts, each being a subsegment of the array, such that each part is a tandem repeat.  In one operation you can choose an arbitrary letter $$$c$$$ and insert $$$[c, c]$$$ to any position in the array (at the beginning, between any two integers, or at the end).  You are to perform several operations and split the array into tandem repeats or determine that it is impossible. Please note that you do not have to minimize the number of operations.

Each test contains multiple test cases. The first line contains a single integer $$$t$$$ ($$$1 \le t \le 30\,000$$$) — the number of test cases. Description of the test cases follows. The first line of each test case contains a single integer $$$n$$$ ($$$1 \le n \le 500$$$).  The second line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$1 \le a_i \le 10^9$$$)  — the initial array.  It is guaranteed that the sum of $$$n^2$$$ over all test cases does not exceed $$$250\,000$$$.

For each test case print answer in the following format. If you cannot turn the array into a concatenation of tandem repeats, print a single integer $$$-1$$$. Otherwise print the number of operations $$$q$$$ ($$$0 \le q \le 2 \cdot n^2$$$) that you want to do. Then print the descriptions of operations. In each of the following $$$q$$$ lines print two integers $$$p$$$ and $$$c$$$ ($$$1 \le c \le 10^9$$$), which mean that you insert the integer $$$c$$$ twice after $$$p$$$ elements of the array. If the length of the array is $$$m$$$ before the operation, then the condition $$$0 \le p \le m$$$ should be satisfied. Then you should print any way to split the resulting array into tandem repeats. First, print a single integer $$$d$$$, and then print a sequence $$$t_1, t_2, \ldots, t_d$$$ of even integers of size $$$d$$$ ($$$d, t_i \ge 1$$$). These numbers are the lengths of the subsegments from left to right. Note that the size of the resulting array $$$a$$$ is $$$m = n + 2 \cdot q$$$. The following statements must hold:    $$$m = \sum\limits_{i = 1}^{d}{t_i}$$$.    For all integer $$$i$$$ such that $$$1 \le i \le d$$$, the sequence $$$a_l, a_{l+1}, \ldots, a_r$$$ is a tandem repeat, where $$$l = \sum\limits_{j = 1}^{i - 1}{t_j} + 1$$$, $$$r = l + t_i - 1$$$.  It can be shown that if the array can be turned into a concatenation of tandem repeats, then there exists a solution satisfying all constraints. If there are multiple answers, you can print any.

NoteIn the first test case, you cannot apply operations to the array to make it possible to split it into tandem repeats.In the second test case the array is already a tandem repeat $$$[5, 5] = \underbrace{([5] + [5])}_{t_1 = 2}$$$, thus we can do no operations at all.In the third test case, initially, we have the following array: $$$$$$[1, 3, 1, 2, 2, 3].$$$$$$ After the first insertion with $$$p = 1, c = 3$$$: $$$$$$[1, \textbf{3, 3}, 3, 1, 2, 2, 3].$$$$$$ After the second insertion with $$$p = 5, c = 3$$$: $$$$$$[1, 3, 3, 3, 1, \textbf{3, 3}, 2, 2, 3].$$$$$$ After the third insertion with $$$p = 5, c = 3$$$: $$$$$$[1, 3, 3, 3, 1, \textbf{3, 3}, 3, 3, 2, 2, 3].$$$$$$ After the fourth insertion with $$$p = 10, c = 3$$$: $$$$$$[1, 3, 3, 3, 1, 3, 3, 3, 3, 2, \textbf{3, 3}, 2, 3].$$$$$$ The resulting array can be represented as a concatenation of tandem repeats: $$$$$$\underbrace{([1, 3, 3, 3] + [1, 3, 3, 3])}_{t_1 = 8} + \underbrace{([3, 2, 3] + [3, 2, 3])}_{t_2 = 6}.$$$$$$In the fourth test case, initially, we have the following array: $$$$$$[3, 2, 1, 1, 2, 3].$$$$$$ After the first insertion with $$$p = 0, c = 3$$$: $$$$$$[\textbf{3, 3}, 3, 2, 1, 1, 2, 3].$$$$$$ After the second insertion with $$$p = 8, c = 3$$$: $$$$$$[3, 3, 3, 2, 1, 1, 2, 3, \textbf{3, 3}].$$$$$$ After the third insertion with $$$p = 5, c = 3$$$ $$$$$$[3, 3, 3, 2, 1, \textbf{3, 3}, 1, 2, 3, 3, 3].$$$$$$ After the fourth insertion with $$$p = 6, c = 2$$$: $$$$$$[3, 3, 3, 2, 1, 3, \textbf{2, 2}, 3, 1, 2, 3, 3, 3].$$$$$$ After the fifth insertion with $$$p = 7, c = 1$$$: $$$$$$[3, 3, 3, 2, 1, 3, 2, \textbf{1, 1}, 2, 3, 1, 2, 3, 3, 3].$$$$$$ The resulting array can be represented as a concatenation of tandem repeats: $$$$$$\underbrace{([3] + [3])}_{t_1 = 2} + \underbrace{([3, 2, 1] + [3, 2, 1])}_{t_2 = 6} + \underbrace{([1, 2, 3] + [1, 2, 3])}_{t_3 = 6} + \underbrace{([3] + [3])}_{t_4 = 2}.$$$$$$

'use strict';

function solve(n, a) {
  const map = new Map();
  for (let num of a) {
    var _map$get;
    map.set(num, ((_map$get = map.get(num)) !== null && _map$get !== void 0 ? _map$get : 0) + 1);
  }
  for (let [i, count] of map) if (count & 1) return -1;
  let nums = [...a];
  const ops = [],
        res = [];
  for (let i = n - 1, j = n - 1; i >= 0; i = j) {
    j = i - 1;
    while (nums[j] !== nums[i]) {
      j--;
    }
    let t = j;
    while (i > t) {
      const num = nums[i];
      if (num !== nums[j]) {
        ops.push([j + 1, num]);
        nums.splice(j + 1, 0, num, num);
        i += 2;
        j += 2;
        t += 2;
      }
      i--;
      j--;
    }
    res.push((i - j) * 2);
  }
  res.reverse();
  let str = '';
  if (ops.length) {
    str += `${ops.length}\n${ops.map(arr => arr.join(' ')).join('\n')}`;
  } else {
    str += 0;
  }
  str += `\n${res.length}\n${res.join(' ')}`;
  return str;
}

async function main(read) {
  try {
    let t = Number(await read());
    let res = new Array(t);
    for (let i = 0; i < t; i++) {
      const n = Number(await read());
      const a = (await read()).split(' ').map(Number);
      res[i] = solve(n, a);
    }
    return res.join('\n');
  } catch (error) {
    console.log(error);
  }
}

let inputs,
    str = '';
function read() {
  return inputs.next().value.trim();
}
process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', input => str += input);
process.stdin.on('end', async () => {
  inputs = str.split('\n').values();
  const output = await main(read);
  process.stdout.write(output);
});

let context = {}
context["throw"] = function(a) { throw a }
context["makeDict"] = function() { let ret = {}; for (let i = 0; i < arguments.length; i += 2) { ret[arguments[i]] = arguments[i + 1]; } return ret; }
context["dictKeys"] = function(dict) { return Object.keys(dict) }
context["parseInt"] = parseInt
context["nullCheck"] = function(a) { return a; }

function main(input) {
let lines = (input).split("\n");
let ret = "";
let line_ord = 0;
let nt = context.parseInt(lines[line_ord]);
line_ord = context.parseInt(line_ord+1);
for (let t = 0; t<nt; t = context.parseInt(t+1)) {
let n = context.parseInt(lines[line_ord]);
line_ord = context.parseInt(line_ord+1);
let tokens = (lines[line_ord]).split(" ");
line_ord = context.parseInt(line_ord+1);
let arr = [];
for (let i = 0; i<(tokens).length; i = context.parseInt(i+1)) {
(arr).push(context.parseInt(tokens[i]));

}
let offset = 0;
let ok = true;
let insertions = [];
let splits = [];
while ((arr).length>0&&ok) {
let idx = context.parseInt(0-1);
for (let i = 1; i<(arr).length; i = context.parseInt(i+1)) {
if (arr[i]==arr[0]) {
idx = i;
break;
}

}
if (idx==context.parseInt(0-1)) {
ok = false;
break;
}
let new_arr = [];
for (let j = 1; j<idx; j = context.parseInt(j+1)) {
(insertions).push([context.parseInt(context.parseInt(offset+idx)+j),arr[j]]);

}
for (let j = context.parseInt(idx-1); j>0; j = context.parseInt(j-1)) {
(new_arr).push(arr[j]);

}
for (let j = context.parseInt(idx+1); j<(arr).length; j = context.parseInt(j+1)) {
(new_arr).push(arr[j]);

}
(splits).push(context.parseInt(idx*2));
offset = context.parseInt(offset+context.parseInt(idx*2));
arr = new_arr;

}
if (!ok) {
ret = ret+"-1\n";
} else {ret = ret+("" + ((insertions).length))+"\n";
for (let i = 0; i<(insertions).length; i = context.parseInt(i+1)) {
ret = ret+("" + (insertions[i][0]))+" "+("" + (insertions[i][1]))+"\n";

}
ret = ret+("" + ((splits).length))+"\n";
for (let i = 0; i<(splits).length; i = context.parseInt(i+1)) {
ret = ret+("" + (splits[i]))+"\n";

}
}

}
return ret;
}

const fs = require('fs');
const input = fs.readFileSync(0, 'utf8')
console.log(main(input));

'use strict';

function solve(n, a) {
  const map = new Map();
  for (let num of a) {
    var _map$get;
    map.set(num, ((_map$get = map.get(num)) !== null && _map$get !== void 0 ? _map$get : 0) + 1);
  }
  for (let [i, count] of map) if (count & 1) return -1;
  let nums = [...a];
  const ops = [],
        res = [];
  for (let i = 0, j = 0; i < n; i = j) {
    j = i + 1;
    while (nums[j] !== nums[i]) {
      j++;
    }
    let t = j;
    while (i < t) {
      const num = nums[i];
      if (num !== nums[j]) {
        ops.push([j, num]);
        nums.splice(j, 0, num, num);
      }
      i++;
      j++;
    }
    res.push((j - i) * 2);
  }
  let str = '';
  if (ops.length) {
    str += `${ops.length}\n${ops.map(arr => arr.join(' ')).join('\n')}`;
  } else {
    str += 0;
  }
  str += `\n${res.length}\n${res.join(' ')}`;
  return str;
}

async function main(read) {
  try {
    let t = Number(await read());
    let res = new Array(t);
    for (let i = 0; i < t; i++) {
      const n = Number(await read());
      const a = (await read()).split(' ').map(Number);
      res[i] = solve(n, a);
    }
    return res.join('\n');
  } catch (error) {
    console.log(error);
  }
}

let inputs,
    str = '';
function read() {
  return inputs.next().value.trim();
}
process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', input => str += input);
process.stdin.on('end', async () => {
  inputs = str.split('\n').values();
  const output = await main(read);
  process.stdout.write(output);
});

let context = {}
context["throw"] = function(a) { throw a }
context["makeDict"] = function() { let ret = {}; for (let i = 0; i < arguments.length; i += 2) { ret[arguments[i]] = arguments[i + 1]; } return ret; }
context["dictKeys"] = function(dict) { return Object.keys(dict) }
context["parseInt"] = parseInt
context["nullCheck"] = function(a) { return a; }

function main(input) {
let lines = (input).split("\n");
let ret = "";
let line_ord = 0;
let nt = context.parseInt(lines[line_ord]);
line_ord = context.parseInt(line_ord+1);
for (let t = 0; t<nt; t = context.parseInt(t+1)) {
let n = context.parseInt(lines[line_ord]);
line_ord = context.parseInt(line_ord+1);
let tokens = (lines[line_ord]).split(" ");
line_ord = context.parseInt(line_ord+1);
let arr = [];
for (let i = 0; i<(tokens).length; i = context.parseInt(i+1)) {
(arr).push(context.parseInt(tokens[i]));

}
let offset = 0;
let ok = true;
let insertions = [];
let splits = [];
while ((arr).length>0&&ok) {
let idx = context.parseInt(0-1);
for (let i = 1; i<(arr).length; i = context.parseInt(i+1)) {
if (arr[i]==arr[0]) {
idx = i;
break;
}

}
if (idx==context.parseInt(0-1)) {
ok = false;
break;
}
let new_arr = [];
for (let j = 1; j<idx; j = context.parseInt(j+1)) {
(insertions).push([context.parseInt(context.parseInt(offset+context.parseInt(idx*2))-j),arr[j]]);

}
for (let j = context.parseInt(idx-1); j>0; j = context.parseInt(j-1)) {
(new_arr).push(arr[j]);

}
for (let j = context.parseInt(idx+1); j<(arr).length; j = context.parseInt(j+1)) {
(new_arr).push(arr[j]);

}
(splits).push(context.parseInt(idx*2));
offset = context.parseInt(offset+context.parseInt(idx*2));
arr = new_arr;

}
if (!ok) {
ret = ret+"-1\n";
} else {ret = ret+("" + ((insertions).length))+"\n";
for (let i = 0; i<(insertions).length; i = context.parseInt(i+1)) {
ret = ret+("" + (insertions[i][0]))+" "+("" + (insertions[i][1]))+"\n";

}
ret = ret+("" + ((splits).length))+"\n";
for (let i = 0; i<(splits).length; i = context.parseInt(i+1)) {
ret = ret+("" + (splits[i]))+"\n";

}
}

}
return ret;
}

const fs = require('fs');
const input = fs.readFileSync(0, 'utf8')
console.log(main(input));

let context = {}
context["throw"] = function(a) { throw a }
context["makeDict"] = function() { let ret = {}; for (let i = 0; i < arguments.length; i += 2) { ret[arguments[i]] = arguments[i + 1]; } return ret; }
context["dictKeys"] = function(dict) { return Object.keys(dict) }
context["parseInt"] = parseInt
context["nullCheck"] = function(a) { return a; }

function main(input) {
let lines = (input).split("\n");
let ret = "";
let line_ord = 0;
let nt = context.parseInt(lines[line_ord]);
line_ord = context.parseInt(line_ord+1);
for (let t = 0; t<nt; t = context.parseInt(t+1)) {
let n = context.parseInt(lines[line_ord]);
line_ord = context.parseInt(line_ord+1);
let tokens = (lines[line_ord]).split(" ");
line_ord = context.parseInt(line_ord+1);
let arr = [];
for (let i = 0; i<(tokens).length; i = context.parseInt(i+1)) {
(arr).push(context.parseInt(tokens[i]));

}
let offset = 0;
let ok = true;
let insertions = [];
let splits = [];
while ((arr).length>0&&ok) {
let idx = context.parseInt(0-1);
for (let i = 1; i<(arr).length; i = context.parseInt(i+1)) {
if (arr[i]==arr[0]) {
idx = i;
break;
}

}
if (idx==context.parseInt(0-1)) {
ok = false;
break;
}
let new_arr = [];
for (let j = context.parseInt(idx-1); j>0; j = context.parseInt(j-1)) {
(insertions).push([context.parseInt(context.parseInt(offset+context.parseInt(idx*2))-j),arr[j]]);
(new_arr).push(arr[j]);

}
for (let j = context.parseInt(idx+1); j<(arr).length; j = context.parseInt(j+1)) {
(new_arr).push(arr[j]);

}
(splits).push(context.parseInt(idx*2));
offset = context.parseInt(offset+context.parseInt(idx*2));
arr = new_arr;

}
if (!ok) {
ret = ret+"-1\n";
} else {ret = ret+("" + ((insertions).length))+"\n";
for (let i = 0; i<(insertions).length; i = context.parseInt(i+1)) {
ret = ret+("" + (insertions[i][0]))+" "+("" + (insertions[i][1]))+"\n";

}
ret = ret+("" + ((splits).length))+"\n";
for (let i = 0; i<(splits).length; i = context.parseInt(i+1)) {
ret = ret+("" + (splits[i]))+"\n";

}
}

}
return ret;
}

const fs = require('fs');
const input = fs.readFileSync(0, 'utf8')
console.log(main(input));


There are $$$n$$$ block towers in a row, where tower $$$i$$$ has a height of $$$a_i$$$. You're part of a building crew, and you want to make the buildings look as nice as possible. In a single day, you can perform the following operation:  Choose two indices $$$i$$$ and $$$j$$$ ($$$1 \leq i, j \leq n$$$; $$$i \neq j$$$), and move a block from tower $$$i$$$ to tower $$$j$$$. This essentially decreases $$$a_i$$$ by $$$1$$$ and increases $$$a_j$$$ by $$$1$$$. You think the ugliness of the buildings is the height difference between the tallest and shortest buildings. Formally, the ugliness is defined as $$$\max(a)-\min(a)$$$. What's the minimum possible ugliness you can achieve, after any number of days?

The first line contains one integer $$$t$$$ ($$$1 \leq t \leq 1000$$$) — the number of test cases. Then $$$t$$$ cases follow. The first line of each test case contains one integer $$$n$$$ ($$$2 \leq n \leq 100$$$) — the number of buildings. The second line of each test case contains $$$n$$$ space separated integers $$$a_1, a_2, \ldots, a_n$$$ ($$$1 \leq a_i \leq 10^7$$$) — the heights of the buildings.

For each test case, output a single integer — the minimum possible ugliness of the buildings.

NoteIn the first test case, the ugliness is already $$$0$$$.In the second test case, you should do one operation, with $$$i = 1$$$ and $$$j = 3$$$. The new heights will now be $$$[2, 2, 2, 2]$$$, with an ugliness of $$$0$$$.In the third test case, you may do three operations:   with $$$i = 3$$$ and $$$j = 1$$$. The new array will now be $$$[2, 2, 2, 1, 5]$$$,  with $$$i = 5$$$ and $$$j = 4$$$. The new array will now be $$$[2, 2, 2, 2, 4]$$$,  with $$$i = 5$$$ and $$$j = 3$$$. The new array will now be $$$[2, 2, 3, 2, 3]$$$.  The resulting ugliness is $$$1$$$. It can be proven that this is the minimum possible ugliness for this test.

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 a = lines[i].split(' ').map(Number);
	        var sum = 0;
	        for(j = 0; j < n; j++){
	            sum += a[j];
	        }
	        var min = Math.floor(sum / n);
	        var max = Math.ceil(sum / n);
	        console.log(max - min);
	    }
	}
});

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 sum = 0;
	        for(j = 0; j < n; j++){
	            sum += k[j];
	        }
	        var min = Math.floor(sum / n);
	        var max = Math.ceil(sum / n);
	        console.log(max - min);
	    }
	}
});

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

function* nextLine() {
	let lines = data.trim().split(/\n/g);
	for(let l of lines){
		yield l.trim();
	}
}

let nl = nextLine();

nl.elem = function(funParse) {
		return funParse(this.next().value);
	};

nl.array = function(funParse) {
		return this.next().value.split(/\s/g).map(funParse||(x => x));
	};

nl.num = function() {
		return nl.elem(Number);
	};

nl.nums = function() {
		return nl.array(Number);
	};

nl.line = function() {
		return this.next().value;
	};

const sol = () => {
	//your code this
	let t = nl.num();
	let ans = [];
	for(let i = 0; i< t; i++){
		let n = nl.num();
		let s = nl.nums().reduce((a, b) => a + b, 0);
		ans.push(s%n > 0?1:0);
	}
	console.log(ans.join('\n'));
};

process.stdin.on('end', sol);

let i = ''
process.stdin.on('data', c => i += c)
process.stdin.on('end', () => {
    const {EOL} = require('os')
    const lines = i.split(EOL) /*your input text, split by lines*/

    for (let i = 2; i < lines.length; i+=2) {
        if (!lines[i]) continue;

        let sum = lines[i].split(' ').reduce((a, b) => parseInt(a) + parseInt(b), 0);

        console.log(sum % lines[i-1] ? 1 : 0)
    }
})

'use strict';

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++];
}

var maxN = 2 * 1e5 + 10
var mod = BigInt(1e9 + 7)

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

  // console.log(array)
  Array(Number(xx)).fill(1).map((t, i) => {
    const n = Number(readline());

    // var [a, k] = readline().split(' ').map((x, iii) => {
    //   return parseInt(x)
    // })
    var sum = 0
    var a = readline().split(' ').map((x, iii) => {
      sum+=Number(x)
      return Number(x)
    })
    // console.log(sum)
    if(sum %n ===0) return console.log(0)
    return console.log(1)
// console.log(a)
// console.log(n)
    // if(i===(string.length-2)) return console.log(string)
  })
}

var total = parseInt(readline());

for(var i=0; i<total; i++){
    var n = parseInt(readline());
    var height = readline().split(" ");
    var sums=0;
    var a = 0;
    while(a<height.length){
        sums += parseInt(height[a]);
        a++;
    }
    if (sums%n===0){
        print(0);
    }
    else{
        print(1);
    }
}


Vasya has got two number: a and b. However, Vasya finds number a too short. So he decided to repeat the operation of lengthening number a n times.One operation of lengthening a number means adding exactly one digit to the number (in the decimal notation) to the right provided that the resulting number is divisible by Vasya's number b. If it is impossible to obtain the number which is divisible by b, then the lengthening operation cannot be performed.Your task is to help Vasya and print the number he can get after applying the lengthening operation to number a n times.

The first line contains three integers: a, b, n (1 ≤ a, b, n ≤ 105).

In a single line print the integer without leading zeros, which Vasya can get when he applies the lengthening operations to number a n times. If no such number exists, then print number -1. If there are multiple possible answers, print any of them.

print(function(a, b, n) {

	var i, ans = [];

	n--;
	for (i = 0; i <= 9; i++)
		if ((a * 10 + i) % b === 0) {
			ans.push(a * 10 + i);
			break;
		}

	if (ans.length === 0)
		return -1;

	while (n--)
		ans.push(0);

	return ans.join('');

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

;(function () {
	print(function (a, b, n) {
		while (n-- > 0) {
			var flag = true;
			for (var i = 0; i < 10; i++) {
				if ((+(a + '' + i)%b) === 0) {
					a = +(a + '' + i);
					flag = false;

					if (i === 0) {
						a = a.toString();
						while (n-- > 0){
							a += '0';
						}
					}

					break;
				}
			}

			if (flag) return -1;
		}

		return a;
	}.apply(null, readline().split(' ').map(Number)));
}.call(this));

print(function(a, b, n) {

	var i, ans = [];

	n--;
	for (i = 0; i < 9; i++)
		if ((a * 10 + i) % b === 0) {
			ans.push(a * 10 + i);
			break;
		}

	if (ans.length === 0)
		return -1;

	while (n--)
		ans.push(0);

	return ans.join('');

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

;(function () {
	print(function (a, b, n) {
		while (n--) {
			if (a%10) {
				var flag = true;
				for (var i = 0; i < 10; i++) {
					if ((+(a + '' + i)%b) === 0) {
						a = +(a + '' + i);
						flag = false;
						break;
					}
				}

				if (flag) return -1;
			} else {
				n++;
				break;
			}
		}

		a = a.toString();
		while (n-- > 0) a += '0';

		return a;
	}.apply(null, readline().split(' ').map(Number)));
}.call(this));

;(function () {
	print(function (a, b, n) {
		while (n--) {
			var flag = true;
			for (var i = 0; i < 10; i++) {
				if ((+(a + '' + i)%b) === 0) {
					a = +(a + '' + i);
					flag = false;
					break;
				}
			}

			if (flag) return -1;
		}

		return a;
	}.apply(null, readline().split(' ').map(Number)));
}.call(this));

;(function () {
	print(function (a, b, n) {
		while (n--) {
			if (a%10) {
				var flag = true;
				for (var i = 0; i < 10; i++) {
					if ((+(a + '' + i)%b) === 0) {
						a = +(a + '' + i);
						flag = false;
						break;
					}
				}

				if (flag) return -1;
			} else break;
		}

		a = a.toString();
		while (n--) a += '0';

		return a;
	}.apply(null, readline().split(' ').map(Number)));
}.call(this));


A string is called a k-string if it can be represented as k concatenated copies of some string. For example, the string "aabaabaabaab" is at the same time a 1-string, a 2-string and a 4-string, but it is not a 3-string, a 5-string, or a 6-string and so on. Obviously any string is a 1-string.You are given a string s, consisting of lowercase English letters and a positive integer k. Your task is to reorder the letters in the string s in such a way that the resulting string is a k-string.

The first input line contains integer k (1 ≤ k ≤ 1000). The second line contains s, all characters in s are lowercase English letters. The string length s satisfies the inequality 1 ≤ |s| ≤ 1000, where |s| is the length of string s.

Rearrange the letters in string s in such a way that the result is a k-string. Print the result on a single output line. If there are multiple solutions, print any of them. If the solution doesn't exist, print "-1" (without quotes).

var k=+readline();
var s={};
readline().split('').forEach(function(c){
	if( s[c] ){
		s[c]++;
	}else{
		s[c]=1;
	}
});
var f=false;
Object.keys(s).forEach(function(c){
	if( s[c]%k===0 ){
		s[c]=repeat(s[c]/k, c);
	}else{
		f=true;
	}
});
if(f){
	print(-1);
	quit();
}
s = Object.keys(s).map(function(c){return s[c];}).join('');
var ans='';
for(var i=0; i<k; i++){
	ans+=s;
}
print(ans);

function repeat(n, c){
	var ret = '';
	while(n--){
		ret+=c;
	}
	return ret;
}

;(function () {

	var k = +readline();
	var m = readline().split('').reduce(function (p, e) { p[e] = p[e] ? p[e] + 1 : 1; return p; }, {});

	var str = '';
	for(var key in m) {
		if (m[key] % k) {
			print(-1);
			return;
		} else {
			var l = m[key] / k;
			while (l--) str += key;
		}
	}

	var r = '';
	for (var i = 0; i < k; i++) r += str;
	print(r);

}).call(this)

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 k = parseInt(readline()),
		s = trim(readline()),
		n = s.length,
		letters = [],
		letterCount = {};
	for (var i = 0; i < n; ++i) {
		var ch = s.charAt(i);
		if (letterCount[ch] === undefined) {
			letters.push(ch);
			letterCount[ch] = 0;
		}
		letterCount[ch] += 1;
	}
	letters.sort();
	var word = [], result = [];
	for (var i = 0; i < letters.length; ++i) {
		var letter = letters[i], count = letterCount[letter];
		if (count % k != 0) {
			print(-1);
			return;
		}
		for (var j = count / k; j != 0; --j) {
			word.push(letter);
		}
	}
	word = word.join('');
	for (var i = 0; i < k; ++i) {
		result.push(word);
	}
	print(result.join(''));
}

main();

function main()
{
    var n = parseInt(readline());
    var str = readline();
    if(str.length % n != 0){print(-1); return;}
    var mas = new Array(26);
    for(var i = 0; i < 26; ++i)
    {
        mas[i] = 0;
    }
    for(var i = 0; i < str.length; ++i)
    {
        mas[str.charCodeAt(i)-97] ++;
    }
    for(var i = 0; i < 26; ++i)
    {
        if(mas[i] != 0 && mas[i] % n != 0){print(-1); return;}
    }
    var new_str = "";
    for(var i = 0; i < n; ++i)
    {
        for(var j = 0; j < 26; ++j)
        {
            if(mas[j] != 0)
            {
                for(var h = mas[j] / n; h > 0; --h)
                {
                    new_str = new_str + String.fromCharCode(j + 97);
                }
            }
        }
    }
    print(new_str);
}
main();

var n = +readline();
var s = readline().split('').sort();
s.push('0');
var k = 1;
var ans = [];
var anst = [];
for (var i=0; i<s.length-1; i++) {
	if (s[i] == s[i+1]) {
		k++;
	} else if (k%n == 0) {
		for (var j=0; j<k/n; j++) ans.push(s[i]);
		k = 1;
	} else {
		print(-1);
		k = -1;
		break;
	}
}
if (k != -1) {
	for (var j=0; j<n; j++) anst = anst.concat(ans);
	print (anst.join(''));
	}

//var input = "2\naaaa";
//var index = 0;
//
//function readline(){
//    var data = input.split('\n');
//    if(index < data.length)
//        return data[index++];
//}
//
//function print(output){
//    console.log(output);
//}

function test(arr, k){
    for(var i = 0; i < arr.length; i++){
        if(arr[i] % k !=0)
            return false;
    }
    return true;
}

function main(){
    var k = parseInt(readline());
    var str = readline();
    var a = new Array(26);
    for(var i = 0; i < a.length; i++)
        a[i] = 0;
    for(var i = 0; i < str.length; i++)
        a[str.charCodeAt(i) - 'a'.charCodeAt(0)]++;
    if(test(a, k)){
        var ans = "";
        var contact = "";
        for(var i = 0; i < a.length; i++)
            for(var j = 0; j < a[i] / k; j++)
                contact += String.fromCharCode(i + 'a'.charCodeAt(0));
        while(k > 0){
            ans += contact;
            k--;
        }
        print(ans);
    }else
        print(-1);
}
main();

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 n = +readLine();
  const str = readLine();
  const map = str.split("").reduce((obj, char) => {
    obj[char] = (obj[char] || 0) + 1;
    return obj;
  }, {});
  const keys = Object.keys(map);
  const imPossible = Object.values(map).some((val) => val % n !== 0);

  if (n === 1) {
    console.log(str);
  } else if (!imPossible) {
    let pattern = ``;
    for (let i = 0; i < keys.length; i++) {
      const key = keys[i];
      pattern += key.repeat(map[key] / n);
    }
    console.log(pattern.repeat(n));
  } else {
    console.log(-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++];
}

var dp = {};

function fibonacci(n) {
	if (n === 0) return 0;
	if (n === 1) return 1;

	if (dp[n] !== undefined) return dp[n];
	let result = fibonacci(n - 1) + fibonacci(n - 2);
	return (dp[n] = result);
}

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

function gcdArr() {
	let args = arguments;
	let res = args[0];
	let { length } = args;
	for (let i = 1; i < length; i++) {
		res = gcd(res, args[i]);
	}
	return res;
}

function main() {
	let k = readLine() >> 0;
	let s = readLine().split('');
	let store = {};
	s.forEach(ch => (store[ch] = (store[ch] || 0) + 1));
	let keys = Object.keys(store);
	let l = keys.length;
	let str = '';
	for (let i = 0; i < l; i++) {
		if (store[keys[i]] % k !== 0) {
			console.log(-1);
			return;
		}
		str += keys[i].repeat(store[keys[i]] / k);
	}
	console.log(str.repeat(k));
}

;(function () {

	var k = +readline();
	var m = readline().split('').reduce(function (p, e) { p[e] = p[e] ? p[e] + 1 : 1; return p; }, {});

	var str = '';
	for(var key in m) {
		if (m[key] % k) {
			print(-1);
			return;
		} else {
			var l = m[key] / k;
			while (l--) str += key;
		}
	}

	for (var i = 0; i < k -1 ; i++) str += str;
	print(str);

}).call(this)

;(function () {

	var k = +readline();
	var m = readline().split('').reduce(function (p, e) { p[e] = p[e] ? p[e] + 1 : 1; return p; }, {});

	var str = '';
	for(var key in m) {
		if (m[key] % k) {
			print(-1);
			return;
		} else {
			var l = m[key] / k;
			while (l--) str += key;
		}
	}

	var r = '';
	for (var i = 0; i < k; i++) r += str;
	print(str);

}).call(this)

;(function () {

	var k = +readline();
	var m = readline().split('').reduce(function (p, e) { p[e] = p[e] ? p[e] + 1 : 1; return p; }, {});

	var str = '';
	for(var key in m) {
		if (m[key] % k) {
			print(-1);
			return;
		} else {
			var l = m[key] / k;
			while (l--) str += key;
		}
	}

	var r = '';
	for (var i = 0; i < k -1 ; i++) r += str;
	print(str);

}).call(this)

function main()
{
    var n = parseInt(readline());
    var str = readline();
    if(str.length % n != 0){print(-1); return;}
    var mas = new Array(26);
    for(var i = 0; i < 26; ++i)
    {
        mas[i] = 0;
    }
    for(var i = 0; i < str.length; ++i)
    {
        mas[str.charCodeAt(i)-97] ++;
    }
    var memory = -1;
    for(var i = 0; i < 26; ++i)
    {
        if(memory == -1 && mas[i] != 0){memory = mas[i];}
        if(mas[i] != 0 && mas[i] != memory){print(-1); return;}
    }
    var new_str = "", p = 0;
    for(var i = 0; i < memory; ++i)
    {
        for(var j = 0; j < 26; ++j)
        {
            if(mas[j] != 0)
            {
                new_str = new_str + String.fromCharCode(j + 97);
            }
        }
    }
    print(new_str);
}
main();

var n = +readline();
var s = readline().split('').sort();
var k = 1;
var ans = [];
var anst = [];
for (var i=0; i<s.length-1; i++) {
	if (s[i] == s[i+1]) {
		k++;
		if (i == s.length-2 && k%n == 0) {
			for (var j=0; j<k/n; j++) ans.push(s[i]);
		}
	} else if (k%n == 0) {
		for (var j=0; j<k/n; j++) ans.push(s[i]);
		k = 1;
	} else {
		print(-1);
		k = -1;
		break;
	}
}
if (k != -1) {
	if (k != s.length) {
		for (var j=0; j<n; j++) anst = anst.concat(ans);
		print (anst.join(''));
	}
	else if (k%n == 0) print (s.join(''));
	else print(-1);
}

//var input = "2\naaaa";
//var index = 0;
//
//function readline(){
//    var data = input.split('\n');
//    if(index < data.length)
//        return data[index++];
//}
//
//function print(output){
//    console.log(output);
//}

function test(arr, k){
    var n = k;
    for(var i = 0; i < arr.length; i++){
        if(arr[i] != 0)
            n--;
        if(arr[i] % k !=0)
            return false;
    }
    if(n == k - 1){
        for(var i = 0; i < arr.length; i++){
            if(arr[i] != 0 && arr[i] % k != 0)
                return false;
        }
    }else if(n != 0)
        return false;
    return true;
}

function main(){
    var k = parseInt(readline());
    var str = readline();
    var a = new Array(26);
    for(var i = 0; i < a.length; i++)
        a[i] = 0;
    for(var i = 0; i < str.length; i++)
        a[str.charCodeAt(i) - 'a'.charCodeAt(0)]++;
    if(test(a, k)){
        var n = k;
        var ans = "";
        while(k > 0){
            for(var i = 0; i < a.length; i++){
                if(a[i] != 0){
                    for(var j = 0; j < a[i] / n; j++)
                        ans += String.fromCharCode(i + 'a'.charCodeAt(0));
                }
            }
            k--;
        }
        print(ans);
    }else
        print(-1);
}
main();

//var input = "2\naazz";
//var index = 0;
//
//function readline(){
//    var data = input.split('\n');
//    if(index < data.length)
//        return data[index++];
//}
//
//function print(output){
//    console.log(output);
//}

function test(arr, k){
    var n = k;
    for(var i = 0; i < arr.length; i++){
        if(arr[i] != 0)
            n--;
        if(arr[i] % k !=0)
            return false;
    }
    if(n != 0)
        return false;
    return true;
}

function main(){
    var k = parseInt(readline());
    var str = readline();
    var a = new Array(26);
    for(var i = 0; i < a.length; i++)
        a[i] = 0;
    for(var i = 0; i < str.length; i++)
        a[str.charCodeAt(i) - 'a'.charCodeAt(0)]++;
    if(test(a, k)){
        var ans = "";
        while(k > 0){
            for(var i = 0; i < a.length; i++){
                if(a[i] != 0)
                    ans += String.fromCharCode(i + 'a'.charCodeAt(0));
            }
            k--;
        }
        print(ans);
    }else
        print(-1);
}
main();

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++];
}

var dp = {};

function fibonacci(n) {
	if (n === 0) return 0;
	if (n === 1) return 1;

	if (dp[n] !== undefined) return dp[n];
	let result = fibonacci(n - 1) + fibonacci(n - 2);
	return (dp[n] = result);
}

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

function gcdArr() {
	let args = arguments;
	let res = args[0];
	let { length } = args;
	for (let i = 1; i < length - 1; i++) {
		res = gcd(res, args[i]);
	}
	return res;
}

function main() {
	let k = readLine() >> 0;
	let s = readLine().split('');
	let store = {};
	if (s.length % k !== 0) {
		console.log(-1);
		return;
	}
	if (k === 1) {
		console.log(s.join(''));
		return;
	}

	s.forEach(ch => (store[ch] = (store[ch] || 0) + 1));
	let g = gcdArr(...Object.values(store));

	let str = '';
	if (g > 1) {
		Object.entries(store).forEach(([ch, cnt]) => {
			str += ch.repeat(cnt / g);
		});
		console.log(str.repeat(k));
	} else {
		console.log(-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++];
}

var dp = {};

function fibonacci(n) {
	if (n === 0) return 0;
	if (n === 1) return 1;

	if (dp[n] !== undefined) return dp[n];
	let result = fibonacci(n - 1) + fibonacci(n - 2);
	return (dp[n] = result);
}

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

function gcdArr() {
	let args = arguments;
	let res = args[0];
	let { length } = args;
	for (let i = 1; i < length; i++) {
		res = gcd(res, args[i]);
	}
	return res;
}

function main() {
	let k = readLine() >> 0;
	let s = readLine().split('');
	let store = {};
	if (s.length % k !== 0) {
		console.log(-1);
		return;
	}
	if (k === 1) {
		console.log(s.join(''));
		return;
	}

	s.forEach(ch => (store[ch] = (store[ch] || 0) + 1));

	if (Object.keys(store).length === 1) {
		console.log(s.join(''));
		return;
	}

	let g = gcdArr(...Object.values(store));

	let str = '';
	if (g > 1) {
		Object.entries(store).forEach(([ch, cnt]) => {
			str += ch.repeat(cnt / g);
		});
		console.log(str.repeat(k));
	} else {
		console.log(-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++];
}

var dp = {};

function fibonacci(n) {
	if (n === 0) return 0;
	if (n === 1) return 1;

	if (dp[n] !== undefined) return dp[n];
	let result = fibonacci(n - 1) + fibonacci(n - 2);
	return (dp[n] = result);
}

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

function gcdArr() {
	let args = arguments;
	let res = args[0];
	let { length } = args;
	for (let i = 1; i < length; i++) {
		res = gcd(res, args[i]);
	}
	return res;
}

function main() {
	let k = readLine() >> 0;
	let s = readLine().split('');
	let store = {};
	if (s.length % k !== 0) {
		console.log(-1);
		return;
	}
	if (k === 1) {
		console.log(s.join(''));
		return;
	}

	s.forEach(ch => (store[ch] = (store[ch] || 0) + 1));
	let g = gcdArr(...Object.values(store));

	let str = '';
	if (g > 1) {
		Object.entries(store).forEach(([ch, cnt]) => {
			str += ch.repeat(cnt / g);
		});
		console.log(str.repeat(k));
	} else {
		console.log(-1);
	}
}


Leha somehow found an array consisting of n integers. Looking at it, he came up with a task. Two players play the game on the array. Players move one by one. The first player can choose for his move a subsegment of non-zero length with an odd sum of numbers and remove it from the array, after that the remaining parts are glued together into one array and the game continues. The second player can choose a subsegment of non-zero length with an even sum and remove it. Loses the one who can not make a move. Who will win if both play optimally?

First line of input data contains single integer n (1 ≤ n ≤ 106) — length of the array. Next line contains n integers a1, a2, ..., an (0 ≤ ai ≤ 109).

Output answer in single line. "First", if first player wins, and "Second" otherwise (without quotes).

NoteIn first sample first player remove whole array in one move and win.In second sample first player can't make a move and lose.

var n=+readline()
a=readline().split(' ').filter(function(x){return (+x)%2;})
print(a.length?"First":"Second")


Let's call an array $$$t$$$ dominated by value $$$v$$$ in the next situation.At first, array $$$t$$$ should have at least $$$2$$$ elements. Now, let's calculate number of occurrences of each number $$$num$$$ in $$$t$$$ and define it as $$$occ(num)$$$. Then $$$t$$$ is dominated (by $$$v$$$) if (and only if) $$$occ(v) > occ(v')$$$ for any other number $$$v'$$$. For example, arrays $$$[1, 2, 3, 4, 5, 2]$$$, $$$[11, 11]$$$ and $$$[3, 2, 3, 2, 3]$$$ are dominated (by $$$2$$$, $$$11$$$ and $$$3$$$ respectevitely) but arrays $$$[3]$$$, $$$[1, 2]$$$ and $$$[3, 3, 2, 2, 1]$$$ are not.Small remark: since any array can be dominated only by one number, we can not specify this number and just say that array is either dominated or not.You are given array $$$a_1, a_2, \dots, a_n$$$. Calculate its shortest dominated subarray or say that there are no such subarrays.The subarray of $$$a$$$ is a contiguous part of the array $$$a$$$, i. e. the array $$$a_i, a_{i + 1}, \dots, a_j$$$ for some $$$1 \le i \le j \le n$$$.

The first line contains single integer $$$T$$$ ($$$1 \le T \le 1000$$$) — the number of test cases. Each test case consists of two lines. The first line contains single integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) — the length of the array $$$a$$$. The second line contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le n$$$) — the corresponding values of the array $$$a$$$. It's guaranteed that the total length of all arrays in one test doesn't exceed $$$2 \cdot 10^5$$$.

Print $$$T$$$ integers — one per test case. For each test case print the only integer — the length of the shortest dominated subarray, or $$$-1$$$ if there are no such subarrays.

NoteIn the first test case, there are no subarrays of length at least $$$2$$$, so the answer is $$$-1$$$.In the second test case, the whole array is dominated (by $$$1$$$) and it's the only dominated subarray.In the third test case, the subarray $$$a_4, a_5, a_6$$$ is the shortest dominated subarray.In the fourth test case, all subarrays of length more than one are dominated.

function nextInt() { return parseInt(nextString()); }
function nextFloat() { return parseFloat(nextString()); }
let input_stdin = "";
let input_cursor = 0;
function nextString() {
    let next_string = "";
    clearWhitespaces();
    while (input_cursor < input_stdin.length && !isWhitespace(input_stdin[input_cursor]))next_string += input_stdin[input_cursor], input_cursor += 1;
    return next_string;
}
function nextChar() {
    clearWhitespaces();
    if (input_cursor < input_stdin.length) return input_stdin[input_cursor++]; else return '\0';
}
process.stdin.resume();
process.stdin.setEncoding('ascii');
process.stdin.on('data', function (data) { input_stdin += data; });
process.stdin.on('end', function () { main(); });
function isWhitespace(character) { return ' \t\n\r\v'.indexOf(character) > -1; }
function clearWhitespaces() { while (input_cursor < input_stdin.length && isWhitespace(input_stdin[input_cursor])) input_cursor += 1; }

const N = 2e5 + 2;
let fd = new Array(N);
let a = new Array(N);

function solve(){
    let n = nextInt();
    fd.fill(-1);
    for (let i = 0; i < n; i++)a[i] = nextInt();
    let an = N + 2, flg = false;
    for (let i = 0; i < n; i++){
        if (fd[a[i]] !== -1){
            an = Math.min(an, i - fd[a[i]] + 1);
            flg = true;
        }
        fd[a[i]] = i;
    }
    console.log(flg ? an : -1);
}

function main() {
    let t = nextInt();
    while(t--)solve();
}

function nextInt() { return parseInt(nextString()); }
function nextFloat() { return parseFloat(nextString()); }
let input_stdin = "";
let input_cursor = 0;
function nextString() {
    let next_string = "";
    clearWhitespaces();
    while (input_cursor < input_stdin.length && !isWhitespace(input_stdin[input_cursor])) {
        next_string += input_stdin[input_cursor];
        input_cursor += 1;
    }
    return next_string;
}
function nextChar() {
    clearWhitespaces();
    if (input_cursor < input_stdin.length) return input_stdin[input_cursor++]; else return '\0';
}
process.stdin.resume();
process.stdin.setEncoding('ascii');
process.stdin.on('data', function (data) { input_stdin += data; });
process.stdin.on('end', function () { main(); });
function isWhitespace(character) { return ' \t\n\r\v'.indexOf(character) > -1; }
function clearWhitespaces() { while (input_cursor < input_stdin.length && isWhitespace(input_stdin[input_cursor])) input_cursor += 1; }

const N = 2e5 + 2;
let frq = new Array(N);
let a = new Array(N);

function solve(){
    let n = nextInt();
    frq.fill(0);
    for (let i = 0; i < n; i++)a[i] = nextInt();
    if (n === 1){
        console.log(-1);
        return;
    }
    let l = 0, an = N + 2, flg = false;
    for (let r = 0; r < n; r++){
        frq[a[r]]++;
        while(frq[a[r]] > 1){
            flg = true;
            frq[a[l]]--;
            an = Math.min(an, r - l + 1);
            l++;
        }
    }
    console.log(flg ? an : -1);
}

function main() {
    let t = nextInt();
    while(t--)solve();
}

function nextInt() { return parseInt(nextString()); }
function nextFloat() { return parseFloat(nextString()); }
let input_stdin = "";
let input_cursor = 0;
function nextString() {
    let next_string = "";
    clearWhitespaces();
    while (input_cursor < input_stdin.length && !isWhitespace(input_stdin[input_cursor])) {
        next_string += input_stdin[input_cursor];
        input_cursor += 1;
    }
    return next_string;
}
function nextChar() {
    clearWhitespaces();
    if (input_cursor < input_stdin.length) return input_stdin[input_cursor++]; else return '\0';
}
process.stdin.resume();
process.stdin.setEncoding('ascii');
process.stdin.on('data', function (data) { input_stdin += data; });
process.stdin.on('end', function () { main(); });
function isWhitespace(character) { return ' \t\n\r\v'.indexOf(character) > -1; }
function clearWhitespaces() { while (input_cursor < input_stdin.length && isWhitespace(input_stdin[input_cursor])) input_cursor += 1; }

const N = 200000 + 2;
let frq = new Array(N);
let a = new Array(N);

function solve(){
    let n = nextInt();
    frq.fill(0);
    for (let i = 0; i < n; i++)a[i] = nextInt();
    if (n === 1){
        console.log(-1);
        return;
    }
    let l = 0, an = N + 2, flg = false;
    for (let r = 0; r < n; r++){
        frq[a[r]]++;
        while(frq[a[r]] > 1){
            flg = true;
            frq[a[l]]--;
            an = Math.min(an, r - l + 1);
            l++;
        }
    }
    console.log(flg ? an : -1);
}

function main() {
    let t = nextInt();
    while(t--)solve();
}

function nextInt() { return parseInt(nextString()); }
function nextFloat() { return parseFloat(nextString()); }
let input_stdin = "";
let input_cursor = 0;
function nextString() {
    let next_string = "";
    clearWhitespaces();
    while (input_cursor < input_stdin.length && !isWhitespace(input_stdin[input_cursor])) {
        next_string += input_stdin[input_cursor];
        input_cursor += 1;
    }
    return next_string;
}
function nextChar() {
    clearWhitespaces();
    if (input_cursor < input_stdin.length) return input_stdin[input_cursor++]; else return '\0';
}
process.stdin.resume();
process.stdin.setEncoding('ascii');
process.stdin.on('data', function (data) { input_stdin += data; });
process.stdin.on('end', function () { main(); });
function isWhitespace(character) { return ' \t\n\r\v'.indexOf(character) > -1; }
function clearWhitespaces() { while (input_cursor < input_stdin.length && isWhitespace(input_stdin[input_cursor])) input_cursor += 1; }

const N = 200000 + 2;
let frq = new Array(N);

function solve(){
    let n = nextInt();
    let a = new Array(n + 1);
    frq.fill(0);
    for (let i = 0; i < n; i++)a[i] = nextInt();
    if (n === 1){
        console.log(-1);
        return;
    }
    let l = 0, an = N + 2, flg = false;
    for (let r = 0; r < n; r++){
        frq[a[r]]++;
        while(frq[a[r]] > 1){
            flg = true;
            frq[a[l]]--;
            an = Math.min(an, r - l + 1);
            l++;
        }
    }
    console.log(flg ? an : -1);
}

function main() {
    let t = nextInt();
    while(t--)solve();
}

function nextInt() { return parseInt(nextString()); }
function nextFloat() { return parseFloat(nextString()); }
let input_stdin = "";
let input_cursor = 0;
function nextString() {
    let next_string = "";
    clearWhitespaces();
    while (input_cursor < input_stdin.length && !isWhitespace(input_stdin[input_cursor])) {
        next_string += input_stdin[input_cursor];
        input_cursor += 1;
    }
    return next_string;
}
function nextChar() {
    clearWhitespaces();
    if (input_cursor < input_stdin.length) return input_stdin[input_cursor++]; else return '\0';
}
process.stdin.resume();
process.stdin.setEncoding('ascii');
process.stdin.on('data', function (data) { input_stdin += data; });
process.stdin.on('end', function () { main(); });
function isWhitespace(character) { return ' \t\n\r\v'.indexOf(character) > -1; }
function clearWhitespaces() { while (input_cursor < input_stdin.length && isWhitespace(input_stdin[input_cursor])) input_cursor += 1; }

const N = 20002;

function solve(){
    let n = nextInt();
    let a = new Array(n + 1);
    let frq = new Array(N);
    frq.fill(0);
    for (let i = 0; i < n; i++)a[i] = nextInt();
    if (n === 1){
        console.log(-1);
        return;
    }
    let l = 0, an = N + 2;
    for (let r = 0; r < n; r++){
        frq[a[r]]++;
        while(frq[a[r]] > 1){
            frq[a[l]]--;
            an = Math.min(an, r - l + 1);
            l++;
        }
    }
    console.log(an);
}

function main() {
    let t = nextInt();
    while(t--)solve();
}

function nextInt() { return parseInt(nextString()); }
function nextFloat() { return parseFloat(nextString()); }
let input_stdin = "";
let input_cursor = 0;
function nextString() {
    let next_string = "";
    clearWhitespaces();
    while (input_cursor < input_stdin.length && !isWhitespace(input_stdin[input_cursor])) {
        next_string += input_stdin[input_cursor];
        input_cursor += 1;
    }
    return next_string;
}
function nextChar() {
    clearWhitespaces();
    if (input_cursor < input_stdin.length) return input_stdin[input_cursor++]; else return '\0';
}
process.stdin.resume();
process.stdin.setEncoding('ascii');
process.stdin.on('data', function (data) { input_stdin += data; });
process.stdin.on('end', function () { main(); });
function isWhitespace(character) { return ' \t\n\r\v'.indexOf(character) > -1; }
function clearWhitespaces() { while (input_cursor < input_stdin.length && isWhitespace(input_stdin[input_cursor])) input_cursor += 1; }

const N = 20002;

function solve(){
    let n = nextInt();
    let a = new Array(n + 1);
    let frq = new Array(N);
    frq.fill(0);
    for (let i = 0; i < n; i++)a[i] = nextInt();
    if (n === 1){
        console.log(n);
        return;
    }
    let l = 0, an = N + 2;
    for (let r = 0; r < n; r++){
        frq[a[r]]++;
        while(frq[a[r]] > 1){
            frq[a[l]]--;
            an = Math.min(an, r - l + 1);
            l++;
        }
    }
    console.log(an);
}

function main() {
    let t = nextInt();
    while(t--)solve();
}

function nextInt() { return parseInt(nextString()); }
function nextFloat() { return parseFloat(nextString()); }
let input_stdin = "";
let input_cursor = 0;
function nextString() {
    let next_string = "";
    clearWhitespaces();
    while (input_cursor < input_stdin.length && !isWhitespace(input_stdin[input_cursor])) {
        next_string += input_stdin[input_cursor];
        input_cursor += 1;
    }
    return next_string;
}
function nextChar() {
    clearWhitespaces();
    if (input_cursor < input_stdin.length) return input_stdin[input_cursor++]; else return '\0';
}
process.stdin.resume();
process.stdin.setEncoding('ascii');
process.stdin.on('data', function (data) { input_stdin += data; });
process.stdin.on('end', function () { main(); });
function isWhitespace(character) { return ' \t\n\r\v'.indexOf(character) > -1; }
function clearWhitespaces() { while (input_cursor < input_stdin.length && isWhitespace(input_stdin[input_cursor])) input_cursor += 1; }

const N = 20002;

function solve(){
    let n = nextInt();
    let a = new Array(n + 1);
    let frq = new Array(N);
    frq.fill(0);
    for (let i = 0; i < n; i++)a[i] = nextInt();
    if (n === 1){
        console.log(-1);
        return;
    }
    let l = 0, an = N + 2, flg = false;
    for (let r = 0; r < n; r++){
        frq[a[r]]++;
        while(frq[a[r]] > 1){
            flg = true;
            frq[a[l]]--;
            an = Math.min(an, r - l + 1);
            l++;
        }
    }
    console.log(flg ? an : -1);
}

function main() {
    let t = nextInt();
    while(t--)solve();
}