One way to create a task is to learn from math. You can generate some random math statement or modify some theorems to get something new and build a new task from that.For example, there is a statement called the "Goldbach's conjecture". It says: "each even number no less than four can be expressed as the sum of two primes". Let's modify it. How about a statement like that: "each integer no less than 12 can be expressed as the sum of two composite numbers." Not like the Goldbach's conjecture, I can prove this theorem.You are given an integer n no less than 12, express it as a sum of two composite numbers.

The only line contains an integer n (12 ≤ n ≤ 106).

Output two composite integers x and y (1 < x, y < n) such that x + y = n. If there are multiple solutions, you can output any of them.

NoteIn the first example, 12 = 4 + 8 and both 4, 8 are composite numbers. You can output "6 6" or "8 4" as well.In the second example, 15 = 6 + 9. Note that you can't output "1 14" because 1 is not a composite number.

var x = parseInt(readline()); // user input
//var x = 787
var a = -1, b = -1;
var siv = new Array(x + 1).fill(1)
for (var n = 2; n * n <= x; n++) {
if (siv[n]) {
for (var k = n * n; k <= x; k += n)siv[k] = 0;
}
}
for (var n = 2; n < x; n++) {
if (!siv[n] && !siv[x - n]) {
a = n;
b = x - n;
break;
}
}
print(a +' '+ b)
//console.log(a, b);

var x = parseInt(readline());
//var x = 18
var a = -1, b = -1;
var siv = new Array(x + 1).fill(1)
for (var n = 2; n * n <= x; n++) {
if (siv[n]) {
for (var k = n * n; k <= x; k += n)siv[k] = 0;
}
}
for (var n = 2; n < x; n++) {
if (!siv[n] && !siv[x - n]) {
a = n;
b = x - n;
break;
}
}
print(a +' '+ b)
//console.log(a, b);

// Generated by CoffeeScript 1.10.0
(function() {
  var a, f, i, j, k, l, len, m, n, ref, ref1, ref2, ref3;

  n = parseInt(readline());

  a = [];

  for (i = j = 2, ref = Math.sqrt(n); 2 <= ref ? j <= ref : j >= ref; i = 2 <= ref ? ++j : --j) {
    if (!a[i]) {
      for (k = l = ref1 = 2 * i, ref2 = n, ref3 = i; ref3 > 0 ? l <= ref2 : l >= ref2; k = l += ref3) {
        a[k] = true;
      }
    }
  }

  for (i = m = 0, len = a.length; m < len; i = ++m) {
    f = a[i];
    if (i < 2) {
      continue;
    }
    if (f && a[n - i]) {
      print(i + ' ' + (n - i));
      break;
    }
  }

}).call(this);

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

// Need gcd.

function gcd(a, b) {
	if (b === 0) return a;
	return gcd(b, a % b);
}

function modularPow(a, n, mod) {
	if (n === 1) return a % mod;
	var pow = modularPow(a, Math.floor(n / 2), mod);
	if (n % 2 === 0) {
		return (pow * pow) % mod;
	}
	return (pow * pow * a) % mod;
}

function notPrime(p) {
	// exactly not prime
	// Fermat's little theorem
	if (p === 2) return false;

	var a = 2; // choose small parameter.
	if (gcd(a, p) !== 1) return true; // not prime.
	var expr = modularPow(a, p - 1, p);
	return !(expr === 1); // Exact not prime.
}

function main(number) {
	var div = 4;
	while (div < number) {
		if (notPrime(number - div) && notPrime(div)) {
			return (number - div) + ' ' + div;
		}
		div++;
	}
}

var sourceNumber = +readline();
var firstNumber = Math.floor(sourceNumber/2);
var secondNumber = Math.ceil(sourceNumber/2);
var isFirstNumberComposite = false;
var isSecondNumberComposite = false;

while (!isSecondNumberComposite || !isFirstNumberComposite) {
    for (var start = 2; start<=Math.ceil(Math.sqrt(firstNumber)); start++) {
        if (firstNumber%start === 0) {
            isFirstNumberComposite = true;
            // print("F" + firstNumber + "/" + start);
        }
    }
    for (var start = 2; start<=Math.ceil(Math.sqrt(secondNumber)); start++) {
        if (secondNumber%start === 0) {
            isSecondNumberComposite = true;
            // print("S" + secondNumber + "/" + start);
        }
    }

    if (!isSecondNumberComposite || !isFirstNumberComposite) {
        firstNumber--;
        secondNumber++;
        isFirstNumberComposite = false;
        isSecondNumberComposite = false;
    }
}
print(firstNumber + " " + secondNumber);

function factorization(a){
	var da = [1];
	for(i = 2; i < a; i++){
		if( a%i == 0 ){
			da.push(i);
			a = a/i;
			i = 1;
		}
	}
	da.push(a);
	return da;
}

var n = +readline();

for(var j = 4; ; j++){
	if( factorization(j).length == 2 ){
		continue;
	}
	else if( factorization(n-j).length == 2 ){
		continue;
	}
	else{
		write(j + " " + (n-j));
		break;
	}
}

var r = +readline();
var first_comp = 0;
var sec_comp = 0;

if(r % 2 == 0){
	first_comp = r - 8;
	sec_comp = r - first_comp;
 	print(first_comp + " " + sec_comp);
}else if (r % 2 != 0){
	first_comp = r - 9;
	sec_comp = r - first_comp;
	print(first_comp + " " + sec_comp);
}

var r = +readline();

// var first_num = Math.floor((r / 3) + 1);
// var sec_num = Math.floor(r - first_num);

if(r % 2 == 0){
	var first_num = Math.floor(r - 8);
	var sec_num = Math.floor(r - first_num);
 	print(first_num + " " + sec_num);
}else if (r % 2 != 0){
	var first_num = Math.floor(r - 9);
	var sec_num = Math.floor(r - first_num);
	print(first_num + " " + sec_num);
}

var n = readline() - 0;
if (n & 1) {
        print('9 ' + (n - 9));
} else {
    var a = n / 2;
    if (a & 1) {
        print((a - 1) + ' ' + (a + 1));
    } else {
        print(a + ' ' + a);
    }
}

function readNums() {
    return readline().split(' ').map(v => v - 0);
}

;(function () {

	var simpleArray = (function (n) {

		var retArray = [], controlArray = new Array(n);

		for (var i = 2; i < n; i ++) {
			if (controlArray[i] !== false) {
				retArray.push(i);

				for (var j = i; j < n; j += i) {
					controlArray[j] = false;
				}
			}
		}

		return retArray;

	})(1e6 + 5);

	print(function (n) {

		var n1, n2;

		for (var i = 4; i < n; i++) {
			n1 = i; n2 = n - n1;

			if (simpleArray.indexOf(n1) === -1 && simpleArray.indexOf(n2) === -1) {
				break;
			}
		}

		return [n1, n2].join(' ');

	}(+readline()));

}.call(this));

var numbers = parseInt(readline());
if(numbers % 2 == 1){
    print(9, numbers - 9);
} else {
    print(4, numbers - 4);
}

var n = Number(readline());
if (n%2 === 0) {
    print(4, n-4);
}
else {
    print(9, n-9);
}

function ProblemSolver() {

    this.solveCase = function() {
        var res , i , j , a , b , c ;
        res = -1;
        c = 0 ;
        for( i = 2 ; i < this.n ; i++ ) {
            a = i ;
            b = this.n - a ;
            if( this.arr[ a ] == 0 && this.arr[ b ] == 0 ) {
                c = 1 ;
                break;
            }
        }
        if( c == 0 ) {
            print( res );
        }
        else {
            print( a + " " + b );
        }
    };

    this.getInput = function( irObj ) {
        var hasMoreInput , i;
        hasMoreInput = true;
        try {
            this.n = irObj.nextInt();
        }
        catch( ex ) {
            hasMoreInput = false;
        }
        return hasMoreInput;
    };

    this.clearArraysPerCase = function() {
        var i;
        this.arr = new Array();
        this.brr = new Array();
        this.adj_list = new Array();
        for( i = 0 ; i < this.lim1 ; i++ ) {
            this.arr.push( 0 );
            this.brr.push( 0 );
            this.adj_list.push( new Array() );
        }
    };

    this.clearPerCase = function() {
        this.cn = 0;
        this.cc++;
        //this.clearArraysPerCase() ;
    };

    this.HAS_TEST_CASES = false;
    this.INPUT_FILE_NAME = "test.in";
    this.OUTPUT_FILE_NAME = "out.txt";
    this.DO_OUTPUT_TO_FILE = false;

    this.declareAndFillArrays = function() {
        var i , j;
        this.srr = new Array();
        this.vis = new Array();
        this.arr = new Array();
        this.brr = new Array();
        this.memo = new Array();
        this.done = new Array();
        this.adj_list = new Array();
        for( i = 0 ; i < this.lim1 ; i++ ) {
            this.srr.push( "" );
            this.vis.push( 0 );
            this.arr.push( 0 );
            this.brr.push( 0 );
            this.adj_list.push( new Array() );
        }
        for( i = 0 ; i < this.lim2 ; i++ ) {
            this.memo.push( new Array() );
            this.done.push( new Array() );
            for( j = 0 ; j < this.lim2 ; j++ ) {
                this.memo[ i ].push( -1 );
                this.done[ i ].push( 0 );
            }
        }
    };

    this.init = function() {
        var i , sz , a ;
        this.lim1 = 1000010;
        this.lim2 = 110;
        this.cc = 1;
        this.ind = 1;
        this.n = 0;
        this.cn = 0;
        this.declareAndFillArrays();
        this.bmfObj = new BasicMathFunctions();
        this.primes = this.bmfObj.getPrimes( 1000000 ) ;
        sz = this.primes.length;
        for( i = 0 ; i < sz ; i++ ) {
            a = this.primes[ i ] ;
            this.arr[ a ] = 1 ;
        }
    };

    this.memsetArray1D = function( arrParam , val ) {
        var i;
        if( arrParam == null ) {
            throw new Error( "No array supplied in the parameter!" );
        }
        if( val == null ) {
            throw new Error( "No value for memset has been supplied in the parameter!" );
        }
        arrParam = new Array();
        for( i = 0 ; i < this.lim1 ; i++ ) {
            arrParam.push( val );
        }
        return arrParam;
    };

    this.getStringLength = function( stringData ) {
        var len , lengthType;
        len = stringData.length;
        lengthType = typeof len;
        if( lengthType == "function" ) {
            len = stringData.length();
        }
        else {
            len = stringData.length;
        }
        return len;
    };

    this.init();
}

function InputReader() {
    this.allLines = new Array();
    this.currrentLineNumber = 0;
    this.currrentCharacterIndex = 0;

    this.readAllLines = function() {
        var singleLine;
        while( true ) {
            try {
                singleLine = readline();
                if( singleLine == null ) {
                    break;
                }
            }
            catch( ex ) {
                break;
            }
            this.allLines.push( singleLine );
        }
    };

    this.readAllLinesFromRhinoStdin = function() {
        importPackage( java.io );
        importPackage( java.lang );
        var singleLine , reader;
        reader = new BufferedReader( new InputStreamReader( System[ "in" ] ) );
        this.allLines = [];
        while( true ) {
            singleLine = reader.readLine();
            if( singleLine != null ) {
                this.allLines.push( singleLine );
            }
            else {
                break;
            }
        }
    };

    this.readAllLinesFromNodeStdin = function() {
        var fsObj , size , rawData;
        process.stdin.setEncoding( 'ascii' );
        fsObj = require( 'fs' );
        size = fsObj.fstatSync( process.stdin.fd ).size;
        rawData = fsObj.readSync( process.stdin.fd , size )[ 0 ];
        this.parseRawData( rawData );
    };

    this.parseRawData = function( data ) {
        var len , i , currentString;
        len = data.length;
        currentString = "";
        for( i = 0 ; i < len ; i++ ) {
            if( data[ i ] == '\r' ) {
            }
            else if( data[ i ] == '\n' ) {
                this.allLines.push( currentString );
                currentString = "";
            }
            else {
                currentString += data[ i ];
            }
        }
        if( currentString != "" ) {
            this.allLines.push( currentString );
        }
    };

    this.readAllLinesFromFile = function( inputFileName ) {
        var currentDirectory , fsObj , inputFilePath , rawData;
        fsObj = require( 'fs' );
        currentDirectory = __dirname;
        inputFilePath = currentDirectory + "\\" + inputFileName;
        rawData = fsObj.readFileSync( inputFilePath , "utf8" );
        this.parseRawData( rawData );
    };

    this.next = function( flag ) {
        var len , i , startIdx , res , endIdx , lengthType;
        len = this.allLines[ this.currrentLineNumber ].length;
        lengthType = typeof len;
        if( lengthType == "function" ) {
            len = this.allLines[ this.currrentLineNumber ].length();
        }
        if( flag == 0 ) {
            res = "";
            for( i = this.currrentCharacterIndex ; i < len ; i++ ) {
                res += String.fromCharCode( this.allLines[ this.currrentLineNumber ].charCodeAt( i ) );
            }
            this.currrentLineNumber++;
            this.currrentCharacterIndex = 0;
            return res;
        }
        while( true ) {
            if( this.currrentLineNumber >= this.allLines.length ) {
                throw new Error( "No more tokens available!" );
            }
            startIdx = -1;
            for( i = this.currrentCharacterIndex ; i < len ; i++ ) {
                if( this.allLines[ this.currrentLineNumber ].charCodeAt( i ) != ' '.charCodeAt( 0 ) && this.allLines[ this.currrentLineNumber ].charCodeAt( i ) != '\t'.charCodeAt( 0 ) ) {
                    startIdx = i;
                    break;
                }
            }
            if( startIdx == -1 ) {
                this.currrentLineNumber++;
                this.currrentCharacterIndex = 0;
                continue;
            }
            res = "";
            endIdx = -1;
            for( i = startIdx ; i < len ; i++ ) {
                if( this.allLines[ this.currrentLineNumber ].charCodeAt( i ) == ' '.charCodeAt( 0 ) || this.allLines[ this.currrentLineNumber ].charCodeAt( i ) == '\t'.charCodeAt( 0 ) ) {
                    endIdx = i;
                    break;
                }
                res += String.fromCharCode( this.allLines[ this.currrentLineNumber ].charCodeAt( i ) );
            }
            if( endIdx == -1 ) {
                this.currrentLineNumber++;
                this.currrentCharacterIndex = 0;
            }
            else {
                this.currrentCharacterIndex = endIdx;
            }
            return res;
        }
    };

    this.nextInt = function() {
        return parseInt( this.next( 1 ) );
    };

    this.nextDouble = function() {
        return parseFloat( this.next( 1 ) );
    };

    this.nextString = function() {
        return this.next( 1 );
    };

    this.nextLine = function() {
        this.next( 0 );
    };
}

function FileOutputHandler() {
    this.resultantStringArray = new Array();

    this.addNewLine = function( newString ) {
        this.resultantStringArray.push( newString );
    };

    this.clearPercase = function() {
        this.resultantStringArray = new Array();
    };

    this.flushOutOutputToFile = function( outputFileName ) {
        var i , sz , res , currentDirectory , fsObj , outputFilePath;
        res = "";
        sz = this.resultantStringArray.length;
        for( i = 0 ; i < sz ; i++ ) {
            if( i != 0 ) {
                res += "\n";
            }
            res += this.resultantStringArray[ i ];
        }
        fsObj = require( 'fs' );
        currentDirectory = __dirname;
        outputFilePath = currentDirectory + "\\" + outputFileName;
        if( currentDirectory.charAt( 1 ) != ":" ) {
            //not local machine/windows
            outputFilePath = outputFileName;
        }
        fsObj.writeFileSync( outputFilePath , res );
        this.clearPercase();
    };
}

function CodeExecutioner() {
    this.irObj = new InputReader();
    this.psObj = new ProblemSolver();
    this.fohObj = new FileOutputHandler();

    this.runCode = function() {
        var testCases , i , hasMoreTestCases , isLocalMachine , localContext;
        isLocalMachine = false;
        try {
            if( __dirname != null && __dirname.charAt( 1 ) == ':' ) {
                //only on windows
                isLocalMachine = true;
            }
        }
        catch( ex ) {
            isLocalMachine = false;
        }
        if( isLocalMachine == true ) {
            //local machine runs on node and relies on file i/o
            print = console.log;
            if( this.psObj.DO_OUTPUT_TO_FILE == true ) {
                localContext = this.fohObj;
                print = function() {
                    localContext.addNewLine.apply( localContext , arguments );
                }
            }
            this.irObj.readAllLinesFromFile( this.psObj.INPUT_FILE_NAME );
        }
        else {
            //server machine
            try {
                var rlObj = readline;
                //server runs on javasctipt v8 distribution and has readline method on global context
                this.irObj.readAllLines();
            }
            catch( ex ) {
                try {
                    var pObj = process;
                    //server runs on node
                    print = console.log;
                    this.irObj.readAllLinesFromNodeStdin();
                }
                catch( ex ) {
                    try {
                        var ipObj = importPackage;
                        //server runs on rhino
                        this.irObj.readAllLinesFromRhinoStdin();
                    }
                    catch( ex ) {
                        throw new Error( "Unknown javasctipt distribution!" );
                    }
                }
            }
        }
        if( this.psObj.HAS_TEST_CASES == true ) {
            testCases = this.irObj.nextInt();
            for( i = 0 ; i < testCases ; i++ ) {
                this.psObj.clearPerCase();
                this.psObj.getInput( this.irObj );
                this.psObj.solveCase();
            }
        }
        else {
            while( true ) {
                this.psObj.clearPerCase();
                hasMoreTestCases = this.psObj.getInput( this.irObj );
                if( hasMoreTestCases == false ) {
                    break;
                }
                this.psObj.solveCase();
            }
        }
        if( this.psObj.DO_OUTPUT_TO_FILE == true ) {
            //only works for local machine(tested)
            this.fohObj.flushOutOutputToFile( this.psObj.OUTPUT_FILE_NAME );
        }
    };

    this.runCode();
}

function BasicMathFunctions() {
    this.eps = 1e-9;

    this.getPrimes = function( n ) {
        var sq , i , j , a , bitSize;
        bitSize = 31;
        this.pre = new Array();
        this.primes = new Array();
        for( i = 0 ; i < n ; i++ ) {
            this.pre.push( 0 );
        }
        sq = Math.ceil( Math.sqrt( n * 1.0 ) + this.eps );
        for( i = 3 ; i < sq ; i += 2 ) {
            a = this.pre[ i >> 6 ] & ( 1 << ( ( i >> 1 ) & bitSize ) );
            if( a == 0 ) {
                for( j = i * i ; j <= n ; j += ( i << 1 ) ) {
                    this.pre[ j >> 6 ] |= ( 1 << ( ( j >> 1 ) & bitSize ) );
                }
            }
        }
        this.primes.push( 2 );
        for( i = 3 ; i <= n ; i += 2 ) {
            a = this.pre[ i >> 6 ] & ( 1 << ( ( i >> 1 ) & bitSize ) );
            if( a == 0 ) {
                this.primes.push( i );
            }
        }
        return this.primes;
    };

    this.isPrimeUptoSqrt = function( n ) {
        var sq , i , res;
        sq = Math.ceil( Math.sqrt( n * 1.0 ) + this.eps );
        res = true;
        for( i = 2 ; i <= sq ; i++ ) {
            if( n % i == 0 ) {
                res = false;
                break;
            }
        }
        return res;
    };

    this.factorize = function( n ) {
        var sq , i , lastPrime , cnt , res;
        if( this.primes == null || this.primes.length == 0 ) {
            throw new Error( "No primes are available for factorization!" );
        }
        lastPrime = this.primes[ this.primes.length - 1 ];
        if( lastPrime * lastPrime < n ) {
            throw new Error( "Insufficient number of primes are available for factorization!" );
        }
        res = new Array();
        if( n == 1 ) {
            return res;
        }
        sq = Math.ceil( Math.sqrt( n * 1.0 ) + this.eps );
        for( i = 0 ; this.primes[ i ] <= sq ; i++ ) {
            if( n % this.primes[ i ] == 0 ) {
                cnt = 0;
                while( n % this.primes[ i ] == 0 ) {
                    n = Math.floor( n / this.primes[ i ] );
                    cnt++;
                }
                res.push( new Array() );
                res[ res.length - 1 ].push( this.primes[ i ] );
                res[ res.length - 1 ].push( cnt );
                sq = Math.ceil( Math.sqrt( n * 1.0 ) + this.eps );
            }
        }
        if( n > 1 ) {
            res.push( new Array() );
            res[ res.length - 1 ].push( n );
            res[ res.length - 1 ].push( 1 );
        }
        return res;
    };

    this.modLongInteger = function( n , mod ) {
        var factoList , sz , i , j , cnt , res , a;
        if( n == null ) {
            throw new Error( "Need the n(first) parameter!" );
        }
        if( mod == null ) {
            throw new Error( "Need the mod(second) parameter!" );
        }
        factoList = this.factorize( n );
        sz = factoList.length;
        res = 1;
        for( i = 0 ; i < sz ; i++ ) {
            a = factoList[ i ][ 0 ];
            cnt = factoList[ i ][ 1 ];
            for( j = 0 ; j < cnt ; j++ ) {
                if( res * a > 9e15 ) {
                    throw new Error( "The multiplication of numbers have gone beyond 2^53!" );
                }
                res = ( res * a ) % mod;
            }
        }
        return res;
    };

    this.multiplyTwoLongInteger = function( n , m , mod ) {
        var factoList , sz , i , j , cnt , res , a;
        if( n == null ) {
            throw new Error( "Need the n(first) parameter!" );
        }
        if( m == null ) {
            throw new Error( "Need the m(second) parameter!" );
        }
        if( mod == null ) {
            throw new Error( "Need the mod(third) parameter!" );
        }
        factoList = this.factorize( n );
        sz = factoList.length;
        res = 1;
        for( i = 0 ; i < sz ; i++ ) {
            a = factoList[ i ][ 0 ];
            cnt = factoList[ i ][ 1 ];
            for( j = 0 ; j < cnt ; j++ ) {
                if( res * a > 9e15 ) {
                    throw new Error( "The multiplication of numbers have gone beyond 2^53!" );
                }
                res = ( res * a ) % mod;
            }
        }
        factoList = this.factorize( m );
        sz = factoList.length;
        for( i = 0 ; i < sz ; i++ ) {
            a = factoList[ i ][ 0 ];
            cnt = factoList[ i ][ 1 ];
            for( j = 0 ; j < cnt ; j++ ) {
                if( res * a > 9e15 ) {
                    throw new Error( "The multiplication of numbers have gone beyond 2^53!" );
                }
                res = ( res * a ) % mod;
            }
        }
        return res;
    };

    this.bigModLongInteger = function( a , p , mod ) {
        var res , x;
        x = a;
        res = 1;
        while( p > 0 ) {
            if( p % 2 != 0 ) {
                res = this.multiplyTwoLongInteger( res , x , mod );
            }
            x = this.multiplyTwoLongInteger( x , x , mod );
            p >>= 1;
        }
        return res;
    };
}

new CodeExecutioner();

'use strict';

const isСompositeNumber = num => {
    for (let i = 2; i < num - 1; i++) {
        if (num % i === 0) {
            return true;
        }
    }

    return false;
};

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

     for (let i = 4; i < n - 1; i++) {
        if (
          isСompositeNumber(i) &&
          isСompositeNumber(n - i)
        ) {
          write(i + ' ' + (n - i));
          return;
        }
     }
 })();

var n = readline();
var q;
for (x=4;x<n;x++){
    y = n - x;
    if (sost(x)&&sost(y)){
    print(x + " " +  y);
    break;
    }
}
function sost(a){
    for (i=2;i<=Math.sqrt(a);i++){
        if (a%i==0) {q = true; break;}
        else q = false;
    }
return q;
}

function main() {
	var n = parseInt(readline());
	var a, b;
	if (n % 2 == 0) {
		a = 8;
		b = n - 8;
	} else {
		a = 9;
		b = n - 9;
	}
	print(a, b);
}

main();

var n = Number(readline());

if (n % 2 === 0) {
    print(8, n-8);
}
else {
    print(9, n-9);
}

var entrada = readline();
var numero = parseInt(entrada);
var x = 4;
var y;
if(numero%2===0){
    y = numero-x;
} else {
    x = 9;
	y = numero-9;
}
print(x+' '+y);

var n = parseInt(readline());
var a = 0;
function composite(n) {
	for (var i = 2; i <= Math.ceil(Math.sqrt(n)); i++){
		if (n % i == 0) return true;
	};
	return false;
}

for (var i = Math.ceil(n / 2) - 1; i > 0; i--){
	if (composite(i) && composite(n - i)) {
		a = i;
		break;
	}

}
print (a + ' ' + (n-a));

var designTask = function(n)
    {
        var checkArr = [4, 6, 8, 9];
        for (var i = 0; i <= 3; i++)
        {
            if ((n - checkArr[i]) % 2 === 0) return (n - checkArr[i]) + ' ' + checkArr[i];
            else if ((n - checkArr[i]) % 3 === 0) return (n - checkArr[i]) + ' ' + checkArr[i];
        }
    }
var input = readline();
print(designTask(+input));

var n = parseInt(readline());

var x = (n - n % 2) / 2, y = (n + n % 2) / 2;
while ((isPrime(x) || isPrime(y))){
	x--; y++;
}
print(x + " " + y);

function isPrime(p) {
	for(var i = 2; i <= Math.sqrt(p); i++) {
		if (p % i === 0)
			return false;
	}
	return true;
}

(function () {
    var num = parseInt(readline());

    if (num % 2 == 0){
        print(8 + " " + (num - 8))
    } else {
        print(9 + " " + (num - 9))
    }

    return 0;
})();

function isComposite(n) {
    for(var i = 2; i * i <= n; ++i) {
        if(n % i == 0) {
            return true;
        }
    }
    return false;
}

var n = parseInt(readline());
for(var i = 4; i * 2 <= n; ++i) {
    if(isComposite(i) && isComposite(n - i)) {
        print(i, n - i);
        break;
    }
}

// Solution By: Problem Setter

var n = parseInt(readline());  // user input
if (n % 2 == 0) print(4, + n - 4);
else print(9, n - 9);

var number = parseInt(readline());
//var number = 91;
var found = false;
for (i = 1, j = number - 1; i < j && j > 0 && i < number; i++, j--) {
  if (isPrime(i) || i < 2 || isPrime(j) || j < 2) {
    continue;
  } else {
    found = true;
    break;
  }
}
if (found) print(i + ' ' + j);
//console.log(found ? `${i},${j}` : "Not found");
function isPrime(value) {
  for (var i = 2; i < value; i++) {
    if (value % i === 0) {
      return false;
    }
  }
  return value > 1;
}

var n = parseInt(readline());
var x = 4;
var y = 0;
if(n%2==0)
{
    y = n - x;
}
else
{
    x = 9;
	y = n - 9;
}
print(x + ' ' + y);

var n = parseInt(readline()),
			x = 4, y = 0;

		while(true)	{
			if(isCheck(x))	{
				y = n - x;
				if(isCheck(y))	break;
			}

			x++;
		}

		print(x + ' ' + y);

		function isCheck(num)	{
			if(num == 2 || num == 3)	return false;
			if(num % 2 == 0 || num % 3 == 0)	return true;
			else	return false;
		};

var n = parseInt(readline())
var x = 2, y = 0

for(;x <= n/2;x++){
    y = n - x
    if(!isPrime(y) && !isPrime(x)){
        print(x + ' ' + y)
        break
    }
}

function isPrime(x){
    for(var i = 2;i<=Math.sqrt(x);i++){
        if(x%i === 0){
            return false
        }
    }
    return true
}

//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();
  for(var i = 2; i < N; i++){
    var x = i;
    var y = N - i;
    if(!isPrime(x) && !isPrime(y)){
      myout(x + " " + y);
      return;
    }
  }
}
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;
}

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

let ans = (x, y) => console.log(`${x} ${y}`);
function isPrime(num) {
  if (num <= 1) return false;
  if (num % 2 == 0 && num > 2) return false;
  let s = Math.sqrt(num);
  for (let i = 3; i <= s; i++) {
    if (num % i === 0) return false;
  }
  return true;
}

rl.on('line', (d) => {
  let x = Math.floor(+d / 2);
  let y = Math.ceil(+d / 2);;

  while (isPrime(x) || isPrime(y)) {
    x--;
    y++;
  }

  ans(x, y);
});

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

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

readLine.on('close', () => {
  let nums = parseInt(input[0]);

  let left = 0, right = 0;
  if (nums % 2 === 0) { left = nums/2; right = nums/2; }
  else { left = (nums-1)/2; right = (nums+1)/2; }

  while (true) {
    if ( (left % 2 === 0 || (left % 3 === 0 && left !== 3)   || (left % 5 === 0 && left !== 5) || (left % 7 === 0 && left !== 7)) &&
        (right % 2 === 0 || (right % 3 === 0 && right !== 3) || (right % 5 === 0 && right !== 5) || (right % 7 === 0 && right !== 7)) ) {
      console.log(`${left} ${right}`);
      break;
    } else {
      right -= 1; left += 1;
    }
  }
});

let fs = require("fs");

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

function doit(num) {
    let max=num-4;
    let min=4;
    while (true) {
        if(composite(max)&&composite(min)){
            console.log(min,max);
            return;
        }else{
            --max;
            ++min;
        }
    }
}

function composite(num) {
    for (let i = 2; i <= num / 2; i++) {
        if (num % i === 0) return true

    }
    return false;
}

// Sample code to perform I/O:

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

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

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

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

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

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

    let inputs = +str.trim();
    let compositeNum = [];
    for (let i = 4; i < inputs; i++) {

        if (!checkPrime(i)) {
            let difference = inputs - i;
            if (!checkPrime(difference)) {
                compositeNum.push(i, difference);
                break;
            }
        }
    }
    return compositeNum.join(' ').toString();
}

function checkPrime(num) {
    let isPrime = true;
    for (i = 2; i <= num / 2; ++i) {
        if (num % i == 0) {
            isPrime = false;
            break;
        }
    }
    return isPrime;
}

'use strict';

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

let inputString = '';
let currentLine = 0;

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

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

    main();
});

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

function main() {
    let n = parseInt(readLine());
    if (n % 2 == 0) console.log(n - 4, 4)
    else console.log(n - 9, 9)
}

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

// Need gcd.

function gcd(a, b) {
	if (b === 0) return a;
	return gcd(b, a % b);
}

function modularPow(a, n, mod) {
	if (n === 1) return a % mod;
	var pow = modularPow(a, Math.floor(n / 2), mod);
	if (n % 2 === 0) {
		return (pow * pow) % mod;
	}
	return (pow * pow * a) % mod;
}

function notPrime(p) {
	// exactly not prime
	// Fermat's little theorem
	if (p === 2) return false;

	var a = 2; // choose small parameter.
	if (gcd(a, p) !== 1) return true; // not prime.
	var expr = modularPow(a, p - 1, p);
	console.log(expr)
	return !(expr === 1); // Exact not prime.
}

function main(number) {
	var div = 4;
	while (div < number) {
		if (notPrime(number - div) && notPrime(div)) {
			return number + ' ' + div;
		}
	}
}

function primToN(n){
	var answer = [2];

	for(j = 3; j <= n; j++){
		if( answer.every(function(number){return (j%number != 0) ? true : false}) ){
			answer.push(j);
		}
	}
	j = undefined, number = undefined;
	return answer;
}

var n = +readline(), primes = primToN( (n < 100) ? n : 100 );

for(i = 4; ;i++){
	if( primes.some(function(number){return (number == i) ? true : false}) ){
		continue;
	}
	else if( primes.some(function(number){return (number == (n-i)) ? true : false}) ){
		continue;
	}
	else{
		write(i + " " + (n-i));
		break;
	}
}

var r = +readline();

if(r % 2 == 0){
	print(r / 2 + " " + r / 2);
}else if (r % 2 != 0){
	var first_num = Math.floor((r / 3) + 1);
	var sec_num = Math.floor(r - first_num);
	print(first_num + " " + sec_num);
}

var r = +readline();

if(r % 2 == 0){
	var odd = r - 1;
	var first_num = Math.floor((odd / 3) + 1);
	var sec_num = Math.floor(r - first_num);
 	print(first_num + " " + sec_num);
}else if (r % 2 != 0){
	var first_num = Math.floor((r / 3) + 1);
	var sec_num = Math.floor(r - first_num);
	print(first_num + " " + sec_num);
}

var r = +readline();

if(r % 2 == 0){
	var first_num = Math.floor(r - 4);
	var sec_num = Math.floor(r - first_num);
 	print(sec_num + " " + first_num);
}else if (r % 2 != 0){
	var first_num = Math.floor((r / 3) + 1);
	var sec_num = Math.floor(r - first_num);
	print(first_num + " " + sec_num);
}

var r = +readline();

if(r % 2 == 0){
	var odd = r - 1;
	var first_num = Math.floor((odd / 3) + 1);
	var sec_num = Math.floor(odd - first_num);
 	print(first_num + " " + sec_num);
}else if (r % 2 != 0){
	var first_num = Math.floor((r / 3) + 1);
	var sec_num = Math.floor(r - first_num);
	print(first_num + " " + sec_num);
}

var numbers = parseInt(readline());
if(numbers % 2 == 1){
    print(9, numbers - 9);
} else {
    var half = numbers / 2;
    print(half, half);
}

var numbers = parseInt(readline());
if(numbers % 2 == 1){
    print(9, numbers - 9);
} else {
    var half = numbers / 2;
    print(4, half - 4);
}

var n = Number(readline());
print(4, n-4);

var n = readline();
if(n%2==0)
print(n/2, n/2)
for (var i=1; i<10; i++){
  var c = n-(0+i);
  var b = n-c;
  if (b>2&&b%2==0)
  {
	print(c,b);
  break;
  }
}

var n = readline();
var c = n-6;
n%2==0? print(n/2, n/2):print(6, c)

var n = readline();
var c = n-3;
n%2==0? print(n/2, n/2):print(3, c)

var n = readline();
if(n%2==0)
print(n/2, n/2)
else{
for (var i=1; i<10; i++){
  var c = n-(0+i);
  var b = n-c;
  if (b>2&&b%2==0)
  {
	print(c,b);
  break;
  }
}
}

var entrada = readline();
var numero = parseInt(entrada);
var num = 0;
if(numero%2===0){
    num = numero-8;
    print('8 '+num);
} else {
	y = numero-9;
    print('9 '+num);
}

var entrada = readline();
var numero = parseInt(entrada);
var x = 4;
var y;
if(numero%2===0){
    y = numero-x;
} else {
    x = 9;
	y = numero-9;
}
print(x+', '+y);

var n = parseInt(readline());
var a = 0;
function composite(n) {
	for (var i = 2; i <= Math.ceil(Math.sqrt(n)); i++){
		if (n % i == 0) return true;
	};
	return false;
}

for (var i = 1; i < Math.ceil(n / 2); i++){
	if (composite(i) && composite(n - i)) {
		a = i;
		break;
	}

}
print (a + ' ' + (n-a));

var n = parseInt(readline());

if (n % 2 === 0) {
	print (n / 2 + " " + n / 2);
}
else {
	var x = (n - 1) / 2, y = x + 1;
	while ((isPrime(x) || isPrime(y))){
		x--; y++;
	}
	print(x + " " + y);
}

function isPrime(p) {
	for(var i = 2; i <= Math.sqrt(p); i++) {
		if (p % i === 0)
			return false;
	}
	return true;
}

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

    var names = ["Sheldon", "Leonard", "Penny", "Rajesh", "Howard"];

    var r = 1;
    while (r * 5 < n)
    {
        n -= r * 5;
        r *= 2;
    }

    print(names[Math.floor((n - 1) / r)]);

    return 0;
})();

function isComposite(n) {
    for(var i = 2; i * i < n; ++i) {
        if(n % i == 0) {
            return true;
        }
    }
    return false;
}

var n = parseInt(readline());
for(var i = 4; i * 2 <= n; ++i) {
    if(isComposite(i) && isComposite(n - i)) {
        print(i, n - i);
        break;
    }
}

function isComposite(n) {
    for(var i = 2; i * i < n; ++i) {
        if(n % i == 0) {
            return true;
        }
    }
    return false;
}

var n = parseInt(readline());
for(var i = 4; i * 2 < n; ++i) {
    if(isComposite(i) && isComposite(n - i)) {
        print(i + " " + n);
        break;
    }
}

function isComposite(n) {
    for(var i = 2; i * i < n; ++i) {
        if(n % i == 0) {
            return true;
        }
    }
    return false;
}

var n = parseInt(readline());
for(var i = 4; i * 2 <= n; ++i) {
    if(isComposite(i) && isComposite(n - i)) {
        print(i, n);
        break;
    }
}

function isComposite(n) {
    for(var i = 2; i * i < n; ++i) {
        if(n % i == 0) {
            return true;
        }
    }
    return false;
}

var n = parseInt(readline())
for(var i = 4; i * 2 < n; ++i) {
    if(isComposite(i) && isComposite(n - i)) {
        print(i , n);
        break;
    }
}

var n = parseInt(readline());  // user input
print(n % 2 == 0 ? (4 + ' ' + n - 4) : (9 + ' ' + n - 9));

var n = parseInt(readline());  // user input
print(n % 2 == 0 ? (4, n - 4) : (9, n - 9));

var n = parseInt(readline());  // user input
if (n % 2 == 0) print(4 + ' ' + n - 4);
else print(9 + ' ' + n - 9);

var x= parseInt(readline());
for(var i=2; i<x; i++)
{
if(x%i==0) {var y=x/i; break;}
}
var z= parseInt(y/2)+1;
z*=i;
print(z+' '+ x-z);

function getTwoNums(num) {
    if(num >= 12 && num <= 1000000) {
    var numStr = num.toString();
    var numArr = numStr.split('');
    var firstNum = numArr.reduce(function(accumulator, current) {
    return Number(accumulator) + Number(current);
    })
    var secondNum = num - firstNum;
    return [firstNum, secondNum]
    }
    }
    var k = parseInt(readline());
    print(getTwoNums(k).join(' '))

var input = parseInt(readline());
if (input % 2) print(2 + ' ' + input - 2)
else print((input / 2) + 1 + ' ' + (input / 2) - 1)

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

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

readLine.on('close', () => {
  let nums = parseInt(input[0]);

  let left = 0, right = 0;
  if (nums % 2 === 0) { left = nums/2; right = nums/2; }
  else { left = (nums-1)/2; right = (nums+1)/2; }

  while (true) {
    if ( (left % 2 === 0 || left % 3 === 0 || left % 5 === 0 || (left % 7 === 0 && left !== 7)) &&
        (right % 2 === 0 || right % 3 === 0 || right % 5 === 0 || (right % 7 === 0 && right !== 7)) ) {
      console.log(`${left} ${right}`);
      break;
    } else {
      right -= 1; left += 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.replace(/\s*$/, '')
        .split('\n')
        .map(str => str.replace(/\s*$/, ''));

    main();
});

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

function main() {
    let n = parseInt(readLine());
    if (n % 2 == 0) console.log(n / 2, n / 2)
    else console.log(n - 9, 9)
}


Luntik has decided to try singing. He has $$$a$$$ one-minute songs, $$$b$$$ two-minute songs and $$$c$$$ three-minute songs. He wants to distribute all songs into two concerts such that every song should be included to exactly one concert.He wants to make the absolute difference of durations of the concerts as small as possible. The duration of the concert is the sum of durations of all songs in that concert.Please help Luntik and find the minimal possible difference in minutes between the concerts durations.

The first line contains a single integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. Each test case consists of one line containing three integers $$$a, b, c$$$ $$$(1 \le a, b, c \le 10^9)$$$ — the number of one-minute, two-minute and three-minute songs.

For each test case print the minimal possible difference in minutes between the concerts durations.

NoteIn the first test case, Luntik can include a one-minute song and a two-minute song into the first concert, and a three-minute song into the second concert. Then the difference will be equal to $$$0$$$.In the second test case, Luntik can include two one-minute songs and a two-minute song and a three-minute song into the first concert, and two three-minute songs into the second concert. The duration of the first concert will be $$$1 + 1 + 2 + 3 = 7$$$, the duration of the second concert will be $$$6$$$. The difference of them is $$$|7-6| = 1$$$.

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

//Don't have to see. end------------------------------------------
function Main(){
	var t = nextInt();
	while(hasNext()){
		var a = nextInt() % 2;
		var b = nextInt() % 2;
		var c = nextInt() % 2;
		if(a == 0){
			a += 2;
		}
		if(b == 0){
			b += 2;
		}
		if(c == 0){
			c += 2;
		}
		var check = [a,b,c];
		var N = check.length;
		var isOK = false;
		for(var i = 0; i < (1 << N); i++){
			var L = [];
			var R = [];
			for(var j = 0; j < N; j++){
				if((i & (1 << j)) != 0){
					L.push(j + 1);
				}else{
					R.push(j + 1);
				}
			}
			if(L.length > 0 && R.length > 0){

				var LV = 0;
				for(var j = 0; j < L.length; j++){
					LV += check[L[j] - 1] * L[j];
				}
				var RV = 0;
				for(var j = 0; j < R.length; j++){
					RV += check[R[j] - 1] * R[j];
				}
				if(LV == RV){
					isOK = true;
					break;
				}else{

				}
			}
		}

		if(isOK){
			myout(0);
			continue;
		}
		if(a == 2 && b == 1 && c == 2){
			myout(0);
			continue;
		}
		myout(1);
		//myout((isOK) ? 0 : 1);

	}
}

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];
    for(l = 1; l <= n; l++){
        var k = lines[l].split(' ').map(Number);
        var a = k[0];
        var b = k[1];
        var c = k[2];
        var total = a + (b * 2) + (c * 3);
        if(total % 2 === 0){
            console.log(0);
        }else{
            console.log(1);
        }
    }
});

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

function solve(a, b, c) {
    const oa = a & 1
    const ob = b & 1
    const oc = c & 1
    if (oa) {
        if (ob) {
            if (oc) {
                return 0
            } else {
                return 1
            }
        } else {
            if (oc) {
                return b ? 0 : 1
            } else {
                return 1
            }
        }
    } else {
        if (ob) {
            if (oc) {
                return 1
            } else {
                return 0
            }
        } else {
            if (oc) {
                return 1
            } else {
                return 0
            }
        }
    }
    // if (true) {}
    // const sum = a + 2 * b + 3 * c
    // const half = Math.floor(sum / 2)
    // const k = Math.floor(half / 3)
    // const r = half % 3
    // if (sum & 1) {
    //     if (k <= c) {
    //         switch (r) {
    //         case 2: return (b || a >= 2) ? 0 : (a ? 1 : 2)
    //         case 1: return (b || a >= 2) ? 0 : 1
    //         default:
    //         case 0: return 1
    //         }
    //     } else {
    //         const d = half - 3 * c
    //         if (d & 1) {
    //             return (b >= d / 2 && a) || (a >= d) ? 0 : 1
    //         } else {
    //             return (b >= d / 2 || a >= d) ? 0 : 1
    //         }
    //     }
    // } else {
    //     if (k <= c) {
    //         switch (r) {
    //         case 2: return (b || a >= 2) ? 0 : (a ? 1 : 2)
    //         case 1: return a ? 0 : 1
    //         default:
    //         case 0: return 0
    //         }
    //     } else {
    //         const d = half - 3 * c
    //         if (d & 1) {
    //             return (b >= d / 2 && a) || (a >= d) ? 0 : 1
    //         } else {
    //             return (b >= d / 2 || a >= d) ? 0 : 1
    //         }
    //     }
    // }
}

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];
    for(var l = 1; l <= n; l++){
        var k = lines[l].split(' ').map(Number);
        var a = k[0];
        var b = k[1];
        var c = k[2];
        var total = a + (b * 2) + (c * 3);
        if(total % 2 === 0){
            console.log(0);
        }else{
            console.log(1);
        }
    }
});

function solve() {
   const [a, b, c] = readArray(BigInt);
   write((a + 2n * b + 3n * c) & 1n);
}

function sortF(a, b) {
   if (a < b) {
      return -1;
   }
   if (a > b) {
      return 1;
   }
   return 0;
}

function init() {
   try {
      var T;
      T = 1;
      T = Number(read());
      for (var t = 0; t < T; t++) {
         solve();
      }
   } catch (e) {
      write(e);
   }
}

function readArray(mapF) {
   var res = read().split(' ');
   if (mapF) {
      res = res.map(mapF);
   }
   return res;
}

var isNode = typeof console !== 'undefined';
var MEMORY = [];
var MEMORY_INDEX = 0;
if (isNode) {
   var fs = require('fs');

   var inTextName;
   var outTextName;
   if (process.argv.length === 5) {
      inTextName = process.argv[3];
      outTextName = process.argv[4];
   }
   MEMORY = fs.readFileSync(inTextName ? require('path').join(__dirname, inTextName) : 0, 'utf8').split('\r\n');
}
init();

function write(value) {
   isNode ? console.log('' + value) : print('' + value);
}
function read() {
   return isNode ? MEMORY[MEMORY_INDEX++] : readline();
}
function readAll() {
   if (isNode) {
      return MEMORY;
   }
   var res = [];
   var x;
   while (x = read()) {
      res.push(x);
   }
   return res;
}

// using ES6 modules import - you need to have the "module" property set to "commonjs" in the package.json
// const { readline, print, console } = require('@ip-algorithmics/codeforces-io');
var n = readline();
for(var k = 0; k < n; k++){
    var result = 0;
    var num = readline().split(" ").map(x => parseInt(x));
    for (var i = 0; i < num.length; i++) {
        result+=(num[i] * (i+1))
    }
    print(result % 2)
}
// var num = readline().split(" ").map(x => parseInt(x));
// var h,l;
// h=num[0],l=num[1];

// var r= (l*l-h*h)/(2*h);
// print(r);

// var num = readline().split(" ").map(x => parseInt(x));
// var h,l;
// h=num[0],l=num[1];

// var r= (l*l-h*h)/(2*h);
// print(r);

//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] = BigInt(next());
		}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 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 getCountMap(list){
	var map = {};
	for(var i = 0; i < list.length; i++){
		if(map[list[i]] == null){
			map[list[i]] = 0;
		}
		map[list[i]]++;
	}
	return map;
}
function init(input){
	return {
		list : input, index : 0, max : input.length,
		hasNext : function(){return (this.index < this.max);},
		next : function(){if(this.hasNext()){return this.list[this.index++];}else{throw 'ArrayIndexOutOfBoundsException ‚There is no more input';}},
		isReturn : function(){return retcode.has(this.index);}
	};
}
function myout(s){outputList.push(s);}
function myerr(s){console.error('debug:' + require('util').inspect(s,false,null));}
function isReturn(){return obj.isReturn();}
//param "no" is
//unknown or outlier : return i. 1: parseInt.
//2: split space. 4: split space and parseInt.
//6: split 1 character. 7: split 1 character and parseInt.
//8: join space. 9: join nextline. 0: join no character.
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(' ');case 4:return i.split(' ').map(Number);case 6:return i.split('');case 7:return i.split('').map(Number);case 8:return i.join(' ');case 9:return i.join('\n');case 0:return i.join('');default:return i;}}catch(e){return i;}}

//Don't have to see. end------------------------------------------
function Main(){
	var t = nextInt();
	while(hasNext()){
		var a = nextInt() % 2;
		var b = nextInt() % 2;
		var c = nextInt() % 2;
		if(a == 0){
			a += 2;
		}
		if(b == 0){
			b += 2;
		}
		if(b == 0){
			b += 2;
		}
		var check = [a,b,c];
		var N = check.length;
		var isOK = false;
		for(var i = 0; i < (1 << N); i++){
			var L = [];
			var R = [];
			for(var j = 0; j < N; j++){
				if((i & (1 << j)) != 0){
					L.push(j + 1);
				}else{
					R.push(j + 1);
				}
			}
			if(L.length > 0 && R.length > 0){
				var LV = 0;
				for(var j = 0; j < L.length; j++){
					LV += check[L[j] - 1] * L[j];
				}
				var RV = 0;
				for(var j = 0; j < R.length; j++){
					RV += check[R[j] - 1] * R[j];
				}
				if(LV == RV){
					isOK = true;
					break;
				}
			}
		}
		myout((isOK) ? 0 : 1);

	}
}

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

//Don't have to see. end------------------------------------------
function Main(){
	var t = nextInt();
	while(hasNext()){
		var a = nextInt() % 2;
		var b = nextInt() % 2;
		var c = nextInt() % 2;
		var check = [a,b,c];
		var N = check.length;
		var isOK = false;
		for(var i = 0; i < (1 << N); i++){
			var L = [];
			var R = [];
			for(var j = 0; j < N; j++){
				if((i & (1 << j)) != 0){
					L.push(j + 1);
				}else{
					R.push(j + 1);
				}
			}
			if(L.length > 0 && R.length > 0){
				var LV = 0;
				for(var j = 0; j < L.length; j++){
					LV += check[L[j] - 1] * L[j];
				}
				var RV = 0;
				for(var j = 0; j < R.length; j++){
					RV += check[R[j] - 1] * R[j];
				}
				if(LV == RV){
					isOK = true;
					break;
				}
			}
		}
		myout((isOK) ? 0 : 1);

	}
}

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

//Don't have to see. end------------------------------------------
function Main(){
	var t = nextInt();
	while(hasNext()){
		var a = nextInt();
		var b = nextInt();
		var c = nextInt();
		var check = [a,b,c];
		var N = check.length;
		var isOK = false;
		for(var i = 0; i < (1 << N); i++){
			var L = [];
			var R = [];
			for(var j = 0; j < N; j++){
				if((i & (1 << j)) != 0){
					L.push(j + 1);
				}else{
					R.push(j + 1);
				}
			}
			if(L.length > 0 && R.length > 0){
				var LV = 0;
				for(var j = 0; j < L.length; j++){
					LV += check[L[j] - 1] * L[j];
				}
				var RV = 0;
				for(var j = 0; j < R.length; j++){
					RV += check[R[j] - 1] * R[j];
				}
				if(LV == RV){
					isOK = true;
					break;
				}
			}
		}
		if(isOK){
			myout(0);
			continue;
		}

		var diff = (c % 2 == 1) ? 3 : 0;
		if(diff > 0 && b > 0){
			diff -= 2;
			b--;
		}
		if(diff > 0 && a > 0){
			diff--;
			a--;
		}
		if(b % 2 == 1){
			diff = 2;
			if(a > 0){
				var tmp = Math.min(a, 2);
				diff -= tmp;
				a -= tmp;
			}
		}
		if(a % 2 == 1){
			diff++;
		}
		myout(diff);
	}
}

//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] = BigInt(next());
		}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 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 getCountMap(list){
	var map = {};
	for(var i = 0; i < list.length; i++){
		if(map[list[i]] == null){
			map[list[i]] = 0;
		}
		map[list[i]]++;
	}
	return map;
}
function init(input){
	return {
		list : input, index : 0, max : input.length,
		hasNext : function(){return (this.index < this.max);},
		next : function(){if(this.hasNext()){return this.list[this.index++];}else{throw 'ArrayIndexOutOfBoundsException ‚There is no more input';}},
		isReturn : function(){return retcode.has(this.index);}
	};
}
function myout(s){outputList.push(s);}
function myerr(s){console.error('debug:' + require('util').inspect(s,false,null));}
function isReturn(){return obj.isReturn();}
//param "no" is
//unknown or outlier : return i. 1: parseInt.
//2: split space. 4: split space and parseInt.
//6: split 1 character. 7: split 1 character and parseInt.
//8: join space. 9: join nextline. 0: join no character.
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(' ');case 4:return i.split(' ').map(Number);case 6:return i.split('');case 7:return i.split('').map(Number);case 8:return i.join(' ');case 9:return i.join('\n');case 0:return i.join('');default:return i;}}catch(e){return i;}}

//Don't have to see. end------------------------------------------
function Main(){
	var t = nextInt();
	while(hasNext()){
		var a = nextInt();
		var b = nextInt();
		var c = nextInt();
		if(a + b * 2 == c * 3){
			myout(0);
			continue;
		}
		if(a + c * 3 == b * 2){
			myout(0);
			continue;
		}
		var diff = (c % 2 == 1) ? 3 : 0;
		if(diff > 0 && b > 0){
			diff -= 2;
			b--;
		}
		if(diff > 0 && a > 0){
			diff--;
			a--;
		}
		if(b % 2 == 1){
			diff = 2;
			if(a > 0){
				var tmp = Math.min(a, 2);
				diff -= tmp;
				a -= tmp;
			}
		}
		if(a % 2 == 1){
			diff++;
		}
		myout(diff);
	}
}

//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] = BigInt(next());
		}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 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 getCountMap(list){
	var map = {};
	for(var i = 0; i < list.length; i++){
		if(map[list[i]] == null){
			map[list[i]] = 0;
		}
		map[list[i]]++;
	}
	return map;
}
function init(input){
	return {
		list : input, index : 0, max : input.length,
		hasNext : function(){return (this.index < this.max);},
		next : function(){if(this.hasNext()){return this.list[this.index++];}else{throw 'ArrayIndexOutOfBoundsException ‚There is no more input';}},
		isReturn : function(){return retcode.has(this.index);}
	};
}
function myout(s){outputList.push(s);}
function myerr(s){console.error('debug:' + require('util').inspect(s,false,null));}
function isReturn(){return obj.isReturn();}
//param "no" is
//unknown or outlier : return i. 1: parseInt.
//2: split space. 4: split space and parseInt.
//6: split 1 character. 7: split 1 character and parseInt.
//8: join space. 9: join nextline. 0: join no character.
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(' ');case 4:return i.split(' ').map(Number);case 6:return i.split('');case 7:return i.split('').map(Number);case 8:return i.join(' ');case 9:return i.join('\n');case 0:return i.join('');default:return i;}}catch(e){return i;}}

//Don't have to see. end------------------------------------------
function Main(){
	var t = nextInt();
	while(hasNext()){
		var a = nextInt();
		var b = nextInt();
		var c = nextInt();
		var diff = (c % 2 == 1) ? 3 : 0;
		if(diff > 0 && b > 0){
			diff -= 2;
			b--;
		}
		if(diff > 0 && a > 0){
			diff--;
			a--;
		}
		if(b % 2 == 1){
			diff = 2;
			if(a > 0){
				var tmp = Math.min(a, 2);
				diff -= tmp;
				a -= tmp;
			}
		}
		if(a % 2 == 1){
			diff++;
		}
		myout(diff);
	}
}

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];
    for(var l = 1; l <= n; l++){
        var k = lines[l].split(' ').map(Number);
        var a = k[0];
        var b = k[1];
        var c = k[2];
        var total = a + b + c;
        if(total % 2 === 1){
            console.log(0);
        }else{
            console.log(1);
        }
    }
});

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];
    for(var l = 1; l <= n; l++){
        var k = lines[l].split(' ').map(Number);
        var a = k[0];
        var b = k[1];
        var c = k[2];
        var total = a + b + c;
        if(total % 2 === 0){
            console.log(0);
        }else{
            console.log(1);
        }
    }
});

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

function solve(a, b, c) {
    const oa = a & 1
    const ob = b & 1
    const oc = c & 1
    if (oa) {
        if (ob) {
            if (oc) {
                return 0
            } else {
                return 1
            }
        } else {
            if (oc) {
                return b ? 0 : 1
            } else {
                return 1
            }
        }
    } else {
        if (ob) {
            if (oc) {
                return 1
            } else {
                return 0
            }
        } else {
            if (oc) {
                return 3
            } else {
                return 0
            }
        }
    }
    // if (true) {}
    // const sum = a + 2 * b + 3 * c
    // const half = Math.floor(sum / 2)
    // const k = Math.floor(half / 3)
    // const r = half % 3
    // if (sum & 1) {
    //     if (k <= c) {
    //         switch (r) {
    //         case 2: return (b || a >= 2) ? 0 : (a ? 1 : 2)
    //         case 1: return (b || a >= 2) ? 0 : 1
    //         default:
    //         case 0: return 1
    //         }
    //     } else {
    //         const d = half - 3 * c
    //         if (d & 1) {
    //             return (b >= d / 2 && a) || (a >= d) ? 0 : 1
    //         } else {
    //             return (b >= d / 2 || a >= d) ? 0 : 1
    //         }
    //     }
    // } else {
    //     if (k <= c) {
    //         switch (r) {
    //         case 2: return (b || a >= 2) ? 0 : (a ? 1 : 2)
    //         case 1: return a ? 0 : 1
    //         default:
    //         case 0: return 0
    //         }
    //     } else {
    //         const d = half - 3 * c
    //         if (d & 1) {
    //             return (b >= d / 2 && a) || (a >= d) ? 0 : 1
    //         } else {
    //             return (b >= d / 2 || a >= d) ? 0 : 1
    //         }
    //     }
    // }
}


The sequence is called ordered if it is non-decreasing or non-increasing. For example, sequnces [3, 1, 1, 0] and [1, 2, 3, 100] are ordered, but the sequence [1, 3, 3, 1] is not. You are given a sequence of numbers. You are to find it's shortest subsequence which is not ordered.A subsequence is a sequence that can be derived from the given sequence by deleting zero or more elements without changing the order of the remaining elements.

The first line of the input contains one integer n (1 ≤ n ≤ 105). The second line contains n space-separated integers — the given sequence. All numbers in this sequence do not exceed 106 by absolute value.

If the given sequence does not contain any unordered subsequences, output 0. Otherwise, output the length k of the shortest such subsequence. Then output k integers from the range [1..n] — indexes of the elements of this subsequence. If there are several solutions, output any of them.

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

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

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

function main() {
	var n = parseInt(readline());
	var inArr = tokenizeIntegers(readline());
	var arr = [inArr[0]], indices = [1];
	for (var i = 1; i < inArr.length; ++i) {
		if (inArr[i] != arr[arr.length-1]) {
			arr.push(inArr[i]);
			indices.push(i+1);
		}
	}

	for (var i = 2; i < n; ++i) {
		if (arr[i-2] < arr[i-1] && arr[i-1] > arr[i] ||
			arr[i-2] > arr[i-1] && arr[i-1] < arr[i]) {
				print(3);
				print([indices[i-2], indices[i-1], indices[i]].join(" "));
				return;
			}
	}
	print(0);
}

main();

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

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

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

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

	for (var i = 2; i < n; ++i) {
		if (arr[i-2] < arr[i-1] && arr[i-1] > arr[i] ||
			arr[i-2] > arr[i-1] && arr[i-1] < arr[i]) {
				print(3);
				return;
			}
	}
	print(0);
}

main();

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

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

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

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

	for (var i = 2; i < n; ++i) {
		if (arr[i-2] < arr[i-1] && arr[i-1] > arr[i] ||
			arr[i-2] > arr[i-1] && arr[i-1] < arr[i]) {
				print(3);
				print([i-2, i-1, i].join(" "));
				return;
			}
	}
	print(0);
}

main();

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

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

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

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

	for (var i = 2; i < n; ++i) {
		if (arr[i-2] < arr[i-1] && arr[i-1] > arr[i] ||
			arr[i-2] > arr[i-1] && arr[i-1] < arr[i]) {
				print(3);
				print([i-1, i, i+1].join(" "));
				return;
			}
	}
	print(0);
}

main();

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

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

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

function main() {
	var n = parseInt(readline());
	var inArr = tokenizeIntegers(readline());
	var arr = [inArr[0]];
	for (var i = 1; i < inArr.length; ++i) {
		if (inArr[i] != arr[arr.length-1]) {
			arr.push(inArr[i]);
		}
	}

	for (var i = 2; i < n; ++i) {
		if (arr[i-2] < arr[i-1] && arr[i-1] > arr[i] ||
			arr[i-2] > arr[i-1] && arr[i-1] < arr[i]) {
				print(3);
				print([i-1, i, i+1].join(" "));
				return;
			}
	}
	print(0);
}

main();


Berland scientists face a very important task - given the parts of short DNA fragments, restore the dinosaur DNA! The genome of a berland dinosaur has noting in common with the genome that we've used to: it can have 26 distinct nucleotide types, a nucleotide of each type can occur at most once. If we assign distinct English letters to all nucleotides, then the genome of a Berland dinosaur will represent a non-empty string consisting of small English letters, such that each letter occurs in it at most once.Scientists have n genome fragments that are represented as substrings (non-empty sequences of consecutive nucleotides) of the sought genome.You face the following problem: help scientists restore the dinosaur genome. It is guaranteed that the input is not contradictory and at least one suitable line always exists. When the scientists found out that you are a strong programmer, they asked you in addition to choose the one with the minimum length. If there are multiple such strings, choose any string.

The first line of the input contains a positive integer n (1 ≤ n ≤ 100) — the number of genome fragments. Each of the next lines contains one descriptions of a fragment. Each fragment is a non-empty string consisting of distinct small letters of the English alphabet. It is not guaranteed that the given fragments are distinct. Fragments could arbitrarily overlap and one fragment could be a substring of another one. It is guaranteed that there is such string of distinct letters that contains all the given fragments as substrings.

In the single line of the output print the genome of the minimum length that contains all the given parts. All the nucleotides in the genome must be distinct. If there are multiple suitable strings, print the string of the minimum length. If there also are multiple suitable strings, you can print any of them.

var n = readline();

var alph = {};
var alphLength = 0;
var strs = [];

for (i = 0; i < n; i++) {
	var line = readline().toLowerCase();
	for (j = 0; j < line.length; j++) {
		var letter = line[j];
		if (!alph[letter])	{
			alph[letter] = {};
		}
		if (!alph[letter].prev && j != 0) {
			alph[letter].prev = line[j - 1];
		}
		if (!alph[letter].next && j != (line.length - 1)) {
			alph[letter].next = line[j + 1];
		}
	}
}

var begining = [];
for (key in alph) {
	if (!alph[key].prev) {
		begining.push(key);
	}
}

var str = '';

for (i = 0; i < begining.length; i++) {
	var letter = begining[i];
	while (true) {
		str += letter;
		if (alph[letter].next) {
			letter = alph[letter].next;
		} else {
			break;
		}
	}
}

print(str);


You have $$$n$$$ gifts and you want to give all of them to children. Of course, you don't want to offend anyone, so all gifts should be equal between each other. The $$$i$$$-th gift consists of $$$a_i$$$ candies and $$$b_i$$$ oranges.During one move, you can choose some gift $$$1 \le i \le n$$$ and do one of the following operations:  eat exactly one candy from this gift (decrease $$$a_i$$$ by one);  eat exactly one orange from this gift (decrease $$$b_i$$$ by one);  eat exactly one candy and exactly one orange from this gift (decrease both $$$a_i$$$ and $$$b_i$$$ by one). Of course, you can not eat a candy or orange if it's not present in the gift (so neither $$$a_i$$$ nor $$$b_i$$$ can become less than zero).As said above, all gifts should be equal. This means that after some sequence of moves the following two conditions should be satisfied: $$$a_1 = a_2 = \dots = a_n$$$ and $$$b_1 = b_2 = \dots = b_n$$$ (and $$$a_i$$$ equals $$$b_i$$$ is not necessary).Your task is to find the minimum number of moves required to equalize all the given gifts.You have to answer $$$t$$$ independent test cases.

The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. Then $$$t$$$ test cases follow. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 50$$$) — the number of gifts. The second line of the test case contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 10^9$$$), where $$$a_i$$$ is the number of candies in the $$$i$$$-th gift. The third line of the test case contains $$$n$$$ integers $$$b_1, b_2, \dots, b_n$$$ ($$$1 \le b_i \le 10^9$$$), where $$$b_i$$$ is the number of oranges in the $$$i$$$-th gift.

For each test case, print one integer: the minimum number of moves required to equalize all the given gifts.

NoteIn the first test case of the example, we can perform the following sequence of moves:  choose the first gift and eat one orange from it, so $$$a = [3, 5, 6]$$$ and $$$b = [2, 2, 3]$$$;  choose the second gift and eat one candy from it, so $$$a = [3, 4, 6]$$$ and $$$b = [2, 2, 3]$$$;  choose the second gift and eat one candy from it, so $$$a = [3, 3, 6]$$$ and $$$b = [2, 2, 3]$$$;  choose the third gift and eat one candy and one orange from it, so $$$a = [3, 3, 5]$$$ and $$$b = [2, 2, 2]$$$;  choose the third gift and eat one candy from it, so $$$a = [3, 3, 4]$$$ and $$$b = [2, 2, 2]$$$;  choose the third gift and eat one candy from it, so $$$a = [3, 3, 3]$$$ and $$$b = [2, 2, 2]$$$.

function solve() {
    var n = readInt()
    var aArr = readIntArray()
    var bArr = readIntArray()

    var aMin = Number.MAX_VALUE
    var bMin = Number.MAX_VALUE
    for(var i=0;i<n;i++) {
        if (aArr[i] < aMin) {
            aMin = aArr[i]
        }
        if (bArr[i] < bMin) {
            bMin = bArr[i]
        }
    }

    var answer = 0
    for(var j=0; j<n;j++) {
        var x = aArr[j] - aMin
        var y = bArr[j] - bMin
        answer += Math.max(x,y)
    }
    print(answer)
}

var testCases = readInt();
var testCaseNum;
for(testCaseNum=0; testCaseNum<testCases; testCaseNum++) {
  solve()
}

function readIntArray() {
    return readline().split(" ").map(function(x) { return parseInt(x); });
}

function readInt() {
    return parseInt(readline())
}

function sortIntArr(arr) {
  return arr.sort((a, b) => a - b)
}

const readline = require("readline");
const rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
});
//
// rl.question("", function (n) {
//   functions();
// })
//
// function functions() {
//   rl.question("", function (num) {
//     rl.question("", function (name) {
//       var bool = true;
//       var sN = name.split(" ");
//       var na = sN.sort();
//       for (var i = 0; i < na.length; i++) {
//         if (na[i + 1] - na[i] > 1) {
//           var bool = false;
//         }
//       }
//       if (bool) {
//         console.log('YES')
//       } else {
//         console.log('NO')
//       }
//       functions();
//     });
//   })
// }
rl.question('', function () {
  functions();
})
function functions() {
  rl.question('', function (n) {
    rl.question('', function (a) {
      rl.question('', function (b) {
        var s = 0;
        var sa = a.split(' ');
        var sb = b.split(' ');
        // console.log(n, newA, s, sa, sb)
        for (var i = 0; i < n; i++) {
          var newA = [];
          var ai = sa[i] - Math.min.apply(Math, sa)
          var bi = sb[i] - Math.min.apply(Math, sb)
          newA.push(ai);
          newA.push(bi);
          s += Math.max.apply(Math, newA);
          // console.log()
        }
        console.log(s)
        functions();
      })
    })
  })
}

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++];
}
function main() {
  let t = +readLine();
  while (t--) {
    let len = +readLine();
    const candy = readLine()
      .split(" ")
      .map((n) => parseInt(n));
    const orange = readLine()
      .split(" ")
      .map((n) => parseInt(n));
    let count = 0;
    const [min1, min2] = [Math.min(...candy), Math.min(...orange)];
    for (let i = 0; i < len; i++) {
      const [a, b] = [candy[i], orange[i]];
      const [move1, move2] = [a - min1, b - min2];
      count += Math.max(move1, move2);
    }

    console.log(count);
  }
}

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

let input = [];

rl.on('line', function (line) {
    input.push(line);
});

rl.on('close', function () {
    const total = Number(input[0]);
    for (let ii = 0; ii < 3 * total; ii += 3) {
        let arr1 = input[ii + 2].split(' ').map(x => Number(x));
        let arr2 = input[ii + 3].split(' ').map(x => Number(x));
        let ans = 0;
        let min1 = arr1[0];
        let min2 = arr2[0];
        for(let i =1; i<arr1.length; i++) {
            if (min1 > arr1[i]) {
                min1 = arr1[i];
            }
            if (min2 > arr2[i]) {
                min2 = arr2[i];
            }
        }

        for (let i = 0; i < arr1.length; i++) {
            ans += Math.max(arr1[i] - min1, arr2[i] - min2);
        }
        console.log(ans)
    }
});

const readline = require('readline');

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

let tests = [];
rl.on('line', (line) => {
  tests.push(line);
}).on('close', () => {
  for (ii = 1; ii < tests.length; ii += 3) {
    let countStap = 0;
    const candy = tests[ii + 1].split(' ').map(x => +x);
    const orange = tests[ii + 2].split(' ').map(x => +x);
    const minCandy = Math.min(...candy);
    const minOrange = Math.min(...orange);

    for (i = 0; i < candy.length; i++) {
      if (candy[i] > minCandy && orange[i] > minOrange) {
        const minStap = Math.min(candy[i] - minCandy, orange[i] - minOrange);

        countStap += minStap + (candy[i] - minCandy - minStap) + (orange[i] - minOrange - minStap);
      } else if (candy[i] > minCandy && orange[i] == minOrange) {
        countStap += candy[i] - minCandy
      } else if (orange[i] > minOrange && candy[i] == minCandy) {
        countStap += orange[i] - minOrange
      }
    }
    process.stdout.write(`${countStap}\n`);
  }
});

//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 t = nextInt();
  var output = new Array(t);
  for(var i = 0; i < t; i++){
    var n = nextInt();
    var alist = nextIntArray();
    var blist = nextIntArray();
    var amin = Math.min.apply(null, alist);
    var bmin = Math.min.apply(null, blist);
    var aminlist = new Array(n).fill(0);
    var bminlist = new Array(n).fill(0);
    var count = 0;
    for(var j = 0; j < n; j++){
      if(alist[j] > amin){
        aminlist[j] = alist[j] - amin;
      }
      if(blist[j] > bmin){
        bminlist[j] = blist[j] - bmin;
      }
    }
    for(var j = 0; j < n; j++){
      if(aminlist[j] > 0 && bminlist[j] > 0){
        var common = Math.min(aminlist[j], bminlist[j]);
        count += aminlist[j] + bminlist[j] - common;
      }else{
        count += aminlist[j] + bminlist[j];
      }
    }
    output[i] = count;
  }
  myout(myconv(output, 9));
}

let inputString = '';
let currentLine = 0;

const runMain = () => {
  inputString = inputString.trim().split('\n').map(string => string.trim());
  main();
  process.exit();
}
const readLine = () => inputString[currentLine++];

process.stdin.on('data', inputStdin => inputString += inputStdin);
process.stdin.on('end', runMain);
process.on('SIGINT', runMain);

function main() {
  let t = readLine();
  while (t--) {
    const n = readLine();
    const a = readLine().split(' ').map(num => Number(num));
    const b = readLine().split(' ').map(num => Number(num));
    const aMin = Math.min(...a);
    const bMin = Math.min(...b);
    let res = 0;
    for (let i = 0; i < n; i++) {
      res += Math.max(a[i] - aMin, b[i] - bMin);
    }
    console.log(res);
  }
}

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

let stdinInput = '';

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

process.stdin.on('end', () => {
  main(stdinInput);
});

function main(data) {
	data = data.split('\n');
	const testCases = data[0] * 3;
    let i = 1;
    outer:
	while (i <= testCases) {
	  let n = data[i] * 1;
	  let a = data[i + 1].trim().split(' ').map(Number);
	  let b = data[i + 2].trim().split(' ').map(Number);
	  let count = 0;
	  let minA = Math.min(...a);
	  let minB = Math.min(...b);
	  for (let j = 0; j < n; j += 1) {
	    let diffA = a[j] - minA;
      let diffB = b[j] - minB;
      if (a[j] > minA && b[j] > minB) {
        let min = Math.min(diffA, diffB);
        if (min === diffA) {
          count += diffA;
          count += (diffB - diffA);
        } else {
          count += diffB;
          count += (diffA - diffB);
        }
      } else if (a[j] > minA) count += diffA;
      else count += diffB;
	  }
	  console.log(count);
    i += 3;
	}
}

'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 print(s) {
  process.stdout.write(`${s}`);
}
// Make a Snippet for the code above this and then write your logic in main();

function main() {
  // input
  let t = +readline();
  for (let i = 0; i < t; i++) {
    const n = +readline();
    const a = readline().split(' ').map(x => parseInt(x));
    const b = readline().split(' ').map(x => parseInt(x));
    const minA = Math.min(...a);
    const minB = Math.min(...b);
    let m = 0;
    for (let i = 0; i < n; i++) {
      m += Math.max(Math.abs(a[i] - minA), Math.abs(b[i] - minB));
    }
    print(`${m}\n`);
  }
}

const processData = (lines) => {
    let acc = 0
    const n = +lines[acc++]
    for (let i=0; i<n; i++) {
        const count =  +lines[acc++]
        const a = lines[acc++].split(' ').map(x => +x)
        const b = lines[acc++].split(' ').map(x => +x)

        const leastA = Math.min(...a)
        const leastB = Math.min(...b)

        let sum = 0

        for (let i=0; i< count; i++) {
            const diffA = a[i] - leastA
            const diffB = b[i] - leastB
            sum += Math.max(diffA, diffB)
        }

        console.log(sum)
    }

}

let i = ''
process.stdin.on('data', c => i += c)
process.stdin.on('end', () => {
    const {EOL} = require('os')
    const lines = i.split(EOL) /*your input text, split by lines*/
    processData(lines)
})

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

    main()
})

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

const s2i = s => parseInt(s, 10)

const readLineOfBigInts = () => {
  const split = readLine().split(' ')
  const result = []
  for (let i = 0, l = split.length; i < l; i++) {
    result.push(BigInt(split[i]));
  }
  return result
}

const cmpi = (a, b) => a - b

function main() {
  let T = s2i(readLine())
  let out = ''

  while (T--) {
    const n = s2i(readLine())
    const a = readLine().split(' ').map(s2i)
    const b = readLine().split(' ').map(s2i)

    let minA = a[0]
    let minB = b[0]

    for (let i = 1; i < n; i++) {
      if (a[i] < minA) minA = a[i]
      if (b[i] < minB) minB = b[i]
    }

    let moves = 0

    for (let i = 0; i < n; i++) {
      moves += Math.max(a[i] - minA, b[i] - minB)
    }

    out += moves + '\n'
  }

  console.log(out)
}

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

function main() {
	let t = readLine() >> 0;
	while (t--) {
		let n = readLine() >> 0;
		let candy = readLine()
			.split(' ')
			.map(x => x >> 0);
		let orange = readLine()
			.split(' ')
			.map(x => x >> 0);

		let minC = Math.min(...candy);
		let minO = Math.min(...orange);

		let count = 0;

		for (let i = 0; i < n; i++) {
			let gc = candy[i];
			let go = orange[i];

			let x = Math.min(gc - minC, go - minO);

			if (gc > minC && go > minO) {
				count += x;
				gc -= x;
				go -= x;
			}

			if (gc > minC) {
				count += gc - minC;
			}

			if (go > minO) {
				count += go - minO;
			}
		}

		console.log(count);
	}
}

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());
    for(let k = 0; k < t; k++){
        let n = parseInt(readline());
        let a = readline().split(' ');
        let b = readline().split(' ');

        let minA = 999999999999999;
        let minB = 999999999999999;

        for(let i = 0; i < n; i++){
            minA = Math.min(minA, a[i]);
            minB = Math.min(minB, b[i]);
        }

        for(let i = 0; i < n; i++){
            a[i] = a[i]-minA;
            b[i] = b[i]-minB;
        }

        let res = 0;
        for(let i = 0; i < n; i++)
            if(a[i] !== 0 || b[i] !== 0)
                res += Math.max(a[i],b[i]);

        console.log(res);
    }
}

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

let input = [];

rl.on('line', function (line) {
    input.push(line);
});

rl.on('close', function () {
    const total = Number(input[0]);
    for (let ii = 0; ii < 2 * total; ii += 3) {
        let arr1 = input[ii + 2].split(' ').map(x => Number(x));
        let arr2 = input[ii + 3].split(' ').map(x => Number(x));
        let ans = 0;
        let min1 = arr1[0];
        let min2 = arr2[0];
        for(let i =1; i<arr1.length; i++) {
            if (min1 > arr1[i]) {
                min1 = arr1[i];
            }
            if (min2 > arr2[i]) {
                min2 = arr2[i];
            }
        }

        for (let i = 0; i < arr1.length; i++) {
            ans += Math.max(arr1[i] - min1, arr2[i] - min2);
        }
        console.log(ans)
    }
});

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());
    for(let k = 0; k < t; k++){
        let n = parseInt(readline());
        let a = readline().split(' ');
        let b = readline().split(' ');

        let minA = 99999999;
        let minB = 99999999;

        for(let i = 0; i < n; i++){
            minA = Math.min(minA, a[i]);
            minB = Math.min(minB, b[i]);
        }

        for(let i = 0; i < n; i++){
            a[i] = a[i]-minA;
            b[i] = b[i]-minB;
        }

        let res = 0;
        for(let i = 0; i < n; i++)
            if(a[i] !== 0 || b[i] !== 0)
                res += Math.max(a[i],b[i]);

        console.log(res);
    }
}