var tests = parseInt(readline());
for (var t=0; t < tests; t++) {
    var n = readline();
    var arr = readline().split(' ').map(x => parseInt(x));
    print(arr[0]);
}

var t = parseInt(readline());

while(t--){

var n = parseInt(readline());

var ar =[];
var i;

ar= readline().split(' ').map(x => parseInt(x));

print(ar[ar.length-1]);

}

var limit = parseInt(readline());
for (var i = 0; i < limit; i++)
{
    readline();
    var caseArray = readline().split(" ");
    print(caseArray[0]);
}

"use strict";
function toInt(x) {
    return parseInt(x);
}

let t = parseInt(readline());
while (t--) {
    let n = parseInt(readline());
    let a = readline().split(' ').map(toInt);
    outer: for (let ind = 0; ind < n; ind++) {
    	let xor = 0;
    	for (let i = 0; i < n; i++) {
    		if (i != ind) xor ^= a[i];
     	}
     	if (xor == a[ind]) {
     		print(xor);
     	    break outer;
     	}
    }
}

var t = +readline();

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

    var t1 = readline();
    var t2 = readline().split(' ').map((t) => +t);
    print(ShuffleArray(t2))

}

function ShuffleArray(arr){

  function checkArr(idx){
    // var shuff =

    var init = 0;
    for(var i = 0; i<arr.length;i++){
      if (idx != i) init ^= arr[i];
    }

    return init;

  }

  for(var j = 0; j<arr.length; j++){
    if (checkArr(j) === arr[j]){
      return arr[j]
    }
  }

  return -1

}

'use strict';

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

let inputString = '';
let currentLine = 0;

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

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

    main();
});

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

function output(x) {
    if (typeof x !== 'string') {
        x = x.toString();
    }
    //process.stdout.write(x);   // without auto '\n' (newline)
    console.log(x);  // with auto '\n' (newline)
}

function main() {
    let N = readline();

    for (let i = 0; i < N; i++) {
        let n = Number(readline());
        let arr = readline().split(' ').map(Number);
        let prefix = Array(n).fill(0);
        let suffix = Array(n).fill(0);

        for (let j = 1; j < n; j++) {
            prefix[j] = prefix[j - 1] ^ arr[j - 1];
            suffix[n - 1 - j] = suffix[n - j] ^ arr[n - j];
        }

        const result = arr.find((value, index) => prefix[index] ^ suffix[index] === value);
        output(result);
    }
}

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

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

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

function main() {
  let q = parseInt(readline());
  for (let i = 0; i < q; i++) {
    let n = parseInt(readline());
    let num = readline().split(" ").map(Number);
    print(num[0]);
  }
}

'use strict';

function solve(n, a) {
  return a[0];
}

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

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

const tests = parseInt(readline());
for (var t=0; t < tests; t++) {
    var n = readline();
    var arr = readline().split(" ").map(x => parseInt(x));
    print(arr[0]);
}

var tests = parseInt(readline());
for (var t=0; t < tests; t++) {
    var n = readline();
    var arr = readline().split(" ").map(x => parseInt(x));
    print(arr[0]);
}

var t = parseInt(readline());

while(t--){

var n = parseInt(readline());

var x ;
var i= 0;

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

   x= parseInt(readline());

}

print(x);

}

var t = parseInt(readline());

while(t--){

var n = parseInt(readline());

var x =n;var i= 0;

for( i=0;i<x;i++){

   x= parseInt(readline());

}

print(x);

}


var readline = require('readline');

var rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
});
var lines = [];
rl.on('line', function(input) {
    lines.push(input);
});
rl.on('close', function() {
    var t = parseInt(lines[0]);
    var l = 1;
    for (var i = 0; i < t; i++) {
        var n = +lines[l++]
        var ranges = lines.slice(l, l + n).map(str => str.split(' ').map(Number))
        l += n
        var edges = lines.slice(l, l + n - 1).map(str => str.split(' ').map(Number))
        l += n - 1
        console.log(solve(n, ranges, edges));
    }
});

function solve(n, ranges, edges) {
    const adj = {}
    edges.forEach(([a, b]) => {
        a--
        b--
        adj[a] = adj[a] || []
        adj[b] = adj[b] || []
        adj[a].push(b)
        adj[b].push(a)
    })

    const dp = [[], []]
    dfs(dp, adj, 0, -1, ranges)
    return Math.max(dp[0][0], dp[1][0])
}

function dfs(dp, adj, u, p, ranges) {
    // dp[0][u] = max sum if `u` select min `au`
    // dp[1][u] = max sum if `u` select max `au`
    dp[0][u] = dp[1][u] = 0
    adj[u].forEach(v => {
        if (v === p) return

        dfs(dp, adj, v, u, ranges)
        dp[0][u] += Math.max(
            dp[0][v] + Math.abs(ranges[u][0] - ranges[v][0]),
            dp[1][v] + Math.abs(ranges[u][0] - ranges[v][1])
        )
        dp[1][u] += Math.max(
            dp[0][v] + Math.abs(ranges[u][1] - ranges[v][0]),
            dp[1][v] + Math.abs(ranges[u][1] - ranges[v][1])
        )
    })
}

'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

var os = require('os');

const stdin = process.stdin;
const stdout = process.stdout;
const integerRegex = /-?\d+/g;
const decimalRegex = /-?\d+(?:\.\d+)?/g;
class InputAndOutput {
    constructor() {
        this.lineIndex = 0;
        this.lines = [];
    }
    dried() {
        return this.lineIndex >= this.lines.length;
    }
    readLine() {
        const line = this.lines[this.lineIndex];
        this.lineIndex += 1;
        return line;
    }
    readIntegersOfLine() {
        const line = this.readLine();
        const m = line.match(integerRegex);
        if (m == null)
            return [];
        return m.map(x => Number(x));
    }
    readNumsOfLine() {
        const line = this.readLine();
        const m = line.match(decimalRegex);
        if (m == null)
            return [];
        return m.map(x => Number(x));
    }
    print(content) {
        stdout.write(content);
    }
    async init() {
        const lines = await this.readLines();
        this.lines = lines;
    }
    readLines() {
        const buffers = [];
        return new Promise(resolve => {
            stdin.on('data', (buffer) => buffers.push(buffer));
            stdin.on('end', function () {
                const inputs = buffers.join('');
                const lines = inputs.split(os.EOL);
                resolve(lines);
            });
        });
    }
}
async function __main__(handle) {
    const io = new InputAndOutput();
    await io.init();
    handle(io);
}

const MAX_N = 1e5 + 10;
const dp = new Array(MAX_N);
for (let i = 0; i < dp.length; ++i)
    dp[i] = new Array(2);
function solve(N, vertexes, G) {
    for (let i = 0; i < N; ++i)
        dp[i][0] = dp[i][1] = -1;
    return Math.max(dfs(-1, 0, 0), dfs(-1, 0, 1));
    function dfs(p, u, dir) {
        if (dp[u][dir] !== -1)
            return dp[u][dir];
        let answer = 0;
        const value = vertexes[u][dir];
        for (const v of G[u]) {
            if (v === p)
                continue;
            answer += Math.max(dfs(u, v, 0) + Math.abs(value - vertexes[v][0]), dfs(u, v, 1) + Math.abs(value - vertexes[v][1]));
        }
        dp[u][dir] = answer;
        return answer;
    }
}
const vertexes = new Array(MAX_N);
const G = new Array(MAX_N);
__main__(function (io) {
    const T = Number(io.readLine());
    for (let kase = 1; kase <= T; ++kase) {
        const N = Number(io.readLine());
        for (let i = 0; i < N; ++i) {
            vertexes[i] = io.readIntegersOfLine();
            G[i] = [];
        }
        for (let i = 1; i < N; ++i) {
            const [u, v] = io.readIntegersOfLine();
            G[u - 1].push(v - 1);
            G[v - 1].push(u - 1);
        }
        const answer = solve(N, vertexes, G);
        io.print('' + answer + '\n');
    }
});

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

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

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

let n, g, l, h;
let dp;

function dfs (u=0, p=-1) {
	for (const v of g[u]) {
		if (v == p) continue;
		dfs(v, u);
		dp[u][0] += Math.max(dp[v][0] + Math.abs(l[u] - l[v]), dp[v][1] + Math.abs(l[u] - h[v]));
		dp[u][1] += Math.max(dp[v][0] + Math.abs(h[u] - l[v]), dp[v][1] + Math.abs(h[u] - h[v]));
	}
}

function main () {
	let T = rn();
	while (T--) {
		n = rn();
		l = [], h = [];
		g = Array.from(Array(n), _ => []);
		for (let i = 0; i < n; i++) [l[i], h[i]] = rna();
		for (let i = 0; i < n - 1; i++) {
			let [u, v] = rna(); u--, v--;
			g[u].push(v);
			g[v].push(u);
		}

		dp = Array.from(Array(n), _ => [0, 0]);
		dfs();

		console.log(Math.max(dp[0][0], dp[0][1]));
	}
}


function ProblemSolver() {
    this.HAS_TEST_CASES = false ;
    this.INPUT_FILE_NAME = "sample.in" ;
    this.OUTPUT_FILE_NAME = "sample.out" ;
    this.DO_OUTPUT_TO_FILE = false ;
    this.CLEAR_ARRAY_PER_CASE = false ;

    this.solveCase = function() {
        var res , i , j , fl , cn , a , b , c ;
        res = 0 ;
        this.arr = this.arr.sort( function( le , ri ) { return le - ri ; } ) ;
        if( this.arr[ 0 ] == 1 ) {
            res = -1 ;
        }
        else {
            res = 1 ;
        }
        print( res ) ;
    } ;

    this.init = function() {
        this.lim1 = 100010 ;
        this.lim2 = 110 ;
        this.cc = 1 ;
        this.ind = 1 ;
        this.n = 0 ;
        this.cn = 0 ;
        this.declareAndFillArrays() ;
    } ;

    this.getInput = function( irObj ) {
        var hasMoreInput , i ;
        hasMoreInput = true ;
        try {
        	this.n = irObj.nextInt() ;
            this.arr = [] ;
            for( i = 0 ; i < this.n ; i++ ) {
                this.arr.push( irObj.nextInt() ) ;
            }
        }
        catch( ex ) {
            hasMoreInput = false ;
        }
        return hasMoreInput ;
    } ;

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

    this.clearPerCase = function() {
        this.cn = 0 ;
        this.cc++ ;
        if( this.CLEAR_ARRAY_PER_CASE == true ) {
            this.clearArraysPerCase() ;
        }
    } ;

    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.adjList = 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.adjList.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 InputReader() {
    var self = this ;
    this.allLines = new Array() ;
    this.currrentLineNumber = 0 ;
    this.currrentCharacterIndex = 0 ;
    this.callBackFunction = null ;
    this.parentContext = null ;

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

    this.readAllLinesFromRhino = function() {
        var brObj , line ;
        importPackage( java.io ) ;
        importPackage( java.lang ) ;
        brObj = new BufferedReader( new InputStreamReader( System[ 'in' ] ) ) ;
        this.allLines = [] ;
        while( true ) {
            line = brObj.readLine() ;
            if( line == null ) {
                break;
            }
            this.allLines.push( line ) ;
        }
    } ;

    this.readSingleLinesFromNodeJsJudgeServer = function( chunk ) {
        self.chunkData += chunk ;
    } ;

    this.readEndFromNodeJsJudgeServer = function() {
        self.parseRawData( self.chunkData ) ;
        self.parentContext.runCases() ;
    } ;

    this.readAllLinesFromNodeJsJudgeServer = function( parentContext ) {
        this.parentContext = parentContext ;
        process.stdin.resume() ;
        process.stdin.setEncoding( 'utf8' ) ;
        this.chunkData = '' ;
        process.stdin.on( 'data' , this.readSingleLinesFromNodeJsJudgeServer ) ;
        process.stdin.on( 'end' , this.readEndFromNodeJsJudgeServer ) ;
    } ;

    this.parseRawData = function( data ) {
        var len , i , currentString ;
        len = data.length ;
        currentString = '' ;
        this.allLines = [] ;
        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 ;
        if( currentDirectory.indexOf( 'D:' ) != -1 ) {
            //on windows
            inputFilePath = currentDirectory + '\\' + inputFileName ;
        }
        else {
            //on linux
            inputFilePath = currentDirectory + '/' + inputFileName ;
        }
        rawData = fsObj.readFileSync( inputFilePath , "utf8" ) ;
        this.parseRawData( rawData ) ;
    } ;

    this.next = function( flag ) {
        var len , i , startIdx , res , endIdx ;
        if( flag == 0 ) {
            if( this.currrentCharacterIndex != 0 ) {
                this.currrentLineNumber++ ;
                this.currrentCharacterIndex = 0 ;
            }
            res = '' ;
            len = this.allLines[ this.currrentLineNumber ].length ;
            if( typeof( len ) == 'function' ) {
                len = this.allLines[ this.currrentLineNumber ].length() ;
            }
            for( i = this.currrentCharacterIndex ; i < len ; i++ ) {
                res += '' + this.allLines[ this.currrentLineNumber ].charAt( 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 ;
            len = this.allLines[ this.currrentLineNumber ].length ;
            if( typeof( len ) == 'function' ) {
                len = this.allLines[ this.currrentLineNumber ].length() ;
            }
            for( i = this.currrentCharacterIndex ; i < len ; i++ ) {
                if( this.allLines[ this.currrentLineNumber ].charCodeAt( i ) != ' '.charCodeAt( 0 ) ) {
                    startIdx = i ;
                    break ;
                }
            }
            if( startIdx == -1 ) {
                this.currrentLineNumber++ ;
                this.currrentCharacterIndex = 0 ;
                continue ;
            }
            res = '' ;
            endIdx = len - 1 ;
            for( i = startIdx ; i < len ; i++ ) {
                if( this.allLines[ this.currrentLineNumber ].charCodeAt( i ) == ' '.charCodeAt( 0 ) ) {
                    endIdx = i ;
                    break ;
                }
                if( this.allLines[ this.currrentLineNumber ].charCodeAt( i ) >= 48 && this.allLines[ this.currrentLineNumber ].charCodeAt( i ) <= 57 ) {
                    res += '' + ( this.allLines[ this.currrentLineNumber ].charCodeAt( i ) - 48 ) ;
                }
                else {
                    res += '' + this.allLines[ this.currrentLineNumber ].charAt( i ) ;
                }
            }
            this.currrentCharacterIndex = endIdx ;
            if( endIdx == len - 1 ) {
                this.currrentLineNumber++ ;
                this.currrentCharacterIndex = 0 ;
            }
            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() {
        return 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 ;
        if( currentDirectory.indexOf( 'D:' ) != -1 ) {
            //on windows
            outputFilePath = currentDirectory + '\\' + outputFileName ;
        }
        else {
            //on linux
            outputFilePath = currentDirectory + '/' + outputFileName ;
        }
        fsObj.writeFileSync( outputFilePath , res ) ;
        this.clearPercase() ;
    } ;
}

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

    this.runCases = function() {
		var testCases , hasMoreTestCases , i ;
        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 ) {
            this.fohObj.flushOutOutputToFile( this.psObj.OUTPUT_FILE_NAME ) ;
        }
    } ;

    this.detectEnvironmentType = function() {
        var environmentType = null ;
        try {
            if( importPackage != null ) {
                environmentType = 'rhino' ;
            }
        }
        catch( ex1 ) {
            try {
                //for nodejs local server check
                if( __dirname != null && ( __dirname.indexOf( 'D:') != -1 || __dirname.indexOf( '/media/') != -1 ) ) {
                    environmentType = 'local-node-js' ;
                }
                else {
                    environmentType = 'server-node-js' ;
                }
            }
            catch( ex2 ) {
                try {
                    if( readline == null || typeof( readline ) != 'function' ) {
                        environmentType = 'server-node-js' ;
                    }
                    else {
                        try {
                            if( Map != null ) {
                                environmentType = 'spider-monkey' ;
                            }
                            else {
                                environmentType = 'javascript-v8' ;
                            }
                        }
                        catch( ex3 ) {
                            environmentType = 'javascript-v8' ;
                        }
                    }
                }
                catch( ex3 ) {
                    environmentType = 'server-node-js' ;
                }
            }
        }
        return environmentType ;
    } ;

    this.configureStreamsAndReadInput = function() {
        var localContext , isNodeJsJudgeServer , environmentType ;
        isNodeJsJudgeServer = false ;
        environmentType = this.detectEnvironmentType() ;
        if( environmentType == 'local-node-js' ) {
            try {
                if( print == null || typeof( print ) != 'function' ) {
                    print = console.log ;
                }
            }
            catch( ex ) {
                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 ) ;
            this.runCases() ;
        }
        else if( environmentType == 'server-node-js' ) {
            try {
                if( print == null || typeof( print ) != 'function' ) {
                    print = console.log ;
                }
            }
            catch( ex ) {
                print = console.log ;
            }
            this.irObj.readAllLinesFromNodeJsJudgeServer( this ) ;
        }
        else if( environmentType == 'javascript-v8' ) {
            this.irObj.readAllLines() ;
            this.runCases() ;
        }
        else if( environmentType == 'rhino' ) {
            this.irObj.readAllLinesFromRhino() ;
            this.runCases() ;
        }
        else if( environmentType == 'spider-monkey' ) {
            this.irObj.readAllLines() ;
            this.runCases() ;
        }
    } ;

    this.configureStreamsAndReadInput() ;
}

new CodeExecutioner() ;

var n = readline();
var numbers = readline().split(' ');
if(numbers.indexOf('1') == -1) {
    print(1);
} else {
    print(-1);
}

n = readline();
str = readline().split(' ').map(Number);

for (var i = 0; i < str.length - 1; i++) {
	for (var j = i + 1; j < str.length; j++) {
		if (str[i] > str[j]) {
			var temp = str[i];
			str[i] = str[j];
			str[j] = temp;
		};
	};
};

if (str[0] !== 1) {
	print(1);
} else {
	print(-1);
};

function sorting(a,n){
	var buf;
	for(i=0; i<= +(n-2); i++){
		for(x=i+1; x<=+(n-1); x++){
			if(+a[i]>+a[x]){
				buf = a[i];
				a[i] = a[x];
				a[x] = buf;
			}
		}
	}
}

function unluckySum(a,n){
	if(+a[0] == 1){
		write("-1");
	}
	else{
		write("1");
	}
}

var n = readline(), a = readline().split(" ");
sorting(a,n);
unluckySum(a,n);

n=readline().split(" ");
ar=readline().split(" ");
a=1
for(i=0;i<n;i++){
    if(ar[i]==1)
        a=0;
}
if(a==0) print(-1);
else print(1);

n = readline();
str = readline().split(' ').map(Number);

if (str[0] !== 1) {
	print(1);
} else {
	print(-1);
};


var n = parseInt(readline());
var line = readline().split(' ');
var a = new Int32Array(n);
var inc = new Int32Array(n);
var dec = new Int32Array(n);
var i;
for (i = 0; i < n; i++) {
  a[i] = parseInt(line[i]);
}

inc[0] = 1;
for (i = 1; i < n; i++) {
  if (a[i] > a[i-1]) {
    inc[i] = inc[i-1]+1;
  } else {
    inc[i] = 1;
  }
}

dec[n-1] = 1;
for (i = n-2; i >= 0; i--) {
  if (a[i] < a[i+1]) {
    dec[i] = dec[i+1]+1;
  } else {
    dec[i] = 1;
  }
}

var max = n;
if (n > 2) {
  max = Math.max(dec[1]+1, inc[n-2]+1);
}

for (i = 1; i < n-1; i++) {
  if (a[i] <= a[i-1] || a[i] >= a[i+1]) { // si hay un hoyo
    if (a[i-1]+1 < a[i+1]) { // si se arregla la serie con un cambio
      max = Math.max(max, inc[i-1] + dec[i+1] + 1);
    } else { // si el cambio solamente agrega un elemento a las series originales
      max = Math.max(max, inc[i-1]+1, dec[i+1]+1);
    }
  }
}

print(max);

var n = readline()*1;
var arr = readline().split(" ");
//=====================================================
var seqIni = [];
var seqLen = [];

var ini = -1;
var len = 1;

for (var i = 0; i < arr.length-1; i++) {
  if(arr[i]*1 < arr[i+1]*1){
    if(ini == -1){
      ini = i;
    }
    len++;
  }else{
    if(ini != -1){
      seqIni.push(ini);
      seqLen.push(len);
      ini = -1;
      len = 1;
    }
  }
}
if(ini != -1){
  seqIni.push(ini);
  seqLen.push(len);
}
/*
console.log(arr);
console.log(seqIni);
console.log(seqLen);
*/
//===================================================
if(arr.length == 1){
  var mayor = 1;
}else{
  var mayor = 2;

  for (var i = 0; i < arr.length-2; i++) {
    if(arr[i]*1+2 <= arr[i+2]*1 && ((arr[i]*1 >= arr[i+1]*1) || (arr[i+1]*1 >= arr[i+2]*1))){
      var l= buscar(i,i+1)+1+buscar(i+2,i+1);
      if(l > mayor){
        mayor = l;
      }
    }
  }
  var r= buscar(0,0)+1;
  if(r > mayor){
    mayor = r;
  }
  r= buscar(arr.length-1,arr.length-1)+1;
  if(r > mayor){
    mayor = r;
  }

  for (var i = 0; i < seqIni.length; i++) {
    if(seqLen[i]+1 <= arr.length){
      if(seqLen[i]+1 > mayor){
        mayor = seqLen[i]+1;
      }
    }else{
      if(seqLen[i] > mayor){
        mayor = seqLen[i];
      }
    }
  }

}

function buscar(i,elMalo){
  for(var j=0; j< seqIni.length; j++){
    if(i >= seqIni[j] && i <= seqIni[j]+seqLen[j]-1){
      //console.log(i,elMalo);
      if(elMalo >= seqIni[j] && elMalo <= seqIni[j]+seqLen[j]-1){
        return seqLen[j]-1;
      }
      return seqLen[j];
    }
  }
  return 1;
}

print(mayor);

;(function () {

	print(function (n) {

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

		var p = 0, l = [];
		for (var i = 1; i < n; i++) {
			if (s[i] <= s[i-1]) {
				l.push(i - p);
				p = i;
			}
		}
		l.push(n - p);

		var k = [];
		l.forEach(function (e) {
			k.push(s.splice(0, e));
		});

		k.push([]); k.unshift([]);

		var max = 0;
		for (var i = 0; i < l.length + 1; i++) {
			var a = k[i], b = k[i + 1];

			if (a.length === 0 || b.length === 0) {
				max = Math.max(max, a.length + b.length);
			} else
			if (a.length === 1 || b.length === 1) {
				max = Math.max(max, a.length + b.length);
			} else
			if (b[0] - a.slice(-2)[0] > 1 || b[1] - a.slice(-1)[0] > 1) {
				max = Math.max(max, a.length + b.length);
			} else
			if (true) {
				max = Math.max(max, a.length + 1, b.length + 1);
			}
		}

		return max;

	}(+readline()));

}.call(this));

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

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

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

function main() {
	var n = parseInt(readline()),
		data = tokenizeIntegers(readline()),
		increasing = {},
		start = 0, starts = [];
	while (start < n) {
		var seek = start+1;
		while (seek < n && data[seek] > data[seek-1]) {
			++seek;
		}
		increasing[start] = seek-start;
		starts.push(start);
		start = seek;
	}
	var max = increasing[starts[0]];
	if (starts.length != 1) {
		max = Math.max(max, increasing[starts[starts.length-1]]+1);
	}
	for (var i = 1; i < starts.length; ++i) {
		var hinge = starts[i],
			prefix = increasing[starts[i-1]],
			suffix = increasing[starts[i]];
		if (suffix != 1 && (data[hinge-1]+1 < data[hinge+1] ||
					data[hinge-2]+1 < data[hinge])) {
			max = Math.max(max, prefix+suffix);
		} else {
			max = Math.max(max, prefix+1);
		}
	}
	print(max);
}

main();

function main() {
    var n = Number(readline());
    var data = readline().split(' ').map(Number);

    var l = [1];
    for(var i=1;i<n;i++){
        if(data[i] > data[i-1]){
            l[i] = l[i-1] + 1;
        } else {
            l[i] = 1;
        }
    }
    var r = [];
    r[n-1] = 1;
    for(var i=n-2;i>=0;i--){
        if(data[i] < data[i+1]){
            r[i] = r[i+1] + 1;
        } else {
            r[i] = 1;
        }
    }
    var max = Math.max(...r);
    if(max == data.length){
        return print(max);
    } else {
        max++;
    }
    for(var i=1;i<n-1;i++){
        if(data[i-1] + 1 < data[i+1]){
           max = Math.max(max, l[i-1] + 1 + r[i+1])
        }
    }
    print(max)
}

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], 10);
	};
	return tokens;
}

function main() {
	var n = parseInt(readline()),
		data = tokenizeIntegers(readline()),
		increasing = {},
		start = 0, starts = [];
	while (start < n) {
		var seek = start+1;
		while (seek < n && data[seek] > data[seek-1]) {
			++seek;
		}
		increasing[start] = seek-start;
		starts.push(start);
		start = seek;
	}
	var max = increasing[starts[0]];
	for (var i = 1; i < starts.length; ++i) {
		var hinge = starts[i],
			prefix = increasing[starts[i-1]],
			suffix = increasing[starts[i]];
		if (suffix != 1 && data[hinge-1]+1 < data[hinge+1]) {
			max = Math.max(max, prefix+suffix);
		} else {
			max = Math.max(max, prefix+1);
		}
	}
	print(max);
}

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], 10);
	};
	return tokens;
}

function main() {
	var n = parseInt(readline()),
		data = tokenizeIntegers(readline()),
		increasing = {},
		start = 0, starts = [];
	while (start < n) {
		var seek = start+1;
		while (seek < n && data[seek] > data[seek-1]) {
			++seek;
		}
		increasing[start] = seek-start;
		starts.push(start);
		start = seek;
	}
	var max = increasing[starts[0]];
	for (var i = 1; i < starts.length; ++i) {
		var hinge = starts[i],
			prefix = increasing[starts[i-1]],
			suffix = increasing[starts[i]];
		if (suffix != 1 && data[hinge]+1 < data[hinge+1]) {
			max = Math.max(max, prefix+suffix);
		} else {
			max = Math.max(max, prefix+1);
		}
	}
	print(max);
}

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], 10);
	};
	return tokens;
}

function main() {
	var n = parseInt(readline()),
		data = tokenizeIntegers(readline()),
		increasing = {},
		start = 0, starts = [];
	while (start < n) {
		var seek = start+1;
		while (seek < n && data[seek] > data[seek-1]) {
			++seek;
		}
		increasing[start] = seek-start;
		starts.push(start);
		start = seek;
	}
	var max = increasing[starts[0]];
	if (starts.length > 1) {
		max = Math.max(max, 1+increasing[starts[starts.length-1]]);
	}
	for (var i = 1; i < starts.length; ++i) {
		var hinge = starts[i],
			prefix = increasing[starts[i-1]],
			suffix = increasing[starts[i]];
		if (suffix != 1 && data[hinge-1]+1 < data[hinge+1]) {
			max = Math.max(max, prefix+suffix);
		} else {
			max = Math.max(max, prefix+1);
		}
	}
	print(max);
}

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], 10);
	};
	return tokens;
}

function main() {
	var n = parseInt(readline()),
		data = tokenizeIntegers(readline()),
		increasing = {},
		start = 0, starts = [];
	while (start < n) {
		var seek = start+1;
		while (seek < n && data[seek] > data[seek-1]) {
			++seek;
		}
		increasing[start] = seek-start;
		starts.push(start);
		start = seek;
	}
	var max = increasing[starts[0]];
	for (var i = 1; i < starts.length; ++i) {
		var hinge = starts[i],
			prefix = increasing[starts[i-1]],
			suffix = increasing[starts[i]];
		if (suffix != 1 && (data[hinge-1]+1 < data[hinge+1] ||
					data[hinge-2]+1 < data[hinge])) {
			max = Math.max(max, prefix+suffix);
		} else {
			max = Math.max(max, prefix+1);
		}
	}
	print(max);
}

main();

var n = readline()*1;
var arr = readline().split(" ");
//=====================================================
var seqIni = [];
var seqLen = [];

var ini = -1;
var len = 1;

for (var i = 0; i < arr.length-1; i++) {
  if(arr[i]*1 < arr[i+1]*1){
    if(ini == -1){
      ini = i;
    }
    len++;
  }else{
    if(ini != -1){
      seqIni.push(ini);
      seqLen.push(len);
      ini = -1;
      len = 1;
    }
  }
}
if(ini != -1){
  seqIni.push(ini);
  seqLen.push(len);
}
/*
console.log(arr);
console.log(seqIni);
console.log(seqLen);
*/
//===================================================
if(arr.length == 1){
  var mayor = 1;
}else{
  var mayor = 2;

  for (var i = 0; i < arr.length-2; i++) {
    if(arr[i]*1+2 <= arr[i+2]*1 && (arr[i]*1 >= arr[i+1]*1) || (arr[i+1]*1 >= arr[i+2]*1)){
      var l= buscar(i,i+1)+1+buscar(i+2,i+1);
      if(l > mayor){
        mayor = l;
      }
    }
  }

  var r= buscar(0,0)+1;
  if(r > mayor){
    mayor = r;
  }
  r= buscar(arr.length-1,arr.length-1)+1;
  if(r > mayor){
    mayor = r;
  }

  for (var i = 0; i < seqIni.length; i++) {
    if(seqLen[i]+1 <= arr.length){
      if(seqLen[i]+1 > mayor){
        mayor = seqLen[i]+1;
      }
    }else{
      if(seqLen[i] > mayor){
        mayor = seqLen[i];
      }
    }
  }

}

function buscar(i,elMalo){
  for(var j=0; j< seqIni.length; j++){
    if(i >= seqIni[j] && i <= seqIni[j]+seqLen[j]-1){
      if(elMalo >= seqIni[j] && elMalo <= seqIni[j]+seqLen[j]-1){
        return seqLen[j]-1;
      }
      return seqLen[j];
    }
  }
  return 1;
}

print(mayor);

var n = readline()*1;
var arr = readline().split(" ");
//=====================================================
var seqIni = [];
var seqLen = [];

var ini = -1;
var len = 1;

for (var i = 0; i < arr.length-1; i++) {
  if(arr[i]*1 < arr[i+1]*1){
    if(ini == -1){
      ini = i;
    }
    len++;
  }else{
    if(ini != -1){
      seqIni.push(ini);
      seqLen.push(len);
      ini = -1;
      len = 1;
    }
  }
}
if(ini != -1){
  seqIni.push(ini);
  seqLen.push(len);
}
/*
console.log(arr);
console.log(seqIni);
console.log(seqLen);
*/
//===================================================
if(arr.length == 1){
  var mayor = 1;
}else{
  var mayor = 2;

  for (var i = 0; i < arr.length-2; i++) {
    if(arr[i]*1+2 <= arr[i+2]*1 && arr[i]*1 >= arr[i+1]*1){
      var l= buscar(i,i+1)+1+buscar(i+2,i+1);
      if(l > mayor){
        mayor = l;
      }
    }
  }

  var r= buscar(0,0)+1;
  if(r > mayor){
    mayor = r;
  }
  r= buscar(arr.length-1,arr.length-1)+1;
  if(r > mayor){
    mayor = r;
  }

  for (var i = 0; i < seqIni.length; i++) {
    if(seqLen[i]+1 <= arr.length){
      if(seqLen[i]+1 > mayor){
        mayor = seqLen[i]+1;
      }
    }else{
      if(seqLen[i] > mayor){
        mayor = seqLen[i];
      }
    }
  }

}

function buscar(i,elMalo){
  for(var j=0; j< seqIni.length; j++){
    if(i >= seqIni[j] && i <= seqIni[j]+seqLen[j]-1){
      if(elMalo >= seqIni[j] && elMalo <= seqIni[j]+seqLen[j]-1){
        return seqLen[j]-1;
      }
      return seqLen[j];
    }
  }
  return 1;
}

print(mayor);

var n = readline()*1;
var arr = readline().split(" ");

var mayor = 0;

for (var i = 0; i < arr.length-2; i++) {
  if(arr[i]*1+2== arr[i+2]*1){
    var l=3;
    var j= i;
    while(j-1>=0){
      if(arr[j-1]*1 == arr[j]-1){
        l++;
        j--;
      }else{
        break;
      }
    }
    var j= i+2;
    while(j+1<arr.length){
      if(arr[j+1]*1 == arr[j]*1+1){
        l++;
        j++;
      }else{
        break;
      }
    }
    if(l > mayor){
      mayor = l;
    }
  }
}

print(mayor);

;(function () {

	print(function (n) {

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

		var p = 0, l = [];
		for (var i = 1; i < n; i++) {
			if (s[i] <= s[i-1]) {
				l.push(i - p);
				p = i;
			}
		}
		l.push(n - p);

		var k = [];
		l.forEach(function (e) {
			k.push(s.splice(0, e));
		});

		k.push([]); k.unshift([]);

		var max = 0;
		for (var i = 0; i < l.length - 1; i++) {
			var a = k[i], b = k[i + 1];

			if (a.length === 1 || b.length === 1) {
				max = Math.max(max, a.length + b.length);
			} else
			if (b[0] - a.slice(-2)[0] > 1 || b[1] - a.slice(-1)[0] > 1) {
				max = Math.max(max, a.length + b.length);
			} else
			if (true) {
				max = Math.max(max, a.length + 1, b.length + 1);
			}
		}

		return max;

	}(+readline()));

}.call(this));

;(function () {

	print(function (n) {

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

		var p = 0, l = [];
		for (var i = 1; i < n; i++) {
			if (s[i] <= s[i-1]) {
				l.push(i - p);
				p = i;
			}
		}
		l.push(n - p);

		var k = [];
		l.forEach(function (e) {
			k.push(s.splice(0, e));
		});

		k.push([]); k.unshift([]);

		var max = 0;
		for (var i = 0; i < l.length + 1; i++) {
			var a = k[i], b = k[i + 1];

			if (a.length === 1 || b.length === 1) {
				max = Math.max(max, a.length + b.length);
			} else
			if (b[0] - a.slice(-2)[0] > 1 || b[1] - a.slice(-1)[0] > 1) {
				max = Math.max(max, a.length + b.length);
			} else
			if (true) {
				max = Math.max(max, a.length + 1, b.length + 1);
			}
		}

		return max;

	}(+readline()));

}.call(this));

;(function () {

	print(function (n) {

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

		var p = 0, l = [];
		for (var i = 1; i < n; i++) {
			if (s[i] <= s[i-1]) {
				l.push(i - p);
				p = i;
			}
		}
		l.push(n - p);

		var k = [];
		l.forEach(function (e) {
			k.push(s.splice(0, e));
		});

		var max = 0;
		for (var i = 0; i < l.length - 1; i++) {
			var a = k[i], b = k[i + 1];

			if (a.length === 1 || b.length === 1) {
				max = Math.max(max, a.length + b.length);
			} else
			if (b[0] - a.slice(-2)[0] > 1 || b[1] - a.slice(-1)[0] > 1) {
				max = Math.max(max, a.length + b.length);
			} else
			if (true) {
				max = Math.max(max, a.length + 1, b.length + 1);
			}
		}

		return max;

	}(+readline()));

}.call(this));

;(function () {

	print(function (n) {

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

		var p = 0, l = [];
		for (var i = 1; i < n; i++) {
			if (s[i] <= s[i-1]) {
				l.push(i - p);
				p = i;
			}
		}
		l.push(n - p);

		var k = [];
		l.forEach(function (e) {
			k.push(s.splice(0, e));
		});

		var max = 0;
		for (var i = 0; i < l.length - 1; i++) {
			var a = k[i], b = k[i + 1];

			if (a.length === 1 || b.length === 1) {
				max = Math.max(max, a.length + b.length);
			} else
			if (b[0] - a.slice(-2)[0] > 1 || b[1] - a.slice(-1)[0] > 1) {
				max = Math.max(max, a.length + b.length);
			} else
			if (true) {
				max = Math.max(max, a.length + 1, b.length + 1);
			}
		}

		return max || 1;

	}(+readline()));

}.call(this));

;(function () {

	print(function (n) {

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

		var p = 0, l = [];
		for (var i = 1; i < n; i++) {
			if (s[i] <= s[i-1]) {
				l.push(i - p);
				p = i;
			}
		}
		l.push(n - p);

		var k = [];
		for (var i = 1, _i = l.length; i < _i; i++) {
			k.push(l[i - 1] + l[i]);
		}

		return Math.max.apply(null, k);

	}(+readline()));

}.call(this));

var n = parseInt(readline());
var line = readline().split(' ');
var a = new Int32Array(n);
var inc = new Int32Array(n);
var dec = new Int32Array(n);
var i;
for (i = 0; i < n; i++) {
  a[i] = parseInt(line[i]);
}

inc[0] = 1;
for (i = 1; i < n; i++) {
  if (a[i] > a[i-1]) {
    inc[i] = inc[i-1]+1;
  } else {
    inc[i] = 1;
  }
}

dec[n-1] = 1;
for (i = n-1; i >= 0; i--) {
  if (a[i] < a[i+1]) {
    dec[i] = dec[i+1]+1;
  } else {
    dec[i] = 1;
  }
}

var max = 1;
if (n > 1) {
  max = dec[1]+1;
}

for (i = 1; i < n; i++) {
  if (a[i] <= a[i-1]) { // si hay un hoyo
    if (i < n-1) { // si hay siguiente
      if (a[i-1]+1 < a[i+1]) { // si se arregla la serie con un cambio
        max = Math.max(max, inc[i-1] + dec[i+1] + 1);
      } else { // si el cambio solamente agrega un elemento a las series originales
        max = Math.max(max, inc[i-1]+1, dec[i+1]+1);
      }
    } else {
      max = Math.max(max, inc[i-1]+1);
    }
  }
}

print(max);

var n = parseInt(readline());
var line = readline().split(' ');
var a = new Int32Array(n);
var inc = new Int32Array(n);
var dec = new Int32Array(n);
var i;
for (i = 0; i < n; i++) {
  a[i] = parseInt(line[i]);
}

inc[0] = 1;
for (i = 1; i < n; i++) {
  if (a[i] > a[i-1]) {
    inc[i] = inc[i-1]+1;
  } else {
    inc[i] = 1;
  }
}

dec[n-1] = 1;
for (i = n-2; i >= 0; i--) {
  if (a[i] < a[i+1]) {
    dec[i] = dec[i+1]+1;
  } else {
    dec[i] = 1;
  }
}

var max = 1;
if (n > 1) {
  max = dec[1]+1;
}

for (i = 1; i < n; i++) {
  if (a[i] <= a[i-1]) { // si hay un hoyo
    if (i < n-1) { // si hay siguiente
      if (a[i-1]+1 < a[i+1]) { // si se arregla la serie con un cambio
        max = Math.max(max, inc[i-1] + dec[i+1] + 1);
      } else { // si el cambio solamente agrega un elemento a las series originales
        max = Math.max(max, inc[i-1]+1, dec[i+1]+1);
      }
    } else {
      max = Math.max(max, inc[i-1]+1);
    }
  }
}

print(max);


var readline = require('readline');

var rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
});
var lines = [];
rl.on('line', function(input) {
    lines.push(input);
});
rl.on('close', function() {
    var t = parseInt(lines[0]);
    var l = 1;
    for (var i = 0; i < t; i++) {
        var n = +lines[l++]
        var a = lines[l++].trim().split(' ').map(Number)
        var b = lines[l++].trim().split(' ').map(Number)
        console.log(solve(n, a, b))
    }
});

function solve(n, a, b) {
    const sa = []
    a.forEach((x, i) => sa[i] = i ? x + sa[i - 1] : x)
    const sb = []
    b.forEach((x, i) => sb[i] = i ? x + sb[i - 1] : x)

    let min = Infinity
    for (let i = 0; i < n; i++) {
        // row 0, 0-i is a
        // row 1, i-n is a
        const score = Math.max(sa[n - 1] - sa[i], i ? sb[i - 1] : 0)
        min = Math.min(min, score)
    }
    return min
}

var limit = parseInt(readline());
    for (var i = 0; i < limit; i++) {
        var caseLength = parseInt(readline());
        var topArray = readline().split(" ");
        var bottomArray = readline().split(" ");
        var topIntArray = new Array(caseLength);
        topIntArray[0] = 0;
        var bottomIntArray = new Array(caseLength);
        bottomIntArray[caseLength - 1] = 0;
        var index = 0;
        var revIndex = caseLength - 1;
        var topTotal = 0;
        var bottomTotal = 0;
        while (index < caseLength - 1) {
            var topValue = parseInt(topArray[revIndex]);
            topTotal += topValue;
            topIntArray[revIndex] = topTotal;
            var bottomValue = parseInt(bottomArray[index]);
            bottomTotal += bottomValue;
            bottomIntArray[index] = bottomTotal;
            index++;
            revIndex--;
        }
        var minValue = Math.min(topTotal, bottomTotal);
        for (var k = 1; k < caseLength - 1; k++) {
            var higher = Math.max(topIntArray[k + 1], bottomIntArray[k - 1]);
            minValue = (higher < minValue) ? higher : minValue;
        }
        print(minValue);
    }

'use strict'
Object.defineProperty(exports, '__esModule', { value: !0 })
var os = require('os')
const stdin = process.stdin,
  stdout = process.stdout,
  integerRegex = /-?\d+/g,
  decimalRegex = /-?\d+(?:\.\d+)?/g
class InputAndOutput {
  lineIndex = 0
  lines = []
  dried() {
    return this.lineIndex >= this.lines.length
  }
  readLine() {
    const e = this.lines[this.lineIndex]
    return (this.lineIndex += 1), e
  }
  readIntegersOfLine() {
    const e = this.readLine().match(integerRegex)
    return null == e ? [] : e.map(e => Number(e))
  }
  readNumsOfLine() {
    const e = this.readLine().match(decimalRegex)
    return null == e ? [] : e.map(e => Number(e))
  }
  print(e) {
    stdout.write(e)
  }
  async init() {
    const e = await this.readLines()
    this.lines = e
  }
  readLines() {
    const e = []
    return new Promise(n => {
      stdin.on('data', n => e.push(n)),
        stdin.on('end', function () {
          const t = e.join('').split(os.EOL)
          n(t)
        })
    })
  }
}
async function __main__(e) {
  const n = new InputAndOutput()
  await n.init(), e(n)
}
function solve(e, n, t) {
  if (e <= 1) return 0
  let s = 0
  for (let t = 0; t < e; ++t) s += n[t]
  let i = Number.MAX_SAFE_INTEGER
  for (let r = 0, o = 0, d = 0; r < e; ++r) {
    o += n[r]
    const e = Math.max(s - o, d)
    ;(d += t[r]), i > e && (i = e)
  }
  return i
}
__main__(function (e) {
  const n = Number(e.readLine())
  for (let t = 1; t <= n; ++t) {
    const n = solve(
      Number(e.readLine()),
      e.readIntegersOfLine(),
      e.readIntegersOfLine(),
    )
    e.print(n + '\n')
  }
})

'use strict'
Object.defineProperty(exports, '__esModule', { value: !0 })
var os = require('os')
const stdin = process.stdin,
  stdout = process.stdout,
  integerRegex = /-?\d+/g,
  decimalRegex = /-?\d+(?:\.\d+)?/g
class InputAndOutput {
  lineIndex = 0
  lines = []
  dried() {
    return this.lineIndex >= this.lines.length
  }
  readLine() {
    const e = this.lines[this.lineIndex]
    return (this.lineIndex += 1), e
  }
  readIntegersOfLine() {
    const e = this.readLine().match(integerRegex)
    return null == e ? [] : e.map(e => Number(e))
  }
  readNumsOfLine() {
    const e = this.readLine().match(decimalRegex)
    return null == e ? [] : e.map(e => Number(e))
  }
  print(e) {
    stdout.write(e)
  }
  async init() {
    const e = await this.readLines()
    this.lines = e
  }
  readLines() {
    const e = []
    return new Promise(n => {
      stdin.on('data', n => e.push(n)),
        stdin.on('end', function () {
          const t = e.join('').split(os.EOL)
          n(t)
        })
    })
  }
}
async function __main__(e) {
  const n = new InputAndOutput()
  await n.init(), e(n)
}
const MAX_N = 100010,
  sum1 = new Array(MAX_N)
function solve(e, n, t) {
  if (e <= 1) return 0
  sum1[0] = n[0]
  for (let t = 1; t < e; ++t) sum1[t] = sum1[t - 1] + n[t]
  const s = e - 1
  let i = sum1[s] - n[0]
  for (let n = 1, r = t[0]; n < e; ++n) {
    const e = Math.max(sum1[s] - sum1[n], r)
    ;(r += t[n]), i > e && (i = e)
  }
  return i
}
__main__(function (e) {
  const n = Number(e.readLine())
  for (let t = 1; t <= n; ++t) {
    const n = solve(
      Number(e.readLine()),
      e.readIntegersOfLine(),
      e.readIntegersOfLine(),
    )
    e.print(n + '\n')
  }
})

"use strict";
const fs = require("fs");
//let filename = "0.txt";
let filename = 0;
const input = fs.readFileSync(filename, "utf8").trim().split("\n");
let line = 0;
function readline() {
  return input[line++];
}
function iInpArr() {
  return readline()
    .trim()
    .split(" ")
    .map((cur) => parseInt(cur));
}
function BInpArr() {
  return readline()
    .trim()
    .split(" ")
    .map((cur) => BigInt(cur));
}
function string() {
  return readline().trim();
}
function stringArr() {
  return readline().trim().split("");
}

function stringArr1() {
  return readline().trim().split(" ");
}
function getValue() {
  return parseInt(readline());
}
function iInpArr1() {
  return readline()
    .trim()
    .split("")
    .map((cur) => parseInt(cur));
}
let mod = 1e9 + 7;
mod = BigInt(mod);
const pow = (num, exp, mod) => {
  if (exp === BigInt(0)) return BigInt(1);
  let x = pow(num, exp / BigInt(2), mod);
  if (exp % BigInt(2)) return (((x * x) % mod) * num) % mod;
  else return (x * x) % mod;
};
const inverse = (num, exp) => {
  return pow(BigInt(num), BigInt(exp), BigInt(mod));
};
const sqrt = (n) => {
  let low = 1n,
    high = n,
    ans;
  while (low <= high) {
    let mid = (low + high) / 2n;
    if (mid * mid <= n) {
      ans = mid;
      low = mid + 1n;
    } else high = mid - 1n;
  }
  return ans;
};
const solve = () => {
  let t = getValue();
  while (t--) {
    let n = getValue();
    let arr1 = iInpArr();
    let arr2 = iInpArr();
    let psum1 = [],
      psum2 = [],
      s1 = 0,
      s2 = 0;
    for (let i = 0; i < n; i++) {
      s1 += arr1[i];
      s2 += arr2[i];
      psum1[i] = s1;
      psum2[i] = s2;
    }
    let ans = Infinity,
      end = n - 1,
      st = 0;
    for (let i = 0; i < n; i++) {
      let v1 = psum1[end] - psum1[i];
      let v2 = i !== 0 ? psum2[i - 1] : 0;
      ans = Math.min(ans, Math.max(v1, v2));
    }
    console.log(ans);
  }
};
solve();

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

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

const INF = Number.POSITIVE_INFINITY;
function main () {
	let t = rn();
	while (t--) {
		let m = rna();
		let a = [];
		a[0] = rna();
		a[1] = rna();

		let sm1 = 0;
		for (let i = 0; i < m; i++)
			sm1 += a[0][i];

		let ans = INF;
		for(let i = 0, cursm1 = cursm2 = 0; i < m; i++) {
			cursm1 += a[0][i];
			cursm2 += a[1][i];
			ans = Math.min(ans, Math.max(sm1 - cursm1, cursm2 - a[1][i]))
		}

		console.log(ans);
	}
}

var T = parseInt(readline());

for (var t = 0; t < T; t++) {
    var m = parseInt(readline());
    var a1 = readline().split(' ').map((x) => parseInt(x));
    var a2 = readline().split(' ').map((x) => parseInt(x));

    var acc1 = 0, acc2 = 0;
    for (var i = 0; i < m; i++) {
        acc1 += a1[i];
    }

    var mi = Infinity;
    for (var i = 0; i < m; i++) {
        acc1 -= a1[i];
        mi = Math.min(mi, Math.max(acc1, acc2));
        acc2 += a2[i];
    }
    print(mi);
}

var T = parseInt(readline());

for (var t = 0; t < T; t++) {
    var m = parseInt(readline());
    var a1 = readline().split(' ').map((x) => parseInt(x));
    var a2 = readline().split(' ').map((x) => parseInt(x));

    var acc1 = 0, acc2 = 0;
    for (var i = 0; i < m; i++) {
        acc1 += a1[i];
    }

    var mi = 10000000;
    for (var i = 0; i < m; i++) {
        acc1 -= a1[i];
        mi = Math.min(mi, Math.max(acc1, acc2));
        acc2 += a2[i];
    }
    print(mi);
}

var T = parseInt(readline());

for (var t = 0; t < T; t++) {
    var m = parseInt(readline());
    var a1 = readline().split(' ').map((x) => parseInt(x));
    var a2 = readline().split(' ').map((x) => parseInt(x));

    var acc1 = 0, acc2 = 0;
    for (var i = 0; i < m; i++) {
        acc1 += a1[i];
    }

    var m = 10000000;
    for (var i = 0; i < m; i++) {
        acc1 -= a1[i];
        print(m, acc1, acc2);
        m = Math.min(m, Math.max(acc1, acc2));
        acc2 += a2[i];
    }
    print(m);
}

var T = parseInt(readline());

for (var t = 0; t < T; t++) {
    var m = parseInt(readline());
    var a1 = readline().split(' ').map((x) => parseInt(x));
    var a2 = readline().split(' ').map((x) => parseInt(x));

    var acc1 = 0, acc2 = 0;
    for (var i = 0; i < m; i++) {
        acc1 += a1[i];
    }

    var m = 10000000;
    for (var i = 0; i < m; i++) {
        acc1 -= a1[i];
        m = Math.min(m, Math.max(acc1, acc2));
        acc2 += a2[i];
    }
    print(m);
}

var T = parseInt(readline());

for (var t = 0; t < T; t++) {
    var m = parseInt(readline());
    var a1 = readline().split(' ').map((x) => parseInt(x));
    var a2 = readline().split(' ').map((x) => parseInt(x));

    var acc1 = 0, acc2 = 0;
    for (var i = 0; i < m; i++) {
        acc1 += a1[i];
    }

    var m = 10000000;
    for (var i = 0; i < m; i++) {
        acc1 -= a1[i];
        m = Math.min(m, Math.max(acc1, acc2));
        acc2 += a1[i];
    }
    print(m);
}

var T = parseInt(readline());

for (var t = 0; t < T; t++) {
    var m = parseInt(readline());
    var a1 = readline().split(' ').map((x) => parseInt(x));
    var a2 = readline().split(' ').map((x) => parseInt(x));

    var acc1 = 0, acc2 = 0;
    for (var i = 0; i < m; i++) {
        acc1 += a1[i];
    }

    var m = 10000000;
    for (var i = 0; i < m; i++) {
        acc1 -= a1[i];
        m = Math.min(m, acc1, acc2);
        acc2 += a1[i];
    }
    print(m);
}

var T = parseInt(readline());

for (var t = 0; t < T; t++) {
    var m = parseInt(readline());
    var a1 = readline().split(' ').map((x) => parseInt(x));
    var a2 = readline().split(' ').map((x) => parseInt(x));
    var a = [a1, a2];

    var s1 = find(a, m);

    for (var i = 0; i <= s1[1]; i++)
        a[0][i] = 0;
    for (var i = s1[1]; i < m; i++)
        a[1][i] = 0;

    print(JSON.stringify(a));

    var s2 = find(a, m);
    print(s2[0]);
}

function find(a, m) {
    var acc1 = 0, acc2 = 0;
    for (var i = 0; i < m; i++)
        acc2 += a[1][i];

    var max = 0, maxi = 0;
    for (var i = 0; i < m; i++) {
        acc1 += a[0][i];

        if (acc1 + acc2 > max) {
            max = acc1 + acc2;
            maxi = i;
        }

        acc2 -= a[1][i];
    }

    return [max, maxi];
}

var T = parseInt(readline());

for (var t = 0; t < T; t++) {
    var m = parseInt(readline());
    var a1 = readline().split(' ').map((x) => parseInt(x));
    var a2 = readline().split(' ').map((x) => parseInt(x));
    var a = [a1, a2];

    var s1 = find(a, m);

    for (var i = 0; i <= s1[1]; i++)
        a[0][i] = 0;
    for (var i = s1[1]; i < m; i++)
        a[1][i] = 0;

    var s2 = find(a, m);
    print(s2[0]);
}

function find(a, m) {
    var acc1 = 0, acc2 = 0;
    for (var i = 0; i < m; i++)
        acc2 += a[1][i];

    var max = 0, maxi = 0;
    for (var i = 0; i < m; i++) {
        acc1 += a[0][i];

        if (acc1 + acc2 > max) {
            max = acc1 + acc2;
            maxi = i;
        }

        acc2 -= a[1][i];
    }

    return [max, maxi];
}


let i = ''
process.stdin.on('data', c => i += c);
process.stdin.on('end', () => {
    const {EOL} = require('os')
    const lines = i.split(EOL)
    preRun(lines);
});

// preRun([
// 	"1",
// 	"6",
// 	"62190969 830257761",
// 	"133433399 602982864",
// 	"249519268 512360334",
// 	"706277914 269089955",
// 	"763878605 823076990",
// 	"860629446 664543503"
// ]);

function preRun(lines)
{
	let cases = parseInt(lines[0]);
	let p = 1;
	for(let i=0;i<cases;i++)
	{
		let n = parseInt(lines[p]);p++;
		let xs = [];
		let ys = [];
		for(let i=0;i<n;i++)
		{
			let [x,y] = lines[p].split(" ").map((e) => parseInt(e));p++;
			xs.push(x);
			ys.push(y);
		}
		xs.sort((a,b) => a-b);
		ys.sort((a,b) => a-b);
		let rx = BigInt(calcRange(xs));
		let ry = BigInt(calcRange(ys));
		console.log((rx*ry)+"");
	}
}

function calcRange(cs)
{
	if (cs.length%2==1)
	{
		return 1;
	}
	else
	{
		let m = (cs.length/2);
		return (cs[m]-cs[m-1])+1;
	}
}

'use strict';

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

let inputString = '';
let currentLine = 0;

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

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

    main();
});

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

// Make a Snippet for the code above this and then write your logic in main();

var height = []

function main() {
    var xx = Number(readline())
    Array(Number(xx)).fill(1).map((t, i) => {

        var n = parseInt(readline())
        var y = new Array(n)
        var x = new Array(n)
        var xx, yy
        for (let j = 0; j < n; j++) {
            [xx, yy] = readline().split(' ').map((x, i) => {
                return parseInt(x)
            })
            x[j] = xx;
            y[j] = yy;
        }

        x = x.sort((a, b) => a - b)
        y = y.sort((a, b) => a - b)

        if (n % 2 === 1) return console.log(1)
        var a = x[Math.floor((n) / 2)] - x[Math.floor(n / 2 - 1)] + 1
        var b = y[Math.floor((n) / 2)] - y[Math.floor(n / 2 - 1)] + 1
        a = BigInt(a)
        b = BigInt(b)
        // console.log(x)
        // console.log(y)
        console.log((a*b).toString())
    })
}

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

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

function main () {
	let T = rn();
	while (T--) {
		let n = rn();
		let x = Array(n);
		let y = Array(n);
		for (let i = 0; i < n; i++) {
			[x[i], y[i]] = rna();;
		}

		x.sort((a, b) => a - b);
		y.sort((a, b) => a - b);

		let ans = 1;
		if (n%2 == 0) {
			const k = n/2 - 1;
			ans = BigInt(x[k+1] - x[k] + 1) * BigInt(y[k+1] - y[k] + 1);
		}

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

'use strict';

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

let inputString = '';
let currentLine = 0;

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

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

    main();
});

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

// Make a Snippet for the code above this and then write your logic in main();

var height = []

function main() {
    var xx = Number(readline())
    Array(Number(xx)).fill(1).map((t, i) => {

        var n = parseInt(readline())
        var y = new Array(n)
        var x = new Array(n)
        var xx, yy
        for (let j = 0; j < n; j++) {
            [xx, yy] = readline().split(' ').map((x, i) => {
                return parseInt(x)
            })
            x[j] = xx;
            y[j] = yy;
        }

        x = x.sort((a, b) => a - b)
        y = y.sort((a, b) => a - b)

        if (n%2 === 1) return console.log(1)
        var asnwer = x[Math.floor((n ) / 2)] - x[Math.floor(n/2-1)] + 1
        asnwer *= y[Math.floor((n ) / 2)]- y[Math.floor(n/2-1)] + 1

        // console.log(x)
        // console.log(y)
        console.log(asnwer)
    })
}

'use strict';

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

let inputString = '';
let currentLine = 0;

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

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

    main();
});

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

// Make a Snippet for the code above this and then write your logic in main();

var height = []

function main() {
    var xx = Number(readline())
    Array(Number(xx)).fill(1).map((t, i) => {

        var n = parseInt(readline())
        var y = new Array(n)
        var x = new Array(n)
        var xx, yy
        for (let j = 0; j < n; j++) {
            [xx, yy] = readline().split(' ').map((x, i) => {
                return parseInt(x)
            })
            x[j] = xx;
            y[j] = yy;
        }

        x = x.sort((a, b) => a - b)
        y = y.sort((a, b) => a - b)

        if (n === 1) return console.log(1)
        var asnwer = x[Math.floor((n ) / 2)] - x[Math.floor(n/2-1)] + 1
        asnwer *= y[Math.floor((n ) / 2)]- y[Math.floor(n/2-1)] + 1

        // console.log(x)
        // console.log(y)
        console.log(asnwer)
    })
}

'use strict';

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

let inputString = '';
let currentLine = 0;

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

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

    main();
});

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

// Make a Snippet for the code above this and then write your logic in main();

var height = []

function main() {
    var xx = Number(readline())
    Array(Number(xx)).fill(1).map((t, i) => {

        var n = parseInt(readline())
        var xy = new Array(n)
        var xx, yy
        var sameLineX = true
        var sameLineY = true
        for (let j = 0; j < n; j++) {
            [xx, yy] = readline().split(' ').map((x, i) => {
                return parseInt(x)
            })
            xy[j] = {x: xx, y: yy}
        }

        var sumx = 0
        var sumY = 0
        for (let i = 0; i < n; i++) {
            sumx += xy[i].x
            sumY += xy[i].y
        }
        // console.log(xy)
        // console.log(sumx, sumY, sumx / n, sumY / n)
        sumx = sumx / n
        var sumy = sumY / n
        if (sumx === 0 && sumy === 0) return console.log(1)
        if (n === 2) {
            if (sumx === Math.ceil(sumx) && sumy === Math.ceil(sumy)) {
                // if (sumx === xy[0].x && sumy === xy[0].y) {
                //     return console.log(1)
                // }
                // if (sumx !== xy[0][0] || sumy !== xy[0][1]) {
                return console.log(3)
                // }
                // return console.log(1)
            }
            if (sumx === (Math.ceil(sumx) + Math.floor(sumx)) * 0.5 && sumy === (Math.ceil(sumy) + Math.floor(sumy)) * 0.5) {
                return console.log(4)
            }
            return console.log(2)
        }
        if (n === 3) {
        }

        if (sumx === Math.ceil(sumx) && sumy === Math.ceil(sumy)) {
            return console.log(1)
        }

        // console.log(sumx, sumy)
        // if(sumx === Math.ceil(sumx) || sumy === Math.ceil(sumy) ){
        //     return console.log(2)
        // }
        // console.log(sumx, sumy)
        // console.log(sumx === (Math.ceil(sumx) + Math.floor(sumx)) * 0.5, sumy)

        if (sumx === (Math.ceil(sumx) + Math.floor(sumx)) * 0.5 && sumy === (Math.ceil(sumy) + Math.floor(sumy)) * 0.5) {
            return console.log(4)
        }
        console.log(1)

    })
}

var lower_limit = 0.01;

// Function to return the sum of Euclidean
// Distances
function distSum(p, arr, n) {
    var sum = 0;
    for (var i = 0; i < n; i++) {
        var distx = Math.abs(arr[i].x - p.x);
        var disty = Math.abs(arr[i].y - p.y);
        sum += Math.sqrt((distx * distx) + (disty * disty));
    }

    // Return the sum of Euclidean Distances
    return sum;
}

var test_point = [{x: -1.0, y: 0.0},
    {x: 0.0, y: 1.0},
    {x: 1.0, y: 0.0},
    {x: 0.0, y: -1.0}];
// function geometricMedian(arr, n) {
//
//     // Current x coordinate and y coordinate
//     var current_point = {x: 0, y: 0};
//
//     for (var i = 0; i < n; i++) {
//         current_point.x += arr[i].x;
//         current_point.y += arr[i].y;
//     }
//
//     // Here current_point becomes the
//     // Geographic MidPoint
//     // Or Center of Gravity of equal
//     // discrete mass distributions
//     current_point.x /= n;
//     current_point.y /= n;
//
//     // minimum_distance becomes sum of
//     // all distances from MidPoint to
//     // all given points
//     var minimum_distance = distSum(current_point, arr, n);
//
//     var k = 0;
//     while (k < n) {
//         for (var i = 0; i < n && i !== k; i++) {
//             var newpoint = {};
//             newpoint.x = arr[i].x;
//             newpoint.y = arr[i].y;
//             var newd =
//                 distSum(newpoint, arr, n);
//             console.log(newd)
//             console.log(minimum_distance)
//             if (newd < minimum_distance) {
//                 minimum_distance = newd;
//                 current_point.x = newpoint.x;
//                 current_point.y = newpoint.y;
//             }
//         }
//         k++;
//     }
//
//     // Assume test_distance to be 1000
//     var test_distance = 1000.0;
//     var flag = 0;
//
//     // Test loop for approximation starts here
//     while (test_distance > lower_limit) {
//
//         flag = 0;
//
//         // Loop for iterating over all 4 neighbours
//         for (var i = 0; i < 4; i++) {
//
//             // Finding Neighbours done
//             var newpoint = {}
//             newpoint.x = current_point.x
//                 + test_distance * test_point[i].x;
//             newpoint.y = current_point.y
//                 + test_distance * test_point[i].y;
//
//             // New sum of Euclidean distances
//             // from the neighbor to the given
//             // data points
//             var newd = distSum(newpoint, arr, n);
//
//             if (newd < minimum_distance) {
//
//                 // Approximating and changing
//                 // current_point
//                 minimum_distance = newd;
//                 current_point.x = newpoint.x;
//                 current_point.y = newpoint.y;
//                 flag = 1;
//                 break;
//             }
//         }
//
//         // This means none of the 4 neighbours
//         // has the new minimum distance, hence
//         // we divide by 2 and reiterate while
//         // loop for better approximation
//         if (flag === 0)
//             test_distance /= 2;
//     }
//
//     // cout << "Geometric Median = ("
//     // console.log(current_point)
//     return current_point
//     // current_point.x << ", "
//     // << current_point.y << ")";
//     // cout << " with minimum distance = "
//     // console.log(minimum_distancecurrent_point);
// }

'use strict';

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

let inputString = '';
let currentLine = 0;

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

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

    main();
});

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

// Make a Snippet for the code above this and then write your logic in main();

var height = []

function main() {
    var xx = Number(readline())
    Array(Number(xx)).fill(1).map((t, i) => {

        var n = parseInt(readline())
        var nn = n
        var xy = new Array(n)
        var xx, yy
        var sameLineX = true
        var sameLineY = true
        for (let j = 0; j < n; j++) {
            [xx, yy] = readline().split(' ').map((x, i) => {
                return parseInt(x)
            })
            xy[j] = {x: xx, y: yy}
        }
        if (n === 1) return console.log(1)
        // console.log(xy)
        // console.log(geometricMedian(xy, n))
        var point = geometricMedian(xy, n)
        // console.log(point.x === (Math.ceil(point.x) + Math.floor(point.x))*0.5 )

        var sameX = point.x === (Math.ceil(point.x) + Math.floor(point.x)) * 0.5
        var sameY = point.y === (Math.ceil(point.y) + Math.floor(point.y)) * 0.5

        // console.log(sameX, sameY, point)
        if (Math.ceil(point.y) === point.y && Math.ceil(point.x) === point.x) {
            if(n===2) {
                if(xy[0].x === point.x &&xy[0].y === point.y) return console.log(1)
                return console.log(3)
            }
            return console.log(1)
        }
        if (Math.ceil(point.y) === point.y && sameX) {
            return console.log(2)
        }
        if (Math.ceil(point.x) === point.x && sameY) {
            return console.log(2)
        }

        if (sameX && sameY) {
            return console.log(4)
        }
        console.log(1)
    })

}

var lower_limit = 0.01;

// Function to return the sum of Euclidean
// Distances
function distSum(p, arr, n) {
    var sum = 0;
    for (var i = 0; i < n; i++) {
        var distx = Math.abs(arr[i].x - p.x);
        var disty = Math.abs(arr[i].y - p.y);
        sum += Math.sqrt((distx * distx) + (disty * disty));
    }

    // Return the sum of Euclidean Distances
    return sum;
}

function geometricMedian(arr, n) {

    // Current x coordinate and y coordinate
    var current_point = {x: 0, y: 0};

    for (var i = 0; i < n; i++) {
        current_point.x += arr[i].x;
        current_point.y += arr[i].y;
    }

    // Here current_point becomes the
    // Geographic MidPoint
    // Or Center of Gravity of equal
    // discrete mass distributions
    current_point.x /= n;
    current_point.y /= n;

    // minimum_distance becomes sum of
    // all distances from MidPoint to
    // all given points
    var minimum_distance = distSum(current_point, arr, n);

    var k = 0;
    while (k < n) {
        for (var i = 0; i < n && i !== k; i++) {
            var newpoint = {};
            newpoint.x = arr[i].x;
            newpoint.y = arr[i].y;
            var newd =
                distSum(newpoint, arr, n);
            if (newd < minimum_distance) {
                minimum_distance = newd;
                current_point.x = newpoint.x;
                current_point.y = newpoint.y;
            }
        }
        k++;
    }

    // Assume test_distance to be 1000
    var test_distance = 1000.0;
    var flag = 0;

    // Test loop for approximation starts here
    // while (test_distance > lower_limit) {
    //
    //     flag = 0;
    //
    //     // Loop for iterating over all 4 neighbours
    //     for (var i = 0; i < 4; i++) {
    //
    //         // Finding Neighbours done
    //         var newpoint = {}
    //         newpoint.x = current_point.x
    //             + test_distance * test_point[i].x;
    //         newpoint.y = current_point.y
    //             + test_distance * test_point[i].y;
    //
    //         // New sum of Euclidean distances
    //         // from the neighbor to the given
    //         // data points
    //         var newd = distSum(newpoint, arr, n);
    //
    //         if (newd < minimum_distance) {
    //
    //             // Approximating and changing
    //             // current_point
    //             minimum_distance = newd;
    //             current_point.x = newpoint.x;
    //             current_point.y = newpoint.y;
    //             flag = 1;
    //             break;
    //         }
    //     }
    //
    //     // This means none of the 4 neighbours
    //     // has the new minimum distance, hence
    //     // we divide by 2 and reiterate while
    //     // loop for better approximation
    //     if (flag === 0)
    //         test_distance /= 2;
    // }

    // cout << "Geometric Median = ("
    // console.log(current_point)
    return current_point
    // current_point.x << ", "
    // << current_point.y << ")";
    // cout << " with minimum distance = "
    // console.log(minimum_distancecurrent_point);
}

// let i = ''
// process.stdin.on('data', c => i += c);
// process.stdin.on('end', () => {
//     const {EOL} = require('os')
//     const lines = i.split(EOL)
//     preRun(lines);
// });

preRun([
	"1",
	"6",
	"62190969 830257761",
	"133433399 602982864",
	"249519268 512360334",
	"706277914 269089955",
	"763878605 823076990",
	"860629446 664543503"
]);

function preRun(lines)
{
	let cases = parseInt(lines[0]);
	let p = 1;
	for(let i=0;i<cases;i++)
	{
		let n = parseInt(lines[p]);p++;
		let xs = [];
		let ys = [];
		for(let i=0;i<n;i++)
		{
			let [x,y] = lines[p].split(" ").map((e) => parseInt(e));p++;
			xs.push(x);
			ys.push(y);
		}
		xs.sort((a,b) => a-b);
		ys.sort((a,b) => a-b);
		let rx = BigInt(calcRange(xs));
		let ry = BigInt(calcRange(ys));
		console.log((rx*ry)+"");
	}
}

function calcRange(cs)
{
	if (cs.length%2==1)
	{
		return 1;
	}
	else
	{
		let m = (cs.length/2);
		return (cs[m]-cs[m-1])+1;
	}
}

let i = ''
process.stdin.on('data', c => i += c);
process.stdin.on('end', () => {
    const {EOL} = require('os')
    const lines = i.split(EOL)
    preRun(lines);
});

// preRun([
// 	"1",
// 	"6",
// 	"62190969 830257761",
// 	"133433399 602982864",
// 	"249519268 512360334",
// 	"706277914 269089955",
// 	"763878605 823076990",
// 	"860629446 664543503"
// ]);

function preRun(lines)
{
	let cases = parseInt(lines[0]);
	let p = 1;
	for(let i=0;i<cases;i++)
	{
		let n = parseInt(lines[p]);p++;
		let xs = [];
		let ys = [];
		for(let i=0;i<n;i++)
		{
			let [x,y] = lines[p].split(" ").map((e) => parseInt(e));p++;
			xs.push(x);
			ys.push(y);
		}
		xs.sort((a,b) => a-b);
		ys.sort((a,b) => a-b);
		let rx = calcRange(xs);
		let ry = calcRange(ys);
		console.log(rx*ry);
	}
}

function calcRange(cs)
{
	if (cs.length%2==1)
	{
		return 1;
	}
	else
	{
		let m = (cs.length/2);
		return (cs[m]-cs[m-1])+1;
	}
}

let i = ''
process.stdin.on('data', c => i += c);
process.stdin.on('end', () => {
    const {EOL} = require('os')
    const lines = i.split(EOL)
    preRun(lines);
});

function preRun(lines)
{
	let cases = parseInt(lines[0]);
	let p = 1;
	for(let i=0;i<cases;i++)
	{
		let n = parseInt(lines[p]);p++;
		let xs = [];
		let ys = [];
		for(let i=0;i<n;i++)
		{
			let [x,y] = lines[p].split(" ").map((e) => parseInt(e));p++;
			xs.push(x);
			ys.push(y);
		}
		xs.sort();
		ys.sort();
		let rx = calcRange(xs);
		let ry = calcRange(ys);
		console.log(rx*ry);
	}
}

function calcRange(cs)
{
	if (cs.length%2==1)
	{
		return 1;
	}
	else
	{
		let m = (cs.length/2);
		return (cs[m]-cs[m-1])+1;
	}
}

let i = ''
process.stdin.on('data', c => i += c);
process.stdin.on('end', () => {
    const {EOL} = require('os')
    const lines = i.split(EOL)
    preRun(lines);
});

// preRun([

// 	"6",
// 	"3",
// 	"0 0",
// 	"2 0",
// 	"1 2",
// 	"4",
// 	"1 0",
// 	"0 2",
// 	"2 3",
// 	"3 1",
// 	"4",
// 	"0 0",
// 	"0 1",
// 	"1 0",
// 	"1 1",
// 	"2",
// 	"0 0",
// 	"1 1",
// 	"2",
// 	"0 0",
// 	"2 0",
// 	"2",
// 	"0 0",
// 	"0 0"
// ]);

function preRun(lines)
{
	let cases = parseInt(lines[0]);
	let p = 1;
	for(let i=0;i<cases;i++)
	{
		let n = parseInt(lines[p]);p++;
		let xs = [];
		let ys = [];
		for(let i=0;i<n;i++)
		{
			let [x,y] = lines[p].split(" ").map((e) => parseInt(e));p++;
			xs.push(x);
			ys.push(y);
		}
		xs.sort();
		ys.sort();
		let rx = calcRange(xs);
		let ry = calcRange(ys);
		console.log(rx*ry);
	}
}

function calcRange(cs)
{
	if (cs.length==1) return 1;

	let t = 0;
	for(let i=0;i<cs.length;i++) t+= cs[i];
	let m = t/cs.length;
	let bef = 0,aft = 0,b = 0, a = -1;
	for(let i=0;i<cs.length;i++)
	{
		if (cs[i]==m) return 1;
		if (cs[i]<m)
		{
			bef++;
			b = cs[i];
		}
		if (cs[i]>m)
		{
			aft++;
			if (a==-1) a = cs[i];
		}
	}
	if (bef==aft)
	{
		return (a-b)+1;
	}
	else
	{
		return 1;
	}
}

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

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

function main () {
	let T = rn();
	while (T--) {
		let n = rn();
		let x = Array(n);
		let y = Array(n);
		for (let i = 0; i < n; i++) {
			[x[i], y[i]] = rna();;
		}

		x.sort((a, b) => a - b);
		y.sort((a, b) => a - b);

		let ans = 1;
		if (n%2 == 0) {
			const k = n/2 - 1;
			ans = (x[k+1] - x[k] + 1) * (y[k+1] - y[k] + 1);
		}

		console.log(ans);
	}
}


var cat = [{rep: 0}]
var min = 1

readline() // ignore # of catacombs
// var line = '0 0'
// var line = '0 1 0 1 3'
      //t 0 1 2 3 4 5
var line = readline()
var history = line.split(' ').map(function(x) { return parseInt(x) })

var rep = null
for (var i = 0; i < history.length; i++) {
  rep = cat[history[i]]
  if (rep.rep === history[i]) {
    rep.rep = i+1
    cat.push(rep)
  } else {
    min++
    cat.push({rep: i+1})
  }
  // console.log(i, history[i], cat)
}
// console.log(cat)
// console.log(min)
print(min)

var n = Number(readline())
var arr = readline().split(" ");
var arrMarked = [];

var count = 1;

for(var i = n-1; i>=0; i--) {
	var minute = i+1;
	if (arrMarked[minute])
		continue;
	while (minute >= 0 && !arrMarked[minute]) {
		arrMarked[minute] = count;
		minute = arr[minute-1];
	}
	count++;
}

print(count-1);