You are given a positive decimal number x.Your task is to convert it to the "simple exponential notation".Let x = a·10b, where 1 ≤ a < 10, then in general case the "simple exponential notation" looks like "aEb". If b equals to zero, the part "Eb" should be skipped. If a is an integer, it should be written without decimal point. Also there should not be extra zeroes in a and b.

The only line contains the positive decimal number x. The length of the line will not exceed 106. Note that you are given too large number, so you can't use standard built-in data types "float", "double" and other.

Print the only line — the "simple exponential notation" of the given number x.


Alice and Bob are playing a game. Initially, they are given a non-empty string $$$s$$$, consisting of lowercase Latin letters. The length of the string is even. Each player also has a string of their own, initially empty.Alice starts, then they alternate moves. In one move, a player takes either the first or the last letter of the string $$$s$$$, removes it from $$$s$$$ and prepends (adds to the beginning) it to their own string.The game ends when the string $$$s$$$ becomes empty. The winner is the player with a lexicographically smaller string. If the players' strings are equal, then it's a draw.A string $$$a$$$ is lexicographically smaller than a string $$$b$$$ if there exists such position $$$i$$$ that $$$a_j = b_j$$$ for all $$$j < i$$$ and $$$a_i < b_i$$$.What is the result of the game if both players play optimally (e. g. both players try to win; if they can't, then try to draw)?

The first line contains a single integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of testcases. Each testcase consists of a single line — a non-empty string $$$s$$$, consisting of lowercase Latin letters. The length of the string $$$s$$$ is even. The total length of the strings over all testcases doesn't exceed $$$2000$$$.

For each testcase, print the result of the game if both players play optimally. If Alice wins, print "Alice". If Bob wins, print "Bob". If it's a draw, print "Draw".

NoteOne of the possible games Alice and Bob can play in the first testcase:   Alice picks the first letter in $$$s$$$: $$$s=$$$"orces", $$$a=$$$"f", $$$b=$$$"";  Bob picks the last letter in $$$s$$$: $$$s=$$$"orce", $$$a=$$$"f", $$$b=$$$"s";  Alice picks the last letter in $$$s$$$: $$$s=$$$"orc", $$$a=$$$"ef", $$$b=$$$"s";  Bob picks the first letter in $$$s$$$: $$$s=$$$"rc", $$$a=$$$"ef", $$$b=$$$"os";  Alice picks the last letter in $$$s$$$: $$$s=$$$"r", $$$a=$$$"cef", $$$b=$$$"os";  Bob picks the remaining letter in $$$s$$$: $$$s=$$$"", $$$a=$$$"cef", $$$b=$$$"ros". Alice wins because "cef" < "ros". Neither of the players follows any strategy in this particular example game, so it doesn't show that Alice wins if both play optimally.

'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(read) {
  const s = read(),
        n = s.length;
  if (n % 2 == 0) {
    const cache = Array.from({
      length: n
    }, () => new Map());
    const dfs = (i, j, p) => {
      if (j - i === 1) {
        if (s[i] === s[j]) return 0;
        return 1;
      }
      if (cache[i].has(j)) return cache[i].get(j);
      let res = 1;
      if (j - i & 1) {
        let a = dfs(i + 1, j, s[i]),
            b = dfs(i, j - 1, s[j]);
        if (a === -1 && b === -1) {
          res = -1;
        } else if (a === 0 && b === 0) {
          res = 0;
        }
        cache[i].set(j, res);
      } else {
        let a = dfs(i + 1, j, s[i]),
            b = dfs(i, j - 1, s[j]);
        if (a === 0 && s[i] < p || b === 0 && s[j] < p) {
          res = -1;
        } else if (a === 0 && s[i] === p || b === 0 && s[j] === p) {
          res = 0;
        }
      }
      return res;
    };
    let res = dfs(0, n - 1, '');
    if (res === 0) return 'Draw';else if (res === 1) return 'Alice';
    return 'Bob';
  }
  return 'Bob';
}

function main(r) {
  try {
    let t = Number(r());
    let res = new Array(t);
    for (let i = 0; i < t; i++) {
      var _solve;
      const s = (_solve = solve(r)) !== null && _solve !== void 0 ? _solve : '';
      if (t < 100) {
        process.stdout.write(s.toString());
        process.stdout.write('\n');
      } else {
        res[i] = s;
      }
    }
    if (t >= 100) {
      return res.join('\n');
    } else {
      return '';
    }
  } catch (error) {
    console.log(error);
  }
}

const inputs = fs__default["default"].readFileSync(0, 'utf-8').split(/\s+/);
void function () {
  const read = ((i = 0) => () => inputs[i++])();
  const output = main(read);
  process.stdout.write(output);
}();

/*
** <problem_number> - <problem_title>
*/

// Common Template Starts //
//*
process.stdin.resume();
process.stdin.setEncoding("utf-8");

let inputString = "";
let currentLine = 0;

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

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

    main();
});

function readline() {
    return inputString[currentLine++];
}
// Common Template Ends //

function main() {
    let testcases = parseInt(readline())

    while (testcases--) {
        let str = readline().split('')
        let left = 0
        let right = str.length - 1

        while(str[left] == str[right]){
            if(left >= right) break
            left++
            right--
        }

        while(str[left] == str[left+1]) {
            if(left >= right) break
            left += 2
        }

        ( left <= right ) ? console.log('Alice') : console.log('Draw')
    }
}

const util = require("util")

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

let inputString = '';
let currentLine = 0;

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

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

    main();
});

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

//

function main() {
    let t = parseInt(readLine())
    while (t--) {
        let str = readLine()
        const n = str.length
        str = "a"+str+"a"
        let f = []
        for (let i = 0; i <= n+1; i ++) {
            f[i] = []
            for (let j = 0; j <= n+1; j++) {
                f[i][j] = i > j
            }
        }
        // console.log(util.inspect(f, {depth: null, colors: true}))
        for (let len = 2; len <= n; len += 2) {
            for (let i = 1; i + len - 1 <= n; i ++) {
                let j = i + len - 1
                if (str[i] === str[i+1] && str[j-1] === str[j]) {
                    f[i][j] = f[i][j] || (f[i+2][j] && f[i][j-2])
                }
                if (str[i] === str[j]) {
                    f[i][j] = f[i][j] || f[i+1][j-1]
                }
            }
        }
        if (f[1][n]) {
            console.log("Draw")
        } else {
            console.log("Alice")
        }
    }
}

const readline = require('readline')

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

function solve(str) {
    const n = str.length
    let prev
    for (let l = 2; l <= n; l += 2) {
        const dp = Array(n)
        for (let i = 0; i + l - 1 < n; i++) {
            if (l === 2) {
                dp[i] = Math.min(
                    cmp(0, str[i], str[i + 1]),
                    cmp(0, str[i + 1], str[i])
                )
                continue
            }
            const a = Math.max(
                cmp(prev[i + 2], str[i], str[i + 1]),
                cmp(prev[i + 1], str[i], str[i + l - 1])
            )
            const b = Math.max(
                cmp(prev[i], str[i + l - 1], str[i + l - 2]),
                cmp(prev[i + 1], str[i + l - 1], str[i])
            )
            dp[i] = Math.min(a, b)
        }
        // console.log(dp)
        prev = dp
    }
    return prev[0] < 0 ? 'Alice' : (prev[0] > 0 ? 'Bob' : 'Draw')

    function cmp(sub, a, b) {
        if (sub === 0) {
            return a < b ? -1 : (a > b ? 1 : 0)
        } else {
            return sub
        }
    }
}

'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(read) {
  const s = read(),
        n = s.length;
  if (n % 2 == 0) {
    const cache = Array.from({
      length: n
    }, () => new Map());
    const dfs = (i, j) => {
      if (j - i === 1) {
        return s[i] !== s[j];
      }
      if (cache[i].has(j)) return cache[i].get(j);
      if (j - i & 1) {
        if (s[i] !== s[j]) return true;
      }
      let a = dfs(i + 1, j),
          b = dfs(i, j - 1);
      if (a && b) {
        cache[i].set(j, false);
        return false;
      }
      cache[i].set(j, true);
      return true;
    };
    if (dfs(0, n - 1)) return 'Alice';
    return 'Draw';
  }
  return 'Bob';
}

function main(r) {
  try {
    let t = Number(r());
    let res = new Array(t);
    for (let i = 0; i < t; i++) {
      var _solve;
      const s = (_solve = solve(r)) !== null && _solve !== void 0 ? _solve : '';
      if (t < 100) {
        process.stdout.write(s.toString());
        process.stdout.write('\n');
      } else {
        res[i] = s;
      }
    }
    if (t >= 100) {
      return res.join('\n');
    } else {
      return '';
    }
  } catch (error) {
    console.log(error);
  }
}

const inputs = fs__default["default"].readFileSync(0, 'utf-8').split(/\s+/);
void function () {
  const read = ((i = 0) => () => inputs[i++])();
  const output = main(read);
  process.stdout.write(output);
}();

'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(read) {
  const s = read(),
        n = s.length;
  if (n % 2 == 0) {
    const cache = Array.from({
      length: n
    }, () => new Map());
    const dfs = (i, j) => {
      if (j - i === 1) {
        return s[i] === s[j];
      }
      if (cache[i].has(j)) return cache[i].get(j);
      if (j - i & 1) {
        let a = dfs(i + 1, j),
            b = dfs(i, j - 1);
        if (a && b) {
          cache[i].set(j, true);
          return true;
        }
        cache[i].set(j, false);
        return false;
      } else {
        if (dfs(i + 1, j) || dfs(i, j - 1)) {
          cache[i].set(j, true);
          return true;
        }
        cache[i].set(j, false);
        return false;
      }
    };
    if (dfs(0, n - 1)) return 'Draw';
    return 'Alice';
  }
  return 'Bob';
}

function main(r) {
  try {
    let t = Number(r());
    let res = new Array(t);
    for (let i = 0; i < t; i++) {
      var _solve;
      const s = (_solve = solve(r)) !== null && _solve !== void 0 ? _solve : '';
      if (t < 100) {
        process.stdout.write(s.toString());
        process.stdout.write('\n');
      } else {
        res[i] = s;
      }
    }
    if (t >= 100) {
      return res.join('\n');
    } else {
      return '';
    }
  } catch (error) {
    console.log(error);
  }
}

const inputs = fs__default["default"].readFileSync(0, 'utf-8').split(/\s+/);
void function () {
  const read = ((i = 0) => () => inputs[i++])();
  const output = main(read);
  process.stdout.write(output);
}();

'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(read) {
  const s = read(),
        n = s.length;
  if (n % 2 == 0) {
    let flag = true;
    for (let i = 0, j = n - 1; i < j; i++, j--) {
      if (s[i] !== s[j]) {
        flag = false;
        break;
      }
    }
    if (flag) return 'Draw';else return 'Alice';
  }
  return 'Bob';
}

function main(r) {
  try {
    let t = Number(r());
    let res = new Array(t);
    for (let i = 0; i < t; i++) {
      var _solve;
      const s = (_solve = solve(r)) !== null && _solve !== void 0 ? _solve : '';
      if (t < 100) {
        process.stdout.write(s.toString());
        process.stdout.write('\n');
      } else {
        res[i] = s;
      }
    }
    if (t >= 100) {
      return res.join('\n');
    } else {
      return '';
    }
  } catch (error) {
    console.log(error);
  }
}

const inputs = fs__default["default"].readFileSync(0, 'utf-8').split(/\s+/);
void function () {
  const read = ((i = 0) => () => inputs[i++])();
  const output = main(read);
  process.stdout.write(output);
}();

'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(read) {
  const s = read();
  const strs = [[], []];
  for (let i = 0, j = s.length - 1; i <= j;) {
    let k = i + (s.length - j - 1) & 1;
    if (s[i] <= s[j]) strs[k].push(s[i++]);else strs[k].push(s[j--]);
  }
  const [a, b] = strs;
  a.reverse();
  b.reverse();
  const n = Math.max(strs.length, b.length);
  for (let i = 0; i < n; i++) {
    if (a[i] === b[i]) continue;
    if (a[i] === undefined || a[i] < b[i]) return 'Alice';else return 'Bob';
  }
  return 'Draw';
}

function main(r) {
  try {
    let t = Number(r());
    let res = new Array(t);
    for (let i = 0; i < t; i++) {
      var _solve;
      const s = (_solve = solve(r)) !== null && _solve !== void 0 ? _solve : '';
      if (t < 100) {
        process.stdout.write(s.toString());
        process.stdout.write('\n');
      } else {
        res[i] = s;
      }
    }
    if (t >= 100) {
      return res.join('\n');
    } else {
      return '';
    }
  } catch (error) {
    console.log(error);
  }
}

const inputs = fs__default["default"].readFileSync(0, 'utf-8').split(/\s+/);
void function () {
  const read = ((i = 0) => () => inputs[i++])();
  const output = main(read);
  process.stdout.write(output);
}();

'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(read) {
  const s = read();
  const a = [],
        b = [];
  for (let i = 0, j = s.length - 1; i < j; i++, j--) {
    let [x, y] = [s[i], s[j]];
    if (x > y) [x, y] = [y, x];
    a.push(x);
    if (i < j - 1) b.push(y);
  }
  a.reverse();
  b.reverse();
  const n = Math.max(a.length, b.length);
  for (let i = 0; i < n; i++) {
    if (a[i] === b[i]) continue;
    if (a[i] === undefined || a[i] < b[i]) return 'Alice';else return 'Bob';
  }
  return 'Draw';
}

function main(r) {
  try {
    let t = Number(r());
    let res = new Array(t);
    for (let i = 0; i < t; i++) {
      var _solve;
      const s = (_solve = solve(r)) !== null && _solve !== void 0 ? _solve : '';
      if (t < 100) {
        process.stdout.write(s.toString());
        process.stdout.write('\n');
      } else {
        res[i] = s;
      }
    }
    if (t >= 100) {
      return res.join('\n');
    } else {
      return '';
    }
  } catch (error) {
    console.log(error);
  }
}

const inputs = fs__default["default"].readFileSync(0, 'utf-8').split(/\s+/);
void function () {
  const read = ((i = 0) => () => inputs[i++])();
  const output = main(read);
  process.stdout.write(output);
}();

'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(read) {
  const s = read();
  let l = 0,
      r = s.length - 1;
  while (l < r - 1) {
    if (s[l] === s[r]) {
      l++;
      r--;
    } else return 'Alice';
  }
  if (l === r - 1) return 'Draw';
  return 'Bob';
}

function main(r) {
  try {
    let t = Number(r());
    let res = new Array(t);
    for (let i = 0; i < t; i++) {
      var _solve;
      const s = (_solve = solve(r)) !== null && _solve !== void 0 ? _solve : '';
      if (t < 100) {
        process.stdout.write(s.toString());
        process.stdout.write('\n');
      } else {
        res[i] = s;
      }
    }
    if (t >= 100) {
      return res.join('\n');
    } else {
      return '';
    }
  } catch (error) {
    console.log(error);
  }
}

const inputs = fs__default["default"].readFileSync(0, 'utf-8').split(/\s+/);
void function () {
  const read = ((i = 0) => () => inputs[i++])();
  const output = main(read);
  process.stdout.write(output);
}();

/*
** <problem_number> - <problem_title>
*/

// Common Template Starts //
//*
process.stdin.resume();
process.stdin.setEncoding("utf-8");

let inputString = "";
let currentLine = 0;

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

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

    main();
});

function readline() {
    return inputString[currentLine++];
}
// Common Template Ends //

function main() {
    let testcases = parseInt( readline() )

    while(testcases--) {
        let str = readline()
        let alice = bob = ''

        let round = 1, moves = str.length
        while( str !== '' ){
            let firstChar = str.charAt(0)
            let lastChar = str.charAt(str.length - 1)
            let pickedChar = ''

            if( firstChar <= lastChar ) {
                pickedChar = firstChar
                str = str.substring(1)
            } else {
                pickedChar = lastChar
                str = str.substring(0, str.length - 1)
            }

            if( round % 2 == 1 ) alice = pickedChar.concat(alice)
            else bob = pickedChar.concat(bob)

            round++
        }

        if( alice == bob ) console.log('Draw')
        else console.log('Alice')
    }
}

/*
** <problem_number> - <problem_title>
*/

// Common Template Starts //
//*
process.stdin.resume();
process.stdin.setEncoding("utf-8");

let inputString = "";
let currentLine = 0;

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

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

    main();
});

function readline() {
    return inputString[currentLine++];
}
// Common Template Ends //

function main() {
    let testcases = parseInt( readline() )

    while(testcases--) {
        let str = readline()
        let alice = bob = ''

        let re = /[\W_]/g;
        let lowRegStr = str.toLowerCase().replace(re, '');
        let reverseStr = lowRegStr.split('').reverse().join('');
        if( reverseStr === lowRegStr ) console.log('Draw')
        else {

            let round = 1
            while( str !== '' ){
                let first = str.charAt(0)
                let last = str.charAt(str.length - 1)
                let picked = ''

                if( first > last ) {
                    picked = last
                    str = str.substring(0, str.length - 1)
                } else if( first < last ){
                    picked = first
                    str = str.substring(1)
                } else {
                    if( round % 2 == 1 ) {
                        picked = last
                        str = str.substring(0, str.length - 1)
                    } else {
                        picked = first
                        str = str.substring(1)
                    }
                }

                if( round % 2 == 1 ) alice = picked.concat(alice)
                else bob = picked.concat(bob)

                round++
            }

            if( alice < bob ) console.log('Alice')
            if( alice > bob ) console.log('Bob')
            if( alice == bob ) console.log('Draw')

        }

    }
}

/*
** <problem_number> - <problem_title>
*/

// Common Template Starts //
//*
process.stdin.resume();
process.stdin.setEncoding("utf-8");

let inputString = "";
let currentLine = 0;

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

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

    main();
});

function readline() {
    return inputString[currentLine++];
}
// Common Template Ends //

function main() {
    let testcases = parseInt( readline() )

    while(testcases--) {
        let str = readline()
        let alice = bob = ''

        let round = 1, moves = str.length
        while( str !== '' ){
            let firstChar = str.charAt(0)
            let lastChar = str.charAt(str.length - 1)
            let pickedChar = ''

            if( firstChar <= lastChar ) {
                pickedChar = firstChar
                str = str.substring(1)
            } else {
                pickedChar = lastChar
                str = str.substring(0, str.length - 1)
            }

            if( round % 2 == 1 ) alice = pickedChar.concat(alice)
            else bob = pickedChar.concat(bob)

            round++
        }

        if( alice < bob ) console.log('Alice')
        if( alice > bob ) console.log('Bob')
        if( alice == bob ) console.log('Draw')
    }
}

/*
** <problem_number> - <problem_title>
*/

// Common Template Starts //
//*
process.stdin.resume();
process.stdin.setEncoding("utf-8");

let inputString = "";
let currentLine = 0;

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

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

    main();
});

function readline() {
    return inputString[currentLine++];
}
// Common Template Ends //

function main() {
    let testcases = parseInt( readline() )

    while(testcases--) {
        let str = readline()
        let alice = bob = ''

        let round = 1, moves = str.length
        while( str !== '' ){
            let firstChar = str.charAt(0)
            let lastChar = str.charAt(str.length - 1)
            let pickedChar = ''

            if( firstChar < lastChar ) {
                pickedChar = firstChar
                str = str.substring(1)
            } else {
                pickedChar = lastChar
                str = str.substring(0, str.length - 1)
            }

            if( round % 2 == 1 ) alice = pickedChar.concat(alice)
            else bob = pickedChar.concat(bob)

            round++
        }

        if( alice < bob ) console.log('Alice')
        if( alice > bob ) console.log('Bob')
        if( alice == bob ) console.log('Draw')
    }
}

/*
** <problem_number> - <problem_title>
*/

// Common Template Starts //
//*
process.stdin.resume();
process.stdin.setEncoding("utf-8");

let inputString = "";
let currentLine = 0;

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

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

    main();
});

function readline() {
    return inputString[currentLine++];
}
// Common Template Ends //

function main() {
    let str = readline()
    let alice = bob = ''

    let round = 1, moves = str.length
    while( str !== '' ){
        let firstChar = str.charAt(0)
        let lastChar = str.charAt(str.length - 1)
        let pickedChar = ''

        if( firstChar < lastChar ) {
            pickedChar = firstChar
            str = str.substring(1)
        } else {
            pickedChar = lastChar
            str = str.substring(0, str.length - 1)
        }

        if( round % 2 == 1 ) alice = pickedChar.concat(alice)
        else bob = pickedChar.concat(bob)

        round++
    }

    if( alice < bob ) console.log('Alice')
    if( alice > bob ) console.log('Bob')
    if( alice == bob ) console.log('Draw')
}

const util = require("util")

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

let inputString = '';
let currentLine = 0;

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

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

    main();
});

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

//

function main() {
    let t = parseInt(readLine())
    while (t--) {
        let str = readLine()
        const n = str.length
        str = "x"+str+"x"
        let f = []
        for (let i = 0; i <= n+1; i ++) {
            f[i] = []
            for (let j = 0; j <= n+1; j++) {
                f[i][j] = []
                for (let k = 0; k < 2; k++) {
                    f[i][j][k] = []
                    for (let l = 0; l < 2; l++) {
                        f[i][j][k][l] = i >= j;
                    }
                }
            }
        }
        // console.log(util.inspect(f, {depth: null, colors: true}))
        for (let len = 2; len <= n; len += 2) {
            for (let i = 1; i + len - 1 <= n; i ++) {
                let j = i + len - 1
                let left = str[i] === str[i+1] ? 1 : 0
                let right = str[j-1] === str[j] ? 1 : 0
                if (str[i] === str[i+1]) {
                    let res = f[i+2][j][0][1] || f[i+2][j][1][1]
                    f[i][j][left][right] = f[i][j][left][right] || res
                }
                if (str[j-1] === str[j]) {
                    let res = f[i][j-2][1][0] || f[i][j-2][1][1]
                    f[i][j][left][right] = f[i][j][left][right] || res
                }
                if (str[i] === str[j]) {
                    let res = cum(f[i+1][j-1])
                    f[i][j][left][right] = f[i][j][left][right] || res
                }
                // console.log(`${i}-${j}-${str.slice(i,j+1)}\t${f[i][j][left][right]}`)
            }
        }
        if (cum(f[1][n])) {
            console.log("Draw")
        } else {
            console.log("Alice")
        }
    }
}

function cum(f) {
    let res = false
    for (let k = 0; k < 2; k ++)
        for (let l = 0; l < 2; l ++) {
            res = res || f[k][l]
        }
    return res
}

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

let inputString = '';
let currentLine = 0;

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

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

    main();
});

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

//

function main() {
    let t = parseInt(readLine())
    while (t--) {
        let oldStr = readLine()
        let newStr = ""
        while (oldStr !== "") {
            let i = 0
            while (i < oldStr.length) {
                if (i < oldStr.length - 1 && oldStr[i] === oldStr[i+1]) {
                    i += 2
                    continue
                }
                newStr += oldStr[i]
                i ++
            }
            // console.log(oldStr, newStr)
            if (oldStr === newStr) break
            oldStr = newStr
            newStr = ""
        }
        if (newStr === "") {
            console.log("Draw")
        } else {
            console.log("Alice")
        }
    }
}


A programming coach has n students to teach. We know that n is divisible by 3. Let's assume that all students are numbered from 1 to n, inclusive.Before the university programming championship the coach wants to split all students into groups of three. For some pairs of students we know that they want to be on the same team. Besides, if the i-th student wants to be on the same team with the j-th one, then the j-th student wants to be on the same team with the i-th one. The coach wants the teams to show good results, so he wants the following condition to hold: if the i-th student wants to be on the same team with the j-th, then the i-th and the j-th students must be on the same team. Also, it is obvious that each student must be on exactly one team.Help the coach and divide the teams the way he wants.

The first line of the input contains integers n and m (3 ≤ n ≤ 48, . Then follow m lines, each contains a pair of integers ai, bi (1 ≤ ai < bi ≤ n) — the pair ai, bi means that students with numbers ai and bi want to be on the same team. It is guaranteed that n is divisible by 3. It is guaranteed that each pair ai, bi occurs in the input at most once.

If the required division into teams doesn't exist, print number -1. Otherwise, print  lines. In each line print three integers xi, yi, zi (1 ≤ xi, yi, zi ≤ n) — the i-th team.  If there are multiple answers, you are allowed to print any of them.

let input = ''

// Input
process.stdin.on('data', line => {
	input += line
})

// Process
process.stdin.on('end', () => {
	const { EOL } = require('os')
	const lines = input.split(EOL).filter(data => data)

	const [ n, m ] = lines[0].split(' ').map(num => +num)
	if (m > n) {
		console.log(-1)
		return
	}
	const teamList = []
	const numOfTeam = n / 3
	const teamNumber = []
	let curTeam = 1
	// Init list
	for (let i = 0; i < n; i++) {
		teamList[i] = []
	}
	// Divide team
	for (let i = 1; i <= m; i++) {
		const [ a, b ] = lines[i].split(' ').map(num => +num)
		// If two people not in any team => they must be on new team
		if (!teamNumber[a] && !teamNumber[b]) {
			teamList[curTeam - 1].push(a)
			teamList[curTeam - 1].push(b)
			teamNumber[a] = curTeam
			teamNumber[b] = curTeam
			curTeam += 1
		}
		// At least one of them are in a team
		else {
			// If both of them have a team
			if (teamNumber[a] && teamNumber[b]) {
				// If both of them are in different teams
				if (teamNumber[a] !== teamNumber[b]) {
					console.log(-1)
					return
				}
			}
			// If only one of them have a team
			else {
				// Get the team that are assigned
				const assignedTeam = teamNumber[a] || teamNumber[b]
				// If assigned team reached the limit members number
				if (teamList[assignedTeam - 1].length >= 3) {
					console.log(-1)
					return
				}
				else {
					assignedTeam === teamNumber[a]
						? teamList[assignedTeam - 1].push(b)
						: teamList[assignedTeam - 1].push(a)
					teamNumber[a] = assignedTeam
					teamNumber[b] = assignedTeam
				}
			}
		}
	}

	// If number of teams is higher than expected
	if (curTeam - 1 > numOfTeam) {
		console.log(-1)
		return
	}

	// Check if there are unassigned people to a team
	curTeam = 1
	for (let i = 1; i <= n; i++) {
		while (curTeam <= numOfTeam && teamList[curTeam - 1].length >= 3) {
			curTeam += 1
		}
		if (!teamNumber[i]) {
			teamList[curTeam - 1].push(i)
		}
	}

	teamList.forEach(list => console.log(list.join(' ')))
})

let input = ''

// Input
process.stdin.on('data', line => {
	input += line
})

// Process
process.stdin.on('end', () => {
	const { EOL } = require('os')
	const lines = input.split(EOL).filter(data => data)

	const [ n, m ] = lines[0].split(' ').map(num => +num)
	if (m > n) {
		console.log(-1)
		return
	}
	const teamList = []
	const numOfTeam = n / 3
	const teamNumber = []
	let curTeam = 1
	// Init list
	for (let i = 0; i < numOfTeam; i++) {
		teamList[i] = []
	}
	// Divide team
	for (let i = 1; i <= m; i++) {
		const [ a, b ] = lines[i].split(' ').map(num => +num)
		// If two people not in any team => they must be on new team
		if (!teamNumber[a] && !teamNumber[b]) {
			teamList[curTeam - 1].push(a)
			teamList[curTeam - 1].push(b)
			teamNumber[a] = curTeam
			teamNumber[b] = curTeam
			curTeam += 1
		}
		// At least one of them are in a team
		else {
			// If both of them have a team
			if (teamNumber[a] && teamNumber[b]) {
				// If both of them are in different teams
				if (teamNumber[a] !== teamNumber[b]) {
					console.log(-1)
					return
				}
			}
			// If only one of them have a team
			else {
				// Get the team that are assigned
				const assignedTeam = teamNumber[a] || teamNumber[b]
				// If assigned team reached the limit members number
				if (teamList[assignedTeam - 1].length >= 3) {
					console.log(-1)
					return
				}
				else {
					assignedTeam === teamNumber[a]
						? teamList[assignedTeam - 1].push(b)
						: teamList[assignedTeam - 1].push(a)
					teamNumber[a] = assignedTeam
					teamNumber[b] = assignedTeam
				}
			}
		}
	}

	// If number of teams is higher than expected
	if (curTeam > numOfTeam) {
		console.log(-1)
		return
	}

	// Check if there are unassigned people to a team
	curTeam = 1
	for (let i = 1; i <= n; i++) {
		while (teamList[curTeam - 1].length >= 3) {
			curTeam += 1
		}
		if (!teamNumber[i]) {
			teamList[curTeam - 1].push(i)
		}
	}

	teamList.forEach(list => console.log(list.join(' ')))
})

let input = ''

// Input
process.stdin.on('data', line => {
	input += line
})

// Process
process.stdin.on('end', () => {
	const { EOL } = require('os')
	const lines = input.split(EOL).filter(data => data)

	const [ n, m ] = lines[0].split(' ').map(num => +num)
	if (m > n) {
		console.log(-1)
		return
	}
	const teamList = []
	const numOfTeam = n / 3
	const teamNumber = []
	let curTeam = 1
	// Init list
	for (let i = 0; i < numOfTeam; i++) {
		teamList[i] = []
	}
	// Divide team
	for (let i = 1; i <= m; i++) {
		const [ a, b ] = lines[i].split(' ').map(num => +num)
		// If two people not in any team => they must be on new team
		if (!teamNumber[a] && !teamNumber[b]) {
			teamList[curTeam - 1].push(a)
			teamList[curTeam - 1].push(b)
			teamNumber[a] = curTeam
			teamNumber[b] = curTeam
			curTeam += 1
		}
		// At least one of them are in a team
		else {
			// If both of them have a team
			if (teamNumber[a] && teamNumber[b]) {
				// If both of them are in different teams
				if (teamNumber[a] !== teamNumber[b]) {
					console.log(-1)
					return
				}
			}
			// If only one of them have a team
			else {
				// Get the team that are assigned
				const assignedTeam = teamNumber[a] || teamNumber[b]
				// If assigned team reached the limit members number
				if (teamList[assignedTeam - 1].length >= 3) {
					console.log(-1)
					return
				}
				else {
					assignedTeam === teamNumber[a]
						? teamList[assignedTeam - 1].push(b)
						: teamList[assignedTeam - 1].push(a)
					teamNumber[a] = assignedTeam
					teamNumber[b] = assignedTeam
				}
			}
		}
	}

	// If number of teams is higher than expected
	if (curTeam > numOfTeam) {
		console.log(-1)
		return
	}

	// Check if there are unassigned people to a team
	curTeam = 1
	for (let i = 1; i <= n; i++) {
		while (curTeam <= numOfTeam && teamList[curTeam - 1].length >= 3) {
			curTeam += 1
		}
		if (!teamNumber[i]) {
			teamList[curTeam - 1].push(i)
		}
	}

	teamList.forEach(list => console.log(list.join(' ')))
})

let input = ''

// Input
process.stdin.on('data', line => {
	input += line
})

// Process
process.stdin.on('end', () => {
	const { EOL } = require('os')
	const lines = input.split(EOL).filter(data => data)

	const [ n, m ] = lines[0].split(' ').map(num => +num)
	if (m > n) {
		console.log(-1)
		return
	}
	const teamList = []
	const numOfTeam = n / 3
	const teamNumber = []
	let curTeam = 1
	// Init list
	for (let i = 0; i < numOfTeam; i++) {
		teamList[i] = []
	}
	// Divide team
	for (let i = 1; i <= m; i++) {
		const [ a, b ] = lines[i].split(' ').map(num => +num)
		// If two people not in any team => they must be on new team
		if (!teamNumber[a] && !teamNumber[b]) {
			teamList[curTeam - 1].push(a)
			teamList[curTeam - 1].push(b)
			teamNumber[a] = curTeam
			teamNumber[b] = curTeam
			curTeam += 1
		}
		// At least one of them are in a team
		else {
			// If both of them have a team
			if (teamNumber[a] && teamNumber[b]) {
				// If both of them are in different teams
				if (teamNumber[a] !== teamNumber[b]) {
					console.log(-2)
					return
				}
			}
			// If only one of them have a team
			else {
				// Get the team that are assigned
				const assignedTeam = teamNumber[a] || teamNumber[b]
				// If assigned team reached the limit members number
				if (teamList[assignedTeam - 1].length >= 3) {
					console.log(-1)
					return
				}
				else {
					assignedTeam === teamNumber[a]
						? teamList[assignedTeam - 1].push(b)
						: teamList[assignedTeam - 1].push(a)
					teamNumber[a] = assignedTeam
					teamNumber[b] = assignedTeam
				}
			}
		}
	}

	// If number of teams is higher than expected
	if (curTeam > numOfTeam) {
		console.log(-1)
		return
	}

	// Check if there are unassigned people to a team
	curTeam = 1
	for (let i = 1; i <= n; i++) {
		while (teamList[curTeam - 1].length >= 3) {
			curTeam += 1
		}
		if (!teamNumber[i]) {
			teamList[curTeam - 1].push(i)
		}
	}

	teamList.forEach(list => console.log(list.join(' ')))
})

let input = ''

// Input
process.stdin.on('data', line => {
	input += line
})

// Process
process.stdin.on('end', () => {
	const { EOL } = require('os')
	const lines = input.split(EOL).filter(data => data)

	const [ n, m ] = lines[0].split(' ').map(num => +num)
	if (m > n) {
		console.log(-1)
		return
	}
	const teamList = []
	const numOfTeam = n / 3
	const teamNumber = []
	let curTeam = 1
	// Init list
	for (let i = 0; i < numOfTeam; i++) {
		teamList[i] = []
	}
	// Divide team
	for (let i = 1; i <= m; i++) {
		const [ a, b ] = lines[i].split(' ').map(num => +num)
		// If two people not in any team => they must be on new team
		if (!teamNumber[a] && !teamNumber[b]) {
			teamList[curTeam - 1].push(a)
			teamList[curTeam - 1].push(b)
			teamNumber[a] = curTeam
			teamNumber[b] = curTeam
			curTeam += 1
		}
		// At least one of them are in a team
		else {
			// If both of them have a team
			if (teamNumber[a] && teamNumber[b]) {
				// If both of them are in different teams
				if (teamNumber[a] !== teamNumber[b]) {
					console.log(-1)
					return
				}
			}
			// If only one of them have a team
			else {
				// Get the team that are assigned
				const assignedTeam = teamNumber[a] || teamNumber[b]
				// If assigned team reached the limit members number
				if (teamList[assignedTeam - 1].length > 3) {
					console.log(-1)
					return
				}
				else {
					assignedTeam === teamNumber[a]
						? teamList[assignedTeam - 1].push(b)
						: teamList[assignedTeam - 1].push(a)
					teamNumber[a] = assignedTeam
					teamNumber[b] = assignedTeam
				}
			}
		}
	}

	// If number of teams is higher than expected
	if (curTeam > numOfTeam) {
		console.log(-1)
		return
	}

	// Check if there are unassigned people to a team
	curTeam = 1
	for (let i = 1; i <= n; i++) {
		while (teamList[curTeam - 1].length >= 3) {
			curTeam += 1
		}
		if (!teamNumber[i]) {
			teamList[curTeam - 1].push(i)
		}
	}

	teamList.forEach(list => console.log(list.join(' ')))
})

let input = ''

// Input
process.stdin.on('data', line => {
	input += line
})

// Process
process.stdin.on('end', () => {
	const { EOL } = require('os')
	const lines = input.split(EOL).filter(data => data)

	const [ n, m ] = lines[0].split(' ').map(num => +num)
	if (m > n) {
		console.log(-1)
		return
	}
	const teamList = []
	const numOfTeam = n / 3
	const teamNumber = []
	let curTeam = 1
	// Init list
	for (let i = 0; i < numOfTeam; i++) {
		teamList[i] = []
	}
	// Divide team
	for (let i = 1; i <= m; i++) {
		const [ a, b ] = lines[i].split(' ').map(num => +num)
		// If two people not in any team => they must be on new team
		if (!teamNumber[a] && !teamNumber[b]) {
			teamList[curTeam - 1].push(a)
			teamList[curTeam - 1].push(b)
			teamNumber[a] = curTeam
			teamNumber[b] = curTeam
			curTeam += 1
		}
		// At least one of them are in a team
		else {
			// If both of them have a team
			if (teamNumber[a] && teamNumber[b]) {
				// If both of them are in different teams
				if (teamNumber[a] !== teamNumber[b]) {
					console.log(-1)
					return
				}
			}
			// If only one of them have a team
			else {
				// Get the team that are assigned
				const assignedTeam = teamNumber[a] || teamNumber[b]
				// If assigned team reached the limit members number
				if (teamList[assignedTeam - 1].length >= 3) {
					console.log(-1)
					return
				}
				else {
					assignedTeam === teamNumber[a]
						? teamList[assignedTeam - 1].push(b)
						: teamList[assignedTeam - 1].push(a)
					teamNumber[a] = assignedTeam
					teamNumber[b] = assignedTeam
				}
			}
		}
	}

	// If number of teams is higher than expected
	if (curTeam > numOfTeam) {
		console.log(-2)
		return
	}

	// Check if there are unassigned people to a team
	curTeam = 1
	for (let i = 1; i <= n; i++) {
		while (teamList[curTeam - 1].length >= 3) {
			curTeam += 1
		}
		if (!teamNumber[i]) {
			teamList[curTeam - 1].push(i)
		}
	}

	teamList.forEach(list => console.log(list.join(' ')))
})


Sherlock has a new girlfriend (so unlike him!). Valentine's day is coming and he wants to gift her some jewelry.He bought n pieces of jewelry. The i-th piece has price equal to i + 1, that is, the prices of the jewelry are 2, 3, 4, ... n + 1.Watson gave Sherlock a challenge to color these jewelry pieces such that two pieces don't have the same color if the price of one piece is a prime divisor of the price of the other piece. Also, Watson asked him to minimize the number of different colors used.Help Sherlock complete this trivial task.

The only line contains single integer n (1 ≤ n ≤ 100000) — the number of jewelry pieces.

The first line of output should contain a single integer k, the minimum number of colors that can be used to color the pieces of jewelry with the given constraints. The next line should consist of n space-separated integers (between 1 and k) that specify the color of each piece in the order of increasing price. If there are multiple ways to color the pieces using k colors, you can output any of them.

NoteIn the first input, the colors for first, second and third pieces of jewelry having respective prices 2, 3 and 4 are 1, 1 and 2 respectively.In this case, as 2 is a prime divisor of 4, colors of jewelry having prices 2 and 4 must be distinct.

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

// utils
const MOD = 1e9 + 7;
const mod = (n) => ((n % MOD) + MOD) % MOD;
const add = (a, b) => mod(mod(a) + mod(b));
const sub = (a, b) => mod(mod(a) - mod(b));
function mul() {
  for (var a = arguments, r = a[0], i = a.length; --i; )
    r = ((((r >> 16) * a[i]) % MOD) * 65536 + (r & 65535) * a[i]) % MOD;
  return r;
}
function inv(b) {
  for (var a = MOD, u = 0, v = 1, t; b; v = t)
    (t = (a / b) | 0), (a -= t * b), (u -= t * v), (t = a), (a = b), (b = t), (t = u), (u = v);
  u %= MOD;
  return u < 0 ? u + MOD : u;
}
function pow(base, n) {
  if (n === 0) return 1;
  let p = pow(base, Math.floor(n / 2));
  let res = mul(mod(p), mod(p));
  if (n % 2 === 1) res = mul(mod(res), base);
  return res;
}
function highestOneBit(i) {
  i |= i >> 1;
  i |= i >> 2;
  i |= i >> 4;
  i |= i >> 8;
  i |= i >> 16;
  return i - (i >>> 1);
}
function permutation(arr, len, store = "", permutations = []) {
  if (store.length === len) {
    permutations.push(store);
    return;
  }
  for (let i = 0; i < arr.length; i++) {
    const newArr = [...arr];
    const newChar = newArr.splice(i, 1);
    permutation(newArr, len, store.concat(newChar), permutations);
  }
  return permutations;
}

function main() {
  const len = +readLine();
  const result = Array(len + 2).fill(1);
  const isPrime = Array(len + 2).fill(true);

  for (let i = 4; i <= len + 2; i += 2) {
    result[i] = 2;
    isPrime[i] = false;
  }

  for (let i = 3; i * i <= len + 2; i += 2) {
    if (isPrime[i]) {
      for (let j = i * i; j <= len + 2; j += i) {
        isPrime[j] = false;
        result[j] = 2;
      }
    }
  }

  result.shift();
  result.shift();

  len <= 2 ? console.log(1) : console.log(2);
  result.length = len;
  console.log(result.join(" "));
}

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

// utils
const MOD = 1e9 + 7;
const mod = (n) => ((n % MOD) + MOD) % MOD;
const add = (a, b) => mod(mod(a) + mod(b));
const sub = (a, b) => mod(mod(a) - mod(b));
function mul() {
  for (var a = arguments, r = a[0], i = a.length; --i; )
    r = ((((r >> 16) * a[i]) % MOD) * 65536 + (r & 65535) * a[i]) % MOD;
  return r;
}
function inv(b) {
  for (var a = MOD, u = 0, v = 1, t; b; v = t)
    (t = (a / b) | 0), (a -= t * b), (u -= t * v), (t = a), (a = b), (b = t), (t = u), (u = v);
  u %= MOD;
  return u < 0 ? u + MOD : u;
}
function pow(base, n) {
  if (n === 0) return 1;
  let p = pow(base, Math.floor(n / 2));
  let res = mul(mod(p), mod(p));
  if (n % 2 === 1) res = mul(mod(res), base);
  return res;
}
function highestOneBit(i) {
  i |= i >> 1;
  i |= i >> 2;
  i |= i >> 4;
  i |= i >> 8;
  i |= i >> 16;
  return i - (i >>> 1);
}
function permutation(arr, len, store = "", permutations = []) {
  if (store.length === len) {
    permutations.push(store);
    return;
  }
  for (let i = 0; i < arr.length; i++) {
    const newArr = [...arr];
    const newChar = newArr.splice(i, 1);
    permutation(newArr, len, store.concat(newChar), permutations);
  }
  return permutations;
}

function main() {
  const len = +readLine();
  const result = Array(len + 2).fill(1);
  const isPrime = Array(len + 2).fill(true);
  [isPrime[0], isPrime[1]] = [false, false];

  for (let i = 4; i <= len + 1; i += 2) {
    result[i] = 2;
    isPrime[i] = false;
  }

  for (let i = 3; i * i <= len + 2; i += 2) {
    if (isPrime[i]) {
      for (let j = i * i; j <= len + 2; j += i) {
        isPrime[j] = false;
        result[j] = result[i] + 1;
      }
    }
  }

  result.shift();
  result.shift();

  console.log(2);
  console.log(result.join(" "));
}

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

// utils
const MOD = 1e9 + 7;
const mod = (n) => ((n % MOD) + MOD) % MOD;
const add = (a, b) => mod(mod(a) + mod(b));
const sub = (a, b) => mod(mod(a) - mod(b));
function mul() {
  for (var a = arguments, r = a[0], i = a.length; --i; )
    r = ((((r >> 16) * a[i]) % MOD) * 65536 + (r & 65535) * a[i]) % MOD;
  return r;
}
function inv(b) {
  for (var a = MOD, u = 0, v = 1, t; b; v = t)
    (t = (a / b) | 0), (a -= t * b), (u -= t * v), (t = a), (a = b), (b = t), (t = u), (u = v);
  u %= MOD;
  return u < 0 ? u + MOD : u;
}
function pow(base, n) {
  if (n === 0) return 1;
  let p = pow(base, Math.floor(n / 2));
  let res = mul(mod(p), mod(p));
  if (n % 2 === 1) res = mul(mod(res), base);
  return res;
}
function highestOneBit(i) {
  i |= i >> 1;
  i |= i >> 2;
  i |= i >> 4;
  i |= i >> 8;
  i |= i >> 16;
  return i - (i >>> 1);
}
function permutation(arr, len, store = "", permutations = []) {
  if (store.length === len) {
    permutations.push(store);
    return;
  }
  for (let i = 0; i < arr.length; i++) {
    const newArr = [...arr];
    const newChar = newArr.splice(i, 1);
    permutation(newArr, len, store.concat(newChar), permutations);
  }
  return permutations;
}

function main() {
  const len = +readLine();
  const result = Array(len + 2).fill(1);
  const isPrime = Array(len + 2).fill(true);
  [isPrime[0], isPrime[1]] = [false, false];

  for (let i = 4; i <= len + 1; i += 2) {
    result[i] = 2;
    isPrime[i] = false;
  }

  for (let i = 3; i * i <= len + 2; i += 2) {
    if (isPrime[i]) {
      for (let j = i * i; j <= len + 2; j += i) {
        isPrime[j] = false;
        result[j] = result[i] + 1;
      }
    }
  }

  result.shift();
  result.shift();

  console.log(result.join(" "));
}

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

// utils
const MOD = 1e9 + 7;
const mod = (n) => ((n % MOD) + MOD) % MOD;
const add = (a, b) => mod(mod(a) + mod(b));
const sub = (a, b) => mod(mod(a) - mod(b));
function mul() {
  for (var a = arguments, r = a[0], i = a.length; --i; )
    r = ((((r >> 16) * a[i]) % MOD) * 65536 + (r & 65535) * a[i]) % MOD;
  return r;
}
function inv(b) {
  for (var a = MOD, u = 0, v = 1, t; b; v = t)
    (t = (a / b) | 0), (a -= t * b), (u -= t * v), (t = a), (a = b), (b = t), (t = u), (u = v);
  u %= MOD;
  return u < 0 ? u + MOD : u;
}
function pow(base, n) {
  if (n === 0) return 1;
  let p = pow(base, Math.floor(n / 2));
  let res = mul(mod(p), mod(p));
  if (n % 2 === 1) res = mul(mod(res), base);
  return res;
}
function highestOneBit(i) {
  i |= i >> 1;
  i |= i >> 2;
  i |= i >> 4;
  i |= i >> 8;
  i |= i >> 16;
  return i - (i >>> 1);
}
function permutation(arr, len, store = "", permutations = []) {
  if (store.length === len) {
    permutations.push(store);
    return;
  }
  for (let i = 0; i < arr.length; i++) {
    const newArr = [...arr];
    const newChar = newArr.splice(i, 1);
    permutation(newArr, len, store.concat(newChar), permutations);
  }
  return permutations;
}

function main() {
  const len = +readLine();
  const result = Array(len + 2).fill(1);
  const isPrime = Array(len + 2).fill(true);

  for (let i = 4; i <= len + 2; i += 2) {
    result[i] = 2;
    isPrime[i] = false;
  }

  for (let i = 3; i * i <= len + 2; i += 2) {
    if (isPrime[i]) {
      for (let j = i * i; j <= len + 2; j += i) {
        isPrime[j] = false;
        result[j] = 2;
      }
    }
  }

  result.shift();
  result.shift();

  console.log(2);
  result.length = len;
  console.log(result.join(" "));
}

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

// utils
const MOD = 1e9 + 7;
const mod = (n) => ((n % MOD) + MOD) % MOD;
const add = (a, b) => mod(mod(a) + mod(b));
const sub = (a, b) => mod(mod(a) - mod(b));
function mul() {
  for (var a = arguments, r = a[0], i = a.length; --i; )
    r = ((((r >> 16) * a[i]) % MOD) * 65536 + (r & 65535) * a[i]) % MOD;
  return r;
}
function inv(b) {
  for (var a = MOD, u = 0, v = 1, t; b; v = t)
    (t = (a / b) | 0), (a -= t * b), (u -= t * v), (t = a), (a = b), (b = t), (t = u), (u = v);
  u %= MOD;
  return u < 0 ? u + MOD : u;
}
function pow(base, n) {
  if (n === 0) return 1;
  let p = pow(base, Math.floor(n / 2));
  let res = mul(mod(p), mod(p));
  if (n % 2 === 1) res = mul(mod(res), base);
  return res;
}
function highestOneBit(i) {
  i |= i >> 1;
  i |= i >> 2;
  i |= i >> 4;
  i |= i >> 8;
  i |= i >> 16;
  return i - (i >>> 1);
}
function permutation(arr, len, store = "", permutations = []) {
  if (store.length === len) {
    permutations.push(store);
    return;
  }
  for (let i = 0; i < arr.length; i++) {
    const newArr = [...arr];
    const newChar = newArr.splice(i, 1);
    permutation(newArr, len, store.concat(newChar), permutations);
  }
  return permutations;
}

function main() {
  const len = +readLine();
  const result = Array(len + 2).fill(1);
  const isPrime = Array(len + 2).fill(true);

  for (let i = 4; i <= len + 2; i += 2) {
    result[i] = 2;
    isPrime[i] = false;
  }

  for (let i = 3; i * i <= len + 2; i += 2) {
    if (isPrime[i]) {
      for (let j = i * i; j <= len; j += i) {
        isPrime[j] = false;
        result[j] = 2;
      }
    }
  }

  result.shift();
  result.shift();

  console.log(2);
  result.length = len;
  console.log(result.join(" "));
}


This is the hard version of the problem. The difference is that in this version the array contains zeros. You can make hacks only if both versions of the problem are solved.You are given an array $$$[a_1, a_2, \ldots a_n]$$$ consisting of integers $$$-1$$$, $$$0$$$ and $$$1$$$. You have to build a partition of this array into the set of segments $$$[l_1, r_1], [l_2, r_2], \ldots, [l_k, r_k]$$$ with the following property:  Denote the alternating sum of all elements of the $$$i$$$-th segment as $$$s_i$$$: $$$s_i$$$ = $$$a_{l_i} - a_{l_i+1} + a_{l_i+2} - a_{l_i+3} + \ldots \pm a_{r_i}$$$. For example, the alternating sum of elements of segment $$$[2, 4]$$$ in array $$$[1, 0, -1, 1, 1]$$$ equals to $$$0 - (-1) + 1 = 2$$$.  The sum of $$$s_i$$$ over all segments of partition should be equal to zero. Note that each $$$s_i$$$ does not have to be equal to zero, this property is about sum of $$$s_i$$$ over all segments of partition.The set of segments $$$[l_1, r_1], [l_2, r_2], \ldots, [l_k, r_k]$$$ is called a partition of the array $$$a$$$ of length $$$n$$$ if $$$1 = l_1 \le r_1, l_2 \le r_2, \ldots, l_k \le r_k = n$$$ and $$$r_i + 1 = l_{i+1}$$$ for all $$$i = 1, 2, \ldots k-1$$$. In other words, each element of the array must belong to exactly one segment.You have to build a partition of the given array with properties described above or determine that such partition does not exist.Note that it is not required to minimize the number of segments in the partition.

Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 10\,000$$$). Description of the test cases follows. The first line of each test case contains an integer $$$n$$$ ($$$1 \le n \le 200\,000$$$) — the length of array $$$a$$$. The second line of each test case contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$a_i$$$ is $$$-1$$$, $$$0$$$, or $$$1$$$) — the elements of the given array. It's guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$200\,000$$$.

For each test case print an integer $$$k$$$ — the number of segments in the partition. If required partition does not exist, print $$$-1$$$. If partition exists, in the $$$i$$$-th of the following $$$k$$$ lines print two integers $$$l_i$$$ and $$$r_i$$$ — description of the $$$i$$$-th segment. The following conditions should be satisfied:   $$$l_i \le r_i$$$ for each $$$i$$$ from $$$1$$$ to $$$k$$$.  $$$l_{i + 1} = r_i + 1$$$ for each $$$i$$$ from $$$1$$$ to $$$(k - 1)$$$.  $$$l_1 = 1, r_k = n$$$.  If there are multiple correct partitions of the array, print any of them.

NoteIn the first test case we can build a partition of $$$4$$$ segments — each of them will contain only one element of the array equals to $$$0$$$. So the sum will be equal to $$$0 + 0 + 0 + 0 = 0$$$.In the second test case we can build a partition of $$$4$$$ segments. The alternating sum of the first segment will be equal to $$$-1$$$, the alternating sum of the second segment will be equal to $$$1$$$, of the third segment — $$$0 - 1 + 0 = -1$$$, of the fourth segment — $$$1 - 0 = 1$$$. The sum will be equal to $$$-1 + 1 -1 + 1 = 0$$$.In the third test case it can be proved that the required partition does not exist.

const readline = require('readline')

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

function solve(n, arr) {
    const sum = arr.reduce((s, x) => s + x, 0)
    // if (!sum) {
    //     return `1\n1 ${n}`
    // }
    const t = sum > 0 ? 1 : -1
    let k = sum / t
    if (k & 1) return -1
    k /= 2
// console.log('k', k)
    const use = Array(n)
    const ans = []
    for (let i = 1; i < arr.length; i++) {
        if (k > 0 && arr[i] === t && !use[i - 1]) {
            use[i - 1] = 1
            use[i] = 1
            // ans.push([i - 1, i])
            ans.push([i, i + 1])
            k--
        }
    }
    if (k > 0) return -1
    for (let i = 0; i < arr.length; i++) {
        if (!use[i]) {
            ans.push([i + 1, i + 1])
        }
    }
    ans.sort((a, b) => a[0] - b[0])
    return ans.length + '\n' + ans.map(x => x.join(' ')).join('\n')
}

'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(read) {
  const [rn, rb, rns, re, rbs] = convertInput(read);
  const n = rn(),
        a = rns();
  const l = [a[0]];
  for (let i = 1; i < n; i++) {
    if (i & 1) {
      l[i] = l[i - 1] - a[i];
    } else {
      l[i] = l[i - 1] + a[i];
    }
  }
  const r = [];
  r[n - 1] = a[n - 1];
  const odd = new Map(),
        even = new Map();
  for (let i = n - 1; i >= 0; i--) {
    if (i < n - 1) {
      if (n - i - 1 & 1) {
        r[i] = a[i] - r[i + 1];
      } else {
        r[i] = a[i] - r[i + 1];
      }
    }
    if (i & 1) {
      if (!odd.has(r[i])) odd.set(r[i], []);
      odd.get(r[i]).push(i);
    } else {
      if (!even.has(r[i])) even.set(r[i], []);
      even.get(r[i]).push(i);
    }
  }
  for (let [key, arr] of odd) arr.reverse();
  for (let [key, arr] of even) arr.reverse();
  const find = arr => {
    while (arr.length && arr[arr.length - 1] > right) arr.pop();
    if (arr.length && arr[arr.length - 1] > left) {
      const ans = arr[arr.length - 1];
      pre = r[ans];
      sum = d = 0;
      res.push([pl, left], [ans, right]);
      right = ans - 1;
      pl = left + 1;
      return true;
    }
    return false;
  };
  let sum = 0,
      pre = 0,
      res = [];
  let left = 0,
      right = n - 1,
      d = 0,
      pl = 0;
  for (; left <= right; left++) {
    if (d & 1) {
      sum -= a[left];
    } else {
      sum += a[left];
    }
    if (sum === 0) {
      res.push([pl, left]);
      pl = left + 1;
      sum = d = 0;
      continue;
    }
    d++;
    if (right & 1) {
      let t = -sum - pre;
      if (odd.has(t)) {
        if (find(odd.get(t))) {
          continue;
        }
      }
      t = -sum + pre;
      if (even.has(t)) {
        if (find(even.get(t))) {
          continue;
        }
      }
    } else {
      let t = -sum - pre;
      if (even.has(t)) {
        if (find(even.get(t))) {
          continue;
        }
      }
      t = -sum + pre;
      if (odd.has(t)) {
        if (find(odd.get(t))) {
          continue;
        }
      }
    }
  }
  res.sort((a, b) => a[0] - b[0]);
  const check = arr => {
    var _arr$, _arr;
    if (((_arr$ = arr[0]) === null || _arr$ === void 0 ? void 0 : _arr$[0]) !== 0 || ((_arr = arr[arr.length - 1]) === null || _arr === void 0 ? void 0 : _arr[1]) !== n - 1) return false;
    for (let i = 1; i < arr.length; i++) {
      if (arr[i][0] !== arr[i - 1][1] + 1) return false;
    }
    return true;
  };
  if (!check(res)) return -1;
  return `${res.length}\n${res.map(arr => arr.map(num => num + 1).join(' ')).join('\n')}`;
}
function convertInput(read) {
  const rn = () => Number(read());
  const rb = () => BigInt(read());
  const rns = () => read().split(/\s+/).map(Number);
  const re = () => read().split(/\s+/).map(s => Number(s) - 1);
  const rbs = () => read().split(/\s+/).map(BigInt);
  return [rn, rb, rns, re, rbs];
}
function main(r) {
  try {
    let t = Number(r());
    let res = new Array(t);
    let limit = 0;
    for (let i = 0; i < t; i++) {
      var _solve;
      const s = (_solve = solve(r)) !== null && _solve !== void 0 ? _solve : '';
      if (t < limit) {
        process.stdout.write(s.toString());
        process.stdout.write('\n');
      } else {
        res[i] = s;
      }
    }
    if (t >= limit) {
      return res.join('\n');
    } else {
      return '';
    }
  } catch (error) {
    console.log(error);
  }
}

const inputs = fs__default["default"].readFileSync(0, 'utf-8').split(/\r?\n/);
void function () {
  const read = ((i = 0) => () => inputs[i++])();
  const output = main(read);
  process.stdout.write(output);
}();


Mihai has an $$$8 \times 8$$$ chessboard whose rows are numbered from $$$1$$$ to $$$8$$$ from top to bottom and whose columns are numbered from $$$1$$$ to $$$8$$$ from left to right.Mihai has placed exactly one bishop on the chessboard. The bishop is not placed on the edges of the board. (In other words, the row and column of the bishop are between $$$2$$$ and $$$7$$$, inclusive.)The bishop attacks in all directions diagonally, and there is no limit to the distance which the bishop can attack. Note that the cell on which the bishop is placed is also considered attacked.     An example of a bishop on a chessboard. The squares it attacks are marked in red. Mihai has marked all squares the bishop attacks, but forgot where the bishop was! Help Mihai find the position of the bishop.

The first line of the input contains a single integer $$$t$$$ ($$$1 \leq t \leq 36$$$) — the number of test cases. The description of test cases follows. There is an empty line before each test case. Each test case consists of $$$8$$$ lines, each containing $$$8$$$ characters. Each of these characters is either '#' or '.', denoting a square under attack and a square not under attack, respectively.

For each test case, output two integers $$$r$$$ and $$$c$$$ ($$$2 \leq r, c \leq 7$$$) — the row and column of the bishop.  The input is generated in such a way that there is always exactly one possible location of the bishop that is not on the edge of the board.

NoteThe first test case is pictured in the statement. Since the bishop lies in the intersection row $$$4$$$ and column $$$3$$$, the correct output is 4 3.

const solve = (arr,n)=>{
     let flag = 0;
     for(let i=0;i<n;i++){
          let cnt = 0,ind;
          for(let j=0;j<n;j++){
               if(arr[i][j]==="#") {
                    cnt++;
                    ind = j;
               }
          }
          if(cnt===2) flag = 1;
          if((flag===1)&&(cnt===1)) return `${i+1} ${ind+1}`
     }
}

function main() {
  const fs = require("fs");
  const input = fs.readFileSync(0, "utf8").trim().split("\n");
  let line = 0;
  function readline() {
    return input[line++];
  }
  let t = parseInt(readline());
  for(let i=0;i<t;i++){
       let n = 8,arr=[];
       readline();
       for(let i=0;i<n;i++)
          arr.push(readline().trim().split(""));
       console.log(solve(arr,n));
  }
}
main();

/* Common Template Starts */
process.stdin.resume();
process.stdin.setEncoding("utf-8");

let inputString = "";
let currentLine = 0;

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

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

    main();
});

function readline() {
    return inputString[currentLine++];
}
/* Common Template Ends */

function main() {
    let n = readline()
    let prev = ''
    let pos = ''

    for (let i = 0; i < n; i++) {
        let space = readline()

        for (let y = 0; y < 8; y++) { // top to bottom loop
            let row = readline()

            if (prev) {
                for (x = 0; x < row.length; x++) { // left to right
                    if (row[x] == '#' && prev[x - 1] == '#' && prev[x + 1] == '#') {

                        let r = x + 1
                        let c = y + 1
                        pos = c + ' ' + r
                    }
                }
            }

            prev = row
        }

        console.log(pos)
        pos = ''
    }
}

/**
 * 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();
    const boundary = `**********`;
    while (t--) {
        let emptyLine = readLine();
        let grid = [];
        grid.push(boundary);
        for (let i = 0; i < 8; i++) {
            grid.push(`${'*'}${readLine()}${'*'}`);
        }
        grid.push(boundary);
        for(let i=2;i<8;i++)
        {
            for(let j=2;j<8;j++){
            let cnt = 0;
            // const {row ,column} = locationsOfBis[i];
            let row = i,column=j;

            //check upper left
            if(grid[row-1][column-1]=='#'){
                cnt++;
            }
            //check upper right
            if(grid[row-1][column+1]=='#'){
                cnt++;
            }
            //check lower left
            if(grid[row+1][column-1]=='#'){
                cnt++;
            }
            //check lower right
            if(grid[row+1][column+1]=='#'){
                cnt++;
            }

            if(cnt==4){
                console.log(`${row} ${column}`);
                break;
            }
        }

        }

    }
}

/**
 * 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();
    const boundary = `**********`;
    while (t--) {
        let emptyLine = readLine();
        let grid = [];
        grid.push(boundary);
        for (let i = 0; i < 8; i++) {
            grid.push(`${'*'}${readLine()}${'*'}`);
        }
        grid.push(boundary);
        let locationsOfBis = [];
        let location = [];
        grid.forEach((v, idx) => {
            let mp = [];
            Array.from(v).forEach((d, id) => {
                if (d == '#'){
                    mp.push({ row: idx, column: id });

                }
            })
            if(mp.length==1){
               let  r = mp[0].row,c = mp[0].column;
               if(r>1 && r<8 && c>1 && c<8){

                   locationsOfBis.push(mp[0]);
               }
            }
            location.push(...mp);

        })
        for(let i=0;i<locationsOfBis.length;i++)
        {
            let cnt = 0;
            const {row ,column} = locationsOfBis[i];

            //check upper left
            if(grid[row-1][column-1]=='#'){
                cnt++;
            }
            //check upper right
            if(grid[row-1][column+1]=='#'){
                cnt++;
            }
            //check lower left
            if(grid[row+1][column-1]=='#'){
                cnt++;
            }
            //check lower right
            if(grid[row+1][column+1]=='#'){
                cnt++;
            }

            if(cnt==4){
                console.log(`${row} ${column}`);
                break;
            }

        }

    }
}

'use strict';

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

let inputString = '';
let currentLine = 0;

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

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

    main();
});

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

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

    function check(r, c, arr) {
        return arr[r-1][c-1] && arr[r-1][c+1] && arr[r+1][c-1] && arr[r+1][c+1];
    }

    for (let test = 0; test < N; test++) {
        readline();
        let rows = new Array(8);
        for (let i = 0; i < 8; i++) {
            rows[i] = readline().split('').map(c => c === '#' ? true : false);
        }

        let resC;
        let resR;
        for (let r = 1; r < 7; r++) {
            for (let c = 1; c < 7; c++) {
                if (check(r, c, rows)) {
                    resC = c + 1;
                    resR = r + 1;
                    break;
                }
            }
        }

        output(resR + ' ' + resC);
    }
}

function Solution() {
  let t = 0;
  const n = Number(lines[t++]);
  const res = [];

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

    const board = [];
    for (let j = 0; j < 8; j++) {
      board.push(lines[t++].split(''));
    }

    for (let z = 1; z < 7; z++) {
      for (let y = 1; y < 7; y++) {
        if (board[z][y] === '#') {
          const a = [[-1, -1], [1, 1], [-1, 1], [1, -1]];
          let flag = true;
          for (let x = 0; x < a.length; x++) {
            if (board[z + a[x][0]][y + a[x][1]] !== '#') {
              flag = false;
              break;
            }
          }
          if (flag) {
            res.push(`${z + 1} ${y + 1}`);
            break;
          }
        }
      }
    }
  }

  return res.join('\n');
}

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', () => {
  console.log(Solution());
});

/*
** 799A
*/

// Common Template Starts //
//*
process.stdin.resume();
process.stdin.setEncoding("utf-8");

let is = "";
let cl = 0;

process.stdin.on("data", (inp) => {
    is += inp;
});

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

const readline = () => is[cl++];
// Common Template Ends //

function main() {
    let n = readline();
    while (n--) {
        readline();
        const lines = [...Array(8)].map(_ => readline());
        const yy = lines.map((l, i) => l.indexOf('#.#') !== -1 ? i : -1).filter(n => n != -1);
        const x = lines[yy[0]].indexOf('#') + 2;
        const y = yy.length === 2 ? (yy[0] + yy[1]) / 2 + 1 : (yy[0] < 2 ? yy[0] : yy[0] + 2)

        console.log(`${y} ${x}`);
    }
}

process.stdin.resume();
process.stdin.setEncoding("utf-8");
//
let standardInputString = "";
let currentLine = 0;
//
process.stdin.on("data", (rawData) => {
  standardInputString += rawData;
});
process.stdin.on("end", (_) => {
  standardInputString = standardInputString
    .trim()
    .split("\n")
    .map((line) => {
      return line.trim();
    });
  main();
});

function readline() {
  return standardInputString[currentLine++];
}
function print(data) {
  console.log(data);
}

//line to array of integers
//readline().split(' ').map(Number)
//  let iter=parseInt(readline())
//multiple integer construction->const [a,b,c]=integer array

function main() {
  let q = parseInt(readline());
  for (let i = 0; i < q; i++) {
    readline();
    let mat = [];
    let got = false;
    for (let j = 0; j < 8; j++) mat.push(readline());
    for (let j = 0; j < 8; j++) {
      for (let k = 0; k < 8; k++) {
        if (mat[j][k] == "#") {
          let type = "r";
          if (j + 1 < 8 && k - 1 >= 0 && mat[j + 1][k - 1] == "#") type = "l";
          print(Travel(j, k, mat, type).join(" "));
          got = true;
          break;
        }
      }
      if (got) break;
    }
  }
}

function Travel(i, j, mat, type) {
  if (Bisop(i, j, mat)) return [i + 1, j + 1];
  if (type == "r") return Travel(i + 1, j + 1, mat, type);
  else return Travel(i + 1, j - 1, mat, type);
}
function Bisop(i, j, mat) {
  if (i + 1 >= 8 || j + 1 >= 8 || i - 1 < 0 || j - 1 < 0) return false;
  return mat[i + 1][j + 1] == "#" && mat[i - 1][j - 1] == "#" && mat[i + 1][j - 1] == "#" && mat[i - 1][j + 1] == "#";
}

'use strict';

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

let inputString = '';
let currentLine = 0;

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

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

    main();
});

function readline() {
    return inputString[currentLine++];
}
// Make a Snippet for the code above this and then write your logic in main();

function findKthLargest(nums, k) {
    k = nums.length - k;
    const quickSelect = (l, r) => {
        let pivot = nums[r];
        let p = l;
        for (let i = l; i < r; i++) {
            if (nums[i] <= pivot) {
                swapper(nums, p, i);
                p++;
            }
        }
        swapper(nums, p, r);

        if (p > k) return quickSelect(l, p - 1);
        else if (p < k) return quickSelect(p + 1, r);
        else return nums[p];
    };

    return quickSelect(0, nums.length - 1);
};

function swapper(array, a, b) {
    const temp = array[b];
    array[b] = array[a];
    array[a] = temp;
};

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

    for(var i=0; i<n; i++){
        (readline());
        var d = [];
        for(var j=0; j<8; j++){
            var x = [];
            var m = readline();
            var had1 = 0, index = 0;
            for(var k=0; k<8; k++){
                const cc = m.charAt(k);
                x.push(cc);

                if(cc=="#"){
                    had1++;
                    index = k;
                }
            }
            d.push(x);
            if(had1==1 && j > 0 && j < 7 && d[j-1][index-1]=="#" && d[j-1][index+1]=="#"){
                foo(`${j+1} ${index+1}`);
            }
        }
    }
}
function foo(x) {
    process.stdout.write(x);   // without auto '\n' (newline)
    console.log();  // with auto '\n' (newline)
}

//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()){
		next();
		var list = nextStrArray(8);
		var ok = false;
		var output = "";
		for(var i = 1; i < 8; i++){
			for(var j = 1; j < 8; j++){
				if(list[i][j] == "#" && list[i - 1][j - 1] == "#" && list[i - 1][j + 1] == "#"
					&& list[i + 1][j - 1] == "#" && list[i + 1][j + 1] == "#"){
					output = (i + 1) + " " + (j + 1);
				}
			}
		}
		myout(output);
	}
}

'use strict';

function solve(a) {
  for (let i = 0; i < 8; i++) {
    for (let j = 0; j < 8; j++) {
      if (a[i][j] === '#') {
        var _a, _a2, _a3, _a4;
        if (((_a = a[i - 1]) === null || _a === void 0 ? void 0 : _a[j - 1]) === '#' && ((_a2 = a[i - 1]) === null || _a2 === void 0 ? void 0 : _a2[j + 1]) === '#' && ((_a3 = a[i + 1]) === null || _a3 === void 0 ? void 0 : _a3[j - 1]) === '#' && ((_a4 = a[i + 1]) === null || _a4 === void 0 ? void 0 : _a4[j + 1]) === '#') return `${i + 1} ${j + 1}`;
      }
    }
  }
}

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

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

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++) {
        l++
        const grid = lines.slice(l, l + 8).map(str => str.trim())
        l += 8
        output[i] = solve(grid)
    }
    console.log(output.join('\n'))
// })()
})

function solve(grid) {
    // console.log(grid)
    for (let i = 1; i < grid.length - 1; i++) {
        for (let j = 1; j < grid[i].length - 1; j++) {
            const a = [
                [i, j],
                [i - 1, j - 1],
                [i - 1, j + 1],
                [i + 1, j - 1],
                [i + 1, j + 1],
            ].every(([x, y]) => grid[x][y] === '#')
            if (a) return [i + 1, j + 1].join(' ')
        }
    }
}

var array = [],x,y,hashtag,found;

var tests = readline();
var found = false;
var pass = false;
while(tests--){
    readline();
    found = false;
    pass = false;
    for(var t = 0;t<8;t++)
    {
         array = readline();
        if(!pass){
        splinter = array.split('#');
        if(splinter.length == 2 && found)
        {
            print(parseInt(t+1) + " " + parseInt(array.indexOf("#") + 1));
            pass = true;
        }
        else if(splinter.length == 3) found = true;
        }
    }
}

var t = +readline();

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

    var t1 = readline();
    var list = [];
    for (var q = 0; q<8;q++){
      var just = readline();
      list.push(just);
    }
      var testone = Task2(list);
    print(testone[0],testone[1])
}

function Task2 (arr){

   function isBishop(i,j){

      var ll = j;
      for(var l = i; l>= 0; l--){
         if (ll < 0) break;
         if (arr[l][ll] != '#') {
            return false;
         }
         ll--;
      }

      var lr = j;
      for(var l1 = i; l1>= 0; l1--){
         if (lr < 0 || lr >= arr.length) break;
         if (arr[l1][lr] != '#') return false;
         lr++;
      }
      var rr = j;
      for(var l2 = i; l2< arr.length; l2++){
         if (rr < 0 || rr >= arr.length) break;
         if (arr[l2][rr] != '#') return false
         ;
         rr++;
      }

      var rl = j;
      for(var l3 = i; l3< arr.length; l3++){
         if (rl < 0 || rl >= arr.length) break;
         if (arr[l3][rl] != '#') return false;
         rl--;
      }

      return true;

   }

   var just = [];

   for(var i = 0; i<arr.length; i++){

      for(var j = 0; j<arr.length; j++){
         if (arr[i][j] == '#') {
            if (isBishop(i,j)) {
                  just.push([i+1,j+1])
            }
         }
      }
   }

   return just.length >= 2 ? just[1] : just[0]

}

const solve = (arr,n)=>{
     let flag = 0;
     for(let i=0;i<n;i++){
          let cnt = 0,ind;
          for(let j=0;j<n;j++){
               if(arr[i][j]==="#") {
                    cnt++;
                    ind = j;
               }
          }
          if(cnt===2) flag = 1;
          if((flag===1)&&(cnt===1)) return `${i+1} ${ind+1}`
     }
}

function main() {
  const fs = require("fs");
  const input = fs.readFileSync(0, "utf8").trim().split("\n");
  let line = 0;
  function readline() {
    return input[line++];
  }
  let t = parseInt(readline());
  for(let i=0;i<t;i++){
       let n = 8,arr=[];
       for(let i=0;i<n;i++)
          arr.push(readline().trim().split(""));
       console.log(solve(arr,n));
  }
}
main();

/* Common Template Starts */
process.stdin.resume();
process.stdin.setEncoding("utf-8");

let inputString = "";
let currentLine = 0;

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

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

    main();
});

function readline() {
    return inputString[currentLine++];
}
/* Common Template Ends */

function main() {
    let n = readline()
    let prev = ''
    let pos = ''

    for (let i = 0; i < n; i++) {
        for (let y = 0; y < 8; y++) { // top to bottom loop
            let row = readline()

            if (prev) {
                for (x = 0; x < row.length; x++) { // left to right
                    if (row[x] == '#' && prev[x - 1] == '#' && prev[x + 1] == '#') {

                        let r = x + 1
                        let c = y + 1
                        pos = c + ' ' + r
                    }
                }
            }

            prev = row
        }

        console.log(pos)
        pos = ''
    }
}