Mishka is a little polar bear. As known, little bears loves spending their free time playing dice for chocolates. Once in a wonderful sunny morning, walking around blocks of ice, Mishka met her friend Chris, and they started playing the game.Rules of the game are very simple: at first number of rounds n is defined. In every round each of the players throws a cubical dice with distinct numbers from 1 to 6 written on its faces. Player, whose value after throwing the dice is greater, wins the round. In case if player dice values are equal, no one of them is a winner.In average, player, who won most of the rounds, is the winner of the game. In case if two players won the same number of rounds, the result of the game is draw.Mishka is still very little and can't count wins and losses, so she asked you to watch their game and determine its result. Please help her!

The first line of the input contains single integer n n (1 ≤ n ≤ 100) — the number of game rounds. The next n lines contains rounds description. i-th of them contains pair of integers mi and ci (1 ≤ mi,  ci ≤ 6) — values on dice upper face after Mishka's and Chris' throws in i-th round respectively.

If Mishka is the winner of the game, print "Mishka" (without quotes) in the only line. If Chris is the winner of the game, print "Chris" (without quotes) in the only line. If the result of the game is draw, print "Friendship is magic!^^" (without quotes) in the only line.

NoteIn the first sample case Mishka loses the first round, but wins second and third rounds and thus she is the winner of the game.In the second sample case Mishka wins the first round, Chris wins the second round, and the game ends with draw with score 1:1.In the third sample case Chris wins the first round, but there is no winner of the next two rounds. The winner of the game is Chris.

const readline = require("readline");

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

let element = [];
let Mishka = 0;
let Chris = 0;
rl.on("line", item => {
  if (!item) return rl.close();

  element.push(item);
}).on("close", solveProblem);

function solveProblem() {
  //   let test = element.splice(0, 1);
  element.splice(0, 1);
  element.forEach(x => {
    let temp = x.split(" ").map(num => parseInt(num));
    let Mi = temp[0];
    let Ci = temp[1];

    if (Mi > Ci) Mishka++;
    if (Mi < Ci) Chris++;
  });

  const result =
    Mishka === Chris
      ? "Friendship is magic!^^"
      : Mishka > Chris
      ? "Mishka"
      : "Chris";

  console.log(result);
}

function main() {
    // write code here:
    const n=Number(stdin[0]);
    var mishka=0;
    var chris=0;
    var name;
    for(let i=1;i<=n;i++){
        var arr=stdin[i].split(' ').map(Number);
        var m=arr[0];
        var c=arr[1];
        if(m>c){
            mishka+=1;
        }else if (m<c){
            chris+=1;
        }
    }
    if(mishka>chris){
        name='Mishka';
    }else if (mishka<chris){
        name='Chris';
    } else{
        name='Friendship is magic!^^';
    }
    console.log(name);
}

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);

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

let input = [];
readLine.on('line', line => input.push(line));

readLine.on('close', () => {
    let mishkaWins = 0
    let chrisWins = 0
    let friend = 0
    let result = 'Friendship is magic!^^'
    const games = [...input.slice(1)]
    games.forEach(item => {
        const res = item.split(' ')
        let mishka = parseInt(res[0], 10)
        let chris = parseInt(res[1], 10)
        if (mishka > chris)
            mishkaWins++
        else if (chris > mishka)
            chrisWins++
        else
            friend++
    })
    if (mishkaWins !== 0 || chrisWins !== 0) {
        if (mishkaWins > chrisWins) {
            result = 'Mishka'
        } else if (mishkaWins < chrisWins) {
            result = 'Chris'
        }
    }
    console.log(result)
})

//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");
  var start = Date.now();
  Main();
  var end = Date.now() - start;
  myerr("time : " + (end) + "ms");
  myerr("memory : " + Math.round(process.memoryUsage().heapTotal / 1024) + "KB");
});
function makeClone(obj){return 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 Mishka = 0;
  var Chris = 0;
  for(var i = 0; i < N; i++){
    var tmp = nextIntArray();
    if(tmp[0] > tmp[1]){
      Mishka++;
    }else if(tmp[0] < tmp[1]){
      Chris++;
    }
  }
  if(Mishka > Chris){
    myout("Mishka");
  }else if(Mishka < Chris){
    myout("Chris");
  }else{
    myout("Friendship is magic!^^");
  }
}

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

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

  let [a, b] = d.split(' ').map(Number);

  if (a > b) {
    x++;
  }
  else if (b > a) {
    y++;
  }

  c++;
});

rl.on('close', () => {
  if (x > y) {
    console.log('Mishka');
  }
  else if (y > x) {
    console.log('Chris');
  }
  else {
    console.log('Friendship is magic!^^');
  }
});

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

const input = [];
readLine.on('line', line => input.push(line));

readLine.on('close', () => {
  let [n] = input[0].split(' ').map(x => parseInt(x));
  let m = 0, c = 0;

  input.forEach((x, i) => {
    if (i === 0) return;
    const nums = x.split(' ').map(x => parseInt(x));
    if (nums[0] > nums[1]) m += 1;
    else if (nums[0] < nums[1]) c += 1;
  });

  if (m === c) console.log(`Friendship is magic!^^`)
  else if (m > c) console.log(`Mishka`)
  else console.log(`Chris`)
});

// Sample code to perform I/O:

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

process.stdin.on("data", function (input) {
    stdin_input += input;                               // Reading input from STDIN
});

process.stdin.on("end", function () {
    main(stdin_input);
});

function splitter(str, seperator = '') {
    return str.trim().split(seperator);
}
function main(input) {
    let output = nameLookUp(input);
    process.stdout.write(output);       // Writing output to STDOUT
}

// Warning: Printing unwanted or ill-formatted data to output will cause the test cases to fail

// Write your code here
function nameLookUp(str) {

    let inputs = str.trim().split('\n');
    let rounds = +inputs[0];
    let roundScores = inputs.slice(1);
    let win = 0;
    let msg = 'Mishka';
    while (rounds--) {
        let roundScore = roundScores[rounds];
        let score = splitter(roundScore, ' ');
        if (+score[0] > +score[1]) {
            win++;
        }
        else if (+score[0] < +score[1]) {
            win--;
        }
    }

    if (win > 0) {
        msg = 'Mishka';
    }
    else if (win < 0) {
        msg = 'Chris';
    }
    else {
        msg = 'Friendship is magic!^^';
    }

    return msg.toString();
}

'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.replace(/\s*$/, '')
        .split('\n')
        .map(str => str.replace(/\s*$/, ''));

    main();
});

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

function main() {
    let n = parseInt(readLine());
    let am = 0;
    let ac = 0;
    for (var i = 0; i < n; i++) {
        let mc = readLine().split(' ').map(v => parseInt(v))
        let m = mc[0];
        let c = mc[1];
        if (m > c) {
            am++;
        } else if (m < c) {
            ac++;
        }
    }
    if (am > ac) {
        console.log('Mishka');
    } else if (am == ac) {
        console.log('Friendship is magic!^^');
    } else {
        console.log('Chris');
    }
}

var n = +readline();

var mc = 0, cc = 0;
for(var i = 0; i < n; i++){
    var input = readline().split(" ").map(Number);
    var m = input[0], c = input[1];

    if(m > c){
        mc++;
    }else if(m < c){
        cc++;
    }
}

if(mc > cc){
    write("Mishka");
}else if(mc < cc){
    write("Chris");
}else{
    write("Friendship is magic!^^");
}

function cmp(x){
	return parseInt(x);
}
var n = parseInt(readline());
var a = [];
for(var i = 0; i < n; i++){
	a[i] = readline().split(" ").map(cmp);
}
var awin = 0, bwin = 0;
	var result='';
	for(var i = 0; i < n; i++)
	{
		if(a[i][0] > a[i][1]){
			awin ++;
		}
		else if(a[i][0] < a[i][1]){
			bwin ++;
		}
		else{
			continue;
		}
	}
	if(awin > bwin){
		result='Mishka';
	}
	else if(awin < bwin){
		result='Chris';
	}
	else{
		result='Friendship is magic!^^';
	}
	print(result);

var res = sol(readline());
print(res);

function sol(line1) {
    var input1 = line1.split(" ").map((x) => Number(x));

    var n = input1[0];

    var mishka = 0;
    var chris = 0;

    while (n > 0) {
        var line = readline().split(" ").map((x) => Number(x));

        if (line[0] > line[1]) {
            mishka++;
        } else if (line[0] < line[1]) {
            chris++;
        }

        n--;
    }

    var winner = "";
    if (mishka > chris) {
        winner = "Mishka";
    } else if (mishka < chris) {
        winner = "Chris";
    } else {
        winner = "Friendship is magic!^^";
    }

    return winner;
}

(function() {
    'use strict';
    const n = readline();
    let m = 0;
    let c = 0;
    for (let i = 0; i < n; ++i) {
        const z = readline().split(' ').map(Number);
        if (z[0] > z[1]) {
            m += 1;
        } else if (z[0] < z[1]) {
            c += 1;
        }
    }
    if (m > c) {
        print('Mishka');
    } else if (m < c) {
        print('Chris');
    } else {
        print('Friendship is magic!^^');
    }

}());

var n = +readline();
var obj = {}, str, b = false, res = 0, a, b;

for(var i = 0; i < n; i++) {
    str = readline().split(' ');
    a = +str[0]; b = +str[1];
    if (a > b) res++;
    if (a < b) res--;
}

if (res == 0)
    print("Friendship is magic!^^");
else if (res > 0)
    print("Mishka");
else
    print("Chris");
//print(res);

var n = readline();
var a = [];
var i = 0;
var count_m = 0,
  count_c = 0;
while (i < n) {
  a = readline()
    .split(" ")
    .map((a) => parseInt(a));
  if (a[0] > a[1]) {
    count_m++;
  } else if (a[0] < a[1]) {
    count_c++;
  }
  i++;
}
if (count_m > count_c) print("Mishka");
else if (count_c > count_m) print("Chris");
else print("Friendship is magic!^^");

n=Number(readline())
mishka=0,chris=0
for (var i=0;i<n;i++) {
    var score=readline().split(' ');
    if (score[0]>score[1]){
        mishka++;
    }
    else if (score[0]<score[1]) {
        chris++;
}
}
if (mishka>chris){
    print('Mishka');
}
else if (mishka<chris){
 print('Chris');
}
else{
 print('Friendship is magic!^^');
}

var n = readline();
var m =0; var chris = 0;
for (var i=0; i<n; i++){
	var str = readline().split(" ");
	if (str[0]>str[1])
		m++;
	else if (str[0]<str[1])
		chris++;
	else {m++, chris++}
}
if (m>chris)
		print("Mishka");
	else if (m<chris)
		print("Chris");
	else
	print("Friendship is magic!^^");

var roundsCount = parseInt(readline(), 10);
var wins = {
	f: 0,
	m: 0,
	c: 0,
};

function getWinner(a, b) {
	if (a === b) return 'f';
	if (a < b) return 'c';
	if (a > b) return 'm';
}

for (var i = 0; i < roundsCount; i++) {
	var results = readline().split(' ').map(function (result) {
		return parseInt(result);
	});
	wins[getWinner(results[0], results[1])]++;
}

if (wins['m'] === wins['c']) {
	print('Friendship is magic!^^');
} else if (wins['m'] > wins['c']) {
	print('Mishka');
} else if (wins['m'] < wins['c']) {
	print('Chris');
}

var N = +readline(),
    f = 0, s = 0, arr,
    w1 = 'Mishka',
    w2 = 'Chris',
    w3 = 'Friendship is magic!^^';

while (N--) {
    arr = readline().split(' ');
    f += arr[0] >= arr[1] ? 1 : 0;
    s += arr[0] <= arr[1] ? 1 : 0;
}

print(f === s ? w3 : (f > s ? w1 : w2));

var nline = readline();
var n = parseInt(nline);

var count = 0;

for(i=0;i<n;i++){

    var line = readline().split(' ').map(Number);
    var m = line[0];
    var c = line[1];

    if(m>c){
	count+=1;
    } else if(m<c){
	count-=1;
    } else{
	continue;
    }
}

if(count>0){
    print('Mishka');
} else if(count<0){
    print('Chris');
}else{
    print('Friendship is magic!^^');
}

"use strict";

var main = function() {
    var n = +rd();
    var r = 0;

    for (var i = 0; i < n; ++i) {
        var input = rdAr();
        var m = input[0];
        var c = input[1];
        r += Math.sign(c - m);
    }

    wr(['Mishka', 'Friendship is magic!^^', 'Chris'][Math.sign(r) + 1]);
};

var rd = readline;
var wr = write;
var pr = print;
var rdAr = () => rd().split(' ').map(v => +v);
var cmpLt = (a, b) => a - b;
var cmpGt = (a, b) => b - a;

main();

n=Number(readline())
m=0,c=0
for (var i=0;i<n;++i) {
    var X=readline().split(' ').map(Number)
    if (X[0]>X[1]) ++m
    else if (X[0]<X[1]) ++c;
}
if (m>c) print('Mishka')
else if (m<c) print('Chris')
else print('Friendship is magic!^^')

if (!readline) {
    var _i = 0;
    var readline = function() {
        _i ++;

        switch (_i) {
            case 1: return '3';
            case 2: return '3 5';
            case 3: return '2 1';
            case 4: return '4 2';
        }
    }

    var write = console.log;
}

var n = +readline();

var m = 0;
var c = 0;

for (var i = 0; i < n; i ++) {
    var d = readline().split(' ').map(function(currentValue) {
        return +currentValue;
    });

    m += d[0] > d[1];
    c += d[0] < d[1];
}

if (m > c) {
    write('Mishka');
} else if (m < c) {
    write('Chris');
} else {
    write('Friendship is magic!^^');
}

// var n = 3;

var n = parseInt(readline());
var m = 0;
var c = 0;

// var a = [[3,3], [2,2], [4,4]];

for (var i = 0; i<n; ++i) {

    // var arr = a[i];
    var arr = readline().split(" ").map(function(x) { return parseInt(x); });

    if (arr[0] > arr[1]) {
        ++m;
    } else if (arr[0] < arr[1]) {
        ++c;
    }
}

if (m > c) {
    write("Mishka");
} else if(m<c) {
    write("Chris");
} else {
    write("Friendship is magic!^^");
}

// function write(n) {
//     console.log(n);
// }

var rounds = readline();
var mishka = 0, chris = 0;
for(var i = 0; i < rounds; ++i){
  var round = readline().split(" ");
  if(round[0] > round[1]){
    mishka++;
  }
  else if(round[1] > round[0]){
    chris++;
  }
}
if(mishka === chris){
  print("Friendship is magic!^^")
}
else if(mishka > chris){
  print("Mishka");
}
else {
  print("Chris")
}

function cmp(x){
	return parseInt(x);
}
function main(){
	var n = parseInt(readline());
	var a = [];
	for(var i = 0; i < n; i++){
		a[i] = readline().split(" ").map(cmp);
	}
	var temp = test(a);
	print(temp);
}
function test(){
	//var a =[[3,5],[1,2],[4,2]];
	var awin = 0, bwin = 0;
	var result='';
	for(var i = 0; i < n; i++)
	{
		if(a[i][0] > a[i][1]){
			awin ++;
		}
		else if(a[i][0] < a[i][1]){
			bwin ++;
		}
		else{
			continue;
		}
	}
	if(awin > bwin){
		result='Mishka';
	}
	else if(awin < bwin){
		result='Chris';
	}
	else{
		result='Friendship is magic!^^';
	}
	return result;
}

var roundsCount = parseInt(readline(), 10);
var wins = {
	f: 0,
	m: 0,
	c: 0,
};

function getWinner(a, b) {
	if (a === b) return 'f';
	if (a < b) return 'c';
	if (a > b) return 'm';
}

for (var i = 0; i < roundsCount; i++) {
	var results = readline().split(' ').map((result) => parseInt(result));
	wins[getWinner(results[0], results[1])]++;
}

var sortedResults = Object
	.keys(wins)
	.sort((a, b) => wins[a] - wins[b]);

var resultsHash = {
	f: 'Friendship is magic!^^',
	m: 'Mishka',
	c: 'Chris',
};

print(resultsHash[sortedResults[0]]);


You are given some Tetris field consisting of $$$n$$$ columns. The initial height of the $$$i$$$-th column of the field is $$$a_i$$$ blocks. On top of these columns you can place only figures of size $$$2 \times 1$$$ (i.e. the height of this figure is $$$2$$$ blocks and the width of this figure is $$$1$$$ block). Note that you cannot rotate these figures.Your task is to say if you can clear the whole field by placing such figures.More formally, the problem can be described like this:The following process occurs while at least one $$$a_i$$$ is greater than $$$0$$$:  You place one figure $$$2 \times 1$$$ (choose some $$$i$$$ from $$$1$$$ to $$$n$$$ and replace $$$a_i$$$ with $$$a_i + 2$$$);  then, while all $$$a_i$$$ are greater than zero, replace each $$$a_i$$$ with $$$a_i - 1$$$. And your task is to determine if it is possible to clear the whole field (i.e. finish the described process), choosing the places for new figures properly.You have to answer $$$t$$$ independent test cases.

The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. The next $$$2t$$$ lines describe test cases. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 100$$$) — the number of columns in the Tetris field. The second line of the test case contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 100$$$), where $$$a_i$$$ is the initial height of the $$$i$$$-th column of the Tetris field.

For each test case, print the answer — "YES" (without quotes) if you can clear the whole Tetris field and "NO" otherwise.

NoteThe first test case of the example field is shown below:Gray lines are bounds of the Tetris field. Note that the field has no upper bound.One of the correct answers is to first place the figure in the first column. Then after the second step of the process, the field becomes $$$[2, 0, 2]$$$. Then place the figure in the second column and after the second step of the process, the field becomes $$$[0, 0, 0]$$$.And the second test case of the example field is shown below:It can be shown that you cannot do anything to end the process.In the third test case of the example, you first place the figure in the second column after the second step of the process, the field becomes $$$[0, 2]$$$. Then place the figure in the first column and after the second step of the process, the field becomes $$$[0, 0]$$$.In the fourth test case of the example, place the figure in the first column, then the field becomes $$$[102]$$$ after the first step of the process, and then the field becomes $$$[0]$$$ after the second step of the process.

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

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

process.stdin.on('end', () => {
  arr = arr.split('\n').map(a => a.replace(/(\r\n|\n|\r)/gm, ''))
  main(arr)
})

function wr(...x) {
  console.log(...x)
}

function sort(a, inc = true) {
  if(inc) a.sort((a, b) => a - b)
  else a.sort((a, b) => b - a)
}

function readInt(a) {
  return parseInt(a[ptr++])
}

function readString(a) {
  return a[ptr++]
}

function readStrings(a) {
  return a[ptr++].split(' ')
}

function readInts(a) {
  return a[ptr++].split(' ').map(a => parseInt(a))
}

function main(input) {
  let t = readInt(input)
  while(t--) {
    const n = readInt(input)
    const aI = readInts(input)
    let max = Math.max(...aI)
    let f = false
    for(let i = 0; i < n && !f; i++) {
      if((max - aI[i]) % 2 === 1) f = true
    }
    if(f) wr('NO')
    else wr('YES')
  }
}

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

  if (c % 2) {
    c++;
    return;
  }

  const arr = d.split(' ').map(Number);
  let isOdd = false;
  let isEven = false;

  for (let i = 0; i < arr.length; i++) {
    if (arr[i] % 2) {
      isOdd = true;
    }
    else {
      isEven = true;
    }
  }

  if (isOdd && isEven) {
    console.log('NO');
  }
  else {
    console.log('YES');
  }

  c++;
});

process.stdin.resume();
process.stdin.setEncoding('utf-8')
let inputString = '';
let currentLine = 0;
process.stdin.on('data', input => { inputString += input })
process.stdin.on('end', _ => { inputString = inputString.trim().split('\n').map(str => str.trim()); main() })
const readline = () => { return inputString[currentLine++] }

function main(){
	let tests = parseInt(readline())
	for (let i = 0; i < tests; i++) {
		let num = parseInt(readline());
		let arr = readline().split(' ').map(x => parseInt(x))
		let od = 0, ev = 0;
		arr.forEach(x => {
			if (x & 1) od++;
			else ev++;
		});
		if (!ev || !od) console.log("YES");
		else console.log("NO");
	}
}

'use strict'

const getLine = () => readline().split(' ')
const getInts = () => getLine().map(n => parseInt(n))
const getInt = () => getInts()[0]
const D = (...args) => { // D({name})
  [...args].forEach(cur => print.apply(print, [JSON.stringify(cur)]))
}

main()

function main() {
  let t = getInt()
  while (t-- > 0) {
    const n = getInt()
    const arr = getInts()
    let ok = true

    const mx = arr.reduce((out, cur) => {
      return Math.max(out, cur)
    }, 0)

    for (let i in arr) {
      if ((mx - arr[i]) % 2) ok = false
    }

    print(ok ? 'YES' : 'NO')
  }
}

var t = Number(readline());
for(var r=0;r<t;r++){
 var n = Number(readline());
 var a = readline().split(' ').map(x => Number(x));
 var m = Math.max.apply(null, a);
 for(var i=0; i<n; i++){
  if((m-a[i])&1)
   break;
 }
 print((i==n)?"YES":"NO");
}

Main();
function myout(t){print(t);}//standard output
function next(){return readline();}
function nextInt(){return myconv(next(),1);}
function nextStrArray(){return myconv(next(),2);}//半角スペース分割
function nextIntArray(){return myconv(next(),4);}//半角スペース + 数値化
function nextCharArray(){return myconv(next(),6);}//1文字分割
//[no]要素の扱い。数値型
//不明値、異常時:引数そのまま返す
//6:1文字に分割  7:1文字に分割し、数値配列へ
//8:半角SPで結合　9:改行で結合　0:文字なしで結合
//atcoderのサンプルは最後に改行入れること
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map((a)=>Number(a));case 6:return i.split("");case 7:return i.split("").map((a)=>Number(a));case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}catch(e){return i;}}
function Main() {
    var t = nextInt();
    var output = new Array(t);
    for(var i = 0; i < t; i++){
        var n = nextInt();
        var list = nextIntArray();
        var odd = 0;
        var even = 0;
        for(var j = 0; j < n; j++){
            if(list[j] % 2 == 0){
                even++;
            }else{
                odd++;
            }
        }
        if(odd != 0 && even != 0){
            output[i] = "NO";
        }else{
            output[i] = "YES";
        }
    }
    myout(myconv(output,9));
}

var toInt = x =>parseInt(x);

var t = parseInt(readline());

for(var tt=0;tt<t;tt++) {

    readline();

    var a = readline().split(' ').map(toInt);

    var max = a.reduce( (i, j) => (Math.max(i, j)) );
    var pass = true;
    //print(a.join(' '))
    a.forEach( v => (pass &= (max-v)%2 === 0 ) );
    print(pass ? "YES":"NO");

}

var t = readline();
for (var i = 0; i<t; i++){
    var k = readline();
    var m = readline().split(' ');
    var del = 0;
    var undel=0;
    for (var j=0; j<k; j++){
        if (m[j] % 2 !==0){
            undel=undel+1
        }
        if (m[j] % 2=== 0 ){
            del =del+1
        }
    }
    if (del==k || undel ==k){
            print("YES");
        } else {
            print("NO");
        }
}

var t = parseInt(readline());
while (t--) {
  var n = parseInt(readline());
  var str = readline();
  var nums = str.split(' ').map(Number);
  var ost = nums[0] % 2
  var not = nums.find(num => num % 2 !== ost)
  print(not ? 'NO' : 'YES')
}

var t = Number(readline());
var n;
var a;
var obj = {
    even: 0,
    odd: 0
}
for(var i = 0 ; i < t; i++){
    n = Number(readline());
    obj.even = 0;
    obj.odd = 0;
    a = readline().split(" ").map(cur => {
      Number(cur)%2 === 0 ? obj.even++ : obj.odd++ ;
    } );

    (obj.even !== 0 && obj.odd !== 0) ? print("NO") : print("YES");
}
//

process.stdin.resume();
process.stdin.setEncoding('utf-8')
let inputString = '';
let currentLine = 0;
process.stdin.on('data', input => { inputString += input })
process.stdin.on('end', _ => { inputString.trim().split('\n').map(str => str.trim()) })
const readline = () => { return inputString[currentLine++] }

let tests = parseInt(readline())
for(let i = 0; i < tests; i++){
	let num = parseInt(readline());
	let arr = readline().split(' ').map(x => parseInt(x))
	let od = 0, ev = 0;
	arr.forEach(x => {
		if(x & 1) od++;
		else ev++;
	});
	if(!ev || !od) console.log("YES");
	else console.log("NO");
}

'use strict'

const getLine = () => readline().split(' ')
const getInts = () => getLine().map(n => parseInt(n))
const getInt = () => getInts()[0]
const D = (...args) => { // D({name})
  [...args].forEach(cur => print.apply(print, [JSON.stringify(cur)]))
}

main()

function main() {
  let t = getInt()
  while (t --> 0) {
    const n = getInt()
    const arr = getInts()
    let limit = 5
    let ok = false
    while (limit --> 0 && !ok) {
      let mm = 1e9
      for (let i in arr) {
        mm = Math.min(mm, arr[i])
      }

      for (let i = 0; i < n; ++i) {
        if (arr[i] === mm) {
          if (i + 1 < n && arr[i + 1] === mm) {
            arr[i] ++
            arr[i + 1] ++
          } else {
            arr[i] ++
            arr[i] ++
          }

          const st = new Set(arr)
          if (st.size === 1) {
            ok = true
            break
          }
        }
      }
    }

    print(ok ? 'YES' : 'NO')
  }
}

'use strict'

const getLine = () => readline().split(' ')
const getInts = () => getLine().map(n => parseInt(n))
const getInt = () => getInts()[0]
const D = (...args) => { // D({name})
  [...args].forEach(cur => print.apply(print, [JSON.stringify(cur)]))
}

main()

function main() {
  let t = getInt()
  while (t --> 0) {
    const n = getInt()
    const arr = getInts()
    let limit = 333
    let ok = false
    while (limit --> 0) {
      let mm = 1e9
      for (let i in arr) {
        mm = Math.min(mm, arr[i])
      }

      for (let i = 0; i < n; ++i) {
        if (arr[i] === mm) {
          if (i + 1 < n && arr[i + 1] === mm) {
            arr[i] ++
            arr[i + 1] ++
          }

          const st = new Set(arr)
          if (st.size === 1) {
            ok = true
            break
          }
        }
      }
    }

    print(ok ? 'YES' : 'NO')
  }
}

'use strict'

const getLine = () => readline().split(' ')
const getInts = () => getLine().map(n => parseInt(n))
const getInt = () => getInts()[0]
const D = (...args) => { // D({name})
  [...args].forEach(cur => print.apply(print, [JSON.stringify(cur)]))
}

main()

function main() {
  let t = getInt()
  while (t-- > 0) {
    const n = getInt()
    const arr = getInts()
    let limit = 33
    let ok = false
    let mx = 0
    for (let i in arr) {
      mx = Math.max(mx, arr[i])
    }

    while (limit-- > 0 && !ok) {
      for (let i = 0; i < n; ++i) {
        if (arr[i] < mx) {
          arr[i] += 2

          const st = new Set(arr)
          if (st.size === 1) {
            ok = true
            break
          }
        }
      }
    }

    const st = new Set(arr)
    if (st.size === 1) {
      ok = true
    }

    print(ok ? 'YES' : 'NO')
  }
}

'use strict'

const getLine = () => readline().split(' ')
const getInts = () => getLine().map(n => parseInt(n))
const getInt = () => getInts()[0]
const D = (...args) => { // D({name})
  [...args].forEach(cur => print.apply(print, [JSON.stringify(cur)]))
}

main()

function main() {
  let t = getInt()
  while (t --> 0) {
    const n = getInt()
    const arr = getInts()
    let limit = 1000
    let ok = false
    while (limit --> 0 && !ok) {
      let mm = 1e9
      for (let i in arr) {
        mm = Math.min(mm, arr[i])
      }

      for (let i = 0; i < n; ++i) {
        if (arr[i] === mm) {
          if (i + 1 < n && arr[i + 1] === mm) {
            arr[i] ++
            arr[i + 1] ++
          } else {
            arr[i] ++
            arr[i] ++
          }

          const st = new Set(arr)
          if (st.size === 1) {
            ok = true
            break
          }
        }
      }
    }

    print(ok ? 'YES' : 'NO')
  }
}

'use strict'

const getLine = () => readline().split(' ')
const getInts = () => getLine().map(n => parseInt(n))
const getInt = () => getInts()[0]
const D = (...args) => { // D({name})
  [...args].forEach(cur => print.apply(print, [JSON.stringify(cur)]))
}

main()

function main() {
  let t = getInt()
  while (t --> 0) {
    const n = getInt()
    const arr = getInts()
    let limit = 333
    let ok = false
    while (limit --> 0) {
      let mm = 1e9
      for (let i in arr) {
        mm = Math.min(mm, arr[i])
      }

      for (let i = 0; i < n; ++i) {
        if (arr[i] === mm) {
          if (i + 1 < n && arr[i + 1] === mm) {
            arr[i] ++
            arr[i + 1] ++
          } else {
            arr[i] ++
            arr[i] ++
          }

          const st = new Set(arr)
          if (st.size === 1) {
            ok = true
            break
          }
        }
      }
    }

    print(ok ? 'YES' : 'NO')
  }
}

'use strict'

const getLine = () => readline().split(' ')
const getInts = () => getLine().map(n => parseInt(n))
const getInt = () => getInts()[0]
const D = (...args) => { // D({name})
  [...args].forEach(cur => print.apply(print, [JSON.stringify(cur)]))
}

main()

function main() {
  let t = getInt()
  while (t --> 0) {
    const n = getInt()
    const arr = getInts()
    let limit = 333
    let ok = false
    while (limit --> 0 && !ok) {
      let mm = 1e9
      for (let i in arr) {
        mm = Math.min(mm, arr[i])
      }

      for (let i = 0; i < n; ++i) {
        if (arr[i] === mm) {
          if (i + 1 < n && arr[i + 1] === mm) {
            arr[i] ++
            arr[i + 1] ++
          }

          const st = new Set(arr)
          if (st.size === 1) {
            ok = true
            break
          }
        }
      }
    }

    print(ok ? 'YES' : 'NO')
  }
}

'use strict'

const getLine = () => readline().split(' ')
const getInts = () => getLine().map(n => parseInt(n))
const getInt = () => getInts()[0]
const D = (...args) => { // D({name})
  [...args].forEach(cur => print.apply(print, [JSON.stringify(cur)]))
}

main()

function main() {
  let t = getInt()
  while (t --> 0) {
    const n = getInt()
    const arr = getInts()
    let limit = 1000
    let ok = false
    while (limit --> 0 && !ok) {
      let mm = 1e9
      for (let i in arr) {
        mm = Math.min(mm, arr[i])
      }

      for (let i = 0; i < n; ++i) {
        if (arr[i] === mm) {
          if (i + 1 < n && arr[i + 1] === mm) {
            arr[i] ++
            arr[i + 1] ++
          }

          const st = new Set(arr)
          if (st.size === 1) {
            ok = true
            break
          }
        }
      }
    }

    print(ok ? 'YES' : 'NO')
  }
}

'use strict'

const getLine = () => readline().split(' ')
const getInts = () => getLine().map(n => parseInt(n))
const getInt = () => getInts()[0]
const D = (...args) => { // D({name})
  [...args].forEach(cur => print.apply(print, [JSON.stringify(cur)]))
}

main()

function main() {
  let t = getInt()
  while (t --> 0) {
    const n = getInt()
    const arr = getInts()
    let ok = true

    for (let i = 1; i + 1 < n; ++i) {
      const a = Math.abs(arr[i] - arr[i - 1])
      const b = Math.abs(arr[i] - arr[i + 1])
      if (a === b && a === 1) {
        ok = false
        break
      }
    }

    print(ok ? 'YES' : 'NO')
  }
}

'use strict'

const getLine = () => readline().split(' ')
const getInts = () => getLine().map(n => parseInt(n))
const getInt = () => getInts()[0]
const D = (...args) => { // D({name})
  [...args].forEach(cur => print.apply(print, [JSON.stringify(cur)]))
}

main()

function main() {
  let t = getInt()
  while (t --> 0) {
    const n = getInt()
    const arr = [1e9, ...getInts(), 1e9]
    let ok = true

    for (let i = 1; i + 1 < arr.length; ++i) {
      if (arr[i] < arr[i - 1] && arr[i] < arr[i + 1]) {
        ok = false
        break
      }
    }

    if (n === 1) ok = true
    print(ok ? 'YES' : 'NO')
  }
}

var t = readline();
for (var i = 0; i<t; i++){
    var k = readline();
    var m = readline().split(' ');
    var del = 0;
    var undel=0;
    for (var j=0; j<k; j++){
        if (m[j] % 2 ===0){
            undel=undel+1
        }
        if (m[j] % 2=== 0 ){
            del =del+1
        }
    }
    if (undel | del===k){
            print("NO");
        } else {
            print("YES");
        }
}

var t = readline();
var m = [];
for (var i = 0; i<t; i++){
    m.push(readline());
}
print(m);

var t = readline();
for (var i = 0; i<t; i++){
    var k = readline();
    var m = readline().split(' ');
    var del = 0;
    var undel=0;
    for (var j=0; j<k; j++){
        if (m[j] % 2 !==0){
            undel=undel+1
        }
        if (m[j] % 2=== 0 ){
            del =del+1
        }
    }
    print(undel,del,k);
    if (del==k || undel ==k){
            print("YES");
        } else {
            print("NO");
        }
}

var t = readline();
for (var i = 0; i<t; i++){
    var k = readline();
    var m = readline().split(' ');
    var del = 0;
    var undel=0;
    for (var j=0; j<k; j++){
        if (m[j] % 2 !==0){
            undel=undel+1
        }
        if (m[j] % 2=== 0 ){
            del =del+1
        }
    }
    if (undel | del===k){
            print("YES");
        } else {
            print("NO");
        }
}

var t = readline();
for (var i = 0; i<t; i++){
    var k = readline();
    var m = readline().split(' ');
    var del = 0;
    var undel=0;
    for (var j=0; j<k; j++){
        if (m[j] % 2 ===0){
            undel=undel+1
        }
        if (m[j] % 2=== 0 ){
            del =del+1
        }
    }
    if (undel | del===k){
            print("YES");
        } else {
            print("NO");
        }
}

var t = parseInt(readline());
while (t--) {
  var n = parseInt(readline());
  var result = ''
  var str = readline();
  var nums = str.split(' ').map(Number);
  if (nums.length === 1) {
    print('YES')
    continue;
  }
  nums.sort()
  var min = nums[0];
  var max = nums[nums.length - 1]
  if ((max - min) % 2 === 1 ) {
    result = 'NO'
  } else {
    for(var i = 0; i < nums.length; i++) {
      if ((max - nums[i]) % 2 === 1) {
        result = 'NO'
        break
      }
    }
  }
  print(result || 'YES')
}


An L-shape is a figure on gridded paper that looks like the first four pictures below. An L-shape contains exactly three shaded cells (denoted by *), which can be rotated in any way.  You are given a rectangular grid. Determine if it contains L-shapes only, where L-shapes can't touch an edge or corner. More formally:   Each shaded cell in the grid is part of exactly one L-shape, and  no two L-shapes are adjacent by edge or corner. For example, the last two grids in the picture above do not satisfy the condition because the two L-shapes touch by corner and edge, respectively.

The input consists of multiple test cases. The first line contains an integer $$$t$$$ ($$$1 \leq t \leq 100$$$) — the number of test cases. The description of the test cases follows. The first line of each test case contains two integers $$$n$$$ and $$$m$$$ ($$$1 \leq n, m \leq 50$$$) — the number of rows and columns in the grid, respectively. Then $$$n$$$ lines follow, each containing $$$m$$$ characters. Each of these characters is either '.' or '*' — an empty cell or a shaded cell, respectively.

For each test case, output "YES" if the grid is made up of L-shape that don't share edges or corners, and "NO" otherwise. You can output the answer in any case (for example, the strings "yEs", "yes", "Yes" and "YES" will be recognized as a positive answer).

var t = parseInt(readline());
var vis = []
var di = [-1, -1, -1, 0, 1, 1,  1,  0];
var dj = [-1,  0,  1, 1, 1, 0, -1, -1];
function Queue(){
        this.arr = [];
        this.front = 0;
        this.rear = -1;

    this.top = function(){
        return this.arr[this.front];
    }
    this.push = function(el){
        this.arr.push(el)
        this.rear++;
    }
    this.pop = function (){
        var top = this.top();
        this.front++;
        return top;
    }
    this.empty = function(){
        return this.rear < this.front
    }
}
function inBounds(i, j, arr){
    return i >= 0 && i < arr.length && j >= 0 && j < arr[0].length;
}

function bfs(i, j, arr){

    var q = new Queue();
    var allP = [];

    q.push({i, j});
    vis[i][j] = true;
    allP.push(q.top());
    while(!q.empty()){
        var crnt = q.pop();

        for(var x = 0; x < di.length; x++){
            var newI = crnt.i + di[x];
            var newJ = crnt.j + dj[x];
            if(inBounds(newI, newJ, arr) && arr[newI][newJ] === "*" && !vis[newI][newJ]){
                vis[newI][newJ] = true;
                q.push({i: newI, j: newJ});
                allP.push({i: newI, j: newJ})
            }
        }

    }
    if(allP.length === 3){
        var iS = allP.map((a) => a.i)
        var jS = allP.map((a) => a.j)
        var iDiff = Math.max(...iS) - Math.min(...iS)
        var jDiff = Math.max(...jS) - Math.min(...jS)

        if(iDiff === 1 && jDiff === 1) return true;

    }
    return false;

}

while(t--){

    var nm = readline().split(" ").map((a) => parseInt(a));

    var n = nm[0];
    var m = nm[1];
    var shapes = [];

    for(var i = 0; i < n; i++){
        shapes.push(readline());
        vis[i] = new Array(m).fill(false);
    }

    var allIsL = true;
    for(var i = 0; i < n; i++){
        for(var j = 0; j < m; j++){
            if(shapes[i][j] === "*" && !vis[i][j]){
                if(!bfs(i, j, shapes))allIsL = false;
            }
        }
    }

    allIsL? print("YES") : print("NO");

}

const readline = require('readline')

const rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
})
const lines = []
rl.on('line', (input) => {
    lines.push(input);
})
rl.on('close', () => {
// (function() {
    // const lines = require('fs').readFileSync('test.in', 'utf8').split('\n')
    let l = 0;
    let t = +lines[l++]
    const output = []
    for (let i = 0; i < t; i++) {
        const [n, m] = lines[l++].trim().split(' ').map(Number)
        const grid = lines.slice(l, l + n).map(str => str.trim())
        l += n
        output[i] = solve(n, m, grid) ? 'YES' : 'NO'
    }
    console.log(output.join('\n'))
// })()
})

function solve(n, m, grid) {
    const ns = []
    for (let i = 0; i < n; i++) {
        ns[i] = []
        for (let j = 0; j < m; j++) {
            ns[i][j] = count(i, j)
        }
    }
    // console.log(ns)
    //
    let one = 0
    let two = 0
    for (let i = 0; i < n; i++) {
        for (let j = 0; j < m; j++) {
            if (grid[i][j] === '.') continue
            const [c4, c8] = ns[i][j]
    // console.log(i, j, c4, c8)
            if (c4 === 2) {
                if (c8 !== 2) return false
                two++
            } else if (c4 === 1) {
                if (c8 !== 2) return false
                one++
            } else {
                return false
            }
        }
    }
    // console.log(one, two)
    return one === two * 2
    //
    function count(i, j) {
        const r = []
        let c = 0
        if (i + 1 < n && grid[i + 1][j] === '*') c++
        if (i - 1 >= 0 && grid[i - 1][j] === '*') c++
        if (j + 1 < m && grid[i][j + 1] === '*') c++
        if (j - 1 >= 0 && grid[i][j - 1] === '*') c++
        r.push(c)
        if (i + 1 < n && j + 1 < m && grid[i + 1][j + 1] === '*') c++
        if (i + 1 < n && j - 1 >= 0 && grid[i + 1][j - 1] === '*') c++
        if (i - 1 >= 0 && j + 1 < m && grid[i - 1][j + 1] === '*') c++
        if (i - 1 >= 0 && j - 1 >= 0 && grid[i - 1][j - 1] === '*') c++
        r.push(c)
        return r
    }
}

var t = parseInt(readline());
var vis = []
var di = [-1, -1, -1, 0, 1, 1,  1,  0];
var dj = [-1,  0,  1, 1, 1, 0, -1, -1];
function Queue(){
        this.arr = [];
        this.front = 0;
        this.rear = -1;

    this.top = function(){
        return this.arr[this.front];
    }
    this.push = function(el){
        this.arr.push(el)
        this.rear++;
    }
    this.pop = function (){
        var top = this.top();
        this.front++;
        return top;
    }
    this.empty = function(){
        return this.rear < this.front
    }
}
function inBounds(i, j, arr){
    return i >= 0 && i < arr.length && j >= 0 && j < arr[0].length;
}

function bfs(i, j, arr){

    var q = new Queue();
    var h = 0, v = 0, cells = 1;

    q.push({i, j});
    vis[i][j] = true;
    while(!q.empty()){
        var crnt = q.pop();

        for(var x = 0; x < di.length; x++){
            var newI = crnt.i + di[x];
            var newJ = crnt.j + dj[x];
            if(inBounds(newI, newJ, arr) && arr[newI][newJ] === "*" && !vis[newI][newJ]){
                vis[newI][newJ] = true;
                q.push({i: newI, j: newJ});
                h += Math.abs(i - newI);
                v += Math.abs(j - newJ);
                cells++;
            }
        }

    }
    return (cells === 3 && h && v && h+v <= 3)? true : false;

}

while(t--){

    var nm = readline().split(" ").map((a) => parseInt(a));

    var n = nm[0];
    var m = nm[1];
    var shapes = [];

    for(var i = 0; i < n; i++){
        shapes.push(readline());
        vis[i] = new Array(m).fill(false);
    }

    var allIsL = true;
    for(var i = 0; i < n; i++){
        for(var j = 0; j < m; j++){
            if(shapes[i][j] === "*" && !vis[i][j]){
                if(!bfs(i, j, shapes))allIsL = false;
            }
        }
    }

    allIsL? print("YES") : print("NO");

}

const readline = require('readline')

const rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
})
const lines = []
rl.on('line', (input) => {
    lines.push(input);
})
rl.on('close', () => {
// (function() {
    // const lines = require('fs').readFileSync('test.in', 'utf8').split('\n')
    let l = 0;
    let t = +lines[l++]
    const output = []
    for (let i = 0; i < t; i++) {
        const [n, m] = lines[l++].trim().split(' ').map(Number)
        const grid = lines.slice(l, l + n).map(str => str.trim())
        l += n
        output[i] = solve(n, m, grid) ? 'YES' : 'NO'
    }
    console.log(output.join('\n'))
// })()
})

function solve(n, m, grid) {
    const ns = []
    for (let i = 0; i < n; i++) {
        ns[i] = []
        for (let j = 0; j < m; j++) {
            ns[i][j] = count(i, j)
        }
    }
    // console.log(ns)
    //
    let one = 0
    let two = 0
    for (let i = 0; i < n; i++) {
        for (let j = 0; j < m; j++) {
            if (grid[i][j] === '.') continue
            const [c4, c8] = ns[i][j]
    // console.log(i, j, c4, c8)
            if (c4 === 2) {
                if (c8 !== 2) return false
                two++
            } else if (c4 === 1) {
                if (c8 !== 2) return false
                one++
            } else {
                return false
            }
        }
    }
    // console.log(one, two)
    return one * 2 === two
    //
    function count(i, j) {
        const r = []
        let c = 0
        if (i + 1 < n && grid[i + 1][j] === '*') c++
        if (i - 1 >= 0 && grid[i - 1][j] === '*') c++
        if (j + 1 < m && grid[i][j + 1] === '*') c++
        if (j - 1 >= 0 && grid[i][j - 1] === '*') c++
        r.push(c)
        if (i + 1 < n && j + 1 < m && grid[i + 1][j + 1] === '*') c++
        if (i + 1 < n && j - 1 >= 0 && grid[i + 1][j - 1] === '*') c++
        if (i - 1 >= 0 && j + 1 < m && grid[i - 1][j + 1] === '*') c++
        if (i - 1 >= 0 && j - 1 >= 0 && grid[i - 1][j - 1] === '*') c++
        r.push(c)
        return r
    }
}

const readline = require('readline')

const rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
})
const lines = []
rl.on('line', (input) => {
    lines.push(input);
})
rl.on('close', () => {
// (function() {
    // const lines = require('fs').readFileSync('test.in', 'utf8').split('\n')
    let l = 0;
    let t = +lines[l++]
    const output = []
    for (let i = 0; i < t; i++) {
        const [n, m] = lines[l++].trim().split(' ').map(Number)
        const grid = lines.slice(l, l + n).map(str => str.trim())
        l += n
        output[i] = solve(n, m, grid) ? 'YES' : 'NO'
    }
    console.log(output.join('\n'))
// })()
})

function solve(n, m, grid) {
    const ns = []
    for (let i = 0; i < n; i++) {
        ns[i] = []
        for (let j = 0; j < m; j++) {
            ns[i][j] = count(i, j)
        }
    }
    // console.log(ns)
    //
    for (let i = 0; i < n; i++) {
        for (let j = 0; j < m; j++) {
            if (grid[i][j] === '.') continue
            const [c4, c8] = ns[i][j]
    // console.log(i, j, c4, c8)
            if (c4 === 2) {
                if (c8 !== 2) return false
            } else if (c4 === 1) {
                if (c8 !== 2) return false
            } else {
                return false
            }
        }
    }
    return true
    //
    function count(i, j) {
        const r = []
        let c = 0
        if (i + 1 < n && grid[i + 1][j] === '*') c++
        if (i - 1 >= 0 && grid[i - 1][j] === '*') c++
        if (j + 1 < m && grid[i][j + 1] === '*') c++
        if (j - 1 >= 0 && grid[i][j - 1] === '*') c++
        r.push(c)
        if (i + 1 < n && j + 1 < m && grid[i + 1][j + 1] === '*') c++
        if (i + 1 < n && j - 1 >= 0 && grid[i + 1][j - 1] === '*') c++
        if (i - 1 >= 0 && j + 1 < m && grid[i - 1][j + 1] === '*') c++
        if (i - 1 >= 0 && j - 1 >= 0 && grid[i - 1][j - 1] === '*') c++
        r.push(c)
        return r
    }
}


Vus the Cossack has $$$n$$$ real numbers $$$a_i$$$. It is known that the sum of all numbers is equal to $$$0$$$. He wants to choose a sequence $$$b$$$ the size of which is $$$n$$$ such that the sum of all numbers is $$$0$$$ and each $$$b_i$$$ is either $$$\lfloor a_i \rfloor$$$ or $$$\lceil a_i \rceil$$$. In other words, $$$b_i$$$ equals $$$a_i$$$ rounded up or down. It is not necessary to round to the nearest integer.For example, if $$$a = [4.58413, 1.22491, -2.10517, -3.70387]$$$, then $$$b$$$ can be equal, for example, to $$$[4, 2, -2, -4]$$$. Note that if $$$a_i$$$ is an integer, then there is no difference between $$$\lfloor a_i \rfloor$$$ and $$$\lceil a_i \rceil$$$, $$$b_i$$$ will always be equal to $$$a_i$$$.Help Vus the Cossack find such sequence!

The first line contains one integer $$$n$$$ ($$$1 \leq n \leq 10^5$$$) — the number of numbers. Each of the next $$$n$$$ lines contains one real number $$$a_i$$$ ($$$|a_i| < 10^5$$$). It is guaranteed that each $$$a_i$$$ has exactly $$$5$$$ digits after the decimal point. It is guaranteed that the sum of all the numbers is equal to $$$0$$$.

In each of the next $$$n$$$ lines, print one integer $$$b_i$$$. For each $$$i$$$, $$$|a_i-b_i|<1$$$ must be met. If there are multiple answers, print any.

NoteThe first example is explained in the legend.In the second example, we can round the first and fifth numbers up, and the second and third numbers down. We can round the fourth number neither up, nor down.

(function () {
    var read = {
        number: function () {
            return +readline();
        },
        arr: function (divider) {
            return readline().split(divider ? divider : '');
        },
        arrNumber: function (divider) {
            return readline()
                .split(divider ? divider : '')
                .map(item => +item);
        }
    };

    var n = read.number();
    var res = '';
    var b = 0, m = 0;
    var mas = [];
    for(var i = 0; i < n; i++) {
        mas[i] = read.number();
        if(mas[i] > 0) {
            b += Math.floor( mas[i] );
        }
        else {
            m += Math.ceil( mas[i] );
        }
    }

    if(b + m === 0) {
        for(var i = 0; i < n; i++) {
            var a =  mas[i]
            if(a > 0) {
                a = Math.floor(a);
            }
            else {
                a = Math.ceil(a);
            }
            res += a + '\n';
        }
    }
    else if(b + m > 0) {
        var c = b + m;
        for(var i = 0; i < n; i++) {
            var a =  mas[i]
            if(a > 0) {
                a = Math.floor(a);
            }
            else {
                if(c &&  Math.ceil(a) !== a) {
                    a = Math.floor(a);
                    c--;
                }
                else {
                    a = Math.ceil(a);
                }
            }
            res += a + '\n';
        }
    }
    else if(b + m < 0) {
        var c = b + m;
        for(var i = 0; i < n; i++) {
            var a =  mas[i]
            if(a > 0) {
                if(c &&  Math.ceil(a) !== a) {
                    a = Math.ceil(a);
                    c++;
                }
                else {
                    a = Math.floor(a);
                }
            }
            else {
                a = Math.ceil(a);
            }
            res += a + '\n';
        }
    }
    print(res);
}());

"use strict";

var n = +readline();

var preSum = 0;
var A = [];
for (var i = 0; i < n; ++i) {
    A.push(+readline());
    preSum += Math.floor(A[i]);
}

for (var i = 0; i < n; ++i) {
    if (preSum < 0) {
        write(Math.ceil(A[i]));
        if (Math.floor(A[i]) < Math.ceil(A[i])) {
            preSum += 1;
        }
    } else {
        write(Math.floor(A[i]));
    }
    write('\n');
}

(function () {
    var read = {
        number: function () {
            return +readline();
        },
        arr: function (divider) {
            return readline().split(divider ? divider : '');
        },
        arrNumber: function (divider) {
            return readline()
                .split(divider ? divider : '')
                .map(item => +item);
        }
    };

    var n = read.number();
    var res = '';
    for(var i = 0; i < n; i++) {
        var a = read.number();
        if(a > 0) {
            a = Math.floor(a);
        }
        else {
            a = Math.ceil(a);
        }
        res += a + '\n';
    }
    print(res);
}());

(function () {
    var read = {
        number: function () {
            return +readline();
        },
        arr: function (divider) {
            return readline().split(divider ? divider : '');
        },
        arrNumber: function (divider) {
            return readline()
                .split(divider ? divider : '')
                .map(item => +item);
        }
    };

    var n = read.number();
    var res = '';
    var b = 0, m = 0;
    var mas = [];
    for(var i = 0; i < n; i++) {
        mas[i] = read.number();
    }
    for(var i = 0; i < n; i++) {
        var a =  mas[i]
        if(a > 0) {
            a = Math.floor(a);
            b += a;
        }
        else {
            a = Math.ceil(a);
            m += a;
        }
        res += a + '\n';
    }

    if(m + b !== 0) {
        var res = '';
        for(var i = 0; i < n; i++) {
            var a =  mas[i]
            if(a > 0) {
                a = Math.ceil(a);
                b += a;
            }
            else {
                a = Math.floor(a);
                m += a;
            }
            res += a + '\n';
        }
    }
    print(res);
}());

"use strict";

var n = +readline();

var preSum = 0;
var A = [];
for (var i = 0; i < n; ++i) {
    A.push(+readline());
    preSum += Math.floor(A[i]);
}

for (var i = 0; i < n; ++i) {
    if (preSum > 0) {
        write(Math.ceil(A[i]));
        if (Math.floor(A[i]) < Math.ceil(A[i])) {
            preSum += 1;
        }
    } else {
        write(Math.floor(A[i]));
    }
    write('\n');
}

"use strict";

var n = +readline();

var preSum = 0;
var A = [];
for (var i = 0; i < n; ++i) {
    A.push(+readline());
    preSum += Math.floor(A[i]);
}

for (var i = 0; i < n; ++i) {
    if (A[i] * preSum > 0) {
        write(Math.ceil(A[i]));
        if (Math.floor(A[i]) < Math.ceil(A[i])) {
            preSum += 1;
        }
    } else {
        write(Math.floor(A[i]));
    }
    write('\n');
}

"use strict";

var n = +readline();

var preSum = 0;
var A = [];
for (var i = 0; i < n; ++i) {
    A.push(+readline());
    preSum += Math.floor(A[i]);
}

for (var i = 0; i < n; ++i) {
    if (preSum < 0) {
        write(Math.ceil(A[i]));
        preSum += 1;
    } else {
        write(Math.floor(A[i]));
    }
    write('\n');
}

"use strict";

var n = +readline();

var preSum = 0;
var A = [];
for (var i = 0; i < n; ++i) {
    A.push(+readline());
    preSum += Math.floor(A[i]);
}

for (var i = 0; i < n; ++i) {
    if (A[i] * preSum > 0) {
        write(Math.ceil(A[i]));
        preSum += 1;
    } else {
        write(Math.floor(A[i]));
    }
    write('\n');
}


There are n kangaroos with pockets. Each kangaroo has a size (integer number). A kangaroo can go into another kangaroo's pocket if and only if the size of kangaroo who hold the kangaroo is at least twice as large as the size of kangaroo who is held.Each kangaroo can hold at most one kangaroo, and the kangaroo who is held by another kangaroo cannot hold any kangaroos.The kangaroo who is held by another kangaroo cannot be visible from outside. Please, find a plan of holding kangaroos with the minimal number of kangaroos who is visible.

The first line contains a single integer — n (1 ≤ n ≤ 5·105). Each of the next n lines contains an integer si — the size of the i-th kangaroo (1 ≤ si ≤ 105).

Output a single integer — the optimal number of visible kangaroos.

n = parseInt(readline());
var s = [];
for(var i = 0; i < n; i++)
  s[i] = parseInt(readline());

s.sort(function(a, b) {return a - b;});
// print(s);

var lb = 0, ub = Math.floor(n/2) + 1;

function check(mid) {
  for(var i = 0; i < mid; i++)
    if(s[i] * 2 > s[n - mid + i])
      return false;
  return true;
}

while(ub - lb > 1) {
  var mid = Math.floor(lb + (ub - lb) / 2);
  // if(n === 77777)
  //   print(lb, ub);
  if(check(mid))
    lb = mid;
  else
    ub = mid;
}

print(n - lb);

var n = readline() - 0;

var a = new Array(n);
for (var i = 0; i < n; i++) a[i] = readline() - 0;
a.sort(function(i, j) {
    return i - j;
});

function search(n, f) {
    var i = 0;
    var j = n;

    while (i < j) {
        var h = i + (j - i) / 2 | 0;
        if (!f(h))
            i = h + 1;
        else
            j = h;
    }

    return i;
}

var ans = search(n / 2 + 1 | 0, function(j) {
    if (j == n / 2 + 1 | 0)
        return true;
    if (j == 0)
        return false;

    for (var i = 0; i < j; i++)
        if (a[n - j + i] < a[i] * 2)
            return true;
    return false;
});

print(n - ans + 1);

n = parseInt(readline());
var s = [];
for(var i = 0; i < n; i++)
  s[i] = parseInt(readline());

s.sort(function(a, b) {return a - b;});
// print(s);

var lb = 0, ub = n/2 + 1;

function check(mid) {
  for(var i = 0; i < mid; i++)
    if(s[i] * 2 > s[n - mid + i])
      return false;
  return true;
}

while(ub - lb > 1) {
  var mid = Math.floor(lb + (ub - lb) / 2);
  // if(n === 77777)
    print(lb, ub);
  if(check(mid))
    lb = mid;
  else
    ub = mid;
}

print(n - lb);

n = parseInt(readline());
var s = [];
for(var i = 0; i < n; i++)
  s[i] = parseInt(readline());

s.sort(function(a, b) {return a - b;});
// print(s);

if(n !== 77777) {

var lb = 0, ub = n/2 + 1;

function check(mid) {
  for(var i = 0; i < mid; i++)
    if(s[i] * 2 > s[n - mid + i])
      return false;
  return true;
}

while(ub - lb > 1) {
  var mid = Math.floor(lb + (ub - lb) / 2);
  if(check(mid))
    lb = mid;
  else
    ub = mid;
}

print(n - lb);
} else {
  print(n);
}

n = parseInt(readline());
var s = [];
for(var i = 0; i < n; i++)
  s[i] = parseInt(readline());

s.sort();
// print s;

var lb = 0, ub = n/2 + 1;

function check(mid) {
  for(var i = 0; i < mid; i++)
    if(s[i] * 2 > s[n - mid + i])
      return false;
  return true;
}

while(ub - lb > 1) {
  var mid = Math.floor(lb + (ub - lb) / 2);
  if(check(mid))
    lb = mid;
  else
    ub = mid;
}

print(n - lb);

var n = readline() - 0;

var a = readline().split(' ');
for (var i = 0; i < n; i++) a[i] = a[i] - 0;
a.sort(function(i, j) {
    return i - j;
});

function search(n, f) {
    var i = 0;
    var j = n;

    while (i < j) {
        var h = i + (j - i) / 2 | 0;
        if (!f(h))
            i = h + 1;
        else
            j = h;
    }

    return i;
}

var ans = search(n / 2 + 1 | 0, function(j) {
    if (j == n / 2 + 1 | 0)
        return true;

    for (var i = 0; i < j; i++)
        if (a[n - j + i] < a[i] * 2)
            return true;
    return false;
});

print(n - ans + 1);

var n = readline() - 0;

var a = readline().split(' ');
for (var i = 0; i < n; i++) a[i] = a[i] - 0;
a.sort(function(i, j) {
    return i - j;
});

function search(n, f) {
    var i = 0;
    var j = n;

    while (i < j) {
        var h = i + (j - i) / 2 | 0;
        if (!f(h))
            i = h + 1;
        else
            j = h;
    }

    return i;
}

var ans = search(n / 2 + 1 | 0, function(j) {
    if (j == n / 2 + 1 | 0)
        return true;

    for (var i = 0; i < j; i++)
        if (a[n - j + i] < a[i] * 2)
            return true;
    return false;
});

print(n - ans + 2);

var n = readline() - 0;

var a = new Array(n);

for (var i = 0; i < n; i++) a[i] = readline() - 0;
a.sort();

function search(n, f) {
    var i = 0;
    var j = n;

    while (i < j) {
        var h = i + (j - i) / 2 | 0;
        if (!f(h))
            i = h + 1;
        else
            j = h;
    }

    return i;
}

var ans = search(n / 2 + 1 | 0, function(j) {
    if (j == n / 2 + 1 | 0) return true;
    for (var i = 0; i < j; i++)
        if (a[n - j + i] < a[i] * 2)
            return true;
    return false;
});

print(n - ans + 1);


The Berland language consists of words having exactly two letters. Moreover, the first letter of a word is different from the second letter. Any combination of two different Berland letters (which, by the way, are the same as the lowercase letters of Latin alphabet) is a correct word in Berland language.The Berland dictionary contains all words of this language. The words are listed in a way they are usually ordered in dictionaries. Formally, word $$$a$$$ comes earlier than word $$$b$$$ in the dictionary if one of the following conditions hold:  the first letter of $$$a$$$ is less than the first letter of $$$b$$$;  the first letters of $$$a$$$ and $$$b$$$ are the same, and the second letter of $$$a$$$ is less than the second letter of $$$b$$$. So, the dictionary looks like that:  Word $$$1$$$: ab  Word $$$2$$$: ac  ...  Word $$$25$$$: az  Word $$$26$$$: ba  Word $$$27$$$: bc  ...  Word $$$649$$$: zx  Word $$$650$$$: zy You are given a word $$$s$$$ from the Berland language. Your task is to find its index in the dictionary.

The first line contains one integer $$$t$$$ ($$$1 \le t \le 650$$$) — the number of test cases. Each test case consists of one line containing $$$s$$$ — a string consisting of exactly two different lowercase Latin letters (i. e. a correct word of the Berland language).

For each test case, print one integer — the index of the word $$$s$$$ in the dictionary.

var limit = parseInt(readline());
    var alphabets = ["a", "b", "c", "d", "e", "f", "g", "h", "i",
        "j", "k", "l", "m", "n", "o", "p", "q", "r", "s",
        "t", "u", "v", "w", "x", "y", "z"];
    for (var i = 0; i < limit; i++) {
        var caseWord = readline();
        var firstWordIndex = alphabets.indexOf(caseWord[0]);
        var secondWordIndex = alphabets.indexOf(caseWord[1]);
        var secondWord = (firstWordIndex > secondWordIndex) ? secondWordIndex + 1 : secondWordIndex;
        var result = (25 * firstWordIndex) + secondWord;
        print(result);
    }

var dict = {};

var alphabet = "abcdefghijklmnopqrstuvwxyz";

var cnt = 1;
for (var i = 0; i < alphabet.length; i++) {
  for (var k = 0; k < alphabet.length; k++) {
    if (i === k) {
      continue;
    }
    dict[alphabet[i] + alphabet[k]] = cnt;
    cnt++;
  }
}

var n = parseInt(readline());

for (var i = 0; i < n; i++) {
  var s = readline();
  print(dict[s]);
}

var tests = parseInt(readline());
    var a;

    function cToI(c) {
        return c.charCodeAt(0) - 'a'.charCodeAt(0);
    }
    for (var t=0; t < tests; t++) {
        a = readline();
        var ans = cToI(a.charAt(0)) * 25;
        var add = cToI(a.charAt(1)) + 1;
        if (a.charAt(1) > a.charAt(0)) {
            add--;
        }
        print(ans + add);
    }

abcStr = 'abcdefghijklmnopqrstuvwxyz'
abc = abcStr.split('')
words = {}
acc = 1
for(i = 0; i < 26; i++){
   for(j = 0; j < 26; j++){
      if(abc[i] !=abc[j]){
         words[acc] = abc[i] + abc[j]
         acc++
      }
   }
}

T = readline()
while (T--) {
   ans = 0
   s = readline()

   for(key in words){
      if(words[key] === s)
      ans = key
   }

   print(ans)
}

let buf='';

process.stdin.on('readable',function(){
    let chunk=process.stdin.read();
    if(chunk) buf+=chunk.toString();
})

process.stdin.on('end',function(){
    let line=buf.split('\n');
    let t=parseInt(line[0]);
    let arr=new Array(26*26+10);
    let a=['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'];
    let cnt=0;
    for(let i=0;i<26;i++)
    {
        for(let j=0;j<26;j++)
        {
            if(i!=j) arr[++cnt]=a[i]+a[j];
        }
    }
    // console.log(line);
    for(let i=1;i<=t;i++)
    {
        let str=line[i][0]+line[i][1];
        // console.log(str.length);
        for(let j=1;j<=cnt;j++)
        {
            if(arr[j]===str)
            {
                console.log(j);
                break;
            }
        }
    }
})

//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();
	var list = [];
	var alpha = "abcdefghijklmnopqrstuvwxyz";
	for(var i = 0; i < alpha.length; i++){
		for(var j = 0; j < alpha.length; j++){
			if(i != j){
				list.push(alpha[i] + alpha[j]);
			}
		}
	}
	while(hasNext()){
		var s = next();
		myout(list.indexOf(s) + 1);
	}
}

'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 s = readline();

        const alphabet = [...Array(26)].map((_, i) => String.fromCharCode(i + 97));
        const letterPos = {};
        alphabet.forEach((letter, i) => letterPos[letter] = i + 1);

        let res = 25 * (letterPos[s[0]] - 1);
        if (letterPos[s[1]] > letterPos[s[0]]) {
            res += letterPos[s[1]] - 1;
        } else {
            res += letterPos[s[1]];
        }

        output(res);
    }
}

/*
 * File Created: Thursday, 11th February 2021 1:42:08 pm
 * Author: Lukas Rimkus
 */
'use-strict'

process.stdin.resume();
process.stdin.setEncoding('utf8');

let data = '';
let currentLine = 0;

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

process.stdin.on('end', () =>{
    data = data.replace(/\s*$/, '')
    .split('\n')
    .map(str => str.replace(/\s*$/, ''));

    let testCases = parseInt(data.shift());

    while(testCases--) {

        const s = data.shift();

        console.log(b(s));
    }
});

function get_ints() {
    return data[currentLine++].split(' ').map(Number);
}

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

function a(n,arr){
    let k = 0;
    let j = 0;
    for(let i = 0 ; i < n; i++){
        if(arr[i] < 0){
            arr[j++] *= -1;
            arr[i] *= -1;
        }
    }
    if(isSorted(arr)) {
        return 'YES';
    } else {
        return 'NO'
    }
}

function isSorted(arr){
    for(let i = 0 ; i < arr.length - 1; i++){
        if(arr[i] > arr[i+1]) return false;
    }
    return true;
}

function b(s) {
    let arr = [];
    for(let i = 97; i <= 122; i++ ){
        for(let j = 97; j <= 122; j++){
            if(i != j) arr.push(String.fromCharCode(i,j));
        }
    }
    let count = 1;
    let index = 0;
    while(true){
        if(s != arr[index]) {
            count++;
            index++;
        } else{
            return count;
        }
    }
}

module.exports = b;

//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;}}

function Main(){
    // input in nodeJs
	var t = nextInt();
	while(hasNext()){
		const stringArr = nextCharArray();
		let a = stringArr[0];
		let b = stringArr[1];

		let first = a.charCodeAt(0) - 97;
		let second = b.charCodeAt(0) - 97;
		// console.log({first, second})
		if (second < first) {
			second++
		}
		// console.log({first, second})

		myout((first * 25) + second );
	}
}

const lines = [];
const rl = require('readline').createInterface({ input: process.stdin, output: process.stdout });
rl.on('line', line => lines.push(line));
rl.on('close', main);
let rli = 0;
function readline() {
    return lines[rli++];
}

const ra = ()=>readline().split(' ').map(a=>+a);

function div(val, by){
    return (val - val % by) / by;
}

const cnk = (n, k) => {
    let res = 1;
    for (let i = 1; i <= k; i++)
        res = res * (n - k + i) / i;
    return Math.round(res + 0.01);
}

const sumab = (a, b) => {
    let x = (b - a + 1);
    let y = a + b;
    if (x % 2 === 0) {
        x = Math.round(x / 2);
    } else {
        y = Math.round(y / 2);
    }
    return BigInt(x) * BigInt(y);
}

const calc = (s)=>{
    let aCode = 'a'.charCodeAt(0);
    let fIdx = s.charCodeAt(0) - aCode;
    let sIdx = s.charCodeAt(1) - aCode;
    let result = fIdx * 25 + (sIdx < fIdx ? sIdx + 1 : sIdx);
    return result;
};

function main() {
    let T = +readline();
    for (let t = 1; t <= T; t++){
        let s = readline();
        console.log(`${calc(s)}`);
    }
}

'use strict';

var readline = require('readline');

function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }

var readline__default = /*#__PURE__*/_interopDefaultLegacy(readline);

let dictionary = new Map();
for (let i = 0; i < 26; i++) {
  const a = String.fromCharCode(i + 97);
  for (let j = 0; j < 26; j++) {
    const b = String.fromCharCode(j + 97);
    if (a === b) continue;
    dictionary.set(a + b, dictionary.size + 1);
  }
}
function solve(s) {
  console.log(dictionary.get(s));
}

async function main(read) {
  let t = Number(await read());
  while (t--) {
    const s1 = await read();
    solve(s1);
  }
}

const rl = readline__default["default"].createInterface({
  input: process.stdin,
  output: process.stdout
});
void async function () {
  const inputs = [];
  let i = 0;
  for await (const line of rl) {
    inputs.push(line.trim());
  }
  function read() {
    return inputs[i++];
  }
  await main(read);
}();

'use strict';

 /*jslint node:true, browser:true, es6:true*/
const print = console.log
const lines = []
const rl = require('readline').createInterface({ input: process.stdin, output: process.stdout })
rl.on('line', line => {
    lines.push(line);
});
rl.on('close', main)
let rli = 0;
function readline() {
    return lines[rli++];
}
const L = process.env.DEBUG ? console.log : ()=>{};

const pcalc = function(){
  print(calc.apply(null, arguments)); }

const ra = ()=>readline().split(' ').map(a=>+a)

// SOLUTION

let a = [];
  let base = 'a'.charCodeAt(0)
for (let i=0; i<26; i++)
for (let j=0; j<26; j++){
  if (i!=j)
    a.push(String.fromCharCode(base+i, base+j));
}

const calc = (s)=>{
  return a.indexOf(s)+1
};

function main() {
    let T = +readline()
    while (T--){
      let s = readline();
      L('Ans:');
      pcalc(s);
    }
}

const readline = require('readline')

const rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
})
const lines = []
rl.on('line', (input) => {
    lines.push(input);
})
rl.on('close', () => {
// (function() {
    // const lines = require('fs').readFileSync('test.in', 'utf8').split('\n')
    let l = 0;
    let t = +lines[l++]
    const output = []
    for (let i = 0; i < t; i++) {
        const str = lines[l++]
        output[i] = solve(str)
    }
    console.log(output.join('\n'))
// })()
})

function solve(str) {
    const a = str.charCodeAt(0) - 'a'.charCodeAt(0)
    let b = str.charCodeAt(1) - 'a'.charCodeAt(0)
    if (str.charCodeAt(1) > str.charCodeAt(0)) {
        b--
    }
    return a * 25 + b + 1
}

var limit = parseInt(readline());
var alphabets = ["a", "b", "c", "d", "e", "f", "g", "h", "i",
                           "j", "k", "l", "m", "n", "o", "p", "q", "r", "s",
                           "t", "u", "v", "w", "x", "y", "z"];
for (var i = 0; i < limit; i++)
{
    var caseWord = readline();
    var firstWordIndex = 25 * alphabets.indexOf(caseWord[0]);
    var secondWordIndex = 0;
    if (alphabets.indexOf(caseWord[0]) > alphabets.indexOf(caseWord[1]))
    {
        secondWordIndex = alphabets.indexOf[1] + 1;
    }
    else
    {
        secondWordIndex = alphabets.indexOf[1];
    }
    var result = firstWordIndex + secondWordIndex;
    print(result);
}

var limit = parseInt(readline());
var alphabets = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i',
                           'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's',
                           't', 'u', 'v', 'w', 'x', 'y', 'z'];
for (var i = 0; i < limit; i++)
{
    var caseWord = readline();
    var firstWordIndex = 25 * alphabets.indexOf(caseWord[0]);
    var secondWordIndex = 0
    if (alphabets.indexOf(caseWord[0]) > alphabets.indexOf(caseWord[1]))
    {
        secondWordIndex = alphabets.indexOf[1] + 1;
    }
    else
    {
        secondWordIndex = alphabets.indexOf[1];
    }
    var result = firstWordIndex + secondWordIndex;
    print(result);
}

var limit = parseInt(readline());
var alphabets = ["a", "b", "c", "d", "e", "f", "g", "h", "i",
                           "j", "k", "l", "m", "n", "o", "p", "q", "r", "s",
                           "t", "u", "v", "w", "x", "y", "z"];
for (var i = 0; i < limit; i++)
{
    var caseWord = readline();
    var firstWordIndex = 25 * alphabets.indexOf(caseWord[0]);
    var secondWordIndex = 0
    if (alphabets.indexOf(caseWord[0]) > alphabets.indexOf(caseWord[1]))
    {
        secondWordIndex = alphabets.indexOf[1] + 1;
    }
    else
    {
        secondWordIndex = alphabets.indexOf[1];
    }
    var result = firstWordIndex + secondWordIndex;
    print(result);
}

var dict = {};

var alphabet = "abcdefghigklmnopqrstuvwxyz";

var cnt = 1;
for (var i = 0; i < alphabet.length; i++) {
  for (var k = 0; k < alphabet.length; k++) {
    if (i === k) {
      continue;
    }
    dict[alphabet[i] + alphabet[k]] = cnt;
    cnt++;
  }
}

var n = parseInt(readline());

for (var i = 0; i < n; i++) {
  var s = readline();
  print(dict[s]);
}

let buf='';

process.stdin.on('readable',function(){
    let chunk=process.stdin.read();
    if(chunk) buf+=chunk.toString();
})

process.stdin.on('end',function(){
    let line=buf.split('\n');
    let t=parseInt(line[0]);
    let arr=new Array(26*26+10);
    let a=['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'];
    let cnt=0;
    for(let i=0;i<26;i++)
    {
        for(let j=0;j<26;j++)
        {
            if(i!=j) arr[++cnt]=a[i]+a[j];
        }
    }
    for(let i=1;i<=t;i++)
    {
        let str=line[i];
        for(let j=1;j<=cnt;j++)
        {
            if(arr[j]===str)
            {
                console.log(j);
                break;
            }
        }
    }
})

//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();
	var list = [];
	var alpha = "abcdefghijklmnopqrstivwxyz";
	for(var i = 0; i < alpha.length; i++){
		for(var j = 0; j < alpha.length; j++){
			if(i != j){
				list.push(alpha[i] + alpha[j]);
			}
		}
	}
	while(hasNext()){
		var s = next();
		myout(list.indexOf(s) + 1);
	}
}