Alice and Bob are playing a game with strings. There will be $$$t$$$ rounds in the game. In each round, there will be a string $$$s$$$ consisting of lowercase English letters. Alice moves first and both the players take alternate turns. Alice is allowed to remove any substring of even length (possibly empty) and Bob is allowed to remove any substring of odd length from $$$s$$$.More formally, if there was a string $$$s = s_1s_2 \ldots s_k$$$ the player can choose a substring $$$s_ls_{l+1} \ldots s_{r-1}s_r$$$ with length of corresponding parity and remove it. After that the string will become $$$s = s_1 \ldots s_{l-1}s_{r+1} \ldots s_k$$$.After the string becomes empty, the round ends and each player calculates his/her score for this round. The score of a player is the sum of values of all characters removed by him/her. The value of $$$\texttt{a}$$$ is $$$1$$$, the value of $$$\texttt{b}$$$ is $$$2$$$, the value of $$$\texttt{c}$$$ is $$$3$$$, $$$\ldots$$$, and the value of $$$\texttt{z}$$$ is $$$26$$$. The player with higher score wins the round. For each round, determine the winner and the difference between winner's and loser's scores. Assume that both players play optimally to maximize their score. It can be proved that a draw is impossible.

The first line of input contains a single integer $$$t$$$ ($$$1\leq t\leq 5\cdot 10^4$$$) denoting the number of rounds. Each of the next $$$t$$$ lines contain a single string $$$s$$$ ($$$1\leq |s|\leq 2\cdot 10^5$$$) consisting of lowercase English letters, denoting the string used for the round. Here $$$|s|$$$ denotes the length of the string $$$s$$$. It is guaranteed that the sum of $$$|s|$$$ over all rounds does not exceed $$$2\cdot 10^5$$$.

For each round, print a single line containing a string and an integer. If Alice wins the round, the string must be "Alice". If Bob wins the round, the string must be "Bob". The integer must be the difference between their scores assuming both players play optimally.

NoteFor the first round, $$$\texttt{"aba"}\xrightarrow{\texttt{Alice}}\texttt{"}{\color{red}{\texttt{ab}}}\texttt{a"}\xrightarrow{} \texttt{"a"}\xrightarrow{\texttt{Bob}}\texttt{"}{\color{red}{\texttt{a}}}\texttt{"}\xrightarrow{}\texttt{""}$$$. Alice's total score is $$$1+2=3$$$. Bob's total score is $$$1$$$.For the second round, $$$\texttt{"abc"}\xrightarrow{\texttt{Alice}}\texttt{"a}{\color{red}{\texttt{bc}}}\texttt{"}\xrightarrow{} \texttt{"a"}\xrightarrow{\texttt{Bob}}\texttt{"}{\color{red}{\texttt{a}}}\texttt{"}\xrightarrow{}\texttt{""}$$$. Alice's total score is $$$2+3=5$$$. Bob's total score is $$$1$$$.For the third round, $$$\texttt{"cba"}\xrightarrow{\texttt{Alice}}\texttt{"}{\color{red}{\texttt{cb}}}\texttt{a"}\xrightarrow{} \texttt{"a"}\xrightarrow{\texttt{Bob}}\texttt{"}{\color{red}{\texttt{a}}}\texttt{"}\xrightarrow{}\texttt{""}$$$. Alice's total score is $$$3+2=5$$$. Bob's total score is $$$1$$$.For the fourth round, $$$\texttt{"n"}\xrightarrow{\texttt{Alice}}\texttt{"n"}\xrightarrow{} \texttt{"n"}\xrightarrow{\texttt{Bob}}\texttt{"}{\color{red}{\texttt{n}}}\texttt{"}\xrightarrow{}\texttt{""}$$$. Alice's total score is $$$0$$$. Bob's total score is $$$14$$$.For the fifth round, $$$\texttt{"codeforces"}\xrightarrow{\texttt{Alice}}\texttt{"}{\color{red}{\texttt{codeforces}}}\texttt{"}\xrightarrow{} \texttt{""}$$$. Alice's total score is $$$3+15+4+5+6+15+18+3+5+19=93$$$. Bob's total score is $$$0$$$.

const fs = require("fs");

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

const testCases = [];
let T;

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

  for (let i = 0; i < T; i++) {
    index++;
    const s = input[index].trim();
    const testCase = {
      s,
    };

    testCases.push(testCase);
  }
}

function solution(testCase) {
  const { s } = testCase;

  const getValue = (c) => c.charCodeAt(0) - 97 + 1;

  const totalScore = s.split("").reduce((acc, val) => acc + getValue(val), 0);
  const isEvenLength = s.length % 2 == 0;
  const minEnd = Math.min(getValue(s[0]), getValue(s[s.length - 1]));

  let result = "";
  if (isEvenLength) {
    result = `Alice ${totalScore}`;
  } else {
    if (totalScore - minEnd > minEnd)
      result = `Alice ${totalScore - 2 * minEnd}`;
    else result = `Bob ${2 * minEnd - totalScore}`;
  }
  console.log(result);
}

parseInput();

testCases.forEach(solution);

let buf='';

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

process.stdin.on('end',function(){
    const {EOL}=require('os');
    let line=buf.split(EOL);
    let t=parseInt(line[0]);
    for(let i=1;i<=t;i++)
    {
        let s=line[i];
        let x=0,y=0;
        let a=new Array(s.length);
        let n=s.length;
        for(let i=0;i<n;i++) a[i]=s[i].charCodeAt()-97+1;
        if(n==1)
        {
            console.log('Bob',a[0]);
        }
        else if(n==2)
        {
            console.log('Alice',a[0]+a[1]);
        }
        else
        {
            if(n&1)
            {
                let sum=0;
                for(let i=0;i<n;i++) sum+=a[i];
                if(a[0]<a[n-1]) x=sum-a[0],y=a[0];
                else x=sum-a[n-1],y=a[n-1];
            }
            else
            {
                for(let i=0;i<n;i++) x+=a[i];
            }
            if(x>y) console.log('Alice',x-y);
            else console.log('Bob',y-x);
        }
    }
})

let buf='';

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

process.stdin.on('end',function(){
    const {EOL}=require('os');
    let line=buf.split(EOL);
    let t=parseInt(line[0]);
    for(let i=1;i<=t;i++)
    {
        let s=line[i];
        let x=0,y=0;
        let a=new Array(s.length);
        let n=s.length;
        for(let i=0;i<n;i++) a[i]=s[i].charCodeAt()-97+1;
        // console.log(a);
        // a.sort(function(x,y){
            // return y-x;
        // })
        // console.log(a);
        if(n==1)
        {
            console.log('Bob',a[0]);
        }
        else if(n==2)
        {
            console.log('Alice',a[0]+a[1]);
        }
        else
        {
            if(n&1)
            {
                let sum=0;
                for(let i=0;i<n;i++) sum+=a[i];
                if(a[0]<a[n-1]) x=sum-a[0],y=a[0];
                else x=sum-a[n-1],y=a[n-1];
                // for(let i=0;i<n-1;i++) x+=a[i];
                // y=a[n-1];
            }
            else
            {
                for(let i=0;i<n;i++) x+=a[i];
            }
            if(x>y) console.log('Alice',x-y);
            else console.log('Bob',y-x);
        }
    }
})

const readline = require('readline')

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

let input = []

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

rl.on('close', () => {
    processInput()
    // console.log(input)
})

function processInput(){
//   input = line.split(' ').map(x => parseInt(x))
    nb=parseInt(input[0])
    for (str of input.slice(1)){
        if (str.length==1)
            console.log("Bob "+(str.charCodeAt(0)-96))
        else if (str.length%2==0)
            console.log("Alice "+sumOfLetterRanks(str))
        else{
            if (str[0]<str.slice(-1))
               console.log("Alice "+(sumOfLetterRanks(str.slice(1)) - str.charCodeAt(0)+96))
            else
               console.log("Alice "+(sumOfLetterRanks(str.slice(0,-1)) - str.slice(-1).charCodeAt(0)+96))
        }
    }
//   console.log(output)
}

function sumOfLetterRanks(str){
    return str.split("").reduce((t,c)=>t+c.charCodeAt(0)-96, 0)
}

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

function solve(s) {
  let a = 0,
      b = 0;
  const calc = s => {
    let res = 0;
    for (let char of s) {
      res += char.charCodeAt(0) - 96;
    }
    return res;
  };
  if (s.length & 1) {
    const a1 = calc(s.slice(0, s.length - 1)),
          a2 = calc(s.slice(1));
    if (a1 > a2) {
      a = a1;
      b = s[s.length - 1].charCodeAt(0) - 96;
    } else {
      a = a2;
      b = s[0].charCodeAt(0) - 96;
    }
  } else {
    a = calc(s);
  }
  if (a > b) {
    console.log('Alice', a - b);
  } else {
    console.log('Bob', b - a);
  }
}

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

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

//Don't have to see. end------------------------------------------
function Main(){
	var t = nextInt();
	while(hasNext()){
        const string = nextCharArray().join("");
        let ans;

        if (string.length === 1) {
            ans = `Bob ${string[0].charCodeAt(0) - 96}`;
        } else if (string.length % 2 === 1) {
            let sum = 0;
            for (let i = 0; i < string.length; i++) {
                sum += string[i].charCodeAt(0) - 96;
            }
            sum = sum - 2*(Math.min(string[0].charCodeAt(0), string[string.length - 1].charCodeAt(0)) - 96);

            ans = `Alice ${sum}`;
        } else if (string.length % 2 === 0) {
            let sum = 0;
            for (let i = 0; i < string.length; i++) {
                sum += string[i].charCodeAt(0) - 96;
            }
            ans = `Alice ${sum}`;
        }

        myout(ans)
	}
}

'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();
    const alphabet = [...Array(26)].map((_, i) => String.fromCharCode(i + 97));
    const letterPos = {};
    alphabet.forEach((letter, i) => letterPos[letter] = i + 1);

    for (let test = 0; test < N; test++) {
        let s = readline().split('');
        let sum = s.reduce((a, b) => a + letterPos[b], 0);
        if (s.length === 1) {
            output('Bob ' + letterPos[s[0]]);
        } else if (s.length % 2 === 0) {
            output('Alice ' + sum);
        } else if (s.length % 2 === 1) {
            let bob = Math.min(letterPos[s[0]], letterPos[s[s.length - 1]]);
            output('Alice ' + (sum - bob * 2));
        }
    }
}

const readline = require("readline");

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

const score = (string) => {
    let sum = 0;
    for(let i = 0; i < string.length; i++){
        sum += string.charCodeAt(i) - 96;
    }
    return sum;
}

const calculate = (input) => {
    const len = input.length;
    const lastIndex = len-1;
    if (len === 1)
        return `Bob ${input.charCodeAt()-96}`
    if (!(len%2))
        return `Alice ${score(input)}`
    const firstScore = input.charCodeAt(0) - 96;
    const lastScore = input.charCodeAt(lastIndex) - 96;
    if (firstScore > lastScore)
        return `Alice ${score(input) - 2*lastScore}`;
    else
        return `Alice ${score(input) - 2*firstScore}`;
}

let n = 0;

rl.on('line', (input) => {
    if(!n) n = input;
    else console.log(calculate(input));
});

process.stdin.resume();
process.stdin.setEncoding('utf-8');
let inputString = '';
let currentLine = 0;
process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});
function readLine() {
    return inputString[currentLine++];
};
process.stdin.on('end', _ => {
    inputString = inputString.trim().split('\n').map(string => {
        return string.trim();
    });
    main();
    // cmd(not powershell): node cp.js < input.txt
});

function main() {
    let t = parseInt(readLine());
    while (t-- > 0) {
        console.log(solve());
    }
}
function solve() {
    let str = readLine();
    if (str.length === 1) {
        return "Bob " + (str.charCodeAt(0) - 96);
    }
    let score = 0;
    let start = 0, end = str.length;
    let subtract = 0;
    if (str.charCodeAt(0) > str.charCodeAt(end - 1)) {
        subtract = str.charCodeAt(str.length - 1) - 96;
        end--;
    } else {
        start = 1;
        subtract = str.charCodeAt(0) - 96;
    }
    if (str.length % 2 === 1) {
        for (let i = start; i < end; i++) {
            score += str.charCodeAt(i) - 96;
        }
        score -= subtract;
    } else {
        for (let i = 0; i < str.length; i++) {
            score += str.charCodeAt(i) - 96;
        }
    }
    return "Alice " + score;
}

/**
 * Author : Fazlul Hoque
 * Node.js version : 12.16.3
 * command : node fileName.js <input.txt >output.txt
 */
"use strict";
process.stdin.resume();
process.stdin.setEncoding("utf-8");
let inputString = ""; //An array of  raw inputs (includes 'n,\r , not usable. need to process before use)
let currentLine = 0; //input sequence controller variable.

process.stdin.on("data", (inputStdin) => {
    inputString += inputStdin;
});
process.stdin.on("end", () => {
    inputString = inputString.split("\n");
    main(); // after input
});

/********** Utility Functions Start **********/
/**
 *  read row Input
 * @returns string
 */
function _readRawLine() {
    return inputString[currentLine++];
}
function readLine(){
    // return _readRawLine().replace(/\s+$/g, '');
    return _readRawLine().replace('\r', '');
}

function print(x) {
    console.log(x);
}

function readSingleInt() {
    const p = readLine();
    return parseInt(p);
}

function readIntArray() {
    return readLine().split(" ").map((v) => parseInt(v));
}

function readArray() {
    return readLine().split(" ");
}

function int(n) {
    return parseInt(n);
}
/********** Utility Functions End **********/
/**
 * Don't Touch this fucntion at all , unless you know what are you doing!
 */
function main() {
    solve();
}

// ********** actual Code Starts from here **********

function solve() {
    let t = readSingleInt();
    while(t--){
        let st = readLine();
        let total = 0;
        let first = st.charCodeAt(0)-96,last = st.charCodeAt(st.length-1)-96;
        for(let i=0;i<st.length;i++){
            total += ( st.charCodeAt(i)-96 );
        }
        let bob  = Math.min(first,last);
        let alice = Math.max(total-first,total-last);
        if(st.length==1){
            console.log("Bob ",total);
        }
        else if(st.length%2==0){
            console.log("Alice ",total);
        }else{
            if(bob>alice){
                console.log("Bob ",Math.abs(alice-bob));
            }else{
                console.log("Alice ",Math.abs(alice-bob));
            }
        }
    }

}

var stdin_input = "";
var stdin_input_itr;
process.stdin.resume();
process.stdin.setEncoding("ascii");
process.stdin.on("data", function (input) { stdin_input += input; });
process.stdin.on("end", function () { stdin_input_itr = stdin_input.split('\n').values(); main(); });

const rl = () => stdin_input_itr.next().value.trim();
const rn = () => Number(rl());
const ra = () => rl().split(' ');
const rna = () => ra().map(x => Number(x));

var deb; const log = msg => (typeof deb != "undefined") && console.log("DEBUG", msg);

const ind = c => c.charCodeAt(0) - 'a'.charCodeAt(0);

function main () {
	let T = rn();
	while (T--) {
		const s = rl();
		const n = s.length;

		let ascr = 0, bscr = 0, sum = 0;
		for (let i = 0; i < n; i++) sum += ind(s[i]) + 1;
		if (n & 1) {
			bscr = s[0] < s[n-1] ? ind(s[0]) + 1 : ind(s[n-1]) + 1;
		}
		ascr = sum - bscr;

		console.log(ascr > bscr ? 'Alice' : 'Bob', Math.abs(ascr - bscr));
	}
}

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).join(' ')
    }
    console.log(output.join('\n'))
// })()
})

function solve(str) {
    let a, b
    if (str.length & 1) {
        if (str[0] < str.slice(-1)) {
            a = cal(str.slice(1))
            b = cal(str[0])
        } else {
            a = cal(str.slice(0, -1))
            b = cal(str.slice(-1))
        }
    } else {
        a = cal(str)
        b = 0
    }
    //
    if (a > b) {
        return ['Alice', a - b]
    } else {
        return ['Bob', b - a]
    }
}
function cal(str) {
    let s = 0
    for (let i = 0; i < str.length; i++) {
        s += str.charCodeAt(i) - 'a'.charCodeAt(0) + 1
    }
// console.log(str, s)
    return s
}

var num=parseInt(readline());
var arr=[];
for(var i=0;i<num;i++){
    arr.push(readline().split(""));
}
// print(String.fromCharCode(97));
// print(String.fromCharCode(122));
// print('a'.charCodeAt(0));
var alice;
var bob;
for(var i=0;i<num;i++){
    alice=0;
    bob=0;
    for(var x=0;x<arr[i].length;x++){
        if(arr[i].length%2===0){
            alice+=arr[i][x].charCodeAt(0)-96;
        }
        else if(arr[i].length==1){
            bob= arr[i][x].charCodeAt(0)-96;
        }
        else{
            if(arr[i][0]>=arr[i][arr[i].length-1]){
                if(x==arr[i].length-1){
                    bob=arr[i][x].charCodeAt(0)-96;
                    break;
                }else{
                    alice+=arr[i][x].charCodeAt(0)-96;
                }
            }
            else{
                bob=arr[i][0].charCodeAt(0)-96;
                if(x===0){
                    continue;
                }else{
                   alice+=arr[i][x].charCodeAt(0)-96;
                }
            }
        }
    }
    if(alice>=bob){
        print(`Alice ${alice-bob}`);
    }
    else{
        print(`Bob ${bob-alice}`);
    }
}

const fs = require("fs");

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

const testCases = [];
let T;

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

  for (let i = 0; i < T; i++) {
    index++;
    const s = input[index].trim();
    const testCase = {
      s,
    };

    testCases.push(testCase);
  }
}

function solution(testCase) {
  const { s } = testCase;

  const getValue = (c) => c.charCodeAt(0) - 97 + 1;

  const totalScore = s.split("").reduce((acc, val) => acc + getValue(val), 0);
  const isEvenLength = s.length % 2 == 0;
  const minEnd = Math.min(getValue(s[0]), getValue(s[s.length - 1]));
  console.log(
    s.length,
    totalScore,
    isEvenLength,
    minEnd,
    s[0],
    getValue(s[0]),
    s[s.length - 1],
    getValue(s[s.length - 1])
  );
  let result = "";
  if (isEvenLength) {
    result = `Alice ${totalScore}`;
  } else {
    if (totalScore - minEnd > minEnd)
      result = `Alice ${totalScore - 2 * minEnd}`;
    else result = `Bob ${2 * minEnd - totalScore}`;
  }
  console.log(result);
}

parseInput();

testCases.forEach(solution);

const fs = require("fs");

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

const testCases = [];
let T;

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

  for (let i = 0; i < T; i++) {
    index++;
    const s = input[index];
    const testCase = {
      s,
    };

    testCases.push(testCase);
  }
}

function solution(testCase) {
  const { s } = testCase;

  const getValue = (c) => c.charCodeAt(0);

  const totalScore = s.split("").reduce((acc, val) => acc + getValue(val), 0);
  const isEvenLength = s.length % 2 == 0;
  const minEnd = Math.min(getValue(s[0]), getValue(s[s.length - 1]));
  console.log(
    s.length,
    totalScore,
    isEvenLength,
    minEnd,
    s[0],
    getValue(s[0]),
    s[s.length - 1],
    getValue(s[s.length - 1])
  );
  let result = "";
  if (isEvenLength) {
    result = `Alice ${totalScore}`;
  } else {
    if (totalScore - minEnd > minEnd)
      result = `Alice ${totalScore - 2 * minEnd}`;
    else result = `Bob ${2 * minEnd - totalScore}`;
  }
  console.log(result);
}

parseInput();

testCases.forEach(solution);

const fs = require("fs");

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

const testCases = [];
let T;

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

  for (let i = 0; i < T; i++) {
    index++;
    const s = input[index];
    const testCase = {
      s,
    };

    testCases.push(testCase);
  }
}

function solution(testCase) {
  const { s } = testCase;

  const getValue = (c) => c.charCodeAt(0);

  const totalScore = s.split("").reduce((acc, val) => acc + getValue(val), 0);
  const isEvenLength = s.length % 2 == 0;
  const minEnd = Math.min(getValue(s[0]), getValue(s[s.length - 1]));
  console.log(
    totalScore,
    isEvenLength,
    minEnd,
    s[0],
    getValue(s[0]),
    s[s.length - 1],
    getValue(s[s.length - 1])
  );
  let result = "";
  if (isEvenLength) {
    result = `Alice ${totalScore}`;
  } else {
    if (totalScore - minEnd > minEnd)
      result = `Alice ${totalScore - 2 * minEnd}`;
    else result = `Bob ${2 * minEnd - totalScore}`;
  }
  console.log(result);
}

parseInput();

testCases.forEach(solution);

const fs = require("fs");

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

const testCases = [];
let T;

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

  for (let i = 0; i < T; i++) {
    index++;
    const s = input[index];
    const testCase = {
      s,
    };

    testCases.push(testCase);
  }
}

function solution(testCase) {
  const { s } = testCase;

  const getValue = (c) => c.charCodeAt(0);

  const totalScore = s.split("").reduce((acc, val) => acc + getValue(val), 0);
  const isEvenLength = s.length % 2 == 0;
  const minEnd = Math.min(getValue(s[0]), getValue(s[s.length - 1]));
  console.log(totalScore, isEvenLength, minEnd);
  let result = "";
  if (isEvenLength) {
    result = `Alice ${totalScore}`;
  } else {
    if (totalScore - minEnd > minEnd)
      result = `Alice ${totalScore - 2 * minEnd}`;
    else result = `Bob ${2 * minEnd - totalScore}`;
  }
  console.log(result);
}

parseInput();

testCases.forEach(solution);

const fs = require("fs");

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

const testCases = [];
let T;

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

  for (let i = 0; i < T; i++) {
    index++;
    const s = input[index];
    const testCase = {
      s,
    };

    testCases.push(testCase);
  }
}

function solution(testCase) {
  const { s } = testCase;

  const getValue = (c) => c.charCodeAt(0) - 97 + 1;

  const totalScore = s.split("").reduce((acc, val) => acc + getValue(val), 0);
  const isEvenLength = s.length % 2 == 0;
  const minEnd = Math.min(getValue(s[0]), getValue(s[s.length - 1]));
  console.log(totalScore, isEvenLength, minEnd);
  let result = "";
  if (isEvenLength) {
    result = `Alice ${totalScore}`;
  } else {
    if (totalScore - minEnd > minEnd)
      result = `Alice ${totalScore - 2 * minEnd}`;
    else result = `Bob ${2 * minEnd - totalScore}`;
  }
  console.log(result);
}

parseInput();

testCases.forEach(solution);

const fs = require("fs");

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

const testCases = [];
let T;

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

  for (let i = 0; i < T; i++) {
    index++;
    const s = input[index];
    const testCase = {
      s,
    };

    testCases.push(testCase);
  }
}

function solution(testCase) {
  const { s } = testCase;

  const getValue = (c) => c.charCodeAt(0) - 97 + 1;

  const totalScore = s.split("").reduce((acc, val) => acc + getValue(val), 0);
  const isEvenLength = s.length % 2 == 0;
  const minEnd = Math.min(getValue(s[0]), getValue(s[s.length - 1]));
  console.error(totalScore, isEvenLength, minEnd);
  let result = "";
  if (isEvenLength) {
    result = `Alice ${totalScore}`;
  } else {
    if (totalScore - minEnd > minEnd)
      result = `Alice ${totalScore - 2 * minEnd}`;
    else result = `Bob ${2 * minEnd - totalScore}`;
  }
  console.log(result);
}

parseInput();

testCases.forEach(solution);

const fs = require("fs");

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

const testCases = [];
let T;

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

  for (let i = 0; i < T; i++) {
    index++;
    const s = input[index];
    const testCase = {
      s,
    };

    testCases.push(testCase);
  }
}

function solution(testCase) {
  const { s } = testCase;

  const getValue = (c) => c.charCodeAt(0) - 97 + 1;

  const totalScore = s.split("").reduce((acc, val) => acc + getValue(val), 0);
  const isEvenLength = s.length % 2 == 0;
  const minEnd = Math.min(getValue(s[0]), getValue(s[s.length - 1]));
  let result = "";
  if (isEvenLength) {
    result = `Alice ${totalScore}`;
  } else {
    if (totalScore - minEnd > minEnd)
      result = `Alice ${totalScore - 2 * minEnd}`;
    else result = `Bob ${2 * minEnd - totalScore}`;
  }
  console.log(result);
}

parseInput();

testCases.forEach(solution);

const fs = require("fs");

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

const testCases = [];
let T;

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

  for (let i = 0; i < T; i++) {
    index++;
    const s = input[index];
    const testCase = {
      s,
    };

    testCases.push(testCase);
  }
}

function solution(testCase) {
  const { s } = testCase;

  const getValue = (c) => c.charCodeAt(0) - "a".charCodeAt(0) + 1;

  const totalScore = s.split("").reduce((acc, val) => acc + getValue(val), 0);
  const isEvenLength = s.length % 2 == 0;
  const minEnd = Math.min(getValue(s[0]), getValue(s[s.length - 1]));
  let result = "";
  if (isEvenLength) {
    result = `Alice ${totalScore}`;
  } else {
    if (totalScore - minEnd > minEnd)
      result = `Alice ${totalScore - 2 * minEnd}`;
    else result = `Bob ${2 * minEnd - totalScore}`;
  }
  console.log(result);
}

parseInput();

testCases.forEach(solution);

const fs = require("fs");

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

const testCases = [];
let T;

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

  for (let i = 0; i < T; i++) {
    index++;
    const s = input[index];
    const testCase = {
      s,
    };

    testCases.push(testCase);
  }
}

function solution(testCase) {
  const { s } = testCase;

  const getValue = (c) => c.charCodeAt() - "a".charCodeAt() + 1;

  const totalScore = s.split("").reduce((acc, val) => acc + getValue(val), 0);
  const isEvenLength = s.length % 2 == 0;
  const minEnd = Math.min(getValue(s[0]), getValue(s[s.length - 1]));
  let result = "";
  if (isEvenLength) {
    result = `Alice ${totalScore}`;
  } else {
    if (totalScore - minEnd > minEnd)
      result = `Alice ${totalScore - 2 * minEnd}`;
    else result = `Bob ${2 * minEnd - totalScore}`;
  }
  console.log(result);
}

parseInput();

testCases.forEach(solution);

let buf='';

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

process.stdin.on('end',function(){
    const {EOL}=require('os');
    let line=buf.split(EOL);
    let t=parseInt(line[0]);
    for(let i=1;i<=t;i++)
    {
        let s=line[i];
        let x=0,y=0;
        let a=new Array(s.length);
        let n=s.length;
        for(let i=0;i<n;i++) a[i]=s[i].charCodeAt()-97+1;
        // console.log(a);
        a.sort(function(x,y){
            return y-x;
        })
        // console.log(a);
        if(n==1)
        {
            console.log('Bob',a[0]);
        }
        else if(n==2)
        {
            console.log('Alice',a[0]+a[1]);
        }
        else
        {
            if(n&1)
            {
                for(let i=0;i<n-1;i++) x+=a[i];
                y=a[n-1];
            }
            else
            {
                for(let i=0;i<n;i++) x+=a[i];
            }
            if(x>y) console.log('Alice',x-y);
            else console.log('Bob',y-x);
        }
    }
})

const readline = require('readline')

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

let input = []

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

rl.on('close', () => {
    processInput()
    console.log(input)
})

function processInput(){
//   input = line.split(' ').map(x => parseInt(x))
    nb=parseInt(input[0])
    for (str of input.slice(1)){
        if (str.length==1)
            console.log("Bob "+(str.charCodeAt(0)-96))
        else if (str.length%2==0)
            console.log("Alice "+sumOfLetterRanks(str))
        else{
            if (str[0]<str.slice(-1))
               console.log("Alice "+(sumOfLetterRanks(str.slice(1)) - str.charCodeAt(0)+96))
            else
               console.log("Alice "+(sumOfLetterRanks(str.slice(0,-1)) - str.slice(-1).charCodeAt(0)+96))
        }
    }
//   console.log(output)
}

function sumOfLetterRanks(str){
    return str.split("").reduce((t,c)=>t+c.charCodeAt(0)-96, 0)
}

'use strict';

var fs = require('fs');

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

var fs__default = /*#__PURE__*/_interopDefaultLegacy(fs);

function solve(s) {
  let a = 0,
      b = 0;
  const calc = s => {
    let res = 0;
    for (let char of s) {
      res += char.charCodeAt(0) - 96;
    }
    return res;
  };
  if (s.length & 1) {
    const a1 = calc(s.slice(0, s.length - 1)),
          a2 = calc(s.slice(1));
    if (a1 > a2) {
      a = a1;
      b = s[s.length - 1].charCodeAt(0) - 96;
    } else {
      a = a2;
      b = s[0].charCodeAt(0) - 96;
    }
  } else {
    a = calc(s);
  }
  if (a > b) {
    console.log('Alice', a - b);
  } else {
    console.log('Bob', b - a);
  }
}

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

const inputs = fs__default["default"].readFileSync(0, 'utf-8').split('\n');
void async function () {
  let i = 0;
  function read() {
    return inputs[i++];
  }
  await main(read);
}();

//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();
    console.log("\n")
	while(hasNext()){
        const string = nextCharArray().join("");
        let ans;

        if (string.length === 1) {
            ans = `Bob ${string[0].charCodeAt(0) - 96}`;
        } else if (string.length % 2 === 1) {
            let sum = 0;
            for (let i = 0; i < string.length; i++) {
                sum += string[i].charCodeAt(0) - 96;
            }
            sum = sum - 2*(Math.min(string[0].charCodeAt(0), string[string.length - 1].charCodeAt(0)) - 96);

            ans = `Alice ${sum}`;
        } else if (string.length % 2 === 0) {
            let sum = 0;
            for (let i = 0; i < string.length; i++) {
                sum += string[i].charCodeAt(0) - 96;
            }
            ans = `Alice ${sum}`;
        }

        myout(ans)
	}
}


Developers often face with regular expression patterns. A pattern is usually defined as a string consisting of characters and metacharacters that sets the rules for your search. These patterns are most often used to check whether a particular string meets the certain rules.In this task, a pattern will be a string consisting of small English letters and question marks ('?'). The question mark in the pattern is a metacharacter that denotes an arbitrary small letter of the English alphabet. We will assume that a string matches the pattern if we can transform the string into the pattern by replacing the question marks by the appropriate characters. For example, string aba matches patterns: ???, ??a, a?a, aba.Programmers that work for the R1 company love puzzling each other (and themselves) with riddles. One of them is as follows: you are given n patterns of the same length, you need to find a pattern that contains as few question marks as possible, and intersects with each of the given patterns. Two patterns intersect if there is a string that matches both the first and the second pattern. Can you solve this riddle?

The first line contains a single integer n (1 ≤ n ≤ 105) — the number of patterns. Next n lines contain the patterns. It is guaranteed that the patterns can only consist of small English letters and symbols '?'. All patterns are non-empty and have the same length. The total length of all the patterns does not exceed 105 characters.

In a single line print the answer to the problem — the pattern with the minimal number of signs '?', which intersects with each of the given ones. If there are several answers, print any of them.

NoteConsider the first example. Pattern xab intersects with each of the given patterns. Pattern ??? also intersects with each of the given patterns, but it contains more question signs, hence it is not an optimal answer. Clearly, xab is the optimal answer, because it doesn't contain any question sign. There are a lot of other optimal answers, for example: aab, bab, cab, dab and so on.


In Python, code blocks don't have explicit begin/end or curly braces to mark beginning and end of the block. Instead, code blocks are defined by indentation.We will consider an extremely simplified subset of Python with only two types of statements.Simple statements are written in a single line, one per line. An example of a simple statement is assignment.For statements are compound statements: they contain one or several other statements. For statement consists of a header written in a separate line which starts with "for" prefix, and loop body. Loop body is a block of statements indented one level further than the header of the loop. Loop body can contain both types of statements. Loop body can't be empty.You are given a sequence of statements without indentation. Find the number of ways in which the statements can be indented to form a valid Python program.

The first line contains a single integer N (1 ≤ N ≤ 5000) — the number of commands in the program. N lines of the program follow, each line describing a single command. Each command is either "f" (denoting "for statement") or "s" ("simple statement"). It is guaranteed that the last line is a simple statement.

Output one line containing an integer - the number of ways the given sequence of statements can be indented modulo 109 + 7.

NoteIn the first test case, there is only one way to indent the program: the second for statement must be part of the body of the first one.simple statementfor statement    for statement        simple statementIn the second test case, there are two ways to indent the program: the second for statement can either be part of the first one's body or a separate statement following the first one.for statement    simple statement    for statement        simple statementorfor statement    simple statementfor statement    simple statement

var n = parseInt(readline());
var i, j;
var mod = 1000 * 1000 * 1000 + 7;

/* Create an n*n two-dimension array */
var map = [];
for (i = 0; i < n; i++) {
  map.push(new Array(n));
}

/* Initial conditions */
map[0][0] = 1;
for (j = 1; j < n; j++) {
  map[0][j] = 0;
}
var prev = readline();

/* start iterations */
for (i = 1; i < n; i++) {
  var current = readline();

  if (prev === 's') {
    var sum = 0;
    for (j = n - 1; j >= 0; j--) {
      sum += map[i - 1][j];
      sum = sum % mod;
      map[i][j] = sum;
    }
  } else if (prev === 'f') {
    map[i][0] = 0;
    for (j = 1; j < n; j++) {
      map[i][j] = map[i - 1][j - 1];
    }
  }
  prev = current;
}

/* sum result */
var result = 0;
for (i = 0; i < n; i++) {
  result += map[n - 1][i];
  result %= mod;
}
print(result);

var n = parseInt(readline());
var i, j;

/* Create an n*n two-dimension array */
var map = [];
for (i = 0; i < n; i++) {
  map.push(new Array(n));
}

/* Initial conditions */
map[0][0] = 1;
for (j = 1; j < n; j++) {
  map[0][j] = 0;
}
var prev = readline();

/* Start iterations */
for (i = 1; i < n; i++) {
  var current = readline();

  if (prev === 's') {
    var sum = 0;
    for (j = n - 1; j >= 0; j--) {
      sum += map[i - 1][j];
      map[i][j] = sum;
    }
  } else if (prev === 'f') {
    map[i][0] = 0;
    for (j = 1; j < n; j++) {
      map[i][j] = map[i - 1][j - 1];
    }
  }
  prev = current;
}

/* Sum result */
var result = 0;
for (i = 0; i < n; i++) {
  result += map[n - 1][i];
}
print(result);


There are $$$n$$$ students in the first grade of Nlogonia high school. The principal wishes to split the students into two classrooms (each student must be in exactly one of the classrooms). Two distinct students whose name starts with the same letter will be chatty if they are put in the same classroom (because they must have a lot in common). Let $$$x$$$ be the number of such pairs of students in a split. Pairs $$$(a, b)$$$ and $$$(b, a)$$$ are the same and counted only once.For example, if there are $$$6$$$ students: "olivia", "jacob", "tanya", "jack", "oliver" and "jessica", then:  splitting into two classrooms ("jack", "jacob", "jessica", "tanya") and ("olivia", "oliver") will give $$$x=4$$$ ($$$3$$$ chatting pairs in the first classroom, $$$1$$$ chatting pair in the second classroom),  splitting into two classrooms ("jack", "tanya", "olivia") and ("jessica", "oliver", "jacob") will give $$$x=1$$$ ($$$0$$$ chatting pairs in the first classroom, $$$1$$$ chatting pair in the second classroom). You are given the list of the $$$n$$$ names. What is the minimum $$$x$$$ we can obtain by splitting the students into classrooms?Note that it is valid to place all of the students in one of the classrooms, leaving the other one empty.

The first line contains a single integer $$$n$$$ ($$$1\leq n \leq 100$$$) — the number of students. After this $$$n$$$ lines follow. The $$$i$$$-th line contains the name of the $$$i$$$-th student. It is guaranteed each name is a string of lowercase English letters of length at most $$$20$$$. Note that multiple students may share the same name.

The output must consist of a single integer $$$x$$$ — the minimum possible number of chatty pairs.

7
kambei
gorobei
shichiroji
kyuzo
heihachi
katsushiro
kikuchiyo

NoteIn the first sample the minimum number of pairs is $$$1$$$. This can be achieved, for example, by putting everyone except jose in one classroom, and jose in the other, so jorge and jerry form the only chatty pair.In the second sample the minimum number of pairs is $$$2$$$. This can be achieved, for example, by putting kambei, gorobei, shichiroji and kyuzo in one room and putting heihachi, katsushiro and kikuchiyo in the other room. In this case the two pairs are kambei and kyuzo, and katsushiro and kikuchiyo.In the third sample the minimum number of pairs is $$$4$$$. This can be achieved by placing three of the students named mike in one classroom and the other two students in another classroom. Thus there will be three chatty pairs in one classroom and one chatty pair in the other classroom.

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

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

  if (obj[str[0]]) {
    obj[str[0]]++;
  }
  else {
    obj[str[0]] = 1;
  }

  c++;
});

rl.on('close', () => {
  const arr = Object.values(obj);
  let ans = 0;
  const scores = {0: 0, 1: 0, 2: 1};

  for (let i = 3; i <= 50; i++) {
    scores[i] = (i - 1) + scores[i - 1];
  }

  for (let i = 0; i < arr.length; i++) {
    const min = Math.floor(arr[i] / 2);
    const max = Math.ceil(arr[i] / 2);

    ans += scores[min];
    ans += scores[max];
  }

  console.log(ans);
});

const unique = (value, index, self) => {
    return self.indexOf(value) === index
  }

let z = '';
process.stdin.on('data', c => z += c);
process.stdin.on('end', () => {
    const {
        EOL
    } = require('os');
    let input = z.split(EOL);
    input.shift();
    input = input.map(item=>item.charAt(0));
    const uniqueNames = input.filter(unique);
    let overall=[];
    uniqueNames.forEach((item)=>{
        let counter=0;
        for(let i=0;i<input.length;i++){
            if(input[i]===item){
                counter++;
            }
        }
        overall.push(counter);
    });
    let result = 0;
    overall.forEach((item)=>{
        let firstClass = parseInt(item/2);
        result += (firstClass * (firstClass-1))/2;
        let secondClass = item-firstClass;
        result += (secondClass * (secondClass-1))/2;
    })
    console.log(result)

});

(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 f =readline()[0];
        if(res[f]) {
            res[f] += 1;
        }
        else {
            res[f] = 1;
        }
    }

    var c = 0;
    for(var k in res) {
        var l = Math.floor(res[k] / 2);
        var r = res[k] - l;

        for(var i = 1; i < l; i++) {
            c+=i;
        }
        for(var i = 1; i < r; i++) {
            c+=i;
        }
    }
    print(c);
}());

var n = parseInt(readline());

var ar = new Array(n);
for(var i =0;i<n;i++) ar[i] = readline();

var letters = {};
ar.forEach((name) => {
    letters[name.charAt(0)] = letters[name.charAt(0)] ? letters[name.charAt(0)]+1:1;
});

var res = 0;

Object.keys(letters).forEach(l=> {
    var a = Math.floor( letters[l] /2);
    var b = Math.floor(letters[l]-a);

    for(var i=0;i<a;i++)
    for(var j=i+1;j<a;j++) res++;

    for(var i=0;i<b;i++)
    for(var j=i+1;j<b;j++) res++;

    // if (b>1 && b%2!==0) {
    //     res+= b;
    // } else {
    //     res+= Math.floor(b/2);
    // }
    // res += Math.floor(a/2) ;
    // print(l, letters[l], a, b);
    // print(Math.floor(a/2), Math.floor(b/2), b%2, b%2*b)
})
print(res)

    var n = +readline();
    var arr = [];
    for(var i =0; i < n; i++) {
        arr.push(readline()[0]);
    }

    //print(k)

    var map = arr.reduce((prev, cur) => {
        if(prev[cur]) {
            prev[cur]++;
        } else {
            prev[cur] = 1;
        }
        return prev;
    }, {});

    var res = 0
    // print(JSON.stringify(map))

    for (var key in map) {
        var value = map[key]
        var low = Math.floor(value / 2)
        var high = value - low

        // print(high, low)
        if(value > 2) {
            res += (high * (high -1) + low * (low -1)) / 2
        }

    }

    print(res)

function main() {
  var i
  var n = +readline()

  var count = new Array(256).fill(0)
  for(i=0; i<n; i++) {
    var string = readline()
    count[string.charCodeAt(0)] = count[string.charCodeAt(0)] + 1
  }

  var ans = 0
  for(i=0; i<256; i++) {
    var a = Math.floor(count[i] / 2)
    var b = count[i] - a
    ans = ans + a * (a-1) / 2 + b * (b-1) / 2
  }
  print(ans)
}

main()

function solution(names) {
  var i
  var n = names.length
  var count = new Array(256).fill(0)

  for (i=0; i<n; i++) {
    var string = names[i]
    count[string.charCodeAt(0)] = count[string.charCodeAt(0)] + 1
  }

  var answer = 0
  for (i=0; i<256; i++) {
    var a = Math.floor(count[i] / 2)
    var b = count[i] - a
    answer = answer + a * (a-1) / 2 + b * (b-1) / 2
  }

  return answer;
}

function main() {
  var i
  var n = +readline()
  var names = []
  for (i=0; i<n; i++) {
    var string = readline()
    names.push(string)
  }

  print(solution(names))
}

main()

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

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

  if (obj[str[0]]) {
    obj[str[0]]++;
  }
  else {
    obj[str[0]] = 1;
  }

  c++;
});

rl.on('close', () => {
  const max = Math.max(...Object.values(obj).sort((a, b) => b - a));
  const a1 = Math.floor(max / 2);
  const a2 = Math.ceil(max / 2);
  let ans = 0;

  for (let i = 0; i < a1; i++) {
    ans += i;
  }

  for (let i = 0; i < a2; i++) {
    ans += i;
  }

  console.log(ans);
});

var n = parseInt(readline());

var ar = new Array(n);
for(var i =0;i<n;i++) ar[i] = readline();

var letters = {};
ar.forEach((name) => {
    letters[name.charAt(0)] = letters[name.charAt(0)] ? letters[name.charAt(0)]+1:1;
});

var res = 0;

Object.keys(letters).forEach(l=> {
    var a = Math.floor( letters[l] /2);
    var b = Math.floor(letters[l]-a);
    res += Math.floor(a/2) + Math.floor(b/2) + (b%2)*2*Math.floor(b/2);
    // print(l, letters[l], a, b);
    // print(Math.floor(a/2), Math.floor(b/2), b%2)
})
print(res)

var n = parseInt(readline());

var ar = new Array(n);
for(var i =0;i<n;i++) ar[i] = readline();

var letters = {};
ar.forEach((name) => {
    letters[name.charAt(0)] = letters[name.charAt(0)] ? letters[name.charAt(0)]+1:1;
});

var res = 0;

Object.keys(letters).forEach(l=> {
    var a = Math.floor( letters[l] /2);
    var b = Math.floor(letters[l]-a);
    res += Math.floor(a/2) + Math.floor(b/2) + (b%2)*Math.min(a, b);
    // print(l, letters[l], a, b);
    // print(Math.floor(a/2), Math.floor(b/2), b%2)
})
print(res)

var n = parseInt(readline());

var ar = new Array(n);
for(var i =0;i<n;i++) ar[i] = readline();

var letters = {};
ar.forEach((name) => {
    letters[name.charAt(0)] = letters[name.charAt(0)] ? letters[name.charAt(0)]+1:1;
});

var res = 0;

Object.keys(letters).forEach(l=> {
    var a = Math.floor( letters[l] /2);
    var b = Math.floor(letters[l]-a);

    if (b>1 && b%2!==0) {
        res+= b;
    } else {
        res+= Math.floor(b/2);
    }
    res += Math.floor(a/2) ;
    // print(l, letters[l], a, b);
    // print(Math.floor(a/2), Math.floor(b/2), b%2, b%2*b)
})
print(res)

    var n = +readline()[0];
    var arr = [];
    for(var i =0; i< n; i++) {
        arr.push(readline());
    }

    //print(k)

    var map = arr.reduce((prev, cur) => {
        var key = cur[0]
        if(prev[key]) {
            prev[key]++;
        } else {
            prev[key] = 1;
        }
        return prev;
    }, {});

    var res = 0
    //print(JSON.stringify(map))

    for (var key in map) {
        var value = map[key]
        var low = Math.floor(value / 2)
        var high = value - low

        // print(high, low)
        if(value > 2) {
            res += (high * (high -1) + low * (low -1)) / 2
        }

    }

    print(res)

function calculate(data) {
    const map = data.reduce(function (prev,cur) {
        if(prev[cur[0]]) {
            prev[cur[0]]++
        } else {
            prev[cur[0]] = 1
        }
        return prev
    }, {})

    var res = 0

    for(var key in map) {
        var k = Math.floor(map[key] / 2)
        var m = Math.floor(map[key] - k)
        res += ( k > 1 ? k*(k-1)/2 : 0) + ( m > 1 ? m*(m-1)/2 : 0)
    }

    return res
}


Nick had received an awesome array of integers $$$a=[a_1, a_2, \dots, a_n]$$$ as a gift for his $$$5$$$ birthday from his mother. He was already going to explore its various properties but after unpacking he was disappointed a lot because the product $$$a_1 \cdot a_2 \cdot \dots a_n$$$ of its elements seemed to him not large enough.He was ready to throw out the array, but his mother reassured him. She told him, that array would not be spoiled after the following operation: choose any index $$$i$$$ ($$$1 \le i \le n$$$) and do $$$a_i := -a_i - 1$$$.For example, he can change array $$$[3, -1, -4, 1]$$$ to an array $$$[-4, -1, 3, 1]$$$ after applying this operation to elements with indices $$$i=1$$$ and $$$i=3$$$. Kolya had immediately understood that sometimes it's possible to increase the product of integers of the array a lot. Now he has decided that he wants to get an array with the maximal possible product of integers using only this operation with its elements (possibly zero, one or more times, as many as he wants), it is not forbidden to do this operation several times for the same index. Help Kolya and print the array with the maximal possible product of elements $$$a_1 \cdot a_2 \cdot \dots a_n$$$ which can be received using only this operation in some order.If there are multiple answers, print any of them.

The first line contains integer $$$n$$$ ($$$1 \leq n \leq 10^{5}$$$) — number of integers in the array. The second line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$-10^{6} \leq a_i \leq 10^{6}$$$) — elements of the array

Print $$$n$$$ numbers — elements of the array with the maximal possible product of elements which can be received using only this operation in some order from the given array. If there are multiple answers, print any of them.

(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 arr = read.arrNumber(' ');

    var min = 0;
    for(var i = 0; i < n; i++) {
        if(arr[i] >= 0) {
            arr[i] = (arr[i] * -1) -1;
        }
        if(arr[i] < arr[min])
            min = i;
    }
    if(n % 2 !== 0) {
        arr[min] = (arr[min] * -1) -1;
    }

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

"use strict";

var n = +readline();
var A = readline().split(' ').map(value => +value);
var R = []

for (var i = 0; i < n; ++i) {
    var opop = A[i];
    if (A[i] >= 0) {
        opop = -A[i] - 1;
    } else if (A[i] < -1) {
        opop = A[i];
    }
    R.push(opop);
}

var ind;
var most = +Infinity;
if (n%2) {
    for (var i = 0; i < n; ++i) {
        if (R[i] < -1 && R[i] < most) {
            most = R[i];
            ind = i;
        }
    }

    if (most !== +Infinity) {
        R[ind] = -R[ind] - 1;
    } else {
        R[0] = 0;
    }
}

write(R.join(' '));

(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 arr = read.arrNumber(' ');

    var onlyZero = true;
    for(var i = 0; i < n; i++) {
        if(arr[i] !== 0) {
            onlyZero = false;
        }
    }

    if(onlyZero && n % 2) {
        print(arr.join(' '));
        return;
    }

    var positiveCount = 0;
    var minPositive = -Infinity;
    for(var i = 0; i < n; i++) {
        if(arr[i] >= 0) {
            positiveCount++;
        }
        if(arr[i] > minPositive) {
            minPositive = arr[i];
        }
    }

    var negativeCount = n - positiveCount;
    if(positiveCount < 2 && negativeCount % 2 === 0) {
        print(arr.join(' '));
        return;
    }

    var all = n % 2 === 0;
    var minChecked = false;
    for(var i = 0; i < n; i++) {
        if(arr[i] >= 0) {
            if(all) {
                arr[i] = (arr[i] * -1) - 1;
            }
            else {
                if(arr[i] !== minPositive) {
                    arr[i] = (arr[i] * -1) - 1;
                }
                else if(minChecked) {
                    arr[i] = (arr[i] * -1) - 1;
                }
                else {
                    minChecked = true;
                }
            }
        }
    }
    print(arr.join(' '));
}());

"use strict";

var n = +readline();
var A = readline().split(' ').map(value => +value);
var R = []

for (var i = 0; i < n; ++i) {
    var opop = A[i];
    if (A[i] >= 0) {
        opop = -A[i] - 1;
    } else if (A[i] < -1) {
        opop = A[i];
    }
    R.push(opop);
}

var ind;
var most = -Infinity;
if (n%2) {
    for (var i = 0; i < n; ++i) {
        if (R[i] < -1 && R[i] > most) {
            most = R[i];
            ind = i
        }
    }

    if (most !== -Infinity) {
        R[ind] = -R[ind] - 1;
    } else {
        R[0] = 0;
    }
}

write(R.join(' '));


Drazil has many friends. Some of them are happy and some of them are unhappy. Drazil wants to make all his friends become happy. So he invented the following plan.There are n boys and m girls among his friends. Let's number them from 0 to n - 1 and 0 to m - 1 separately. In i-th day, Drazil invites -th boy and -th girl to have dinner together (as Drazil is programmer, i starts from 0). If one of those two people is happy, the other one will also become happy. Otherwise, those two people remain in their states. Once a person becomes happy (or if he/she was happy originally), he stays happy forever.Drazil wants to know whether he can use this plan to make all his friends become happy at some moment.

The first line contains two integer n and m (1 ≤ n, m ≤ 100). The second line contains integer b (0 ≤ b ≤ n), denoting the number of happy boys among friends of Drazil, and then follow b distinct integers x1, x2, ..., xb (0 ≤ xi < n), denoting the list of indices of happy boys. The third line conatins integer g (0 ≤ g ≤ m), denoting the number of happy girls among friends of Drazil, and then follow g distinct integers y1, y2, ... , yg (0 ≤ yj < m), denoting the list of indices of happy girls. It is guaranteed that there is at least one person that is unhappy among his friends.

If Drazil can make all his friends become happy by this plan, print "Yes". Otherwise, print "No".

NoteBy  we define the remainder of integer division of i by k.In first sample case:   On the 0-th day, Drazil invites 0-th boy and 0-th girl. Because 0-th girl is happy at the beginning, 0-th boy become happy at this day.  On the 1-st day, Drazil invites 1-st boy and 1-st girl. They are both unhappy, so nothing changes at this day.  On the 2-nd day, Drazil invites 0-th boy and 2-nd girl. Because 0-th boy is already happy he makes 2-nd girl become happy at this day.  On the 3-rd day, Drazil invites 1-st boy and 0-th girl. 0-th girl is happy, so she makes 1-st boy happy.  On the 4-th day, Drazil invites 0-th boy and 1-st girl. 0-th boy is happy, so he makes the 1-st girl happy. So, all friends become happy at this moment.

var line1 = readline().split(" ");
var line2 = readline().split(" ");
var line3 = readline().split(" ");

var b = parseInt(line1[0]);
var g = parseInt(line1[1]);

var b_h = parseInt(line2[0]);
var b_h_i = line2.slice(1).map(function (i) { return parseInt(i); });

var g_h = parseInt(line3[0]);
var g_h_i = line3.slice(1).map(function (i) { return parseInt(i); });

function gcd (a, b) {
    while (b > 0) {
    var temp = b;
    b = a % b;
    a = temp;
    }
    return a;
}

var x = gcd(b, g);

var happy = [];
for (var i =0; i < x; i++) happy.push(-1);

b_h_i.forEach(function (b) {
    happy[b % x] = 1;
});

g_h_i.forEach(function (g) {
    happy[g % x] = 1;
});

var result = "Yes";

happy.forEach(function (el) {
    if (el == -1) result = "No";
});

print(result);

var tok = null;
var index = 0;
function next() {
    while (tok == null || index == tok.length) {
        tok = readline().split(' ');
        index = 0;
    }
    var res = tok[index++];
    return res;
}

function nextInt() {
    return parseInt(next());
}

function sortNumber(a, b) {
    return a - b;
}

function main() {
        var a=nextInt();
var b=nextInt();
var hA=[];
for(var i=0; i<a; i++){
hA[i]=0;
}
var hB=[];
for(var i=0; i<b; i++){
hB[i]=0;
}
var n=nextInt();
for(var i=0; i<n; i++){
hA[nextInt()]=1;
}
n=nextInt();
for(var i=0; i<n; i++){
hB[nextInt()]=1;
}

var m=a*b*a*b;

for(var i=0; i<m; i++){
var x=Math.max(hA[i%a], hB[i%b]);
hA[i%a]=x;
hB[i%b]=x;
}

if(check(hA,hB)){
print("Yes");
}else{
print("No");
}

}

function check(a, b){
for(var i=0; i<a.length; i++){
if(a[i]==0){
return false;
}
}
for(var i=0; i<b.length; i++){
if(b[i]==0){
return false;
}
}
return true;
}

main();

var app = {
    'main' : function main()    {
        var boyCount = 0, girlCount = 0,
            happyBoyArray = [], happyGirlArray = [],
            result = 'Yes';

        boyCount = readline().split(/\s/gi).map(Number);
        girlCount = boyCount[1], boyCount = boyCount[0];

        readline().split(/\s/gi).slice(1).forEach(function(boy)    {
            happyBoyArray[boy] = 1;
        });
        readline().split(/\s/gi).slice(1).forEach(function(boy)    {
            happyGirlArray[boy] = 1;
        });

        for(var i = 0; i < 1e4; i++)    {
            var boyIndex = i % boyCount, girlIndex = i % girlCount,
                boyStatus = happyBoyArray[boyIndex],
                girlStatus = happyGirlArray[girlIndex];

            if(boyStatus)    {
                happyGirlArray[girlIndex] = 1;
            } else    {
                if(girlStatus)    {
                    happyBoyArray[boyIndex] = 1;
                } else    {
                    happyGirlArray[girlIndex] = 0;
                    happyBoyArray[boyIndex] = 0;
                }
            }
        }

        if(happyGirlArray.sort()[0] == 0)    result = 'No';
        if(happyBoyArray.sort()[0] == 0)    result = 'No';

        print(result);
    }
};

app.main();

var tok = null;
var index = 0;
function next() {
    while (tok == null || index == tok.length) {
        tok = readline().split(' ');
        index = 0;
    }
    var res = tok[index++];
    return res;
}

function nextInt() {
    return parseInt(next());
}

function sortNumber(a, b) {
    return a - b;
}

function main() {
        var a=nextInt();
var b=nextInt();
var hA=[];
for(var i=0; i<a; i++){
hA[i]=0;
}
var hB=[];
for(var i=0; i<b; i++){
hB[i]=0;
}
var n=nextInt();
for(var i=0; i<n; i++){
hA[nextInt()]=1;
}
n=nextInt();
for(var i=0; i<n; i++){
hB[nextInt()]=1;
}

var m=a*b;

for(var i=0; i<m; i++){
var x=Math.max(hA[i%a], hB[i%b]);
hA[i%a]=x;
hB[i%b]=x;
}

if(check(hA,hB)){
print("Yes");
}else{
print("No");
}

}

function check(a, b){
for(var i=0; i<a.length; i++){
if(a[i]==0){
return false;
}
}
for(var i=0; i<b.length; i++){
if(b[i]==0){
return false;
}
}
return true;
}

main();

var app = {
    'main' : function main()    {
        var boyCount = 0, girlCount = 0,
            happyBoyArray = [], happyGirlArray = [],
            result = 'Yes';

        boyCount = readline().split(/\s/gi).map(Number);
        girlCount = boyCount[1], boyCount = boyCount[0];

        readline().split(/\s/gi).slice(1).forEach(function(boy)    {
            happyBoyArray[boy] = 1;
        });
        readline().split(/\s/gi).slice(1).forEach(function(boy)    {
            happyGirlArray[boy] = 1;
        });

        for(var i = 0; i < boyCount * girlCount; i++)    {
            var boyIndex = i % boyCount, girlIndex = i % girlCount,
                boyStatus = happyBoyArray[boyIndex],
                girlStatus = happyGirlArray[girlIndex];

            if(boyStatus)    {
                happyGirlArray[girlIndex] = 1;
            } else    {
                if(girlStatus)    {
                    happyBoyArray[boyIndex] = 1;
                } else    {
                    happyGirlArray[girlIndex] = 0;
                    happyBoyArray[boyIndex] = 0;
                }
            }
        }

        if(happyGirlArray.sort()[0] == 0)    result = 'No';
        if(happyBoyArray.sort()[0] == 0)    result = 'No';

        print(result);
    }
};

app.main();


There are $$$n$$$ dormitories in Berland State University, they are numbered with integers from $$$1$$$ to $$$n$$$. Each dormitory consists of rooms, there are $$$a_i$$$ rooms in $$$i$$$-th dormitory. The rooms in $$$i$$$-th dormitory are numbered from $$$1$$$ to $$$a_i$$$.A postman delivers letters. Sometimes there is no specific dormitory and room number in it on an envelope. Instead of it only a room number among all rooms of all $$$n$$$ dormitories is written on an envelope. In this case, assume that all the rooms are numbered from $$$1$$$ to $$$a_1 + a_2 + \dots + a_n$$$ and the rooms of the first dormitory go first, the rooms of the second dormitory go after them and so on.For example, in case $$$n=2$$$, $$$a_1=3$$$ and $$$a_2=5$$$ an envelope can have any integer from $$$1$$$ to $$$8$$$ written on it. If the number $$$7$$$ is written on an envelope, it means that the letter should be delivered to the room number $$$4$$$ of the second dormitory.For each of $$$m$$$ letters by the room number among all $$$n$$$ dormitories, determine the particular dormitory and the room number in a dormitory where this letter should be delivered.

The first line contains two integers $$$n$$$ and $$$m$$$ $$$(1 \le n, m \le 2 \cdot 10^{5})$$$ — the number of dormitories and the number of letters. The second line contains a sequence $$$a_1, a_2, \dots, a_n$$$ $$$(1 \le a_i \le 10^{10})$$$, where $$$a_i$$$ equals to the number of rooms in the $$$i$$$-th dormitory. The third line contains a sequence $$$b_1, b_2, \dots, b_m$$$ $$$(1 \le b_j \le a_1 + a_2 + \dots + a_n)$$$, where $$$b_j$$$ equals to the room number (among all rooms of all dormitories) for the $$$j$$$-th letter. All $$$b_j$$$ are given in increasing order.

Print $$$m$$$ lines. For each letter print two integers $$$f$$$ and $$$k$$$ — the dormitory number $$$f$$$ $$$(1 \le f \le n)$$$ and the room number $$$k$$$ in this dormitory $$$(1 \le k \le a_f)$$$ to deliver the letter.

NoteIn the first example letters should be delivered in the following order:  the first letter in room $$$1$$$ of the first dormitory  the second letter in room $$$9$$$ of the first dormitory  the third letter in room $$$2$$$ of the second dormitory  the fourth letter in room $$$13$$$ of the second dormitory  the fifth letter in room $$$1$$$ of the third dormitory  the sixth letter in room $$$12$$$ of the third dormitory

var _ = parseInt(readline());
var flats = readline().split(" ").map(function(el) {return parseInt(el)});
var letters = readline().split(" ").map(function(el) {return parseInt(el)});
res = [];

sumFlats = flats.map(function(flat, i) {
  return {
    building: i,
    flat: flat
  }
})

for (var i = 1; i<sumFlats.length; i++) {
  sumFlats[i].flat += sumFlats[i-1].flat;
}

var globalCounter = 0;

letters.map(function(letter) {
  if (letter > sumFlats[sumFlats.length - 1].flat) {
    print('impossible')
  } else {
    for (var i = globalCounter; i < sumFlats.length; i++ ) {
      if (letter === sumFlats[i].flat) {
        print([i+1, flats[i]].join(" "));
        globalCounter = i;
        break;
      }
      if (letter < sumFlats[i].flat) {
        if (i === 0) {
          print([1, letter].join(" "));
        } else {
          print([i + 1, letter - sumFlats[i-1].flat].join(" "))
        }
        globalCounter = i;
        break;
      }
    }
  }
});

// function binarySearch(arr, elem) {
//   if (arr.length === 1) {
//     if (elem === arr[0].flat) {
//       return [arr[0].building + 1, flats[arr[0].building]];
//     } else if (elem > arr[0].flat) {
//       return [arr[0].building + 2, elem - flats[arr[0].building]];
//     } else {
//       return [arr[0].building + 1, arr[0].building > 0 ? elem - sumFlats[arr[0].building - 1].flat : elem];
//     }
//   } else if (arr.length === 2) {
//     if (elem === arr[0].flat) {
//       return [arr[0].building + 1, flats[arr[0].building]];
//     } else if (elem > arr[0].flat) {
//       return binarySearch(arr.slice(-1), elem);
//     } else {
//       return [arr[0].building + 1, arr[0].building > 0 ? elem - sumFlats[arr[0].building - 1].flat : elem];
//     }
//   } else {
//     var middle = Math.floor(arr.length / 2);
//     if (elem === arr[middle].flat) {
//       return [arr[middle].building + 1, flats[arr[middle].building]];
//     } else if (elem > arr[middle].flat) {
//       return binarySearch(arr.slice(middle + 1), elem);
//     } else {
//       return binarySearch(arr.slice(0, middle), elem);
//     }
//   }
// }

var result = num => Math.floor(Number(num));
var mn = readline().split(' ');
var n = result(mn[0]), m = result(mn[1]);
var ai = readline().split(' ').map(result);
var bi = readline().split(' ').map(result);
for(var i = 1; i < n; i++) ai[i] += ai[i - 1];
for(var i = 0; i < m; i++) {
  var lo = 0, hi = n - 1, key = bi[i];
  while(lo <= hi) {
    var mid = result(hi - (hi - lo) / 2);
    if(ai[mid] >= key) hi = mid - 1;
    else lo = mid + 1;
  }
  print(lo + 1, bi[i] - ( lo === 0 ? 0 : ai[lo - 1]));
}

var result = num => Math.floor(Number(num));
var mn = readline().split(' ');
var n = result(mn[0]), m = result(mn[1]);
var ai = readline().split(' ').map(result);
var bi = readline().split(' ').map(result);
for(var i = 1; i < n; i++) ai[i] += ai[i - 1];
for(var i = 0; i < m; i++) {
  var lo = 0, hi = n - 1, key = bi[i];
  while(lo <= hi) {
    var mid = result(hi - (hi - lo) / 2);
    if(ai[mid] >= key) hi = mid - 1;
    else lo = mid + 1;
  }
  print(lo + 1, bi[i] - ( lo == 0 ? 0 : ai[lo - 1]));
}

var a = readline();
var amountsOfRooms = readline().split(' ');
var roomNumbers = readline().split(' ');
var currentDorm = 1;
var amountOfRoomsInPreviousDorms = 0;

for (var i=0; i<roomNumbers.length; i++) {
    while ((roomNumbers[i] - amountOfRoomsInPreviousDorms) > amountsOfRooms[currentDorm-1]) {
        amountOfRoomsInPreviousDorms += +amountsOfRooms[currentDorm-1];
        currentDorm++;
    }
    var dormRoomNumber = roomNumbers[i] - amountOfRoomsInPreviousDorms;
    print(currentDorm + ' ' + dormRoomNumber);
}

  var ub = function(a, x) {
    var l = 0;
    var h = a.length; // Not n - 1
    while (l < h) {
      var mid = Math.floor((l + h) / 2);
      if (x >= a[mid]) {
        l = mid + 1;
      } else {
        h = mid;
      }
    }
    return l;
  }

  var tmp = readline().split(' ').map(x => parseInt(x));
  var n = tmp[0];
  var m = tmp[1];
  var d = readline().split(' ').map(x => parseInt(x));
  var ds = [0];
  for(var i = 0; i < n; i += 1) {
    ds.push(ds[i] + d[i]);
  }
  var env = readline().split(' ').map(x => parseInt(x));
  env.forEach(function(x) {
    var s = ub(ds, x - 1);
    print([s, x - ds[s - 1]].join(' '));
  });

var _ = parseInt(readline());
var flats = readline().split(" ").map(function(el) {return parseInt(el)});
var letters = readline().split(" ").map(function(el) {return parseInt(el)});
res = [];

sumFlats = flats.map(function(flat, i) {
  return {
    building: i,
    flat: flat
  }
})

for (var i = 1; i<sumFlats.length; i++) {
  sumFlats[i].flat += sumFlats[i-1].flat;
}

letters.map(function(letter) {
  if (letter > sumFlats[sumFlats.length - 1]) {
    print('impossible')
  } else {
    print(binarySearch(sumFlats, letter).join(" "));
  }
});

function binarySearch(arr, elem) {
  if (arr.length === 1) {
    if (elem === arr[0].flat) {
      return [arr[0].building + 1, flats[arr[0].building]];
    } else if (elem > arr[0].flat) {
      return [arr[0].building + 2, elem - flats[arr[0].building]];
    } else {
      return [arr[0].building + 1, arr[0].building > 0 ? elem - sumFlats[arr[0].building - 1].flat : elem];
    }
  } else if (arr.length === 2) {
    if (elem === arr[0].flat) {
      return [arr[0].building + 1, flats[arr[0].building]];
    } else if (elem > arr[0].flat) {
      return binarySearch(arr.slice(-1), elem);
    } else {
      return [arr[0].building + 1, arr[0].building > 0 ? elem - sumFlats[arr[0].building - 1].flat : elem];
    }
  } else {
    var middle = Math.floor(arr.length / 2);
    if (elem === arr[middle].flat) {
      return [arr[middle].building + 1, flats[arr[middle].building]];
    } else if (elem > arr[middle].flat) {
      return binarySearch(arr.slice(middle + 1), elem);
    } else {
      return binarySearch(arr.slice(0, middle), elem);
    }
  }
}

  var ub = function(a, x) {
    var l = 0;
    var h = a.length; // Not n - 1
    while (l < h) {
      var mid = Math.floor((l + h) / 2);
      if (x >= a[mid]) {
        l = mid + 1;
      } else {
        h = mid;
      }
    }
    return l;
  }

  var tmp = readline().split(' ').map(x => parseInt(x));
  var n = tmp[0];
  var m = tmp[1];
  var d = readline().split(' ').map(x => parseInt(x));
  var ds = [0];
  for(var i = 0; i < n; i += 1) {
    ds.push(ds[i] + d[i]);
  }
  print(ds.join(' '));
  var env = readline().split(' ').map(x => parseInt(x));
  env.forEach(function(x) {
    var s = ub(ds, x - 1);
    print([s, x - ds[s - 1]].join(' '));
  });


Let's denote the Manhattan distance between two points $$$p_1$$$ (with coordinates $$$(x_1, y_1)$$$) and $$$p_2$$$ (with coordinates $$$(x_2, y_2)$$$) as $$$d(p_1, p_2) = |x_1 - x_2| + |y_1 - y_2|$$$. For example, the distance between two points with coordinates $$$(1, 3)$$$ and $$$(4, 2)$$$ is $$$|1 - 4| + |3 - 2| = 4$$$.You are given two points, $$$A$$$ and $$$B$$$. The point $$$A$$$ has coordinates $$$(0, 0)$$$, the point $$$B$$$ has coordinates $$$(x, y)$$$.Your goal is to find a point $$$C$$$ such that:  both coordinates of $$$C$$$ are non-negative integers;  $$$d(A, C) = \dfrac{d(A, B)}{2}$$$ (without any rounding);  $$$d(B, C) = \dfrac{d(A, B)}{2}$$$ (without any rounding). Find any point $$$C$$$ that meets these constraints, or report that no such point exists.

The first line contains one integer $$$t$$$ ($$$1 \le t \le 3000$$$) — the number of test cases. Each test case consists of one line containing two integers $$$x$$$ and $$$y$$$ ($$$0 \le x, y \le 50$$$) — the coordinates of the point $$$B$$$.

For each test case, print the answer on a separate line as follows:   if it is impossible to find a point $$$C$$$ meeting the constraints, print "-1 -1" (without quotes);  otherwise, print two non-negative integers not exceeding $$$10^6$$$ — the coordinates of point $$$C$$$ meeting the constraints. If there are multiple answers, print any of them. It can be shown that if any such point exists, it's possible to find a point with coordinates not exceeding $$$10^6$$$ that meets the constraints.

NoteExplanations for some of the test cases from the example:  In the first test case, the point $$$B$$$ has coordinates $$$(49, 3)$$$. If the point $$$C$$$ has coordinates $$$(23, 3)$$$, then the distance from $$$A$$$ to $$$B$$$ is $$$|49 - 0| + |3 - 0| = 52$$$, the distance from $$$A$$$ to $$$C$$$ is $$$|23 - 0| + |3 - 0| = 26$$$, and the distance from $$$B$$$ to $$$C$$$ is $$$|23 - 49| + |3 - 3| = 26$$$.  In the second test case, the point $$$B$$$ has coordinates $$$(2, 50)$$$. If the point $$$C$$$ has coordinates $$$(1, 25)$$$, then the distance from $$$A$$$ to $$$B$$$ is $$$|2 - 0| + |50 - 0| = 52$$$, the distance from $$$A$$$ to $$$C$$$ is $$$|1 - 0| + |25 - 0| = 26$$$, and the distance from $$$B$$$ to $$$C$$$ is $$$|1 - 2| + |25 - 50| = 26$$$.  In the third and the fourth test cases, it can be shown that no point with integer coordinates meets the constraints.  In the fifth test case, the point $$$B$$$ has coordinates $$$(42, 0)$$$. If the point $$$C$$$ has coordinates $$$(21, 0)$$$, then the distance from $$$A$$$ to $$$B$$$ is $$$|42 - 0| + |0 - 0| = 42$$$, the distance from $$$A$$$ to $$$C$$$ is $$$|21 - 0| + |0 - 0| = 21$$$, and the distance from $$$B$$$ to $$$C$$$ is $$$|21 - 42| + |0 - 0| = 21$$$.

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; i++){
        var a = lines[i].split(' ').map(Number);
        var x = a[0], y = a[1];
        if((x + y) % 2 == 1){
            console.log(-1, -1);
        }else{
            console.log(Math.floor(x / 2), Math.floor((y + 1) / 2));
        }
    }
});

"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.split("\n");
  main();
});
function readline() {
  return inputString[currentLine++];
}
/* ***************************** */

function main() {
  const test = parseInt(readline());

  for (let i = 0; i < test; i++) {
   let [x, y] = readline().split(" ");
   x =  parseInt(x);
   y = parseInt(y);

   let cx = -1,cy = -1;

   if((x + y) % 2 === 1) {
    console.log(cx, cy);
    continue;
   }

   console.log(Math.floor((x + 1)/2), Math.floor(y/2));
  }
}

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 [x, y] = lines[l++].trim().split(' ').map(Number)
        output[i] = solve(x, y).join(' ')
        // const [a, b] = solve(x, y)
        // console.log([a, b])
        // console.log(cal([0, 0], [x, y]), cal([0, 0], [a, b]), cal([x, y], [a, b]))
    }
    console.log(output.join('\n'))
// })()
})

function solve(x, y) {
    const d = Math.abs(x) + Math.abs(y)
    if (d & 1) return [-1, -1]
    const half = d / 2

    if (x >= 0 && y >= 0) {
        if (half <= x) {
            return [half, 0]
        } else {
            return [x, half - x]
        }
    } else {
        return [-1, -1]
    }
}
function cal(a, b) {
    return Math.abs(a[0] - b[0]) + Math.abs(a[1] - b[1])
}

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

//Don't have to see. end------------------------------------------
function Main(){
	var t = nextInt();
	while(hasNext()){
		var x = nextInt();
		var y = nextInt();
		if((x + y) % 2 == 1){
			myout("-1 -1");
			continue;
		}
		var diff = (x + y) / 2;
		if(x >= y){
			x -= diff;
		}else{
			y -= diff;
		}
		myout(x + " " + y);
	}
}

"use strict";

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

function print(x) {
  console.log(x);
}
let inputString = "";
let currentLine = 0;

process.stdin.on("data", (inputStdin) => {
  inputString += inputStdin;
});
process.stdin.on("end", () => {
  inputString = inputString.split("\n");
  main();
});
function readline() {
  return inputString[currentLine++];
}

// ********** Code Start **********

function main() {

const x=+(readline());
let g=[];
for(let i=0;i<x;i++){
    let y=readline().split(" ");
    let xb=parseInt(y[0]);
    let yb=parseInt(y[1]);
    for(let s=0;s<10;s++){let sum=0;
    for(let i=0; i<50;i++){
        for(let u=0;u<50;u++){
            if(Math.abs(i)+Math.abs(u)==Math.abs(xb-i)+Math.abs(yb-u) ) { sum++;
                  g.push(`${i} ${u}`); break ;}

        }

        if(sum>=1) {break;}

    }
   if(sum===0) g.push("-1 -1"); break;

}

}
for(let i=0;i<g.length;i++){
    console.log(g[i]);

}
}

process.stdin.setEncoding('utf-8')
const readline = require('readline')

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

let count = -1
let inputArr = []

rl.on('line', data => {
    if (count === -1) {
        count = +data
    } else if (count !== 0) {
        inputArr.push(data.trim())
        count--
    }
    // max number 2^(53) - 1 ~~ 10^(15)
    if (count === 0) {
        inputArr = inputArr.map(i => i.split(' ').map(j => +j))
        main()
        process.exit(0)
    }
})

function solve([x, y]) {
    let x1 = -1, y1 = -1;
    if ((x + y) % 2 === 0) {
        if (x % 2 === 0 && y % 2 === 0) {
            x1 = Math.floor(x / 2)
            y1 = Math.floor(y / 2)
        } else {
            if (x < y) {
                x1 = x
                y1 = Math.floor((y - x) / 2)
            } else {
                x1 = Math.floor((x - y) / 2)
                y1 = y
            }
        }
    }
    console.log(x1, y1)
}

function main() {
    for (let i = 0; i < inputArr.length; i++) solve(inputArr[i])
}

"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.split("\n");
  main();
});
function readline() {
  return inputString[currentLine++];
}
/* ***************************** */

function main() {
  const test = parseInt(readline());

  for (let i = 0; i < test; i++) {
   let [x, y] = readline().split(" ");
   x =  parseInt(x);
   y = parseInt(y);

   let cx = -1,cy = -1;

   if((x === 0 && y % 2 === 0) || ( y === 0 && x % 2 === 0)) {
    if (x === 0) {
      cx = 0;
      cy = y / 2;
    } else if(y === 0) {
      cy = 0;
      cx = x / 2
    }
   } else if ( ((x + y) % 2 === 0)) {
     cx = 1;
     cy = ((x + y) / 2) - 1;
   }
   console.log(cx, cy);
  }
}

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 [x, y] = lines[l++].trim().split(' ').map(Number)
        output[i] = solve(x, y).join(' ')
    }
    console.log(output.join('\n'))
// })()
})

function solve(x, y) {
    const d = Math.abs(x) + Math.abs(y)
    if (d & 1) return [-1, -1]
    const half = d / 2

    if (x >= 0 && y >= 0) {
        if (half <= x) {
            return [0, half]
        } else {
            return [x, half - x]
        }
    } else {
        return [-1, -1]
    }
}