n=+readline()
dup={};
while(n--) {
    s=readline();
    if (!dup[s]) {
        print('OK');
        dup[s]=1;
    } else {
        print(s+dup[s]);
        dup[s]=dup[s]+1;
    }
}

var a = parseInt( readline() );

var map = {};

while(a--){

	var name = readline();
	if( map.hasOwnProperty(name) ){
		map[name]++;
		print(name + map[name]);
	}else{
		print('OK');
		map[name] = 0;
	}
}

var n = +readline();
var obj = {};

for(i = 0; i < n; i++){
	input = readline();
	if(input in obj){
		obj[input]++;
		print(input + obj[input]);
	}
	else{
		obj[input] = 0;
		print("OK");
	}
}

var n = parseInt(readline());
var m = {};
for (var i = 0; i < n; i++) {
    var a = readline();
    if (!!m[a]) {
        var b = a + m[a];
        write(b+'\n');
        m[a] = m[a] + 1;
        m[b] = 1;

    } else {
        m[a] = 1;
        write('OK'+'\n');
    }
}

function registrationSystem (userName){
	if (!mySet.hasOwnProperty(userName)){
		mySet[userName] = 0;
		print('OK');
	}
	else{
		mySet[userName] += 1;
		var newUser = userName + mySet[userName].toString();
		mySet[newUser] = 0;
		print(newUser)
	}
}
var mySet = {};
var queries = parseInt(readline());
for (var i = 0; i < queries; i ++){
	registrationSystem(readline());
}

;(function () {

	var n = +readline();
	var base = {};

	while (n--) {
		var name = readline();
		if (base.hasOwnProperty(name)) {
			base[name]++;
			print(name + base[name]);
		} else {
			base[name] = 0;
			print('OK');
		}
	}

}).call(this);

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

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

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

function main() {
	var integers = tokenizeIntegers(readline());
	var queryNum = integers[0];

	var names = {};

	for (var i = 0; i < queryNum; i += 1) {
		var query = trim(readline());
		if (names[query] == undefined) {
			print("OK");
			names[query] = 1;
		}
		else {
			print(query+names[query]);
			names[query] += 1;
		}
	}
}

main();

readline = readline || ''
write = write || ''
print = print || ''

readline()

var ns = {}
var ln
while (ln = readline()) ns[ln] ? print(ln + ns[ln]++) : (print('OK'), ns[ln] = 1)

'use strict'

var names = {};
for (var i = parseInt(readline()); i; i--) {
    let name = readline();
    if (names[name]) { write(`${name}${names[name]++}\n`); }
    else { write('OK\n'); names[name] = 1; }
}

'use strict'

const names = {};
for (let i = parseInt(readline()); i; i--) {
    const name = readline();
    if (names[name]) { write(`${name}${names[name]++}\n`); }
    else { write('OK\n'); names[name] = 1; }
}

readline(); x = {};
while(i = readline()) x[i] ? print(i + x[i]++) : (print('OK'), x[i] = 1);

var n = +readline();
var names = {};
for (var i = 0; i < n; i++) {
    var name = readline();
    if (names[name]) { print(`${name}${names[name]}`); names[name] += 1; }
    else { print('OK'); names[name] = 1; }
}

var n = +readline();
var obj = {}, str;

for(var i = 0; i < n; i++) {
    str = readline();
    if (!obj[str]) {
        print('OK');
        obj[str] = 1;
    } else {
        var str2 = str + obj[str];
        obj[str]++;
        print(str2);
        obj[str2] = 1;
    }
}

//print(res);

n = Number(readline());
var names = {};
while (n--) {
    str = readline();
    if (names[str] === undefined) { print('OK'); names[str] = 1; }
    else {print(str + names[str]); names[str]++ }
}

n=Number(readline())
r={}
while (n) {
	w=readline()
	if (w in r) {
		r[w]++;
		print(w+r[w]);
	}
	else {
		r[w]=0;
		print("OK");
	}
	n--;
}

'use strict'

String.prototype.getNumber = function() {
  return String(this).split(' ').map(function (value) {
    return parseInt(value);
  })[0];
}

let n = readline().getNumber(),
    dict = {};

for (let i = 0; i < n; i++) {
  let name = readline();
  if (dict[name]) {
    write(name+(dict[name]++)+'\n');
  } else {
    dict[name] = 1;
    write('OK\n');
  }
}

var o = {
};
var n = readline();
	for (var i=0; i<n; i++){
	    var s = readline();

		if(s in o){
			o[s]++;
			print(s+o[s]);
		}
		else {
		print("OK");
		o[s]=0;
		}
	};

var n = +readline();

var cache = {};
for (var i = 0; i < n; i++) {
    var s = readline();
    if(cache[s]) {
        print(s + cache[s]++)
    }else {
        print('OK');
        cache[s] = 1;
    }
}

var n = parseInt(readline());
var i, j=0, user, userList = {};

for (i=0; i<n; i++){
    user = readline();
    if (user in userList){
        userList[user]++;
        print(user + userList[user]);
    } else {
        userList[user] = 0;
        print('OK');
    }
}

var n = parseInt(readline());
var o = {}; var ii = 0;
for (var i = 0; i < n; i++) {
	var s = readline();
  	if (o[s]) {
      print (s + o[s]);
      o[s] += 1;
    } else {
      o[s] = 1;
      print ('OK');
    }
}

function find(array, name)
{
	if (array[name] !== undefined)
	    {
	    	    return true;
	    }
	  return false;
}

var namesArray = [];
var currentName = null;
for (var counter = +readline(); counter; counter--)
    {
    	    if(!find(namesArray,currentName = readline()))
           {
                namesArray[currentName] = 0;
                print("OK");
                continue;
           }
         print(currentName + ++namesArray[currentName]);
    }

n=Number(readline())
X={}
for (i=0; i<n; ++i) {
    x=readline()
    if (x in X) {
        ++X[x]
        print(`${x}${X[x]}`)
    } else {
        X[x]=0
        print('OK')
    }
}

var n = readline(), str = new Map();
for(var i = 0; i < n; i++) {
    var ss = readline();
    if(str.has(ss)) {
        str.set(ss,str.get(ss) + 1);
        print(ss + str.get(ss));
    }
    else {
        str.set(ss, 0);
        print('OK');
    }
}

var n = parseInt(readline());
var nextInput;
var count = {};

for(var i = 0; i < n ; i++){
    nextInput = readline();
    count[nextInput] ? print(nextInput + count[nextInput]++) : (print("OK"), count[nextInput] = 1);
}

"use strict";

var n = parseInt(readline());
var map = Object.create(null);
for (var i = 0; i < n; i++) {
  var str = readline();
  var prevCount = map[str];
  map[str] = prevCount ? prevCount + 1 : 1;
  if (prevCount) {
    print(str + prevCount);
  } else {
    print("OK");
  }
}

'use strict';
const rl = require('readline')
  .createInterface({ input: process.stdin, output: process.stdout });
const write = (...args) => {
  process.stdout.write(args.join(' '));
};

const lines = [];
rl.on('line', line => {
  lines.push(line);
});

rl.on('close', main);
let rli = 0;

function readline() {
  return lines[rli++];
};

function main() {
  const size = parseInt(readline());
  const registredMap = {};
  for(let i = 0; i < size; ++i){
    const user = readline();
    if(registredMap[user] === undefined) {
      registredMap[user] = 0;
      write("OK\n");
    } else {
      registredMap[user]++;
      write(`${user}${registredMap[user]}\n`);
    }
  }
}

//solved by: asmjaime

'use strict';

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

let input = '';
let currentLine = 0;

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

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

  main();
});

function main() {
  const map = {};

  input.forEach((item, index) => {
    if (index !== 0) {
      if(map[item] !== undefined){
        console.log(`${item}${map[item]}`);
        map[item] += 1;
      } else {
        map[item] = 1;
        console.log('OK');
      }
    }
  });
}

const readline = require('readline')

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

let counts = 0
let inputs = []
let register = {}

RL.on('line', line => {
  const len = inputs.length
  if (!counts) {
    counts = line
  } else if (len < counts) {
    inputs.push(line)
    if (len === counts - 1) {
      solution()
    }
  }
})

function solution() {
  inputs.map(input => {
    if (register[input]) {
      console.log(`${input}${register[input]}`)
      register[input] += 1
    } else {
      console.log('OK')
      register[input] = 1
    }
  })
}

const mainFunction = (lines) => {
    let n = +lines[0],
        map = new Map()
    for (let i = 1; i <= n; i++) {
        let string = lines[i]
        if (map.has(string)) {
            let key = +map.get(string)
            map.delete(string)
            map.set(string, ++key)
            console.log(string + map.get(string))
        } else {
            map.set(string, 0)
            console.log("OK")
        }
    }
}

const { EOL } = require('os')
if (__filename.substr(9, 4) != "azer") {
    let yourInputData = ''
    process.stdin.on('data', i => yourInputData += i)
    process.stdin.on('end', () => mainFunction(yourInputData.split(EOL)))
} else {
    const fileSystem = require("fs");
    mainFunction(fileSystem.readFileSync('input.txt', 'utf8').split(EOL))
}

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

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

readLine.on('close', () => {
  const map = {};
  input.forEach((x, i) => {
    if (i === 0) return;

    if (map[x] !== undefined) {
      console.log(`${x}${map[x]}`);
      map[x] += 1;
    } else {
      map[x] = 1;
      console.log('OK');
    }
  });
});

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

const input = [];

function splitAndParseInt(line) {
  return line.split(" ").map((x) => parseInt(x));
}

readLine.on("line", (line) => input.push(line));
readLine.on("close", () => {
  let n = parseInt(input[0]);
  const map = {};

  for (let i = 1; i <= n; i += 1) {
    const name = input[i];

    if (map[name] === undefined) {
      console.log(`OK`);
      map[name] = 0;
    } else {
      map[name]++;
      console.log(`${name}${map[name]}`);
    }
  }
});

"use strict";
// registration system
// https://codeforces.com/contest/4/problem/C

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

const registered = new Map();
let count=0;
let lines;

rl.on('line', input => {
    if (lines) {
        if (registered.has(input)) {
            registered.set(input, registered.get(input)+1);
            console.log(`${input}${registered.get(input)}`);
        }
        else {
            registered.set(input, 0);
            console.log('OK');
        }
        count++;
        if (count>=lines) process.exit(0);
    }
    else {
        lines = parseInt(input);
    }
    // console.log(input);
});

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

let inputString = "";
let currentLine = 0;

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

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

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

  main();
});
// main();

////////////////////////////////////////////////////////////////////////

function main() {
  let inputNum = parseInt(readline());
  let database = {};
  for (let i = 0; i < inputNum; i++) {
    let inputString = readline();
    if (database[inputString] === undefined) {
      database[inputString] = 0;
      console.log("OK");
    } else {
      database[inputString]++;
      console.log(inputString + database[inputString]);
    }
  }
}

let fs = require("fs");

let txt = fs.readFileSync(0, "utf-8").split(/[\r\n]/).filter(data => data.length > 0);
for (let i = 0; i < txt.length; i ++) {
    if(!isNaN(txt[i]*1)){
        let tab=[];
        for (let i1 = i+1; i1 < i+1+txt[i]*1; i1++) {
            tab.push(txt[i1]);
        }
        doit(tab);
    }
}

function doit(tab) {
    let register=[];
    let enter=[];
    tab.forEach(data => {
        let r=register.indexOf(data);
        if(r!=-1){
            console.log(data+enter[r]);
            ++enter[r];
        }else{
            console.log("OK");
            register.push(data);
            enter.push(1);
        }
    });

}

;(function () {

	var n = +readline();
	var b = [];

	for (var i = 0; i < n; i++) {
		var s = readline();
		var k = b.indexOf(s);

		if (k === -1) {
			b.push(s);
			print('OK');
		} else {
			k = b.filter(function (e) { return e == s; }).length;
			b.push(s + k);
			print(b.slice(-1));
		}
	}

}).call(this);

var names = {};
for (var i = parseInt(readline()); i; i--) {
    var name = readline();
    if (names[name]) { write(`${name}${names[name]++}`); }
    else { write('OK'); names[name] = 1; }
}

'use strict'

String.prototype.getNumber = function() {
  return String(this).split(' ').map(function (value) {
    return parseInt(value);
  })[0];
}

let n = readline().getNumber(),
    dict = {};

for (let i = 0; i < n; i++) {
  let name = readline();
  if (dict[name]) {
    write(name+(dict[name]++));
  } else {
    dict[name] = 1;
    write('OK');
  }
}

var n = readline();
var str = "";

	for (var i=0; i<n; i++){
	    var s = readline();
		var reg = new RegExp("\b"+s+"\b", "g");
		if(reg.test(str))
		{
			s=s+"1"
			print(s);
			str+=s+ " ";
		}
		else {print("OK")
			str+=s+" ";}
	}

var n = readline();
var str = "";

	for (var i=0; i<n; i++){
	    var s = readline();
		var reg = new RegExp(s, "g");
		if(reg.test(str))
		{
			s=s+"1"
			print(s);
			str+=" "+s;
		}
		else {print("OK");
			str+=" "+s;}
	}

var n = readline();
var str = "";

	for (var i=0; i<n; i++){
	    var s = readline();
		var reg = new RegExp(s, "g");
		if(reg.test(str))
		{
			s=s+"1"
			print(s);
			str+=" "+s;
		}
		else {print("OK")
			str+=" "+s;}
	}

var n = readline();
var str = "";
var x = 1;
	for (var i=0; i<n; i++){
	    var s = readline();
		var reg = new RegExp("\\b"+s+"\\b", "g");
		if(reg.test(str))
		{
			s=s+x
			print(s);
			str+=" "+s;
			x++;
		}
		else {print("OK");
			str+=" "+s; x=0;}
	}

var n = readline();
var str = "";

	for (var i=0; i<n; i++){
	    var s = readline();
		var reg = new RegExp("^"+s+"$", "g");
		if(reg.test(str))
		{
			s=s+"1"
			print(s);
			str+=s+ " ";
		}
		else {print("OK")
			str+=s+" ";}
	}

var n = readline();
var str = "";

	for (var i=0; i<n; i++){
	    var s = readline();
		var reg = new RegExp("^"+s+"$", "g");
		if(reg.test(str))
		{
			s=s+"1"
			print(s);
			str+=s;
		}
		else {print("OK")
			str+=s;}
	}

var n = readline();
var str = "";

	for (var i=0; i<n; i++){
	    var s = readline();
		var reg = new RegExp((s));
		if(reg.test(str))
		{
			s=s+"1"
			print(s);
			str+=s;
		}
		else {print("OK")
			str+=s;}
	}

var n = readline();
var str = "";

	for (var i=0; i<n; i++){
	    var s = readline();
		var reg = new RegExp("\b"+s+"\b", "g");
		if(reg.test(str))
		{
			s=s+"1"
			print(s);
			str+=s;
		}
		else {print("OK")
			str+=s;}
	}

var n = readline();
var str = "";

	for (var i=0; i<n; i++){
	    var s = readline();
		var reg = new RegExp(s);
		if(reg.test(str))
		{
			s=s+"1"
			print(s);
			str+=s;
		}
		else {print("OK")
			str+=s;}
	}

var n = readline();
var str = "";

	for (var i=0; i<n; i++){
	    var s = readline();
		var reg = new RegExp("\\b"+s+"\\b", "g");
		if(reg.test(str))
		{
			s=s+"1"
			print(s);
			str+=" "+s;
		}
		else {print("OK");
			str+=" "+s;}
	}

var inputs = parseInt(readline());
var arr = [];
var nextInput;

for(var i = 0; i < inputs; i++){
    nextInput = readline();
    if(arr.includes(nextInput)){
        var num = 1;
        while(arr.includes(nextInput)){
         nextInput =  nextInput+num;
         num++;
        }
        print(nextInput);
    }else{
        print("OK")
    }
    arr.push(nextInput);
}

'use strict';

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

let input = '';
let currentLine = 0;

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

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

  main();
});

function main() {
  const map = {};

  input.forEach((item, index) => {
    if (index !== 0) {
      if(map[item] !== undefined){
        console.log(`${item}${map[item]}`);
        map[item] += 1;
      } else {
        map[item] = 1;
        console.log('ОК');
      }
    }
  });
}

'use strict';

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

let input = '';
let currentLine = 0;

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

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

  main();
});

function main() {
  const map = {};

  input.forEach((item, index) => {
    if (index !== 0) {
      for (let i = ''; true; i += 1) {
        if (map[item + i] === undefined) {
          map[item + i] = 1;
          if (i === '') {
            console.log('OK');
          } else {
            console.log(item + i);
          }
          break;
        }
      }
    }
  });
}

const mainFunction = (lines) => {
    let n = +lines[0],
        map = new Map()
    for (let i = 1; i <= n; i++) {
        let string = lines[i]
        if (map.has(string)) {
            let key = +map.get(string)
            map.clear(string)
            map.set(string, ++key)
            console.log(string + map.get(string))
        } else {
            map.set(string, 0)
            console.log("OK")
        }
    }
}

const { EOL } = require('os')
if (__filename.substr(9, 4) != "azer") {
    let yourInputData = ''
    process.stdin.on('data', i => yourInputData += i)
    process.stdin.on('end', () => mainFunction(yourInputData.split(EOL)))
} else {
    const fileSystem = require("fs");
    mainFunction(fileSystem.readFileSync('input.txt', 'utf8').split(EOL))
}

"use strict";
// registration system
// https://codeforces.com/contest/4/problem/C

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

const registered = new Map();
let count=0;
let lines;

rl.on('line', input => {
    if (lines) {
        if (registered.has(input)) {
            console.log(`${input}1`);
        }
        else {
            registered.set(input, 1);
            console.log('OK');
        }
        count++;
        if (count>=lines) process.exit(0);
    }
    else {
        lines = parseInt(input);
    }
    // console.log(input);
});


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
}

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

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

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


    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)

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)

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
}


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

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


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


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


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

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])
}

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])
}

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

}
}

"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]
    }
}