Bachgold problem is very easy to formulate. Given a positive integer n represent it as a sum of maximum possible number of prime numbers. One can prove that such representation exists for any integer greater than 1.Recall that integer k is called prime if it is greater than 1 and has exactly two positive integer divisors — 1 and k.

The only line of the input contains a single integer n (2 ≤ n ≤ 100 000).

The first line of the output contains a single integer k — maximum possible number of primes in representation. The second line should contain k primes with their sum equal to n. You can print them in any order. If there are several optimal solution, print any of them.

var n = +readline();
print(n >> 1);
print(new Array(n % 2).fill(3).concat(new Array((n - n % 2 * 3) / 2 ).fill(2)).join(' '));

var n = +readline(), k = 0, res = [];
if (n % 2 == 1) {
    n -= 3;
    k += 1;
    res.push(3)
}
k += n / 2;
res.push(...new Array(n / 2).fill(2));
print(k);
print(res.join(' '));

var n = +readline();
print(n / 2 | 0);
print(new Array(n % 2).fill(3).concat(new Array((n - n % 2 * 3) / 2 ).fill(2)).join(' '));

var  n  = parseInt(readline());
var result = '';
var count = 0;
if(n % 2 == 0){
    for(var i = 0; i < n/2; i ++) {
        count ++;
        if(i == n/2 - 1){
            result += '2';
        }else {
            result += '2 ';
        }

    }
} else {
    for(var i = 0; i < (n-3)/2; i ++) {
        count ++;
        result += '2 ';
    }

    result += '3';
    count++;
}

print(count + '\n' + result);

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

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

    var n = input1[0];

    var result = [];

    while (n > 3) {
        n -= 2;
        result.push(2);
    }

    result.push(n);

    return result.length + "\n" + result.join(" ");
}

(function() {
    'use strict';
    let n = readline();
    var x = 0;
    var y = [];
    let i = 0;
    if (n % 2 === 0) {
         x = n / 2;
        while (i < x) {
            y.push(2);
            i++;
        }
    } else {
        x = (n - n % 2) / 2;
        while (i < x - 1) {
            y.push(2);
            i++;
        }
        y.push(3);
    }
    print(x);
    print(y.join(' '));

}());

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

    var ans = n%2==0 ? n/2 : (n-3)/2+1;
    print( ans );
    while ( n > 3 )
    {
        write( 2 + ' ' );
        n -= 2;
    }

    if ( n == 2 ) write( 2 );
    else write( 3 );
    print();

} main();

// Generated by CoffeeScript 1.10.0
(function() {
  var arr, i, j, n, ref, ref1, results, results1;

  n = Number(readline());

  if (n % 2 === 1) {
    arr = (function() {
      results = [];
      for (var i = 0, ref = (n - 3) / 2; 0 <= ref ? i < ref : i > ref; 0 <= ref ? i++ : i--){ results.push(i); }
      return results;
    }).apply(this).map(function(x) {
      return '2';
    });
    arr.push(3);
  } else {
    arr = (function() {
      results1 = [];
      for (var j = 0, ref1 = n / 2; 0 <= ref1 ? j < ref1 : j > ref1; 0 <= ref1 ? j++ : j--){ results1.push(j); }
      return results1;
    }).apply(this).map(function(x) {
      return '2';
    });
  }

  print(arr.length);

  print(arr.join(' '));

}).call(this);

var n = Number(readline());
//var mas=[];
var str = "";
var res = 0;
while(n>1){
	res++;
	if (n-2>1){
		n-=2;
		str+=2+" ";
		//mas.push(2);
		}
	else {
		str+=n;
		break;}

}
print(res);
print(str);

var n = +readline();

var pn = n & 1 ? [((n - 3) / 2), 1] : [n / 2, 0];

print(pn[0] + pn[1]);
print(new Array(pn[0]).fill('2').concat(new Array(pn[1]).fill('3')).join(' '));

var main = function(num)
{
	var arr = [];
	if (num % 2 === 0){
		for (var i = 1; i <= num / 2; i++)
		{
			arr.push(2);
		}
		return arr;
	}
	else
	{
		num -= 3;
		if (num > 0)
		for (var i = 1; i <= num / 2; i++)
		{
			arr.push(2);
		}
		arr.push(3);
		return arr;
	}
}

var input = readline();
print(main(+input).length);
print(main(+input).join(' '));

function sa(n){
        var k = Math.floor(n/2);
        var res = k + "\n";
        for(var i=0;i<k-1;i++){
            res += "2 ";
        }
        if(n%2==0){
            res += 2;
        } else {
            res += 3;
        }
        return res
    }

    var f = readline().split(" ").map(Number);
    var n = f[0];

    print(sa(n));

//var input = readline()
var n = parseInt(readline())

var k = parseInt(n / 2)
if(n % 2 == 0) {
    print(k)
    for(var i=1; i<=k; i++) {
        print(2 +' ')
    }
}
else {
    print(k)
    for(var i=1; i<k; i++) {
        print(2 +' ')
    }
    print(3)
}

//

var n = parseInt( readline(), 10 );
var twosCount = Math.floor(n / 2);
var addThree = n % 2;
var result = "";
if ( addThree ) {
  --twosCount;
  result += "3 ";
}

for ( var i = 0; i < twosCount; ++i ) {
    result += "2 ";
}

print( twosCount + addThree );
print( result.slice( 0, -1 ) );

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

const main = (input) => {
	var num = parseInt(input);

	console.log(Math.floor(num / 2));

	var ans = "";

	if (num % 2 == 1) {
		num -= 3;
		ans += "3 ";
	}

	for (var i = 0; i < num; i += 2) {
		ans += "2 ";
	}

	console.log(ans.trim());
}

function main() {
    // write code here:
    var n = Number(stdin[0]);
    var arr = [];
    var m=0;
    if (n % 2 === 0) {
        m = n / 2;
        for (let i = 0; i < m; i++) {
            arr.push(2);
        }
    }else{
        //既然要求的是最多可以有多少质数之和能等于n，那么2之后即为3
        n -= 3;
        if (n > 0)
            for (let i = 1; i <= n / 2; i++)
            {
                arr.push(2);//减去3之后要push几个2进arr
            }
        arr.push(3);
    }
    console.log(arr.length+'\n'+arr.join(' '));
}

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

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

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

readLine.on('close', () => {
  const count = parseInt(input[0], 10)
  let iter = Math.floor(count / 2)
  let ostatok = count - (iter * 2)
  if (ostatok < 2) {
    ostatok += 2
    iter -= 1
  }
  let _res = ''
  for (let a = 0; a < iter; a++) {
    if (_res === '')
      _res = '2'
    else
      _res += ' 2'
  }
  if (_res === '')
    _res += ostatok
  else
    _res += ` ${ostatok}`
  let _iterOstatok = ostatok > 0 ? 1 : 0
  console.log(`${iter + _iterOstatok}\n${_res}`)
})

//Don't have to see. start------------------------------------------
var read = require('readline').createInterface({
  input: process.stdin, output: process.stdout
});
var obj; var inLine = [];
read.on('line', function(input){inLine.push(input);});
read.on('close', function(){
  obj = init(inLine);
  console.error("\n");
  var start = Date.now();
  Main();
  var end = Date.now() - start;
  myerr("time : " + (end) + "ms");
  myerr("memory : " + Math.round(process.memoryUsage().heapTotal / 1024) + "KB");
});
function makeClone(obj){return JSON.parse(JSON.stringify(obj));}
function nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}
function nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}
function next(){return obj.next();} function hasNext(){return obj.hasNext();}
function init(input){
  return {
    list : input, index : 0, max : input.length,
    hasNext : function(){return (this.index < this.max);},
    next : function(){if(this.hasNext()){return this.list[this.index++];}else{throw "ArrayIndexOutOfBoundsException ‚There is no more input";}}
  };
}
function myout(s){console.log(s);}
function myerr(s){console.error("debug:" + require("util").inspect(s,false,null));}
//param "no" is
//unknown or outlier : return i. 1: parseInt.
//2: split space. 4: split space and parseInt.
//6: split 1 character. 7: split 1 character and parseInt.
//8: join space. 9: join nextline. 0: join no character.
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map(Number);case 6:return i.split("");case 7:return i.split("").map(Number);case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}catch(e){return i;}}

//Don't have to see. end------------------------------------------
function Main(){
  var N = nextInt();
  if(N % 2 == 0){
    var output = new Array(N / 2).fill(2);
    myout(output.length);
    myout(myconv(output, 8));
  }else{
    var output = new Array(Math.floor(N / 2)).fill(2);
    output[0] = 3;
    myout(output.length);
    myout(myconv(output, 8));
  }
}

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

rl.on('line', (d) => {
  let n = +d;
  let count = Math.floor(n / 2);

  console.log(count);
  if (n % 2 === 0) {
    console.log(new Array(count).fill(2).join(' '));
  }
  else {
    console.log(new Array(count - 1).fill(2).join(' ') + ' 3');
  }
});

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

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

function gdc(x, y) {
  let cx = x, cy = y;
  while (cx != 0 && cy != 0) {
    if (cx > cy) cx = cx % cy;
    else cy = cy % cx;
  }
  return cx + cy;
}

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

  const answer = [];

  for (let i = 0; i < ((n % 2 === 0) ? n / 2 : (n-1) / 2); i += 1)
    answer.push(2);

  if (n % 2 !== 0) {
    answer.pop();
    answer.push(3);
  }
  console.log(answer.length);
  console.log(answer.join(' '));
});

let input = [];

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

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

RL.on('close', () => {
    let n = input[0];
    let answer = '';
    if( n % 2 === 0){
        console.log(`${n/2}`)
        for(let i = 0; i < n/2; i++){
            answer += '2 ';
        }
    } else {
        n -= 3;
        console.log(`${n/2 + 1}`);
        answer = '3 ';
        for(let i = 0; i < n/2; i++){
            answer += '2 ';
        }
    }
    console.log(answer);
});

// Sample code to perform I/O:

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

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

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

/**
 *
 * @param {*} str
 * @param {*} seperator
 */
function splitter(str, seperator = '') {
    return str.trim().split(seperator);
}

/**
 *
 * @param {*} arr
 */
function strToNumArr(arr = []) {
    return arr.map(num => Number(num));
}

/**
 *
 * @param {*} num1
 * @param {*} num2
 */
function matrixArray(num1, num2) {
    return Array(num1).fill(Array(num2));
}

let log = function () {
    return Function.prototype.bind.call(console.log, console, '');
}();

function removeEmptyItem(arr, index) {
    return arr.slice(0, index).concat(arr.slice(index + 1, arr.length));
}

function range(min, max) {

    let arr = [];
    for (let index = min; index < max; index++) {
        arr.push(index);

    }
    return arr;
}

function main(input) {
    let output = nameLookUp(input);
    // process.stdout.write(output);       // Writing output to STDOUT
}

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

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

    let n = +str.trim();
    console.log(Math.floor(n / 2));
    let sum = '';
    if (n % 2 === 0) {
        for (let index = 0; index < Math.floor(n / 2); index++) {
            sum += '2 ';
        }
    }
    else if (n % 2 === 1) {
        for (let index = 0; index < Math.floor(n / 2) - 1; index++) {

            sum += '2 ';
        }
        sum += '3';
    }
    console.log(sum);

}

var  n  = parseInt(readline());
var result = '';
if(n % 2 == 0){
    for(var i = 0; i < n/2; i ++) {
        if(i == n/2 - 1){
            result += '2';
        }else {
            result += '2 ';
        }

    }
} else {
    for(var i = 0; i < (n-3)/2; i ++) {
        result += '2 ';
    }

    result += '3'
}

print(result);

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

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

    var n = input1[0];

    var result = [];

    while (n > 3) {
        n -= 2;
        result.push(2);
    }

    result.push(n);

    return result;
}

// Generated by CoffeeScript 1.10.0
(function() {
  var arr, i, n, readline, ref, results;

  readline = function() {
    return '6';
  };

  n = Number(readline());

  arr = (function() {
    results = [];
    for (var i = 1, ref = (n - n % 2) / 2; 1 <= ref ? i <= ref : i >= ref; 1 <= ref ? i++ : i--){ results.push(i); }
    return results;
  }).apply(this).map(function(x) {
    return '2';
  });

  if (n % 2 === 1) {
    arr.push('3');
  }

  print(arr.length);

  print(arr.join(' '));

}).call(this);

// Generated by CoffeeScript 1.10.0
(function() {
  var arr, i, j, n, readline, ref, ref1, results, results1;

  readline = function() {
    return '6';
  };

  n = Number(readline());

  if (n % 2 === 1) {
    arr = (function() {
      results = [];
      for (var i = 1, ref = (n - 3) / 2; 1 <= ref ? i <= ref : i >= ref; 1 <= ref ? i++ : i--){ results.push(i); }
      return results;
    }).apply(this).map(function(x) {
      return '2';
    });
    arr.push(3);
  } else {
    arr = (function() {
      results1 = [];
      for (var j = 1, ref1 = n / 2; 1 <= ref1 ? j <= ref1 : j >= ref1; 1 <= ref1 ? j++ : j--){ results1.push(j); }
      return results1;
    }).apply(this).map(function(x) {
      return '2';
    });
  }

  print(arr.length);

  print(arr.join(' '));

}).call(this);

// Generated by CoffeeScript 1.10.0
(function() {
  var arr, i, j, n, ref, ref1, results, results1;

  n = Number(readline());

  if (n % 2 === 1) {
    arr = (function() {
      results = [];
      for (var i = 1, ref = (n - 3) / 2; 1 <= ref ? i <= ref : i >= ref; 1 <= ref ? i++ : i--){ results.push(i); }
      return results;
    }).apply(this).map(function(x) {
      return '2';
    });
    arr.push(3);
  } else {
    arr = (function() {
      results1 = [];
      for (var j = 1, ref1 = n / 2; 1 <= ref1 ? j <= ref1 : j >= ref1; 1 <= ref1 ? j++ : j--){ results1.push(j); }
      return results1;
    }).apply(this).map(function(x) {
      return '2';
    });
  }

  print(arr.length);

  print(arr.join(' '));

}).call(this);

var n = Number(readline());
var mas=[];
var res = 0;
while(n>1){
	res++;
	if (n-2>1){
		n-=2;
		mas.push(2);
		}
	else {
		mas.push(n)
		break;}

}
print(res);
print(mas);

var main = function(num)
{
	var arr = [];
	if (num % 2 === 0){
		for (var i = 1; i <= num / 2; i++)
		{
			arr.push(2);
		}
		return arr;
	}
	else
	{
		num -= 3;
		if (num > 0)
		for (var i = 1; i <= num / 2; i++)
		{
			arr.push(2);
		}
		arr.push(3);
		return arr;
	}
}

var input = +readline();
print(main(input));

var main = function(num)
{
	var del = 2, arr = [];
	while (num !== 1)
	{
		if (num % del === 0)
		{
			num /= del;
			arr.push(del);
			del = 2;
		}
		else del++;
	}
	return arr;
}

var input = +readline();
print(main(input));

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

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

readLine.on('close', () => {
  const count = parseInt(input[0], 10)
  let iter = Math.floor(count / 2)
  let ostatok = count - (iter * 2)
  if (ostatok < 2) {
    ostatok += 2
    iter -= 1
  }
  let _res = ''
  for (let a = 0; a < iter; a++) {
    if (_res === '')
      _res = '2'
    else
      _res += ' 2'
  }
  if (_res === '')
    _res += ostatok
  else
    _res += ` ${ostatok}`
  console.log(_res)
})


Santa has to send presents to the kids. He has a large stack of $$$n$$$ presents, numbered from $$$1$$$ to $$$n$$$; the topmost present has number $$$a_1$$$, the next present is $$$a_2$$$, and so on; the bottom present has number $$$a_n$$$. All numbers are distinct.Santa has a list of $$$m$$$ distinct presents he has to send: $$$b_1$$$, $$$b_2$$$, ..., $$$b_m$$$. He will send them in the order they appear in the list.To send a present, Santa has to find it in the stack by removing all presents above it, taking this present and returning all removed presents on top of the stack. So, if there are $$$k$$$ presents above the present Santa wants to send, it takes him $$$2k + 1$$$ seconds to do it. Fortunately, Santa can speed the whole process up — when he returns the presents to the stack, he may reorder them as he wishes (only those which were above the present he wanted to take; the presents below cannot be affected in any way).What is the minimum time required to send all of the presents, provided that Santa knows the whole list of presents he has to send and reorders the presents optimally? Santa cannot change the order of presents or interact with the stack of presents in any other way.Your program has to answer $$$t$$$ different test cases.

The first line contains one integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. Then the test cases follow, each represented by three lines. The first line contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le m \le n \le 10^5$$$) — the number of presents in the stack and the number of presents Santa wants to send, respectively. The second line contains $$$n$$$ integers $$$a_1$$$, $$$a_2$$$, ..., $$$a_n$$$ ($$$1 \le a_i \le n$$$, all $$$a_i$$$ are unique) — the order of presents in the stack. The third line contains $$$m$$$ integers $$$b_1$$$, $$$b_2$$$, ..., $$$b_m$$$ ($$$1 \le b_i \le n$$$, all $$$b_i$$$ are unique) — the ordered list of presents Santa has to send. The sum of $$$n$$$ over all test cases does not exceed $$$10^5$$$.

For each test case print one integer — the minimum number of seconds which Santa has to spend sending presents, if he reorders the presents optimally each time he returns them into the stack.

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

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

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

  const t = readInt(arr)

  for(let i = 0; i < t; i++) {
    const [n, m] = readInts(arr, 3 * i)
    const a = readInts(arr, 3 * i + 1)
    const b = readInts(arr, 3 * i + 2)

    const indexes = new Array(100001)

    for(let j = 0; j < n; j++) {
      indexes[a[j]] = j
    }
    // wr(a, b, indexes)

    let ans = 0, y = -1
    for(let j = 0; j < m; j++) {
      if(indexes[b[j]] > y) {
        ans += 2 * (indexes[b[j]] - j) + 1
        y = indexes[b[j]]
      }
      else ans ++
    }

    wr(ans)
  }
})

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

function max(...x) {
  return Math.max(...x)
}

function min(...x) {
  return Math.min(...x)
}

function mod(a, m) {
  let x = a % m
  if(x >= 0 )  return x
  else return m + x
}

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

function readInt(a, i) {
  if(i === undefined) return parseInt(a.shift())
  else return parseInt(a[i])
}
function readInts(a, i) {
  if(i === undefined) return arr.shift().split(' ').map(a => parseInt(a))
  else return arr[i].split(' ').map(a => parseInt(a))
}

let finalInput = '';

process.stdin.setEncoding('utf-8').on('data', input => {
    finalInput += input;
});

process.stdin.setEncoding('utf-8').on('end', () => {
    let lines = finalInput.split('\r\n').filter((_, i) => i >= 1).filter(l => l && l.length > 0);
    for (let i = 0; i < lines.length; i += 3) {
        let [n, m] = lines[i].split(' ').map(Number);
        let aTable = lines[i + 1].split(' ').map(Number);
        let bTable = lines[i + 2].split(' ').map(Number);
        let result = 0;
        let lastVisitedIndex = 0;
        bTable.forEach((b, bIndex) => {
            let aIndex = aTable.indexOf(b, lastVisitedIndex);
            if (aIndex < 0) aIndex = 0;
            if (aIndex > lastVisitedIndex && aIndex - bIndex >= 0) {
                result += (aIndex - bIndex) * 2 + 1;
            } else {
                result += 1;
            }
            // console.log('aIndex', aIndex, 'lastVisitedIndex', lastVisitedIndex, 'result', result);
            lastVisitedIndex = Math.max(lastVisitedIndex, aIndex);
        });
        console.log(result);
    }
});

let finalInput = '';

process.stdin.setEncoding('utf-8').on('data', input => {
    finalInput += input;
});

process.stdin.setEncoding('utf-8').on('end', () => {
    let lines = finalInput.split('\r\n').filter((_, i) => i >= 1).filter(l => l && l.length > 0);
    for (let i = 0; i < lines.length; i += 3) {
        let [n, m] = lines[i].split(' ').map(Number);
        let aTable = lines[i + 1].split(' ').map(Number);
        let bTable = lines[i + 2].split(' ').map(Number);
        let result = 0;
        let lastVisitedIndex = 0;
        bTable.forEach((b, bIndex) => {
            let aIndex = aTable.indexOf(b, lastVisitedIndex);
            if (aIndex > lastVisitedIndex && aIndex - bIndex >= 0) {
                result += (aIndex - bIndex) * 2 + 1;
            } else {
                result += 1;
            }
            // console.log('aIndex', aIndex, 'lastVisitedIndex', lastVisitedIndex, 'result', result);
            lastVisitedIndex = aIndex;
        });
        console.log(result);
    }
});

let finalInput = '';

process.stdin.setEncoding('utf-8').on('data', input => {
    finalInput += input;
});

process.stdin.setEncoding('utf-8').on('end', () => {
    let lines = finalInput.split('\r\n').filter((_, i) => i >= 1).filter(l => l && l.length > 0);
    for (let i = 0; i < lines.length; i += 3) {
        let [n, m] = lines[i].split(' ').map(Number);
        let aTable = lines[i + 1].split(' ').map(Number);
        let bTable = lines[i + 2].split(' ').map(Number);
        let result = 0;
        let lastVisitedIndex = 0;
        bTable.forEach((b, bIndex) => {
            let aIndex = aTable.indexOf(b, lastVisitedIndex);
            if (aIndex === -1) aIndex = 0;
            if (aIndex > lastVisitedIndex && aIndex - bIndex >= 0) {
                result += (aIndex - bIndex) * 2 + 1;
            } else {
                result += 1;
            }
            // console.log('aIndex', aIndex, 'lastVisitedIndex', lastVisitedIndex, 'result', result);
            lastVisitedIndex = aIndex;
        });
        console.log(result);
    }
});


You are given a matrix with $$$n$$$ rows (numbered from $$$1$$$ to $$$n$$$) and $$$m$$$ columns (numbered from $$$1$$$ to $$$m$$$). A number $$$a_{i, j}$$$ is written in the cell belonging to the $$$i$$$-th row and the $$$j$$$-th column, each number is either $$$0$$$ or $$$1$$$.A chip is initially in the cell $$$(1, 1)$$$, and it will be moved to the cell $$$(n, m)$$$. During each move, it either moves to the next cell in the current row, or in the current column (if the current cell is $$$(x, y)$$$, then after the move it can be either $$$(x + 1, y)$$$ or $$$(x, y + 1)$$$). The chip cannot leave the matrix.Consider each path of the chip from $$$(1, 1)$$$ to $$$(n, m)$$$. A path is called palindromic if the number in the first cell is equal to the number in the last cell, the number in the second cell is equal to the number in the second-to-last cell, and so on.Your goal is to change the values in the minimum number of cells so that every path is palindromic.

The first line contains one integer $$$t$$$ ($$$1 \le t \le 200$$$) — the number of test cases. The first line of each test case contains two integers $$$n$$$ and $$$m$$$ ($$$2 \le n, m \le 30$$$) — the dimensions of the matrix. Then $$$n$$$ lines follow, the $$$i$$$-th line contains $$$m$$$ integers $$$a_{i, 1}$$$, $$$a_{i, 2}$$$, ..., $$$a_{i, m}$$$ ($$$0 \le a_{i, j} \le 1$$$).

For each test case, print one integer — the minimum number of cells you have to change so that every path in the matrix is palindromic.

NoteThe resulting matrices in the first three test cases: $$$\begin{pmatrix} 1 & 1\\ 0 & 1 \end{pmatrix}$$$  $$$\begin{pmatrix} 0 & 0 & 0\\ 0 & 0 & 0 \end{pmatrix}$$$  $$$\begin{pmatrix} 1 & 0 & 1 & 1 & 1 & 1 & 1\\ 0 & 1 & 1 & 0 & 1 & 1 & 0\\ 1 & 1 & 1 & 1 & 1 & 0 & 1 \end{pmatrix}$$$

// var lineIdx = 0;
// var readline = () => {
//   var input = ["4", "2 2", "1 1", "0 1", "2 3", "1 1 0", "1 0 0", "3 7", "1 0 1 1 1 1 1", "0 0 0 0 0 0 0", "1 1 1 1 1 0 1", "3 5", "1 0 1 0 0", "1 1 1 1 0", "0 0 1 0 0"]
//   return input[lineIdx++];
// };
// var print = (str) => {
//   console.log(str);
// };

var t = readline().split(" ").map(function(x) { return parseInt(x); })[0];

var step = () => {
  var input = readline().split(" ").map(function(x) { return parseInt(x); });
  var n = input[0];
  var m = input[1];

  var matrix = new Array();

  for(var i = 0; i <n; i++){
    var row = readline().split(" ").map(function(x) { return parseInt(x); });
    matrix.push(row);
  }

  var path = new Array()

  for(var k = 0; k < n+m; k++){
    path[k] = {zero: 0, one: 0};
  }

  var res = 0;
  var half = Math.floor((n+m-2)/2);
  for(var i = 0; i < n; i ++){
    for(var j = 0; j < m; j++){
      if((n + m) % 2 == 0 && i + j == half) {
        continue;
      }
      // if(matrix[i][j] != matrix[n-1 - i][m-1 -j]){
      //   res += 1
      // }

      if(matrix[i][j] == 0){
        path[i+j].zero += 1
      }
      else{
        path[i+j].one += 1
      }
    }
  }

  for(var r = 0; r <=half; r++){
    var one = path[r].one + path[n+m-2-r].one;
    var zero = path[r].zero + path[n+m-2-r].zero;
    res += Math.min(one, zero);
  }

  print(res)

}

for(var i2 = 0; i2 < t; i2++){
  step();
}

function solv() {
    var ip = readline().split(' ').map(x => parseInt(x))
    var x = ip[0]
    var y = ip[1]
    var s = []
    for (var n = 0; n < x; n++) {
        s.push(readline().split(' ').map(x => parseInt(x)))
    }
    var res = 0;

    var v1 = new Array(x + y);
    var v2 = new Array(x + y);;
    v1.fill(0)
    v2.fill(0)
    for (var n = 0; n < x; n++) {
        for (var k = 0; k < y; k++) {
            if (s[n][k] == 1) {
                if (v1[n + k] == null) v1[n + k] = 1
                else v1[n + k]++;
            }
            else {
                if (v2[n + k] == null) v2[n + k] = 1
                else v2[n + k]++;
            }
        }
    }
    var len = x + y - 2;
    var j = (x % 2 == y % 2)
    for (var n = 0; n <= Math.floor((len) / 2) - j; n++) {
        if (n != len - n) {
            res += Math.min(v1[n] + v1[len - n], v2[n] + v2[len - n]);
            var d = v1[n] + v1[len - n]
            var e = v2[n] + v2[len - n]
        }
        else res += Math.min(v1[n], v2[n]);
    }

    print(res)
}

var tc = 1;
tc = parseInt(readline())
while (tc--) solv()

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

    C();
});

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

function pi(a) {
    return parseInt(a);
}

function ti(a){
    for(let i = 0; i < a.length; i++)
        a[i] = pi(a[i]);

    return a;
}

function C(){
    let t = pi(readline());
    while(t > 0){
        t--;
        let [n,m] = ti(readline().split(' '));
        let mat = new Array(n);
        let dp = new Array(n);
        for(let i = 0; i < n; i++){
            dp[i] = new Array(m);
            dp[i].fill(0);
        }

        for(let i = 0; i < n; i++){
            mat[i] = ti(readline().split(' '));
        }

        let len = n+m-2;
        let level = 0;
        let q = [[0,0],[n-1,m-1],null];
        let count = 0;
        let c1 = 0;
        let c0 = 0;
        let isValid = (r,c) => {
            if(r < 0 || r >= n || c < 0 || c >= m) return false;
            if(dp[r][c] === 1) return false;
            return true;
        }

        while(q.length > 0){
            let node = q.shift();
            if(node !== null){
                dp[node[0]][node[1]] = 1;
                if(mat[node[0]][node[1]] === 0) c0+=1;
                if(mat[node[0]][node[1]] === 1) c1+=1;
                if(isValid(node[0]+1, node[1])){
                    dp[node[0]+1][node[1]] = 1;
                    q.push([node[0]+1,node[1]]);
                }
                if(isValid(node[0], node[1]+1)){
                    dp[node[0]][node[1]+1] = 1;
                    q.push([node[0],node[1]+1]);
                }
                if(isValid(node[0]-1,node[1])){
                    dp[node[0]-1][node[1]] = 1;
                    q.push([node[0]-1, node[1]]);
                }
                if(isValid(node[0], node[1]-1)){
                    dp[node[0]][node[1]-1] = 1;
                    q.push([node[0], node[1]-1]);
                }
            }else{
                if(level !== Math.ceil(len/2)){
                    if(c1 !== 0 && c0 !== 0)
                        count += Math.min(c1,c0);
                }
                level += 1;
                c1 = c0 = 0;
                if(q.length !== 0)
                    q.push(null);
            }
        }

        console.log(count);
    }
}


You are given two arrays $$$a$$$ and $$$b$$$ of length $$$n$$$. Array $$$a$$$ contains each odd integer from $$$1$$$ to $$$2n$$$ in an arbitrary order, and array $$$b$$$ contains each even integer from $$$1$$$ to $$$2n$$$ in an arbitrary order.You can perform the following operation on those arrays:   choose one of the two arrays  pick an index $$$i$$$ from $$$1$$$ to $$$n-1$$$  swap the $$$i$$$-th and the $$$(i+1)$$$-th elements of the chosen array  Compute the minimum number of operations needed to make array $$$a$$$ lexicographically smaller than array $$$b$$$.For two different arrays $$$x$$$ and $$$y$$$ of the same length $$$n$$$, we say that $$$x$$$ is lexicographically smaller than $$$y$$$ if in the first position where $$$x$$$ and $$$y$$$ differ, the array $$$x$$$ has a smaller element than the corresponding element in $$$y$$$.

Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 10^4$$$). The first line of each test case contains a single integer $$$n$$$ ($$$1 \le n \le 10^5$$$) — the length of the arrays. The second line of each test case contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$1 \le a_i \le 2n$$$, all $$$a_i$$$ are odd and pairwise distinct) — array $$$a$$$. The third line of each test case contains $$$n$$$ integers $$$b_1, b_2, \ldots, b_n$$$ ($$$1 \le b_i \le 2n$$$, all $$$b_i$$$ are even and pairwise distinct) — array $$$b$$$. It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$10^5$$$.

For each test case, print one integer: the minimum number of operations needed to make array $$$a$$$ lexicographically smaller than array $$$b$$$. We can show that an answer always exists.

NoteIn the first example, the array $$$a$$$ is already lexicographically smaller than array $$$b$$$, so no operations are required.In the second example, we can swap $$$5$$$ and $$$3$$$ and then swap $$$2$$$ and $$$4$$$, which results in $$$[3, 5, 1]$$$ and $$$[4, 2, 6]$$$. Another correct way is to swap $$$3$$$ and $$$1$$$ and then swap $$$5$$$ and $$$1$$$, which results in $$$[1, 5, 3]$$$ and $$$[2, 4, 6]$$$. Yet another correct way is to swap $$$4$$$ and $$$6$$$ and then swap $$$2$$$ and $$$6$$$, which results in $$$[5, 3, 1]$$$ and $$$[6, 2, 4]$$$.

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

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

function main () {
	let T = rn();
	while (T--) {
		const n = rn();
		const a = rna();
		const b = rna();

		const cost = [];
		for (let i = 0; i < n; i++) {
			let cur = b[i];
			while (cur > 0 && cost[cur] == undefined) {
				cost[cur] = i;
				cur--;
			}
		}

		let ans = 1e9;
		for (let i = 0; i < n; i++) {
			ans = Math.min(ans, i + cost[a[i]]);
		}

		console.log(ans);
	}
}

const nextString = (function() {
  const listeners = [], strings = [], ps = process.stdin
  let last = ''
  ps.setEncoding('utf8')
  ps.on('readable', () => {
    let chunk
    while ((chunk = ps.read()) !== null) {
      chunk = (last + chunk).split(/\r\n|\r|\n/)
      last = chunk[chunk.length - 1]
      for (let i = 0; i < chunk.length - 1; ++i) {
        if (chunk[i].length > 0) {
          if (listeners.length > 0) {
            listeners.shift()(chunk[i])
          }
          else {
            strings.push(chunk[i])
          }
        }
      }
    }
  })
  const fn = resolve => {
    if (strings.length > 0) {
      resolve(strings.shift())
    }
    else {
      listeners.push(resolve)
    }
  }
  return () => new Promise(fn)
})()

async function main() {
  let t = +await nextString()
  for (let iii = 0; iii < t; ++iii) {
    let n = +await nextString()
    let mas1 = (await nextString()).split(' ').map(x => +x)
    let mas2 = (await nextString()).split(' ').map(x => +x)
    let a = [[mas1[0], 0]]
    let b = [[mas2[0], 0]]
    for (let i = 1; i < n; ++i) {
      if (mas1[i] < a[a.length - 1][0]) {
        a.push([mas1[i], i])
      }
      if (mas2[i] > b[b.length - 1][0]) {
        b.push([mas2[i], i])
      }
    }
    let ans = +Infinity
    n = a.length - 1
    m = 0
    while (n >= 0 && m < b.length) {
      ans = Math.min(ans, a[n][1] + b[m][1])
      if (n > 0 && a[n - 1][0] < b[m][0]) {
        --n
      }
      else {
        ++m
      }
    }
    console.log(ans)
  }
}

main()

/*
3
2
3 1
4 2
3
5 3 1
2 4 6
5
7 5 9 1 3
2 4 6 10 8
*/

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

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

function main () {
	let T = rn();
	while (T--) {
		const n = rn();
		const a = rna();
		const b = rna();

		let i = 0;
		while (a[i] > b[0]) i++;

		let j = 0;
		while (b[j] < a[0]) j++;

		ans = Math.min(i, j);

		console.log(ans);
	}
}


NotePlease note that the answers to the questions may overflow 32-bit integer type.

var lenArr = readline().split(' ').map(Number);
var ArrNormal = readline().split(' ').map(Number);
var numQue = readline().split(' ').map(Number);
var queArr = [];
var sumArrN = [];
var sumArrS = [];
var ArrSort = ArrNormal.slice().sort(function(a,b){return a-b;});
sumArrN[0] = ArrNormal[0];
sumArrS[0] = ArrSort[0];
for (var t=1; t<lenArr; t++) {
    sumArrN[t]= sumArrN[t-1] + ArrNormal[t];
    sumArrS[t]= sumArrS[t-1] + ArrSort[t];
}
for (var i=0; i<numQue; i++) {
    var summ = 0;
    queArr[i] = readline().split(' ').map(Number);
    if (queArr[i][0] == 1) {
        if (queArr[i][1] == 1) {
            summ = summ = sumArrN[queArr[i][2]-1];
        }
        else {
            summ = sumArrN[queArr[i][2]-1] - sumArrN[queArr[i][1]-2];
        }
    }
    else {
        if (queArr[i][1] == 1) {
            summ = sumArrS[queArr[i][2]-1];
        }
        else {
            summ = sumArrS[queArr[i][2]-1] - sumArrS[queArr[i][1]-2];
        }
    }
    print(summ);
}

function check (index1,index2,arr)
{
	if (index1-2 >=0 && index2-1 >=0){
		return arr[index2-1] - arr[index1-2];
	}
	else{
		return arr[index2-1];
	}
}
// Acquiring the input
var discard = readline();
var arr2 = readline().split(' ').map((val)=>{
	return parseInt(val);
}), arr1 = [...arr2], sum1 = 0;
var questions = parseInt(readline());
// Preprocessing
arr2.sort((a,b)=>{return a-b}).reduce((sum2,val,index,arr2)=>{
	sum1+=arr1[index];
	arr1[index] = sum1;
	sum2 += arr2[index];
	arr2[index] = sum2;
	return sum2;
},0)
// Answering queries
for(var i = 0 ; i < questions; i++){
	var info = readline().split(' ').map((val)=>{
		return parseInt(val);
	})
	if (info[0] == 1){
		print(check(info[1],info[2],arr1));
	}
	else{
		print(check(info[1],info[2],arr2));
	}
}

;(function () {

	print(function (n) {

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

		var v_type1 = [0];
		for (var i = 0; i < n; i++) v_type1.push(v_type1[i] + v[i]);

		v = v.sort(function (a, b) { return a - b; });
		var v_type2 = [0];
		for (var i = 0; i < n; i++) v_type2.push(v_type2[i] + v[i]);

		var m = +readline();

		var questions = [];
		while (m--) {
			questions.push(readline().split(' ').map(Number));
		} m = questions.length;

		return questions.map(function (e) {
			return e[0] === 1 ? (v_type1[e[2]] - v_type1[e[1] - 1]) : (v_type2[e[2]] - v_type2[e[1] - 1]);
		}).join('\n');

	}(+readline()));

}.call(this));

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

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

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

function main() {
	var n = parseInt(readline()),
		stones = tokenizeIntegers(readline()), sorted = new Array(n),
		sumStones = [0], sumSorted = [0],
		qNum = parseInt(readline());
	for (var i = 0; i < n; ++i) {
		sorted[i] = stones[i];
	}
	sorted.sort(function (a, b) {
		return a-b;
	});
	for (var i = 0; i < n; ++i) {
		sumStones.push(sumStones[i]+stones[i]);
		sumSorted.push(sumSorted[i]+sorted[i]);
	}
	for (var i = 0; i < qNum; ++i) {
		var query = tokenizeIntegers(readline());
		if (query[0] == 1) {
			print(sumStones[query[2]]-sumStones[query[1]-1]);
		} else {
			print(sumSorted[query[2]]-sumSorted[query[1]-1]);
		}
	}
}

main();

var n = parseInt(readline()),
	vArr = readline().split(/\s/), vSum = getCumulativeSum(vArr),
	uArr = vArr.sort(function(a, b)	{ return a - b }), uSum = getCumulativeSum(uArr),
	m = parseInt(readline());

for(var index = 0; index < m; index++)	{
	var inputs = readline().split(/\s/).map(Number),
		type = inputs[0], l = inputs[1], r = inputs[2];

	print(type == 1 ? vSum[r] - vSum[l - 1] : uSum[r] - uSum[l - 1]);
}

function getCumulativeSum(arr)	{
	var cumulativeSum = [ 0 ];

	arr = arr.map(function(a, index)	{
		a = parseInt(a);

		cumulativeSum.push(cumulativeSum[cumulativeSum.length - 1] + a);

		return a;
	});

	return cumulativeSum;
};

const lines = [];

const helpers = {
  arrStringtoInt: (arr, splitter) => {
    return arr.split(splitter).map(num => parseInt(num));
  },
  insterAt: (arr, idx, item) => {
    const newArray = [...arr];
    newArray.splice(idx, 0, item);
    return newArray;
  },
  sortAscending: (arr) => {
    return arr.sort((a, b) => a - b);
  },
  sortDescending(arr) {
    return arr.sort((a, b) => b - a);
  }
}

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

// multi line input
readline.on('line', line => {
  lines.push(line);
});

readline.on('close', line => {
  const numbers = helpers.arrStringtoInt(lines[1], ' ');
  const rangeSum1 = [0];
  const rangeSum2 = [0];

  // Get the first range sum of type 1 O(n)
  for (let ii = 0; ii < numbers.length; ii++) {
    rangeSum1.push(numbers[ii] + rangeSum1[ii]);
  }

  // O(nlogn)
  numbers.sort((a, b) => a - b);

  // Get the first range sum of type 2 O(n)
  for (let ii = 0; ii < numbers.length; ii++) {
    rangeSum2.push(numbers[ii] + rangeSum2[ii]);
  }

  // Answer the questions in O(m);
  for (let ii = 3; ii < lines.length; ii++) {
    const inputs = helpers.arrStringtoInt(lines[ii], ' ');
    const t = inputs[0], l = inputs[1], r = inputs[2];
    const arr = t == 1 ? rangeSum1 : rangeSum2;
    console.log(arr[r] - arr[l - 1])
  }
});

/**
 *
Kuriyama Mirai has killed many monsters and got many (namely n) stones. She numbers the stones from 1 to n.
The cost of the i-th stone is vi. Kuriyama Mirai wants to know something about these stones so she will ask you two kinds of questions:

She will tell you two numbers, l and r (1 ≤ l ≤ r ≤ n), and you should tell her .
Let ui be the cost of the i-th cheapest stone (the cost that will be on the i-th place if we arrange all the stone costs in non-decreasing order).
This time she will tell you two numbers, l and r (1 ≤ l ≤ r ≤ n), and you should tell her .
For every question you should give the correct answer, or Kuriyama Mirai will say "fuyukai desu" and then become unhappy.

Input
The first line contains an integer n (1 ≤ n ≤ 105). The second line contains n integers: v1, v2, ..., vn (1 ≤ vi ≤ 109) — costs of the stones.

The third line contains an integer m (1 ≤ m ≤ 105) — the number of Kuriyama Mirai's questions. Then follow m lines, each line contains three integers type,
 l and r (1 ≤ l ≤ r ≤ n; 1 ≤ type ≤ 2), describing a question. If type equal to 1, then you should output the answer for the first question,
 else you should output the answer for the second one.

Output
Print m lines. Each line must contain an integer — the answer to Kuriyama Mirai's question. Print the answers to the questions in the order of input.

[ 6, 10, 12, 19, 21, 28 ]

[ 2, 4, 8, 14, 21, 28 ]

Examples
input
6
6 4 2 7 2 7
3
2 3 6
1 3 4
1 1 6
output
24
9
28
input
4
5 5 2 3
10
1 2 4
2 1 4
1 1 1
2 1 4
2 1 2
1 1 1
1 3 3
1 1 3
1 4 4
1 2 2
output
10
15
5
15
5
5
2
12
3
5
 */

let inputString = '';

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

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

    let lenthOfInput = Number(inputString[0])
    let input = inputString[1].split(" ");
    let lengthOfQuestion = Number(inputString[2])
    let questions = inputString.slice(3)

    solution(lenthOfInput, input, lengthOfQuestion, questions);

});

function solution(lenthOfInput, input, lengthOfQuestion, questions) {

    let perfixSum = [];
    let sortedPerfixSum = [];
    let solutionArray = [];

    for (let index = 0; index < lenthOfInput; index++) {

        perfixSum[index] = (perfixSum[index - 1] ? perfixSum[index - 1] : 0) + Number(input[index])
    }

    input.sort(function (current, next) {
        return current - next;
    })

    for (let index = 0; index < lenthOfInput; index++) {

        sortedPerfixSum[index] = (sortedPerfixSum[index - 1] ? sortedPerfixSum[index - 1] : 0) + Number(input[index])
    }

    for (let index = 0; index < lengthOfQuestion; index++) {

        let question = Number(questions[index].split(" ")[0]);
        let left = Number(questions[index].split(" ")[1])
        let right = Number(questions[index].split(" ")[2])
        let solution;

        if (question == 1)

            solution = perfixSum[right - 1] - (perfixSum[left - 2] ? perfixSum[left - 2] : 0)
        else
            solution = sortedPerfixSum[right - 1] - (sortedPerfixSum[left - 2] ? sortedPerfixSum[left - 2] : 0)

        solutionArray.push(solution);
        solutionArray.push("\n")

    }

    console.log(solutionArray.join(""))

}

/**
 *
Kuriyama Mirai has killed many monsters and got many (namely n) stones. She numbers the stones from 1 to n.
The cost of the i-th stone is vi. Kuriyama Mirai wants to know something about these stones so she will ask you two kinds of questions:

She will tell you two numbers, l and r (1 ≤ l ≤ r ≤ n), and you should tell her .
Let ui be the cost of the i-th cheapest stone (the cost that will be on the i-th place if we arrange all the stone costs in non-decreasing order).
This time she will tell you two numbers, l and r (1 ≤ l ≤ r ≤ n), and you should tell her .
For every question you should give the correct answer, or Kuriyama Mirai will say "fuyukai desu" and then become unhappy.

Input
The first line contains an integer n (1 ≤ n ≤ 105). The second line contains n integers: v1, v2, ..., vn (1 ≤ vi ≤ 109) — costs of the stones.

The third line contains an integer m (1 ≤ m ≤ 105) — the number of Kuriyama Mirai's questions. Then follow m lines, each line contains three integers type,
 l and r (1 ≤ l ≤ r ≤ n; 1 ≤ type ≤ 2), describing a question. If type equal to 1, then you should output the answer for the first question,
 else you should output the answer for the second one.

Output
Print m lines. Each line must contain an integer — the answer to Kuriyama Mirai's question. Print the answers to the questions in the order of input.

[ 6, 10, 12, 19, 21, 28 ]

[ 2, 4, 8, 14, 21, 28 ]

Examples
input
6
6 4 2 7 2 7
3
2 3 6
1 3 4
1 1 6
output
24
9
28
input
4
5 5 2 3
10
1 2 4
2 1 4
1 1 1
2 1 4
2 1 2
1 1 1
1 3 3
1 1 3
1 4 4
1 2 2
output
10
15
5
15
5
5
2
12
3
5
 */

let inputString = '';

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

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

    let lenthOfInput = Number(inputString[0])
    let input = inputString[1].split(" ");
    let lengthOfQuestion = Number(inputString[2])
    let questions = inputString.slice(3)

    solution(lenthOfInput, input, lengthOfQuestion, questions);

});

function solution(lenthOfInput, input, lengthOfQuestion, questions) {

    let perfixSum = [];
    let sortedPerfixSum = [];
    let solutionArray = [];

    for (let index = 0; index < lenthOfInput; index++) {

        perfixSum[index] = (perfixSum[index - 1] ? perfixSum[index - 1] : 0) + Number(input[index])
    }

    input.sort(function (current, next) {
        return current - next;
    })

    for (let index = 0; index < lenthOfInput; index++) {

        sortedPerfixSum[index] = (sortedPerfixSum[index - 1] ? sortedPerfixSum[index - 1] : 0) + Number(input[index])
    }

    for (let index = 0; index < lengthOfQuestion; index++) {

        let question = Number(questions[index].split(" ")[0]);
        let left = Number(questions[index].split(" ")[1])
        let right = Number(questions[index].split(" ")[2])
        let solution;

        if (question == 1)

            solution = perfixSum[right - 1] - (perfixSum[left - 2] ? perfixSum[left - 2] : 0)
        else
            solution = sortedPerfixSum[right - 1] - (sortedPerfixSum[left - 2] ? sortedPerfixSum[left - 2] : 0)

        solutionArray.push(solution);
        solutionArray.push("\n")

    }

    console.log(solutionArray.join(""));

}

var lenArr = readline().split(' ').map(Number); //к-сть каменів
var ArrNormal = readline().split(' ').map(Number); //масив з цінами каменів
var numQue = readline().split(' ').map(Number); //к-сть запитань
var queArr = []; //пустий масив для запитань
var ArrSort = ArrNormal.slice().sort(); //відсортований масив
for (var i=0; i<numQue; i++) { //цикл по к-сті запитань
    var summ = 0;
    queArr[i] = readline().split(' ').map(Number); //зчитування і-го запитання
    if (queArr[i][0] == 1) { // якщо умова 1
        for (var j=queArr[i][1]-1; j<queArr[i][2]; j++) { //цикл від l до r
            summ += ArrNormal[j]; //сума віх цін від l до r
        }
    }
    else { //якщо умова 2
        for (var k=queArr[i][1]-1; k<queArr[i][2]; k++) { //цикл від l до r
            summ += ArrSort[k]; //сума віх цін від l до r
        }
    }
    print(summ); //результат
}

const lines = [];

const helpers = {
  arrStringtoInt: (arr, splitter) => {
    return arr.split(splitter).map(num => parseInt(num));
  },
  insterAt: (arr, idx, item) => {
    const newArray = [...arr];
    newArray.splice(idx, 0, item);
    return newArray;
  },
  sortAscending: (arr) => {
    return arr.sort((a, b) => a - b);
  },
  sortDescending(arr) {
    return arr.sort((a, b) => b - a);
  }
}

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

// multi line input
readline.on('line', line => {
  lines.push(line);
});

readline.on('close', line => {
  const numbers = helpers.arrStringtoInt(lines[1], ' ');
  const rangeSum1 = [0];
  const rangeSum2 = [0];

  for (let ii = 0; ii < numbers.length; ii++) {
    rangeSum1.push(numbers[ii] + rangeSum1[ii]);
  }

  numbers.sort((a, b) => b - a);

  for (let ii = 0; ii < numbers.length; ii++) {
    rangeSum2.push(numbers[ii] + rangeSum2[ii]);
  }

  // // Calculate the range sum
  for (let ii = 3; ii < lines.length; ii++) {
    const inputs = helpers.arrStringtoInt(lines[ii], ' ');
    const t = inputs[0];
    const l = inputs[1];
    const r = inputs[2];
    if (t == 1)
      console.log(answer(rangeSum1, l, r))
    else
      console.log( rangeSum2[r-l+1])
  }

});

function answer(arr, l, r) {
  return arr[r] - arr[l - 1];
}


Ivan is a novice painter. He has $$$n$$$ dyes of different colors. He also knows exactly $$$m$$$ pairs of colors which harmonize with each other.Ivan also enjoy playing chess. He has $$$5000$$$ rooks. He wants to take $$$k$$$ rooks, paint each of them in one of $$$n$$$ colors and then place this $$$k$$$ rooks on a chessboard of size $$$10^{9} \times 10^{9}$$$.Let's call the set of rooks on the board connected if from any rook we can get to any other rook in this set moving only through cells with rooks from this set. Assume that rooks can jump over other rooks, in other words a rook can go to any cell which shares vertical and to any cell which shares horizontal.Ivan wants his arrangement of rooks to have following properties: For any color there is a rook of this color on a board; For any color the set of rooks of this color is connected; For any two different colors $$$a$$$ $$$b$$$ union of set of rooks of color $$$a$$$ and set of rooks of color $$$b$$$ is connected if and only if this two colors harmonize with each other.Please help Ivan find such an arrangement.

The first line of input contains $$$2$$$ integers $$$n$$$, $$$m$$$ ($$$1 \le n \le 100$$$, $$$0 \le m \le min(1000, \,\, \frac{n(n-1)}{2})$$$) — number of colors and number of pairs of colors which harmonize with each other. In next $$$m$$$ lines pairs of colors which harmonize with each other are listed. Colors are numbered from $$$1$$$ to $$$n$$$. It is guaranteed that no pair occurs twice in this list.

Print $$$n$$$ blocks, $$$i$$$-th of them describes rooks of $$$i$$$-th color. In the first line of block print one number $$$a_{i}$$$ ($$$1 \le a_{i} \le 5000$$$) — number of rooks of color $$$i$$$. In each of next $$$a_{i}$$$ lines print two integers $$$x$$$ and $$$y$$$ ($$$1 \le x, \,\, y \le 10^{9}$$$) — coordinates of the next rook. All rooks must be on different cells. Total number of rooks must not exceed $$$5000$$$. It is guaranteed that the solution exists.

NoteRooks arrangements for all three examples (red is color $$$1$$$, green is color $$$2$$$ and blue is color $$$3$$$).

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

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

rl.on('close', function () {
	const [n, m] = input[0].split(' ').map(i => parseInt(i));
	const pairs = input.splice(1).map(pair => {
		const [a, b] = pair.split(' ').map(i => parseInt(i));
		if (a < b) {
			return {a, b};
		} else {
			return {a: b, b: a};
		}
	}).sort((a, b) => {
		if (a.a < b.a) {
			return -1;
		}
		if (a.a > b.a) {
			return 1;
		}
	});
	const colors = [];
	let safe = n + 1;
	for (let i = 0; i < n; i++) {
		colors.push([]);
		colors[i].push({x: i + 1, y: i + 1});
	}
	pairs.forEach(pair => {
		colors[pair.a - 1].push({x: safe, y: pair.a});
		colors[pair.b - 1].push({x: safe, y: pair.b});
		safe++;
	});
	for (let i = 0; i < colors.length; i++) {
		console.log(colors[i].length);
		for (let j = 0; j < colors[i].length; j++) {
			console.log(colors[i][j].x + " " + colors[i][j].y);
		}
	}

	process.exit(0);
});


Given an array $$$a$$$ of length $$$n$$$, tell us whether it has a non-empty subsequence such that the product of its elements is not a perfect square.A sequence $$$b$$$ is a subsequence of an array $$$a$$$ if $$$b$$$ can be obtained from $$$a$$$ by deleting some (possibly zero) elements.

The first line contains an integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. The description of the test cases follows. The first line of each test case contains an integer $$$n$$$ ($$$1 \le n \le 100$$$) — the length of the array $$$a$$$. The second line of each test case contains $$$n$$$ integers $$$a_1$$$, $$$a_2$$$, $$$\ldots$$$, $$$a_{n}$$$ ($$$1 \le a_i \le 10^4$$$) — the elements of the array $$$a$$$.

If there's a subsequence of $$$a$$$ whose product isn't a perfect square, print "YES". Otherwise, print "NO".

NoteIn the first example, the product of the whole array ($$$20$$$) isn't a perfect square.In the second example, all subsequences have a perfect square product.

'use-strict'

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

let data = '';
let currentLine = 0;

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

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

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

    while(testCases--) {

        const n = parseInt(readLine());

        const a = readLine().split(' ').map(Number);

        let end = true;
        for(let i = 0; i < n; i++){
            if(!Number.isInteger(Math.sqrt(a[i]))){
                console.log('YES');
                end = false;
                break;
            }
        }
        if(end) console.log('NO')
    }
});

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

function A(a){
    return Number.isInteger(Math.sqrt(a.reduce((a,b) => a*b)));
}

module.exports = A;

let i = '';
process.stdin.on('data', c => i += c);
process.stdin.on('end', () => {
    const {EOL} = require('os');
    const lines = i.split(EOL);
    var n = lines[0];
    var e = 0;
    for(var j = 1; j <= n * 2; j++){
        if(j % 2 == 1){
            e = lines[j];
        }else{
            var k = lines[j].split(' ').map(Number);
            var found = false;
            for(var l = 0; l < k.length; l++){
                var a = Math.floor(Math.sqrt(k[l]));
                if(a * a != k[l]){
                    found = true;
                    break;
                }
            }
            if(found === true){
                console.log('YES');
            }else{
                console.log('NO');
            }
        }
    }
});

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', line => {
    var t = Number(input[0]);
    var j = 1;
    for (var a = 0; a < t; a++) {
        var n = input[j];
        j++;
        var arr = input[j].split(" ").map((i) => {
            return Number(i);
        });
        j++;
        function isSquareNumber(num) {
            var root = Math.sqrt(num)
            return root === Math.floor(root);
        }
        var i;

        for (i = 0; i < arr.length; i++) {
            if (!isSquareNumber(arr[i])) {
                break;
            }
        }
        if (i === arr.length) {
            console.log("NO");
        } else {
            console.log("YES");
        }
    }
})

let input = '';
process.stdin.on('data', str => input += str)
process.stdin.on('end', () => {
	const lines = input.trim().split('\n').slice(1);

	for (let i=1; i<lines.length; i+=2) {
		const arr = lines[i].split(' ');

		let flag = true;
		for (let j=0; j<arr.length; j++) {
			if (Math.sqrt(+arr[j])%1 !== 0) {
				flag = false;
				break;
			}
		}

		console.log(!flag ? 'YES' : 'NO');
	}
})

"use strict";
//////////// LIBS
Object.defineProperty(exports, "__esModule", { value: true });
class IO {
    constructor() {
        this.lines = [];
        this.tokens = [];
        this.lines = require('fs').readFileSync(0, 'utf8').split('\n');
    }
    getTokens() {
        if (!this.tokens.length) {
            this.tokens = this.nextLine().split(' ');
        }
        return this.tokens;
    }
    nextLine() {
        return this.lines.shift().trim();
    }
    nextNum() {
        return Number(this.getTokens().shift());
    }
    nextNumArray(n) {
        let ret = [];
        while (n--) {
            ret.push(this.nextNum());
        }
        return ret;
    }
}
function solve(n, tab) {
    for (let a of tab) {
        if (Math.floor(Math.sqrt(a)) ** 2 !== a) {
            console.log('YES');
            return;
        }
    }
    console.log('NO');
}
function main() {
    const io = new IO();
    let t = io.nextNum();
    while (t--) {
        let n = io.nextNum();
        let tab = io.nextNumArray(n);
        solve(n, tab);
    }
}
main();

/**
 * 04/19/21 morning
 * https://codeforces.com/contest/1514/problem/A
 */

///////////////////////////////// pre-define /////////////////////////////////////
const pr = console.log;
const mi = Math.min;
const mx = Math.max;
const abs = Math.abs;
const fl = Math.floor;
const ce = Math.ceil;
const sq = Math.sqrt;
///////////////////////////////////////////////////////////////////////////////////

const solve = (n, a) => {
    // pr(n,a);
    for (const e of a) {
        let q = sq(e);
        if (q != q >> 0) return pr('YES');
    }
    pr('NO')
};

const main = () => {
    const readline = require('readline');
    const rl = readline.createInterface({
        input: process.stdin,
        output: process.stdout
    });
    let input = [];
    rl.on('line', (line) => {
        input.push(line.split(" ").map(x => Number(x)));
    });
    rl.on('close', () => {
        let t = input[0][0];
        let i = 1;
        while (t--) {
            solve(input[i][0], input[i + 1]);
            i += 2;
        }
    });
};

main()

//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{
			ret[i] = next();
		}
	}
	return ret;
}
function nextIntArray(size){return nextArray(size, 'int');} function nextStrArray(size){return nextArray(size, 'str');}
function nextCharArray(){return myconv(next(),6);}
function next(){return obj.next();} function hasNext(){return obj.hasNext();} function nextInt(){return myconv(next(),1);}
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();
	for(var i = 0; i < t; i++){
		var N = nextInt();
		var list = nextIntArray(N);
		var isOK = false;
		for(var j = 0; j < N; j++){
			if(list[j] == 1){
				continue;
			}
			var map = getPrimeFactorization(list[j]);
			var keys = Object.keys(map);
			for(var k = 0; k < keys.length; k++){
				if(map[keys[k]] % 2 == 1){
					isOK = true;
				}
			}
		}
		myout((isOK) ? "YES" : "NO");
	}
}
function getPrimeFactorization(val){
  var primeMap = {};
  var div = 2;
  if(isPrime(val)){
    primeMap[val] = 1;
    return primeMap;
  }
  while(val != 1){
    if(val % div == 0){
      var count = 2;
      while(val % Math.pow(div, count) == 0){
         count++;
      }
      (primeMap[div] == null)  ? primeMap[div] = (count - 1) : primeMap[div] += (count - 1);
      val /= Math.pow(div, count - 1);
      if(isPrime(val)){
        (primeMap[val] == null)  ? primeMap[val] = 1 : primeMap[val]++;
        break;
      }
    }
    div = (div == 2) ? div + 1 : div + 2;
  }
  return primeMap;
}
function isPrime(val){
  if(val == null || val <= 1 || (val != 2 && val % 2 == 0)){
    return false;
  }else if(val == 2){
    return true;
  }
  var root = Math.floor(Math.sqrt(val));
  for(var i = 3; i <= root; i += 2){
    if(val % i == 0){
      return false;
    }
  }
  return true;
}

'use strict';

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

let inputString = '';
let currentLine = 0;

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

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

  main();
});

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

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

function main() {
  const xx = readline();
  Array(Number(xx)).fill(1).map((t, i) => {
    var n = parseInt(readline());
    // var [a, b] = readline().split(' ').map((x, iii) => {
    //   return parseInt(x)
    // })
    var a = readline().split(' ').map((x, iii) => {
      return parseInt(x)
    });
    for (let j = 0; j < n; j++) {
      var res = Math.floor(Math.sqrt(a[j]))
      if(res *res !==a[j]) return console.log('YES')
    }
    console.log('NO')
    // var aa = a.slice()
    // a.sort((a, b) => a - b)
    //
    // dp = new Array(n + 1)
    // for (let i = 0; i < n + 1; i++) {
    //   dp[i] = new Array(n).fill(Number.MAX_SAFE_INTEGER)
    // }

  })
}

'use-strict'

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

let data = '';
let currentLine = 0;

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

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

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

    while(testCases--) {

        const n = parseInt(readLine());

        const a = readLine().split(' ').map(Number);

        for(let i = 0; i < n; i++){
            if(!Number.isInteger(Math.sqrt(a[i]))){
                console.log('YES');
            }
        }
        console.log('NO')
    }
});

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

function A(a){
    return Number.isInteger(Math.sqrt(a.reduce((a,b) => a*b)));
}

module.exports = A;

'use-strict'

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

let data = '';
let currentLine = 0;

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

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

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

    while(testCases--) {

        const n = parseInt(readLine());

        const a = readLine().split(' ').map(Number);

        A(a) ? console.log('NO'): console.log('YES');
    }
});

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

function A(a){
    return Number.isInteger(Math.sqrt(a.reduce((a,b) => a*b)));
}

module.exports = A;

let i = '';
process.stdin.on('data', c => i += c);
process.stdin.on('end', () => {
    const {EOL} = require('os');
    const lines = i.split(EOL);
    var n = lines[0];
    var e = 0;
    for(var j = 1; j <= n * 2; j++){
        if(j % 2 == 1){
            e = lines[j];
        }else{
            var k = lines[j].split(' ').map(Number);
            var total = k[0];
            for(var l = 1; l < k.length; l++){
                total *= k[l];
            }
            total = Math.sqrt(total);
            if(total % 1 !== 0){
                console.log('YES');
            }else{
                console.log('NO');
            }
        }
    }
});

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', line => {
    var t = Number(input[0]);
    var j = 1;
    for (var a = 0; a < t; a++) {
        var n = input[j];
        j++;
        var arr = input[j].split(" ").map((i) => {
            return Number(i);
        });
        j++;
        function isSquareNumber(num) {
            return Math.sqrt(num) ** 2 === num;
        }
        var i;
        for (i = 0; i < arr.length; i++) {
            if (!isSquareNumber(arr[i])) {
                break;
            }
        }
        if (i === arr.length) {
            console.log("NO");
        } else {
            console.log("YES");
        }
    }
})

let input = '';
process.stdin.on('data', str => input += str)
process.stdin.on('end', () => {
	const lines = input.trim().split('\n').slice(1);

	for (let i=1; i<lines.length; i+=2) {
		const arr = lines[i].split(' ');

		let flag = true;
		for (let j=0; j<arr.length; j++) {
			if (Math.sqrt(+arr[j])%1 !== 0) {
				flag = false;
				break;
			}
		}

		console.log(flag ? 'YES' : 'NO');
	}
})


Let's call a positive integer composite if it has at least one divisor other than $$$1$$$ and itself. For example:  the following numbers are composite: $$$1024$$$, $$$4$$$, $$$6$$$, $$$9$$$;  the following numbers are not composite: $$$13$$$, $$$1$$$, $$$2$$$, $$$3$$$, $$$37$$$. You are given a positive integer $$$n$$$. Find two composite integers $$$a,b$$$ such that $$$a-b=n$$$.It can be proven that solution always exists.

The input contains one integer $$$n$$$ ($$$1 \leq n \leq 10^7$$$): the given integer.

Print two composite integers $$$a,b$$$ ($$$2 \leq a, b \leq 10^9, a-b=n$$$). It can be proven, that solution always exists. If there are several possible solutions, you can print any.

function myout(t){print(t);}//standard output
function myerr(t){console.error(t);}//standard error
//[no]param
//0:何もしない  1:数値へ変換  2:半角SPで分割  3:改行で分割  4:半角SPで分割し、数値配列へ
//5:改行で分割し、数値配列へ  6:1文字に分割  7:1文字に分割し、数値配列へ
function myconv(i,no){switch(no){case 0:return i;case 1:return parseInt(i);case 2:return i.split(" ");case 3:return i.split("\n");case 4:return i.split(" ").map((a)=>Number(a));case 5:return i.split("\n").map((a)=>Number(a));case 6:return i.split("");case 7:return i.split("").map((a)=>Number(a));}}

function Main() {
  var N = myconv(readline(),1);
  var a = N + 1;
  while(isPrime(a)){
      a++;
  }
  var b = a + N;
  while(isPrime(a) || isPrime(b)){
      a++;
      b++;
  }
  myout(b + " " + a);
}
function isPrime(val){
        if(val <= 1 || (val != 2 && val % 2 == 0)){
                return false;
        }else if(val == 2){
                return true;
        }
        var root = Math.floor(Math.sqrt(val));
        for(var i = 3; i <= root; i += 2){
                if(val % i == 0){
                        return false;
                }
        }
        return true;
}
Main();

var print = this.print || require('lol-io').print; //print --> outputs result and adds (enter)
var write = this.write || require('lol-io').write; //write --> creates output.txt with output
var readline = this.readline || require('lol-io').readline; //readline --> reads unread line of input.txt

var n, a, b, ans = false;

function isPrime(num) {
    for (var i = 2; i < num; i++)
        if(num % i === 0) return false;
    return num > 1;
}

n = Number(readline());
a = n + 2;
b = 2;

while (!ans) {

    if (!isPrime(a) && !isPrime(b)) {

        ans = true;
        break
    } else {

        a++;
        b++;
    }
}

print(`${a} ${b}`)

var T = parseInt(readline());
print(T * 9 + ' ' + T * 8);

var a = parseInt(readline());

var c = (a + 2) * 3;
var b = c - a;

print(c, b);

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

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

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

  const n = parseInt(arr[0])
  let a, b
  if(n % 2 == 1) {
    a = n + 9
    b = 9
  }
  else {
    a = n + 4
    b = 4
  }
  wr(a, b)
})

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

function max(...x) {
  return Math.max(...x)
}

function min(...x) {
  return Math.min(...x)
}

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

rl.on('line', (d) => {
  const n = +d;

  if (n % 2 === 0) {
    console.log(n + 10, 10);
  }
  else {
    console.log(n + 9, 9);
  }
});

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

readline.on('line', line => {
  let num = Number(line);
  if (num === 1) return console.log(`9 8`);
  console.log(`${(num * 2) + num} ${num * 2}`);
});

// readline.on("close", () => {
//   console.log(count, values);
// });

let fs = require('fs');

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

function doit(num) {
    let max=num*2,min=num;
    while (true) {
        if(check(max) &&check(min)){
            console.log(max,min);
            break;
        }else{
            ++max;
            ++min;
        }
    }
}
function check(num){
    for (let i = 2; i < num/2; i++) {
        if(num%i===0)return true;

    }
    return false;
}

function myout(t){print(t);}//standard output
function myerr(t){console.error(t);}//standard error
//[no]param
//0:何もしない  1:数値へ変換  2:半角SPで分割  3:改行で分割  4:半角SPで分割し、数値配列へ
//5:改行で分割し、数値配列へ  6:1文字に分割  7:1文字に分割し、数値配列へ
function myconv(i,no){switch(no){case 0:return i;case 1:return parseInt(i);case 2:return i.split(" ");case 3:return i.split("\n");case 4:return i.split(" ").map((a)=>Number(a));case 5:return i.split("\n").map((a)=>Number(a));case 6:return i.split("");case 7:return i.split("").map((a)=>Number(a));}}

function Main() {
  var N = myconv(readline(),1);
  var a = N + 1;
  if(isPrime(a)){
      a++;
  }
  var b = a + N;
  while(isPrime(b)){
      b++;
  }
  myout(b + " " + a);
}
function isPrime(val){
        if(val <= 1 || (val != 2 && val % 2 == 0)){
                return false;
        }else if(val == 2){
                return true;
        }
        var root = Math.floor(Math.sqrt(val));
        for(var i = 3; i <= root; i += 2){
                if(val % i == 0){
                        return false;
                }
        }
        return true;
}
Main();

function myout(t){print(t);}//standard output
function myerr(t){console.error(t);}//standard error
//[no]param
//0:何もしない  1:数値へ変換  2:半角SPで分割  3:改行で分割  4:半角SPで分割し、数値配列へ
//5:改行で分割し、数値配列へ  6:1文字に分割  7:1文字に分割し、数値配列へ
function myconv(i,no){switch(no){case 0:return i;case 1:return parseInt(i);case 2:return i.split(" ");case 3:return i.split("\n");case 4:return i.split(" ").map((a)=>Number(a));case 5:return i.split("\n").map((a)=>Number(a));case 6:return i.split("");case 7:return i.split("").map((a)=>Number(a));}}

function Main() {
  var N = myconv(readline(),1);
  var a = N + 1;
  while(isPrime(a)){
      a++;
  }
  var b = a + N;
  while(isPrime(b)){
      a++;
      b++;
  }
  myout(b + " " + a);
}
function isPrime(val){
        if(val <= 1 || (val != 2 && val % 2 == 0)){
                return false;
        }else if(val == 2){
                return true;
        }
        var root = Math.floor(Math.sqrt(val));
        for(var i = 3; i <= root; i += 2){
                if(val % i == 0){
                        return false;
                }
        }
        return true;
}
Main();

function myout(t){print(t);}//standard output
function myerr(t){console.error(t);}//standard error
//[no]param
//0:何もしない  1:数値へ変換  2:半角SPで分割  3:改行で分割  4:半角SPで分割し、数値配列へ
//5:改行で分割し、数値配列へ  6:1文字に分割  7:1文字に分割し、数値配列へ
function myconv(i,no){switch(no){case 0:return i;case 1:return parseInt(i);case 2:return i.split(" ");case 3:return i.split("\n");case 4:return i.split(" ").map((a)=>Number(a));case 5:return i.split("\n").map((a)=>Number(a));case 6:return i.split("");case 7:return i.split("").map((a)=>Number(a));}}

function Main() {
  var N = myconv(readline(),1);
  var a = N + 1;
  if(isPrime(a)){
      a++;
  }
  var b = a + N;
  while(isPrime(b)){
      b++;
  }
  myout(a + " " + b);
}
function isPrime(val){
        if(val <= 1 || (val != 2 && val % 2 == 0)){
                return false;
        }else if(val == 2){
                return true;
        }
        var root = Math.floor(Math.sqrt(val));
        for(var i = 3; i <= root; i += 2){
                if(val % i == 0){
                        return false;
                }
        }
        return true;
}
Main();

var print = this.print || require('lol-io').print; //print --> outputs result and adds (enter)
var write = this.write || require('lol-io').write; //write --> creates output.txt with output
var readline = this.readline || require('lol-io').readline; //readline --> reads unread line of input.txt

var n, a, b, ans = false;

function isPrime(num) {
    for (var i = 2; i < num; i++)
        if(num % i === 0) return false;
    return num > 1;
}

n = Number(readline());
a = n + 1;
b = 1;

while (!ans) {

    if (!isPrime(a) && !isPrime(b)) {

        ans = true;
        break
    } else {

        a++;
        b++;
    }
}

print(`${a} ${b}`)

var k = parseInt(readline());
print(k*5 +' '+ k*4);

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

readline.on('line', line => {
  let num = Number(line);
  if (num === 1) return console.log(`8 9`);
  console.log(`${num * 2} ${(num * 2) + num}`);
});

// readline.on("close", () => {
//   console.log(count, values);
// });

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

readline.on('line', line => {
  let num = Number(line);
  if (num === 1) console.log(`8 9`);
  console.log(`${num * 2} ${(num * 2) + num}`);
});

// readline.on("close", () => {
//   console.log(count, values);
// });


Let's call an array good if there is an element in the array that equals to the sum of all other elements. For example, the array $$$a=[1, 3, 3, 7]$$$ is good because there is the element $$$a_4=7$$$ which equals to the sum $$$1 + 3 + 3$$$.You are given an array $$$a$$$ consisting of $$$n$$$ integers. Your task is to print all indices $$$j$$$ of this array such that after removing the $$$j$$$-th element from the array it will be good (let's call such indices nice).For example, if $$$a=[8, 3, 5, 2]$$$, the nice indices are $$$1$$$ and $$$4$$$:   if you remove $$$a_1$$$, the array will look like $$$[3, 5, 2]$$$ and it is good;  if you remove $$$a_4$$$, the array will look like $$$[8, 3, 5]$$$ and it is good. You have to consider all removals independently, i. e. remove the element, check if the resulting array is good, and return the element into the array.

The first line of the input contains one integer $$$n$$$ ($$$2 \le n \le 2 \cdot 10^5$$$) — the number of elements in the array $$$a$$$. The second line of the input contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 10^6$$$) — elements of the array $$$a$$$.

In the first line print one integer $$$k$$$ — the number of indices $$$j$$$ of the array $$$a$$$ such that after removing the $$$j$$$-th element from the array it will be good (i.e. print the number of the nice indices). In the second line print $$$k$$$ distinct integers $$$j_1, j_2, \dots, j_k$$$ in any order — nice indices of the array $$$a$$$. If there are no such indices in the array $$$a$$$, just print $$$0$$$ in the first line and leave the second line empty or do not print it at all.

NoteIn the first example you can remove any element with the value $$$2$$$ so the array will look like $$$[5, 1, 2, 2]$$$. The sum of this array is $$$10$$$ and there is an element equals to the sum of remaining elements ($$$5 = 1 + 2 + 2$$$).In the second example you can remove $$$8$$$ so the array will look like $$$[3, 5, 2]$$$. The sum of this array is $$$10$$$ and there is an element equals to the sum of remaining elements ($$$5 = 3 + 2$$$). You can also remove $$$2$$$ so the array will look like $$$[8, 3, 5]$$$. The sum of this array is $$$16$$$ and there is an element equals to the sum of remaining elements ($$$8 = 3 + 5$$$).In the third example you cannot make the given array good by removing exactly one element.

const readline = require('readline')

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

let lineCount = 0
let num
let list
let sum = 0
let numberMap = {}
let ansList = []
interface.on('line', line => {
  if (lineCount === 0) {
    num = parseInt(line)
  } else {
    list = line.split(' ').map(v => parseInt(v))
    calculate()
    findAnswer()
    printAnswer()
    process.exit()
  }
  lineCount ++
})

function calculate () {
  for (let i = 0; i < num; i++) {
    if (!numberMap[list[i]]) {
      numberMap[list[i]] = 1
    } else {
      numberMap[list[i]] ++
    }

    sum += list[i]
  }
}
function findAnswer () {
  for (let i = 0; i < num; i++) {
    if ((sum - list[i]) % 2 !== 0) continue
    let need = (sum - list[i]) / 2
    if ((list[i] !== need && numberMap[need]) || (list[i] === need && numberMap[need] > 1)) {
      ansList.push(i + 1)
    }
  }
}
function printAnswer () {
  console.log(ansList.length)
  let str = ''
  for (let i = 0; i < ansList.length; i++) {
    str += ansList[i] + ' '
  }
  console.log(str)
}