You are playing a computer game. To pass the current level, you have to kill a big horde of monsters. In this horde, there are $$$n$$$ monsters standing in the row, numbered from $$$1$$$ to $$$n$$$. The $$$i$$$-th monster has $$$a_i$$$ health and a special "Death's Blessing" spell of strength $$$b_i$$$ attached to it.You are going to kill all of them one by one. It takes exactly $$$h$$$ seconds to kill a monster with health $$$h$$$.When the $$$i$$$-th monster dies, it casts its spell that increases the health of its neighbors by $$$b_i$$$ (the neighbors of the $$$j$$$-th monster in the row are the monsters on places $$$j - 1$$$ and $$$j + 1$$$. The first and the last monsters have only one neighbor each).After each monster is killed, the row shrinks, so its former neighbors become adjacent to each other (so if one of them dies, the other one is affected by its spell). For example, imagine a situation with $$$4$$$ monsters with health $$$a = [2, 6, 7, 3]$$$ and spells $$$b = [3, 6, 0, 5]$$$. One of the ways to get rid of the monsters is shown below:  $$$2$$$$$$6$$$$$$7$$$$$$3$$$$$$\xrightarrow{6\ s}$$$$$$8$$$$$$13$$$$$$3$$$$$$\xrightarrow{13\ s}$$$$$$8$$$$$$3$$$$$$\xrightarrow{8\ s}$$$$$$6$$$$$$\xrightarrow{6\ s}$$$$$$\{\}$$$$$$3$$$$$$6$$$$$$0$$$$$$5$$$$$$3$$$$$$0$$$$$$5$$$$$$3$$$$$$5$$$$$$5$$$ The first row represents the health of each monster, the second one — the power of the spells. As a result, we can kill all monsters in $$$6 + 13 + 8 + 6$$$ $$$=$$$ $$$33$$$ seconds. Note that it's only an example and may not be the fastest way to get rid of the monsters.What is the minimum time required to kill all monsters in the row?

The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. The first line of each test case contains a single integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) — the number of monsters in the row. The second line contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 10^9$$$) — the initial health of corresponding monsters. The third line contains $$$n$$$ integers $$$b_1, b_2, \dots, b_n$$$ ($$$0 \le b_i \le 10^9$$$), where $$$b_i$$$ is the strength of the spell for the $$$i$$$-th monster. It's guaranteed that the sum of $$$n$$$ doesn't exceed $$$2 \cdot 10^5$$$.

For each test case, print one integer — the minimum possible total time to kill all monsters.

NoteIn the first test case, there is only one monster that will be killed in $$$10$$$ seconds.In the second test case, it's optimal to kill the first monster, the last monster and then the middle one. It will take $$$100 + 100 + (1 + 1 + 1)$$$ $$$=$$$ $$$203$$$ seconds.In the third test case, it's optimal to kill the first monster, then the third one, then the fourth one and finally the second one. It will take $$$2 + 7 + (3 + 0) + (3 + 6 + 5)$$$ $$$=$$$ $$$26$$$ seconds.

/*
* auther yeling
*
*
*/
'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(str) {
    console.log(str);
}
// const { readline, print, testOutput } = require('@ip-algorithmics/codeforces-io');
// main();
// testOutput();

function begin(n, h, b) {
    let sum = 0;
    let max = Number.MIN_SAFE_INTEGER;
    for(let i = 0; i < n; i++) {
        sum += h[i] + b[i];
        max = Math.max(max, b[i]);
    }
    sum -= max;
    print(sum);

}
function main() {
    var caseNum = parseInt(readline(), 10);
    for (var i = 0; i < caseNum; i++) {
        var n = parseInt(readline(), 10);
        var h = readline()
            .trim()
            .split(' ')
            .map((y) => parseInt(y, 10));
        var b = readline()
            .trim()
            .split(' ')
            .map((y) => parseInt(y, 10));
        begin(n, h, b);
    }
}

'use strict';

var fs = require('fs');

function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }

var fs__default = /*#__PURE__*/_interopDefaultLegacy(fs);

function solve(read) {
  const [rn, rb, rns, re, rbs] = convertInput(read);
  const n = rn(),
        a = rns(),
        b = rns();
  let res = 0;
  for (let l = 0, r = n - 1; l <= r;) {
    if (b[l] < b[r]) {
      res += a[l];
      a[l + 1] += b[l];
      l++;
    } else {
      res += a[r];
      a[r - 1] += b[r];
      r--;
    }
  }
  return res;
}
function convertInput(read) {
  const rn = () => Number(read());
  const rb = () => BigInt(read());
  const rns = () => read().split(/\s+/).map(Number);
  const re = () => read().split(/\s+/).map(s => Number(s) - 1);
  const rbs = () => read().split(/\s+/).map(BigInt);
  return [rn, rb, rns, re, rbs];
}
function main(r) {
  try {
    let t = Number(r());
    let res = new Array(t);
    let limit = 0;
    for (let i = 0; i < t; i++) {
      var _solve;
      const s = (_solve = solve(r)) !== null && _solve !== void 0 ? _solve : '';
      if (t < limit) {
        process.stdout.write(s.toString());
        process.stdout.write('\n');
      } else {
        res[i] = s;
      }
    }
    if (t >= limit) {
      return res.join('\n');
    } else {
      return '';
    }
  } catch (error) {
    console.log(error);
  }
}

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

'use strict';

function sum(arr) {
    var total = 0;
    for (var i = 0; i < arr.length; i++) {
        total += arr[i];
    }
    return total;
}

function solve(a, b) {
    var sumHealths = sum(a);
    var sumDebuffs = sum(b);
    var maxDebuff = Math.max.apply(null, b);

    cl(sumHealths + sumDebuffs - maxDebuff);
}

function main() {
    const numOfCases = rlsn();

    for (let testCase = 0; testCase < numOfCases; testCase++) {
        const num = rlsn();
        const l1 = rlarrn();
        const l2 = rlarrn();

        solve(l1, l2);
    }
}

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

let inStr = '';
let curLine = 0;
const cl = console.log;

process.stdin.on('data', function(inStdin) {inStr += inStdin;});
process.stdin.on('end', function() {inStr = inStr.split('\n');main();});

function readline() {return inStr[curLine++].replace(/\s+$/g, '');}
function rlsn() {return Number(readline());}
function rlarrstr() {return readline().split(' ');}
function rlarrn() {return rlarrstr().map(Number);}
function makeFreqMap(str) {const m={};for (let char of str) m[char]=m[char]+1||1;return m;}

"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 arr = iInpArr();
    let spell = iInpArr();
    let sum = arr.reduce((acc, cur) => acc + cur, 0);
    spell.sort((a, b) => b - a);
    let ans = 0;
    for (let i = 1; i < n; i++) ans += spell[i];
    console.log(sum + ans);
  }
};
solve();

const fs = require("fs");

const input = fs.readFileSync(0, "utf8").trim().split("\n");

const testCases = [];
let T;

function parseInput() {
  T = parseInt(input[0]);
  let index = 0;

  for (let i = 0; i < T; i++) {
    index++;
    const n = parseInt(input[index]);
    index++;
    const a = input[index].split(" ").map((item) => parseInt(item));
    index++;
    const b = input[index].split(" ").map((item) => parseInt(item));
    const testCase = {
      n,
      a,
      b,
    };

    testCases.push(testCase);
  }
}

function solution(testCase) {
  const { n, a, b } = testCase;

  let result = 0;
  let maxi = 0;
  for (let i = 0; i < n; i++) {
    result += a[i] + b[i];
    if (b[i] > maxi) maxi = b[i];
  }
  result -= maxi;
  console.log(result);
}

parseInput();

testCases.forEach(solution);

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

// your code goes here

// declare global variables
var input_stdin = "";
var lines = "";
var input_currentline = 0;

// standard input is stored into input_stdin
process.stdin.on('data', function (data) {
    input_stdin += data;
});

// standard input is done and stored into an array
process.stdin.on('end', function () {
    lines = input_stdin.split("\n");
    start();
});

function start(){
	const T = parseInt(lines[0])
	let line = 1
	for(let t = 1; t <= T; t++) {
	    const n = parseInt(lines[line++].trim().split(' ')[0], 10)
	    let result = 0;
	    let max = 0;
	    lines[line++].trim().split(' ').map(x => {
	        const a = parseInt(x, 10)
	        result += a;
	    })
	    lines[line++].trim().split(' ').map(x => {
	        const b = parseInt(x, 10)
	        result += b;
	        if (max < b)
	            max = b
	   })
	    console.log(result - max)
	}
}

/*
** Template
*/

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

let inputString = "";
let currentLine = 0;

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

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

    main();
});

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

// Driver Function Starts //
const main = () => {
    console.clear()
    let t = parseInt(readline())
    while (t--) {
        let n = parseInt(readline())
        let monsters = readline().split(' ').map( Number )
        let spells   = readline().split(' ').map( Number )

        // let res = parseInt(readline())
        // console.log(res , solve(n, monsters, spells))
        console.log(solve(n, monsters, spells))
    }
}
// Driver Function Ends //

// MAIN LOGIC
const solve = (n, monsters, spells) => {
    if ( n === 1 ) return monsters[0]

    let i = -1, totalTime = 0, maxSpell = Number.MIN_SAFE_INTEGER
    while( ++i < n ){
        totalTime += monsters[i] + spells[i]
        maxSpell = Math.max( maxSpell, spells[i] )
    }

    return totalTime - maxSpell
}

var readline = require('readline');
var inputString = [], currentLine = 0;
process.stdin.resume();
process.stdin.setEncoding('utf-8');
var rl = readline.createInterface(process.stdin);
rl.on('line', line => { inputString.push(line) });
process.stdin.on('end', () => {  main()  });

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

function main() {
    const t = +readLine();
    for(let i = 0; i < t; i++){
        const n = +readLine();
        const a = readLine().split(' ').map(p => +p);
        const b = readLine().split(' ').map(p => +p);
        let result = myFunc(n, a, b);
        console.log(result);
    }
}

function myFunc(n, a, b){

    let sumA = 0;
    let sumB = 0;
    let maxB = 0;

    for(let i = 0; i < n; i++){
        sumA += a[i];
        sumB += b[i];
        if(b[i] > maxB) maxB = b[i];
    }

    return sumA + sumB - maxB;

}

var numOfCases = Number(readline());

for (var testCase = 0; testCase < numOfCases; testCase++) {
    var n = Number(readline()); // num of monsters
    var a = readline().split(' ').map(Number); // array of healthpools
    var b = readline().split(' ').map(Number); // array of debuffs

    var seconds = process(a, b);
    print(seconds);
}

function sum(arr) {
    var total = 0;
    for (var i = 0; i < arr.length; i++) {
        total += arr[i];
    }
    return total;
}

function process(a, b) {
    var sumHealths = sum(a);
    var sumDebuffs = sum(b);
    var maxDebuff = Math.max.apply(null, b);

    return sumHealths + sumDebuffs - maxDebuff;
}

var numOfCases = Number(readline());

for (var testCase = 0; testCase < numOfCases; testCase++) {
    var n = Number(readline()); // num of monsters
    var a = readline().split(' ').map(Number); // array of healthpools
    var b = readline().split(' ').map(Number); // array of debuffs

    var seconds = process(a, b);
    print(seconds);
}

function process(a, b) {
    var result = a.reduce((acc, h) => acc + h, 0);
    var resultB = b.reduce((acc, h) => acc + h, 0);
    var maxB = Math.max(...b);

    return result + resultB - maxB;
}

/*
* auther yeling
*
*
*/
'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(str) {
    console.log(str);
}

// const { readline, print, testOutput } = require('@ip-algorithmics/codeforces-io');
// main();
// testOutput();

function begin2(n, h, b) {
    let blist = b.map((value, index) => [value, index]);
    blist.sort((a,b) => { return a[0] - b[0]});
    //print(blist.join(' '));
    let used = new Array(n).fill(false);
    let sum = 0;
    for(let i = 0; i < n; i++) {
        used[blist[i][1]] = true;
        sum += h[blist[i][1]];
        let next = blist[i][1] + 1;
        while(next < n) {
            if(used[next] == false) {
                h[next] += blist[i][0];
                break;
            }
            next++;
        }
        let pre = blist[i][1] - 1;
        while(pre >= 0) {
            if(used[pre] == false) {
                h[pre] += blist[i][0];
                break;
            }
            pre--;
        }
    }
    print(sum);
}

function begin(n, h, b) {
    let sum = 0;
    let used = new Array(n).fill(false);
    let index = 0;
    while(index < n) {
        let min = Number.MAX_SAFE_INTEGER;
        let minPos = -1;
        let first = -1, last = n - 1;
        for(let i = 0; i < n; i++) {
            if(used[i] == false) {
                if(first == -1) {
                    first = i;
                }
                if(b[i] < min) {
                    min = b[i];
                    minPos = i;
                }
                last = i;
            }
        }
        //
        let choose = -1;
        if( 2 * min < b[first] && 2 * min < b[last]) {
            //choose min
            choose = minPos;
        } else if(b[first] < b[last]) {
            //choose first
            choose = first;
        } else {
            //choose last
            choose = last;
        }
        used[choose] = true;
        sum += h[choose];
        let next = choose + 1;
        while(next < n) {
            if(used[next] == false) {
                h[next] += b[choose];
                break;
            }
            next++;
        }
        let pre = choose - 1;
        while(pre >= 0) {
            if(used[pre] == false) {
                h[pre] += b[choose];
                break;
            }
            pre--;
        }
        index++;
    }
    print(sum);

}
function main() {
    var caseNum = parseInt(readline(), 10);
    for (var i = 0; i < caseNum; i++) {
        var n = parseInt(readline(), 10);
        var h = readline()
            .trim()
            .split(' ')
            .map((y) => parseInt(y, 10));
        var b = readline()
            .trim()
            .split(' ')
            .map((y) => parseInt(y, 10));
        begin(n, h, b);
    }
}

/*
* auther yeling
*
*
*/
'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(str) {
    console.log(str);
}

// const { readline, print, testOutput } = require('@ip-algorithmics/codeforces-io');
// main();
// testOutput();

function begin2(n, h, b) {
    let blist = b.map((value, index) => [value, index]);
    blist.sort((a,b) => { return a[0] - b[0]});
    //print(blist.join(' '));
    let used = new Array(n).fill(false);
    let sum = 0;
    for(let i = 0; i < n; i++) {
        used[blist[i][1]] = true;
        sum += h[blist[i][1]];
        let next = blist[i][1] + 1;
        while(next < n) {
            if(used[next] == false) {
                h[next] += blist[i][0];
                break;
            }
            next++;
        }
        let pre = blist[i][1] - 1;
        while(pre >= 0) {
            if(used[pre] == false) {
                h[pre] += blist[i][0];
                break;
            }
            pre--;
        }
    }
    print(sum);
}

function begin(n, h, b) {
    let sum = 0;
    let used = new Array(n).fill(false);
    let index = 0;
    while(index < n) {
        let min = Number.MAX_SAFE_INTEGER;
        let minPos = -1;
        let first = -1, last = n - 1;
        for(let i = 0; i < n; i++) {
            if(used[i] == false) {
                if(first == -1) {
                    first = i;
                }
                if(b[i] < min) {
                    min = b[i];
                    minPos = i;
                }
                last = i;
            }
        }
        //
        let choose = -1;
        if( 2 * min < b[first] && 2 * min < b[last]) {
            //choose min
            choose = minPos;
        } else if(b[first] < b[last]) {
            //choose first
            choose = first;
        } else {
            //choose last
            choose = last;
        }
        //left 2 select min h
        if(first + 1 == last) {
            if(h[first] < h[last]) {
                choose = first;
            } else {
                choose = last;
            }
        }

        used[choose] = true;
        sum += h[choose];
        let next = choose + 1;
        while(next < n) {
            if(used[next] == false) {
                h[next] += b[choose];
                break;
            }
            next++;
        }
        let pre = choose - 1;
        while(pre >= 0) {
            if(used[pre] == false) {
                h[pre] += b[choose];
                break;
            }
            pre--;
        }
        index++;
    }
    print(sum);

}
function main() {
    var caseNum = parseInt(readline(), 10);
    for (var i = 0; i < caseNum; i++) {
        var n = parseInt(readline(), 10);
        var h = readline()
            .trim()
            .split(' ')
            .map((y) => parseInt(y, 10));
        var b = readline()
            .trim()
            .split(' ')
            .map((y) => parseInt(y, 10));
        begin(n, h, b);
    }
}

/*
* auther yeling
*
*
*/
'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(str) {
    console.log(str);
}

// const { readline, print, testOutput } = require('@ip-algorithmics/codeforces-io');
// main();
// testOutput();

function begin(n, h, b) {
    let blist = b.map((value, index) => [value, index]);
    blist.sort((a,b) => { return a[0] - b[0]});
    //print(blist.join(' '));
    let used = new Array(n).fill(false);
    let sum = 0;
    for(let i = 0; i < n; i++) {
        used[blist[i][1]] = true;
        sum += h[blist[i][1]];
        let next = blist[i][1] + 1;
        while(next < n) {
            if(used[next] == false) {
                h[next] += blist[i][0];
                break;
            }
            next++;
        }
        let pre = blist[i][1] - 1;
        while(pre >= 0) {
            if(used[pre] == false) {
                h[pre] += blist[i][0];
                break;
            }
            pre--;
        }
    }
    print(sum);
}

function main() {
    var caseNum = parseInt(readline(), 10);
    for (var i = 0; i < caseNum; i++) {
        var n = parseInt(readline(), 10);
        var h = readline()
            .trim()
            .split(' ')
            .map((y) => parseInt(y, 10));
        var b = readline()
            .trim()
            .split(' ')
            .map((y) => parseInt(y, 10));
        begin(n, h, b);
    }
}

'use strict';

var fs = require('fs');

function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }

var fs__default = /*#__PURE__*/_interopDefaultLegacy(fs);

function solve(read) {
  const [rn, rb, rns, re, rbs] = convertInput(read);
  const n = rn(),
        a = rns();
  a.sort((a, b) => b - a);
  const check = k => {
    let ans = 0;
    for (let l = 0, r = n - 1; l <= r; l++, r--) {
      while (l <= r && a[l] > k) l++;
      if (l <= r && a[l] <= k) ans++;
    }
    return ans >= k;
  };
  let l = 0,
      r = n;
  while (l < r) {
    const m = l + r + 1 >> 1;
    if (check(m)) {
      l = m;
    } else {
      r = m - 1;
    }
  }
  return l;
}
function convertInput(read) {
  const rn = () => Number(read());
  const rb = () => BigInt(read());
  const rns = () => read().split(/\s+/).map(Number);
  const re = () => read().split(/\s+/).map(s => Number(s) - 1);
  const rbs = () => read().split(/\s+/).map(BigInt);
  return [rn, rb, rns, re, rbs];
}
function main(r) {
  try {
    let t = Number(r());
    let res = new Array(t);
    let limit = 0;
    for (let i = 0; i < t; i++) {
      var _solve;
      const s = (_solve = solve(r)) !== null && _solve !== void 0 ? _solve : '';
      if (t < limit) {
        process.stdout.write(s.toString());
        process.stdout.write('\n');
      } else {
        res[i] = s;
      }
    }
    if (t >= limit) {
      return res.join('\n');
    } else {
      return '';
    }
  } catch (error) {
    console.log(error);
  }
}

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

var numOfCases = Number(readline());

for (var testCase = 0; testCase < numOfCases; testCase++) {
    var n = Number(readline()); // num of monsters
    var a = readline().split(' ').map(Number); // array of healthpools
    var b = readline().split(' ').map(Number); // array of debuffs

    var seconds = process(a, b);
    print(seconds);
}

function processCopy(item, i) {
    return i === 0 || i === b.length - 1 ? item : item * 2;
}

function process(a, b) {
    var result = a.reduce((acc, h) => acc + h, 0);

    while (b.length) {
        var copy = Object.assign([], b);
        copy = copy.map(processCopy);

        var indexOfLeast = copy.indexOf(Math.min(...copy));

        if (b.length > 1) {
            result += copy[indexOfLeast];
        }
        b.splice(indexOfLeast, 1);
    }

    return result;
}


Little Petya very much likes gifts. Recently he has received a new laptop as a New Year gift from his mother. He immediately decided to give it to somebody else as what can be more pleasant than giving somebody gifts. And on this occasion he organized a New Year party at his place and invited n his friends there.If there's one thing Petya likes more that receiving gifts, that's watching others giving gifts to somebody else. Thus, he safely hid the laptop until the next New Year and made up his mind to watch his friends exchanging gifts while he does not participate in the process. He numbered all his friends with integers from 1 to n. Petya remembered that a friend number i gave a gift to a friend number pi. He also remembered that each of his friends received exactly one gift.Now Petya wants to know for each friend i the number of a friend who has given him a gift.

The first line contains one integer n (1 ≤ n ≤ 100) — the quantity of friends Petya invited to the party. The second line contains n space-separated integers: the i-th number is pi — the number of a friend who gave a gift to friend number i. It is guaranteed that each friend received exactly one gift. It is possible that some friends do not share Petya's ideas of giving gifts to somebody else. Those friends gave the gifts to themselves.

Print n space-separated integers: the i-th number should equal the number of the friend who gave a gift to friend number i.

var total = parseInt(readline());
var vals = readline().split(" ").map(Number);

var ans = [];

for (var i = 0; i < vals.length; i++) {
    ans[vals[i] - 1] = i + 1;
}

print(ans.join(" "));

readline();
n = readline().split(' ');
var f = []
for(i= 0 ; i < n.length ; i++)
{ f[parseInt(n[i])] = i + 1;}
print(f.join(' '))

//var input = "4\n2 3 4 1";
//var index = 0;
//
//function readline(){
//    var data = input.split('\n');
//    if(index < data.length)
//        return data[index++];
//}
//
//function print(output){
//    console.log(output);
//}

function main(){
    readline();
    var arr = readline().split(' ');
    var ans = new Array(arr.length + 1);
    var str = "";
    for(var i = 0; i < arr.length; i++)
        ans[arr[i]] = i + 1;
    for(var i = 1; i < ans.length; i++)
        str += ans[i] + " ";
    print(str);
}
main();

const readline = require('readline');
let inputs = [];
const rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
})
rl.on('line', lineInput => {
    inputs.push(lineInput)
})

rl.on('close', () => {
	const n = inputs[0].split(' ').map(function (a) { return parseInt(a); });
    const k = inputs[1].split(' ').map(function (a) { return parseInt(a); });
    console.log(solution(n, k));

})

// End of interface

const solution = (n, presentsArray) => {
	let resArray = [];
	for (let j = 1; j<=n; j++){
		resArray.push(presentsArray.indexOf(j) + 1);
	};
	return resArray.join(' ');
};

let stdin = process.stdin;
stdin.setEncoding('utf8');
stdin.on('data', function (data) {
    let input = data.split('\n');
    let n = input[0].split(' ').map(function (a) { return parseInt(a); });
    let k = input[1].split(' ').map(function (a) { return parseInt(a); });
    let result = solution(n, k);
    console.log(result);
});

// End of interface

const solution = (n, presentsArray) => {
	let res = '';
	let presentsArrayOfObjects = [];
	for (let j = 0; j<n; j++){
		presentsArrayOfObjects.push({p:presentsArray[j], i:j+1})
	}
	let presentsAOOsortedByP = 	presentsArrayOfObjects.sort(function(obj1, obj2){ return obj1.p - obj2.p})
	let resArray =[];
	for (let k =0; k<n; k++){
		resArray.push(presentsAOOsortedByP[k].i)
	}
	res = resArray.join(' ');
	return res;
};

const readline = require('readline');

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

let friendCount, friendNums = [];

rl.on('line', n => {
  if (!friendCount) { friendCount = n } else {
    n = n.split(' ').map(Number);
    let min = Math.min(...n);
    let max = Math.max(...n);
    for (min; min <= max; min++) {
      friendNums.push(n.indexOf(min) + 1);
    }
    console.log(...friendNums);
    rl.close();
  }
});

function main() {
    // write code here:
    var n = Number(stdin[0]);
    var arr=stdin[1].split(' ').map(Number);
    var obj={};
    var newArr=[];
    for(let i=0;i<n;i++){
        obj[arr[i]]=i+1;
    }
    for(var key in obj){
        newArr.push(obj[key]);
    }
    console.log(newArr.join(' '));
}

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

function main() {
    // write code here:
    var n = Number(stdin[0]);
    var arr=stdin[1].split(' ').map(Number);
    var newArr=[];
    for(let i=0;i<n;i++){
        newArr.push(arr.indexOf(i+1)+1);
    }
    console.log(newArr.join(' '));
}

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

//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();
  var list = nextIntArray();
  var output = new Array(N);
  for(var i = 0; i < N; i++){
    output[list[i] - 1] = i + 1;
  }
  myout(myconv(output, 8));
}

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 n = Number(readLine());
  const a = readLine().split(' ').map(_a => Number(_a));
  const b = [];
  a.forEach((_a, i) => b[_a - 1] = i + 1);
  console.log(b.join(' '));
}

const readline = require('readline');

let inputs = [];

// Create readline Interface
const rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
})

// Read Inputs
rl.on('line', lineInput => {
    inputs.push(lineInput)
})

rl.on('close', () => {

    const friends = inputs[1].split(' ');
    let result = [];

    for (let i = 0; i < friends.length; i++) {
        const position = friends.indexOf((i + 1).toString());
        result[i] = position + 1;
    }

    console.log(result.join(' '))

})

'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
  const n = +readline();
  const p = readline().split(' ').map(x => parseInt(x));
  const m = new Map();
  for (let i = 0; i < n; i++) {
    m.set(p[i], i + 1);
  }
  const a = [];
  for (let i = 0; i < n; i++) {
    a.push(m.get(i + 1));
  }
  print(a.join(' '));
}

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

rl.on('line', (d) => {
  if (counter === 0) {
    counter++;
    return;
  }

  const arr = d.split(' ').map(Number);
  const arr2 = [];

  for (let i = 0; i < arr.length; i++) {
    for (let j = 0; j < arr.length; j++) {
      if (arr[j] == i + 1) {
        arr2.push(j + 1);
      }
    }
  }

  console.log(arr2.join(' '));

  counter++;
});

'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 readint() {
    let line = readline().split(' ').map(function(num) {
        return parseInt(num);
    });
    return line;
}

function readfloat() {
    let line = readline().split(' ').map(function(num) {
        return parseFloat(num);
    });
    return line;
}

function print(x) {
    console.log(x);
}

function write(x) {
    process.stdout.write(x);
}
function min(a,b) {
    if(a > b) return b;
    else return a;
}
function main() {
        let n  = parseInt(readline());
        let p = readint();
        let mynew = [];
        p.forEach((v, k) => {
            mynew[v - 1] = k + 1;
        });
        mynew.forEach((v) => {
            write(v + " ");
        });
}

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

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

readLine.on('close', () => {
  const friends = input[1].split(' ').map(x => parseInt(x));
  const answer = [];

  friends.forEach((x, i) => {
    answer[x-1] = i+1;
  });

  console.log(answer.join(' '));
});

const readline = require('readline');
let inputs = [];
const rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
})
rl.on('line', lineInput => {
    inputs.push(lineInput)
})
rl.on('close', () => {
		const n = inputs[0].split(' ').map(function (a) { return parseInt(a); });
    const k = inputs[1].split(' ').map(function (a) { return parseInt(a); });
    console.log(solution(n, k));
})

const solution = (n, presentsArray) => {
	let resArray = [];
	for (let j = 1; j<=n; j++){
		resArray.push(presentsArray.indexOf(j) + 1);
	};
	return resArray.join(' ');
};

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

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

readline.on('close', () => {
    const ints = Array.from(input[1].split(' '), x => parseInt(x));
    const outs = [...ints];
    ints.forEach((v, i) => {
        outs[v - 1] = ints.indexOf(v) + 1;
    })

    console.log(outs.join(' '));
});

'use strict';

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

let inputString = '';
let currentLine = 0;

process.stdin.on('data', inputStdin => {
    // if(Array.isArray(inputString)) inputString = inputString.join('\n');
    inputString += inputStdin;
    // inputString = inputString.trim().split('\n').map(string => {
    //     return string.trim();
    // });

    // main();
});

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

    main();
});

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

function readAsInt(){
  return parseInt(readline());
}

function readAsIntList(){
  return readline().trim().split(' ').filter(i => i).map(i => parseInt(i));
}

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

function main() {
  let l = readAsInt();
  let list = readAsIntList();
  let result = [];
  for(let i = 1; i <= list.length; i++){
    result[list[i-1]-1] = i;
  }
  console.log(result.join(' '));
}

let fs = require("fs");

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

}

function doit(arr) {
    let tab = [];
    arr.forEach((data, index) => {
        tab[data - 1] = index + 1;
    });
    console.log(tab.join(" "));
}

// 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().split('\n');
    let frns = inputs[1].trim().split(' ');
    let auxArray = [];
    for (let i = 0; i < frns.length; i++) {
        auxArray[frns[i]] = i + 1;
    }

    return auxArray.join(' ').trim().toString();
}

const readline = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});
let input = [];
readline.on('line', line => {
  input.push(line);
});
process.stdin.on('end', () => {
let secondLine = input[1].split(' ');
const n = parseInt(input[0], 10);
secondLine = secondLine.map((el) => parseInt(el, 10));
let text = '';
for (let i = 1; i< n + 1; i++) {
  text += `${secondLine.indexOf(i) + 1} `
}
text = text.slice(0, text.length-1)
console.log(text);
});

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

const input = [];
readLine.on('line', line => input.push(line));
const gifts = () => {
        const a = input[1].split(' ').map(x => +x);
    const b = Array(a.length);
    let n = 1;
    for (const x of a) {
        b[x - 1] = n;
        n++;
    }
    console.log(b.join(' '));
};
readLine.on('close', gifts);

'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());
    let arr = readLine()
        .split(' ')
        .map(value => parseInt(value));

    let ans = [];
    for (var i = 1; i <= n; i++) {
        ans.push(arr.indexOf(i) + 1);
    }
    console.log(ans.join(' '));
}

var n=+readline();
var p=readline().split(' ').map(function(v){return+v;});
var ans=[];
p.forEach(function(v,i){
	ans[v]=i+1;
});
ans.shift();
print(ans.join(' '));

var n=readline();
var str = readline().split(" ");
var m =[];
	for (var i=0; i<n; i++){
	   m[str[i]]= i+1;
	}

print(m.join(" "));

var n = parseInt(readline());
var input = readline().split(' ').map(x=>parseInt(x));
for(var i=1 ; i<=n ; i++){
    write((input.indexOf(i)+1) + ' ')
}
print();

step = readline();
var x = readline().split(" ");
var str = "";
for (i=1;i<=step;i++){
    str += (x.indexOf(i.toString())+1)+" ";
}
print(str);

    var n       = parseInt(readline()),
        friends = readline().split(' '),
        arr     = []
    friends.forEach(function(v, i) {
        friends[i] = parseInt(v);
    })

    for(var i = 1; i <= n; i++){

        arr.push(friends.indexOf(i) + 1);

    }

    arr = arr.join(' ');

    print(arr);

var n=+readline();
var p=readline().split(" ").map(function(x){return +x});
ans=[];
for(var i = 0; i<p.length; i++){
    ans[p[i]]=i+1;
}
print(ans.join(" "));

readline();
var nums = readNums();
var res = [];

for (var i = 0; i < nums.length; i++) {
    res[nums[i] - 1] = i + 1;
}
print(res.join(' '));

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

var num = readline(),
	giveGifts = readline().split(' ').map(c => c*1),
	takeObj = {},
	output = [];

giveGifts.forEach(function(current,index){
	takeObj[current] = index+1;
});

for(var i = 1; i <= num; i++){
	output.push(takeObj[i]);
}

print(output.join(' '));

var n = parseInt( readline() );
var inputNumbers = readline().split(' ');
var perm =[];
for(var k=1; k<=n; k++){
    var number = parseInt(inputNumbers[k-1]);
    perm[number] = k;
}
var result = "";
for(var j=1;j<=n;j++){
    result = result + perm[j]+" ";
}
print(result);

var number = Number(readline())
  var numbers = readline().split(' ').map(Number)

  var arr = new Array(number).fill(0)
  for(var i = 0; i < number; i++) {
    arr[numbers[i] - 1] = i + 1
  }

  print(arr.join(' '))

var firstLine = readline().toLowerCase();
var secondLine = readline().toLowerCase();

var obj = secondLine.split(' ').reduce((a, b, index) => (a[index + 1] = b, a), {});
var result = Object.keys(obj).sort(function(a, b){ return obj[a] - obj[b] }).join(' ');

print(result);

var n = readline().split(" ").map(function (x) { return parseInt(x); });
    var tmp = readline().split(" ").map(function (x) { return parseInt(x); });

    var res = []

    for (var i = 1; i <= n; i++) {
        res[tmp[i - 1]] = i;
    }

    res = res.slice(1).toString();
    // console.log(tmp[3], typeof tmp);
    res = res.replace()
    print(res.split(',').join(' '));

var input = parseInt(readline());
var gifts = readline().split(" ").map(x=>parseInt(x));
var output = [];
for(var i=1; i<=input; i++){
    output.push(gifts.indexOf(i)+1);
}
print(output.join(" "))

;(function () {

	readline();
	var p = readline().split(' ').map(function (x) { return +x; });
	var t = new Array(p.length);

	for (var i = 0; i < p.length; i++) t[p[i]] = 1 + i;

	print(t.join(' '));

}).call(this);

var n = parseInt(readline());
var a = readline().split(' ');
var s=new Array(n);

for(var i=0;i<n;i++){
        s[a[i]]=i+1;
}
for(var i=0;i<n;i++){
      print(s[i+1]);
}

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

function sol(line) {
    var input = line.split(" ");

    var n = input[0];

    var giveTo = readline().split(" ");
    var recieveFrom = [];

    for (var i = 0; i < n; i++) {
        recieveFrom[giveTo[i] - 1] = i + 1;
    }

    return recieveFrom.join(" ");
}

var result

var n = +readline()
var p = readline().split(' ').map(function (x) { return +x })
var ans = []
for (var i = 0; i < p.length; i++) {
ans[p[i]] = i + 1
}

ans.shift()
result = ans.join(' ')
print(result)

var n = readline();
var a = [];
var output=[];
var x;
a = readline()
.split(" ")
.map((a) => parseInt(a));
for(var i=1;i<=n;i++){
   x= a.indexOf(i)
   output.push(x+1)
}
print(output.join(" "))

readline();
var data = readline().split(' ').map(Number);
var result = [];

for(var i = 0; i < data.length; i++)
{
	result[data[i]] = i + 1; // +1 because the index of problem started from 1 instead of 0
}

result.splice(0, 1); // must be spliced since result started from index 1 instead of 0
print(result.join(' '));

'use strict';

(function() {
    let n = parseInt(readline());
    let a = readline().split(' ').map(value => parseInt(value));
    let b = new Array(n);

    a.map((value, index) => {
      b[value - 1] = index + 1;
    });

    write(b.join(' '));

})();

var n=readline();
var str = readline().split(" ");
var m =[];
	for (var i=0; i<n; i++){
	   m[str[i]]= i+1;
	}

print(m.join(" "));

var n = parseInt(readline());
var g = (function(a) { for (var i=0; i<a.length; i++) a[i] = parseInt(a[i]); return a; })(readline().split(" "));
var r = new Array(n);

for (var i=0; i<g.length; i++) {
	r[g[i]-1] = i+1;
}

print(r.join(" "));

var n = parseInt(readline());
var line = readline().split(' ');
var gifts = {};
for(var i = 0; i < n; i++)
    gifts[line[i] - 1] = i + 1;

    var o = ''
for(var key in gifts)
     o += gifts[key] + ' ';

     print(o.trim());

/* TEST CASE
input
4
2 3 4 1
output
4 1 2 3

input
3
1 3 2
output
1 3 2

input
2
1 2
output
1 2

*/
function main() {
	var n = parseInt(readline());
	var giveTo = new Array(n);
	var i;
	var splitted = readline().split(' ');
	for (i = 0; i < n; i++) {
		giveTo[parseInt(splitted[i]) - 1] = i + 1;
	}

	print(giveTo.join(' '));
}

main();

var n = Number(readline());
var s = readline().split(' ');
var friends = [];

for (var i = 0; i < s.length; i++) {
    friends[s[i]-1] = i+1;
}
print(friends.join(' '));

var n = parseInt(readline());
var a = readline().split(" ").map(function(x) { return parseInt(x); });
var res = new Array(n);
for (var i = 0; i < a.length; i++) {
	res[a[i]] = i + 1;
}
print (res.join(' '));

var computeFriends = function(arr)
    {
        var min = 1, arrres = [];
        var toNumArr = function(arr)
        {
            arr = arr.split(' ');
            for (var i = 0 ; i <= arr.length - 1; i++)
            {
                arr[i] = +arr[i];
            }
            return arr;
        }
        arr = toNumArr(arr);
        for (var counter = 0; counter <= arr.length - 1;counter++)
        {
            if (arr[counter] === min)
            {
                min++;
                arrres.push(counter + 1);
                counter = -1;
            }
        }
        return arrres.join(' ');
    }
var num = readline();
print(computeFriends(readline()));

var n = parseInt(readline(), 10)
    p = readline().split(' ').map(el => parseInt(el, 10)),
    result = [],
    p_i = 0;

for(var i=0; i<p.length; i++) {
    p_i = p[i]-1;
    result[p_i] = i + 1;
}

print(result.join(' '));

var n = parseInt(readline());
var array = readline().split(" ").map(function convert(value) {return +value; });
var reverse = [];

while(--n + 1)
	reverse[n] = array.indexOf(n + 1) + 1

print(reverse.join(" "));

n = readline().split(' ').map(Number);
data = readline().split(' ').map(Number);
result = []
for (i=0;i<data.length;i++){
	result[data[i]] = i+1;
}
result.splice(0,1);
print(result.join(' '));

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

    var input = readline().trim().split(' ').map(Number);

    var output = [];
    for (var i = 0; i < count; i++){
        output[input[i] - 1] = i + 1;
    }

    var result = "";
    for (var i = 0; i < count; i++){
        result += " " + output[i];
    }

    print(result.trim());

    return 0;
})();

var line1 = readline();
var n = parseInt(line1);

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

var str = '';

for(i=1;i<n+1;i++){
    for(j=0;j<n;j++){
	if(line2[j]===i){
	    str += (j+1);
	    str += ' ';
	    continue;
	}
    }
}

print(str);

var n = readline();
var d = readline().split(' ').map(Number);
var p = [];
for (i=0; i<d.length; i++){
    p[d[i]]= i+1;
}
write(p.join(' '));

var getNums = function () {
    return readline().split(' ').map(function (a) { return parseInt(a) });
};

//136A
//Local attempts - 2
var n = readline();
var data = getNums();
var res = [];
for(var i = 0; i < n; i++) {
    res[data[i]] = i + 1;
}
print(res.join(' '));

var n = +readline();
var gifts = readline().split(" ");
var result = [];
for(var i = 1; i <= n; ++i){
  gifts.forEach((gift,index) => {
    if(gift == i){
      result.push(index);
    }
  });
}
result.forEach((gift) => print(gift+1));

/*x=readline();
var a = [];
a.push(readline());
 a.push(readline());
 a.push(readline());
/*a = a.sort(function(a,b){
    return a-b;
});*/
/*
var max_stack = [];
//(a+b)*c
max_stack.push(parseInt((parseInt(a[0])+parseInt(a[1]))*parseInt(a[2])));
//a*(b+c)
max_stack.push(parseInt(parseInt(a[0])*((parseInt(a[1])+parseInt(a[2])))));
//a*b*c
max_stack.push(parseInt(parseInt(a[0])*parseInt(a[1])*parseInt(a[2])));

//a*b+c

max_stack.push(parseInt(parseInt(a[0])*parseInt(a[1])+parseInt(a[2])));
//a+b*c
max_stack.push(parseInt(parseInt(a[0])+parseInt(a[1])*parseInt(a[2])));
//a+b+c
max_stack.push(parseInt(parseInt(a[0])+parseInt(a[1])+parseInt(a[2])));

var maximus=-999;
for(i=0;i<max_stack.length;i++)
{
  if(maximus<max_stack[i])
  {
      maximus=max_stack;
  }
}
max_stack=max_stack.sort(function(a,b){
    return b-a;
});
print(max_stack[0]);

//for(i=0;i<a.length;i++)
//print(a[0]);

/*var k = readline();
var c = readline();
var len = 0;
for(i=c.length-1,j=0;i>=0,j<k.length;i--,j++)
{
   if(k[i]==c[j]){
       len++;
   }
}
 if(len==c.length)
 {
     print('YES')
 }
 else
 print('NO')*/

/*
var n = readline();
var m = readline().split(' ').map(Number);
var len = 1;
var max = 1;
for(i=0;i<m.length;i++)
{
   if(m[i]-m[i-1]>=0) {
    len++;
    max=Math.max(max,len);
   }
    else
    {
        len=1;
    }
}

print(max)
 */

 var n = readline();
 var d = readline().split(' ').map(Number);
 var c = [];
 for(i=0;i<d.length;i++)
 {
     c[d[i]]=i+1;
 }

 write(c.join(' '));

(function() {
    'use strict';
    let n = readline();
    let x = readline().split(' ').map(Number);
    let i = 0;
    var y = new Array(n);
    var z;
    for (i; i < n; i++) {
        z = x[i] - 1;
        y[z] = i + 1;
    }
    print(y.join(" "));
}());

const readline = require('readline');
let inputs = [];
const rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
})
rl.on('line', lineInput => {
    inputs.push(lineInput)
})

rl.on('close', () => {
	const n = inputs[0].split(' ').map(function (a) { return parseInt(a); });
    const k = inputs[1].split(' ');
    console.log(solution(n, k));

})

// End of interface

const solution = (n, presentsArray) => {
	let resArray = [];
	for (let j = 1; j<=n; j++){
		resArray.push(presentsArray.indexOf(j) + 1);
	};
	return resArray.join(' ');
};

const readline = require('readline');

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

let friendCount, friendNums = [];

rl.on('line', n => {
  if (!friendCount) { friendCount = n } else {
    n = n.split(' ').map(Number);
    let min = Math.min(...n);
    let max = Math.max(...n);
    for (min; min <= max; min++) {
      friendNums.push(n.indexOf(min) + 1);
    }
    console.log(friendNums);
    rl.close();
  }
});

const readline = require('readline');

let inputs = [];

// Create readline Interface
const rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
})

// Read Inputs
rl.on('line', lineInput => {
    inputs.push(lineInput)
})

rl.on('close', () => {

    const friends = inputs[1].split(' ');
    const nOfFriends = friends.length;
    let result = [];

    for (let i = 0; i < nOfFriends; i++) {
        const Pi = Math.floor(Math.random() * friends.length);
        const pickedOne = friends.splice(Pi, 1)[0];
        result.push(pickedOne);
    }

    console.log(...result);

})

const readline = require('readline');

let inputs = [];

// Create readline Interface
const rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
})

// Read Inputs
rl.on('line', lineInput => {
    inputs.push(lineInput)
})

rl.on('close', () => {

    const friends = inputs[0].split(' ');
    let result = [];

    for (let i = 0; i < friends.length; i++) {
        const position = friends.indexOf((i + 1).toString());
        result[i] = position + 1;
    }

    console.log(result.join(' '))

})

const readline = require('readline');

let inputs = [];

// Create readline Interface
const rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
})

// Read Inputs
rl.on('line', lineInput => {
    inputs.push(lineInput)
})

rl.on('close', () => {

    const friends = inputs[0].split(' ');
    const nOfFriends = friends.length;
    let result = [];

    for (let i = 0; i < nOfFriends; i++) {
        const Pi = Math.floor(Math.random() * friends.length);
        const pickedOne = friends.splice(Pi, 1)[0];
        result.push(pickedOne);
    }

    console.log(...result);

})

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

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

readline.on('close', () => {
    const ints = Array.from(input[1].split(' '), x => parseInt(x));
    const outs = [...ints];
    ints.forEach((v, i) => {
        console.log(v);
        outs[v - 1] = ints.indexOf(v) + 1;
    })

    console.log(outs);
});

'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());
    let arr = readLine()
        .split(' ')
        .map(value => parseInt(value));

    let ans = [];
    for (var i = 1; i <= n; i++) {
        ans.push(arr.indexOf(i) + 1);
    }
    console.log(ans);
}

var n=+readline();
var p=readline().split(' ').map(function(v){return+v;});
var ans=[];
p.forEach(function(i,v){
	ans[v]=i+1;
});
ans.shift();
print(ans.join(' '));

step = readline();
var x = readline().replace(/ /g,"");
var str = "";
for (i=1;i<=step;i++){
    str += (x.indexOf(i)+1)+" "
}
print(str)

step = readline();
var x = readline().replace(/ /g,"");
var str = "";
for (i=1;i<=step;i++){
    str += ((x.indexOf(i))+1)+" "
}
print(str)

var n=+readline();
var p=readline().split(" ").map(function(x){return +x});
ans = [];
for(var i = 0; i<p.length; i++){
    ans[p[i]] = i + 1;
}
print(ans.join());

var computeFriends = function(arr)
    {
        var min = 1, arrres = [];
        var toNumArr = function(arr)
        {
            arr = arr.split(' ');
            for (var i = 0 ; i <= arr.length - 1; i++)
            {
                arr[i] = +arr[i];
            }
            return arr;
        }
        arr = toNumArr(arr);
        for (var counter = 0; counter <= arr.length - 1;counter++)
        {
            if (arr[counter] === min)
            {
                min++;
                arrres.push(counter);
                counter = 0;
            }
        }
        return arrres.join(' ');
    }
var num = readline();
print(computeFriends(readline()));

var n = parseInt(readline());
var array = readline().split(" ").map(function convert(value) {return +value; });
var reverse = [];

while(--n + 1)
	reverse[n] = array.indexOf(n + 1) + 1

print(reverse.toString(" "));

 var a = parseInt(readline()),
        b = parseInt(readline()),
        c = parseInt(readline());
    if ((a !== 1) && (b !== 1) && (c !== 1)) {
        print(a * b * c);
    } else if ((a === 1) && (b === 1) && (c === 1)) {
        print(a + b + c);
    } else if ((a === 1) && (c === 1)) {
        print(a + b + c);
    } else if (a === 1) {
        print((a + b) * c);
    } else if (c === 1) {
        print(a * (b + c));
    } else {
        if (a > c) {
            print(a * (b + c));
        } else {
            print((a + b) * c);
        }
    }

var n = +readline();
var gifts = [];
var result = [];
for(var i = 0; i < n; ++i){
  gifts.push(+readline());
}
for(var i = 1; i <= n; ++i){
  gifts.forEach((gift) => {
    print(gift);
    if(gift === i){
      result.push(gift);
    }
  });
}
result.forEach((gift) => print(gift));

var n = +readline();
var gifts = readline().split(" ");
var result = [];
for(var i = 1; i <= n; ++i){
  gifts.forEach((gift) => {
    if(gift == i){
      result.push(gift);
    }
  });
}
result.forEach((gift) => print(gift));

var n = +readline();
var gifts = [];
var result = [];
for(var i = 0; i < n; ++i){
  var a = readline();
  gifts.push(a);
}
for(var i = 1; i <= n; ++i){
  gifts.forEach((gift) => {
    print(gift)
    if(gift === i){
      result.push(gift);
    }
  });
}
result.forEach((gift) => print(gift));

var n = +readline();
var gifts = readline().split(" ");
var result = [];
for(var i = 1; i <= n; ++i){
  gifts.forEach((gift,index) => {
    if(gift == i){
      result.push(index);
    }
  });
}
result.forEach((gift) => print(gift));

var n = +readline();
var gifts = [];
var result = [];
for(var i = 0; i < n; ++i){
  gifts.push(+readline());
}
for(var i = 1; i <= n; ++i){
  gifts.forEach((gift) => {
    if(gift === i){
      result.push(gift);
    }
  });
}
result.forEach((gift) => print(gift));

var n = +readline();
var gifts = [];
var result = [];
for(var i = 0; i < n; ++i){
  gifts.push(+readline());
}
for(var i = 1; i <= n; ++i){
  gifts.forEach((gift) => {
    if(gift == i){
      result.push(gift);
    }
  });
}
result.forEach((gift) => print(gift));

var n = readline();
var gifts = [];
var result = [];
for(var i = 0; i < n; ++i){
  gifts.push(+readline());
}
for(var i = 1; i <= n; ++i){
  gifts.forEach((gift) => {
    if(gift === i){
      result.push(gift);
    }
  });
}
result.forEach((gift) => print(gift));

var n = +readline();
var gifts = [];
var result = [];
for(var i = 0; i < n; ++i){
  gifts.push(+readline());
}
for(var i = 1; i <= n; ++i){
  gifts.forEach((gift) => {
    if(gift === i){
      result.push(gift);
    }
  });
}
print(result)
result.forEach((gift) => print(gift));

var n = +readline();
var gifts = readline().split(" ");
var result = [];
for(var i = 1; i <= n; ++i){
  gifts.forEach((gift) => {
    if(gift === i){
      result.push(gift);
    }
  });
}
result.forEach((gift) => print(gift));

(function() {
    'use strict';
    let n = readline();
    let x = readline().split(' ').map(Number);
    let i = 0;
    let y = Array;
    for (i; i < n; i++) {
        y[x[i]] = i + 1;
    }
    print(y);

}());


You are given two segments $$$[l_1; r_1]$$$ and $$$[l_2; r_2]$$$ on the $$$x$$$-axis. It is guaranteed that $$$l_1 < r_1$$$ and $$$l_2 < r_2$$$. Segments may intersect, overlap or even coincide with each other.    The example of two segments on the $$$x$$$-axis. Your problem is to find two integers $$$a$$$ and $$$b$$$ such that $$$l_1 \le a \le r_1$$$, $$$l_2 \le b \le r_2$$$ and $$$a \ne b$$$. In other words, you have to choose two distinct integer points in such a way that the first point belongs to the segment $$$[l_1; r_1]$$$ and the second one belongs to the segment $$$[l_2; r_2]$$$.It is guaranteed that the answer exists. If there are multiple answers, you can print any of them.You have to answer $$$q$$$ independent queries.

The first line of the input contains one integer $$$q$$$ ($$$1 \le q \le 500$$$) — the number of queries. Each of the next $$$q$$$ lines contains four integers $$$l_{1_i}, r_{1_i}, l_{2_i}$$$ and $$$r_{2_i}$$$ ($$$1 \le l_{1_i}, r_{1_i}, l_{2_i}, r_{2_i} \le 10^9, l_{1_i} < r_{1_i}, l_{2_i} < r_{2_i}$$$) — the ends of the segments in the $$$i$$$-th query.

Print $$$2q$$$ integers. For the $$$i$$$-th query print two integers $$$a_i$$$ and $$$b_i$$$ — such numbers that $$$l_{1_i} \le a_i \le r_{1_i}$$$, $$$l_{2_i} \le b_i \le r_{2_i}$$$ and $$$a_i \ne b_i$$$. Queries are numbered in order of the input. It is guaranteed that the answer exists. If there are multiple answers, you can print any.

function query(l1, r1, l2, r2) {
    if (l1 === l2) {
        return { a: l1, b: r2 };
    } else {
        return { a: l1, b: l2 };
    }
}

function getAnswer() {
    const fs = require('fs');
    const stdinBuffer = fs.readFileSync(0).toString('utf8');
    let [n, ...lines] = stdinBuffer.split('\n');

    lines = lines.slice(0, n);

    const queries = lines.map((line) => {
        const tokens = line.split(' ').map((num) => parseInt(num));

        return {
            l1: tokens[0],
            r1: tokens[1],
            l2: tokens[2],
            r2: tokens[3],
        }
    });

    return queries.map((q) => query(q.l1, q.r1, q.l2, q.r2));
}

const ans = getAnswer();

console.log(ans.map((x) => x.a + ' ' + x.b).join('\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 (obj instanceof Set) ? new Set(Array.from(obj)) : 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 tmp = nextIntArray();
    var L1 = tmp[0];
    var R1 = tmp[1];
    var L2 = tmp[2];
    var R2 = tmp[3];
    var a = L1;
    var b = L2;
    if(a == b){
      b++;
    }
    output[i] = a + " " + b;
  }
  myout(myconv(output, 9));
}

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

rl.on('line', (d) => {
  if (c === 0) {
    c++;
    return;
  }

  const [l1, r1, l2, r2] = d.split(' ').map(Number);

  if (l1 === r2) {
    console.log(l1, l2);
  }
  else {
    console.log(l1, r2);
  }
  c++;
});

var cnt = 0;
var ms = [];
var readliner = require('readline');
var rl = readliner.createInterface(process.stdin, process.stdout, null);
rl.on('line', function (cmd) {
                  //console.log('You just typed: '+cmd);
                  cnt++;
                  if (cnt > 1) ms.push(cmd);
              }).on('close', main);

function main() {
	for (var i=0; i<ms.length; i++) {
		var numbers = ms[i].split(' ');
		var l1 = parseInt(numbers[0]);
		var r1 = parseInt(numbers[1]);
		var l2 = parseInt(numbers[2]);
		var r2 = parseInt(numbers[3]);
		if (l1 !== l2)
			console.log(l1 + " " + l2);
		else if (r1 !== r2)
			console.log(r1 + " " + r2);
		else
			console.log(l1 + " " + r2);
	}
    //console.log(ans);
    //console.log(Q);

    //var x = 1.2345678;
    //console.log('x = ',Number(x).toFixed(5));

    process.exit(0);
};

//var lines = data.split(/\r?\n/);

var q=parseInt(readline());
for(var i=0;i<q;i++){
	var s=readline().split(" ");
	var l1=parseInt(s[0]),r1=parseInt(s[1]),l2=parseInt(s[2]),r2=parseInt(s[3]);
	if(l1===r2){r2--;print(l1+" "+r2);}
	else{print(l1+" "+r2);}
}

function ansa(n,arr){

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

      var flag = 0;
      var as = [];
      var bs = [];
      for(var j = arr[i][0] ; j <= arr[i][1] ; j++ ){
        for(var k = arr[i][2] ; k <= arr[i][3] ; k++ ){
          if(j !== k){
            print(j + ' ' + k);
            flag = 1;
            break;
        }
        }
        if(flag === 1)break;
      }

    }
}

var n = parseInt(readline())
var arr = []
for(var i = 0 ; i < n ; i++){
  var a = readline().split(" ");
  for(var j = 0 ; j < a.length ; j++) a[j] = parseInt(a[j]);
  arr[i] = a;
}

ansa(n,arr);
//ansa(5,[[1,2,1,2],[2,6,3,4],[2,4,1,3],[1,2,1,3],[1,4,5,8]])

var n = parseInt(readline());

for (var t =0;t<n;t++) {
  var ar = readline().split(' ').map((v)=>{return parseInt(v);});

   var l1 = ar[0], r1 = ar[1], l2 = ar[2], r2 = ar[3];

   var a = ar.filter(x=>(l1<= x && x<=r1)).sort((z,h)=>(h-z))
   var b = ar.filter(x=>(l2<= x && x<=r2)).sort()
   var pass = true
   for (var i=0;i<a.length && pass;i++) {

     for (var j=0;j<b.length && pass; j++) {
       if(a[i] != b[j]) {
          print(a[i], b[j]);
          pass = false;
       }
     }
   }
 //  var a=Math.max(ar[0], ar[2]), b=Math.min(ar[1], ar[3]);

//   print(a.join(','), b.join(','))

}

var t = +readline();

for (var i=0; i<t; i++){
	var tn = readline().split(' ').map(Number);
	if (tn[0] != tn[3])	print (tn[0], tn[3]);
	else print (tn[0], tn[2]);
}

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

for(var i=0; i<t; i++) {
    var ar = readline().split(' ')
    var arr = ar.map(Number)
    var a = arr[0]
    var b = arr[1]
    var c = arr[2]
    var d = arr[3]

    var n = a+1
    var m = c+1

    if(n == m) print(a +' '+ m)
    else print(n +' '+ m)

}

//

var t = parseInt(readline())

while(t--) {
    var arr = readline().split(' ')
    var a = parseInt(arr[0])
    var b = parseInt(arr[1])
    var c = parseInt(arr[2])
    var d = parseInt(arr[3])

    var n = a+1
    var m = c+1
    //print('n = '+ n +' '+'m = '+ m)
    if(n == m) print(a +' '+ m)
    else print(n +' '+ m)

}

var t = readline();
for(var i=0;i<t;i++){
var s = readline().split(" ");var r = [... new Set(s)];

var x1 = s[0].slice(0,s[0].length) + s[1].slice(0,s[1].length);// 1 2
var x2 = s[2].slice(0,s[2].length) + s[3].slice(0,s[3].length);// 2 1

if(r.length == 3){
if(x1.indexOf(r[0])){print(r[0] + " " + r[r.length-1])}else{print(r[1] + " " + r[r.length-1])}

}else{print(r[0] + " " + r[r.length-1]);}
}

	// this code is writen by ashraf
	var r = readline();

	for(var p=0;p<r;p++){
		var s = readline().split(" ").map(function(a){return (+a)});
        var x1 = s[0]+s[1];x1=Math.floor(x1/2);
        var x2 = s[2]+s[3];;x2=Math.floor(x2/2);
        if(x1===x2){x2+=1;}
       print(x1 + " " + x2)
	}

function query(l1, r1, l2, r2) {
    if (l1 === l2) {
        return { a: l1, b: r2 };
    } else {
        return { a: l1, b: l2 };
    }
}

function getAnswer() {
    const fs = require('fs');
    const stdinBuffer = fs.readFileSync(0).toString('utf8');
    const [__, ...lines] = stdinBuffer.split('\n');
    const queries = lines.map((line) => {
        const tokens = line.split(' ').map((num) => parseInt(num));

        return {
            l1: tokens[0],
            r1: tokens[1],
            l2: tokens[2],
            r2: tokens[3],
        }
    });

    return queries.map((q) => query(q.l1, q.r1, q.l2, q.r2));
}

const ans = getAnswer();

console.log(ans.map((x) => x.a + ' ' + x.b).join('\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 (obj instanceof Set) ? new Set(Array.from(obj)) : 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 tmp = nextIntArray();
    var L1 = tmp[0];
    var R1 = tmp[1];
    var L2 = tmp[2];
    var R2 = tmp[3];
    var a = Math.max(L1, L2);
    var b = Math.min(R1, R2);
    output[i] = a + " " + b;
  }
  myout(myconv(output, 9));
}

//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 (obj instanceof Set) ? new Set(Array.from(obj)) : 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 tmp = nextIntArray();
    var L1 = tmp[0];
    var R1 = tmp[1];
    var L2 = tmp[2];
    var R2 = tmp[3];
    var a = Math.min(L1, L2);
    var b = Math.max(R1, R2);
    output[i] = a + " " + b;
  }
  myout(myconv(output, 9));
}

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

rl.on('line', (d) => {
  if (c === 0) {
    c++;
    return;
  }

  const [l1, r1, l2, r2] = d.split(' ').map(Number);

  console.log(l1, r2);
  c++;
});

var a = +readline();

for(var i = 0; i < a; i++) {
    var l = readline().split(' ');
    print(l[0] + ' ' + l[3]);
}

function ansa(n,arr){

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

      var q1 = Math.max(arr[i][0],arr[i][2]);
      var q2 = Math.min(arr[i][1],arr[i][3]);
      print(q1,q2)
    }
}

var n = parseInt(readline())
var arr = []
for(var i = 0 ; i < n ; i++){
  var a = readline().split(" ");
  for(var j = 0 ; j < a.length ; j++) a[j] = parseInt(a[j]);
  arr[i] = a;
}
ansa(n,arr);

// var b = readline().split(' ');
// for(var i = 0 ; i < b.length ; i++) b[i] = parseInt(b[i]);

function ansa(n,arr){

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

      var q1 = Math.min(arr[i][0],arr[i][2]);
      var q2 = Math.max(arr[i][1],arr[i][3]);
      print(q1,q2)
    }
}

var n = parseInt(readline())
var arr = []
for(var i = 0 ; i < n ; i++){
  var a = readline().split(" ");
  for(var j = 0 ; j < a.length ; j++) a[j] = parseInt(a[j]);
  arr[i] = a;
}
ansa(n,arr);

// var b = readline().split(' ');
// for(var i = 0 ; i < b.length ; i++) b[i] = parseInt(b[i]);

function ansa(n,arr){

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

      var q1 = Math.max(arr[i][0],arr[i][2]);
      var q2 = Math.min(arr[i][1],arr[i][3]);
      print(q2,q1)
    }
}

var n = parseInt(readline())
var arr = []
for(var i = 0 ; i < n ; i++){
  var a = readline().split(" ");
  for(var j = 0 ; j < a.length ; j++) a[j] = parseInt(a[j]);
  arr[i] = a;
}
ansa(n,arr);

var n = parseInt(readline());

for (var i =0;i<n;i++) {
  var ar = readline().split(' ').map((v)=>{return parseInt(v);});

   var l1 = ar[0], r1 = ar[1], l2 = ar[2], r2 = ar[3];

   var a=Math.max(ar[0], ar[2]), b=Math.min(ar[1], ar[3]);
  if (  l1 > a || a > r1) {
   a = ar[1]-1;
  }

  if (  l2 > b || b > r2) {
   b = ar[3]-1;
  }
   print(a, b)

}

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

for(var i=0; i<n; i++) {
    var arr = readline().split(' ')
    var a = parseInt(arr[0])
    var b = parseInt(arr[1])
    var c = parseInt(arr[2])
    var d = parseInt(arr[3])

    var n = a+1
    var m = c+1

    if(n == m) print(a +' '+ n)
    else print(n +' '+ m)
}

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

for(var i=0; i<t; i++) {
    var arr = readline().split(' ')
    var a = arr[0]
    var b = arr[1]
    var c = arr[2]
    var d = arr[3]

    var n = a+1
    var m = c+1

    if(n == m) print(a +' '+ m)
    else print(n +' '+ m)

}

var n = parseInt(readline())

for(var i=0; i<n; i++) {
    var arr = readline().split(' ')
    var a = parseInt(arr[0])
    var b = parseInt(arr[1])
    var c = parseInt(arr[2])
    var d = parseInt(arr[3])

    var n = a+1
    var m = c+1

    if(n == m) write(a +' '+ m)
    else write(n +' '+ m)
}

var r = readline();for(var p=0;p<r;p++){
var s = readline().split(" ");
var r = [... new Set(s[0].slice(0,s[0].length)+s[1].slice(0,s[1].length))];
var n = [... new Set(s[2].slice(0,s[2].length)+s[3].slice(0,s[3].length))];
print(r[r.length-1] + " " + n[n.length-1]);

		}


A permutation — is a sequence of length $$$n$$$ integers from $$$1$$$ to $$$n$$$, in which all the numbers occur exactly once. For example, $$$[1]$$$, $$$[3, 5, 2, 1, 4]$$$, $$$[1, 3, 2]$$$ — permutations, and $$$[2, 3, 2]$$$, $$$[4, 3, 1]$$$, $$$[0]$$$ — no.Polycarp was recently gifted a permutation $$$a[1 \dots n]$$$ of length $$$n$$$. Polycarp likes trees more than permutations, so he wants to transform permutation $$$a$$$ into a rooted binary tree. He transforms an array of different integers into a tree as follows:   the maximum element of the array becomes the root of the tree;  all elements to the left of the maximum — form a left subtree (which is built according to the same rules but applied to the left part of the array), but if there are no elements to the left of the maximum, then the root has no left child;  all elements to the right of the maximum — form a right subtree (which is built according to the same rules but applied to the right side of the array), but if there are no elements to the right of the maximum, then the root has no right child. For example, if he builds a tree by permutation $$$a=[3, 5, 2, 1, 4]$$$, then the root will be the element $$$a_2=5$$$, and the left subtree will be the tree that will be built for the subarray $$$a[1 \dots 1] = [3]$$$, and the right one — for the subarray $$$a[3 \dots 5] = [2, 1, 4]$$$. As a result, the following tree will be built:     The tree corresponding to the permutation $$$a=[3, 5, 2, 1, 4]$$$. Another example: let the permutation be $$$a=[1, 3, 2, 7, 5, 6, 4]$$$. In this case, the tree looks like this:     The tree corresponding to the permutation $$$a=[1, 3, 2, 7, 5, 6, 4]$$$. Let us denote by $$$d_v$$$ the depth of the vertex $$$a_v$$$, that is, the number of edges on the path from the root to the vertex numbered $$$a_v$$$. Note that the root depth is zero. Given the permutation $$$a$$$, for each vertex, find the value of $$$d_v$$$.

The first line contains one integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. Then $$$t$$$ test cases follow. The first line of each test case contains an integer $$$n$$$ ($$$1 \le n \le 100$$$) — the length of the permutation. This is followed by $$$n$$$ numbers $$$a_1, a_2, \ldots, a_n$$$ — permutation $$$a$$$.

For each test case, output $$$n$$$ values — $$$d_1, d_2, \ldots, d_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 getValue() {
  return parseInt(readline());
}
let mod = BigInt(1e9 + 7);
class node {
  constructor(val, ind) {
    this.ind = ind;
    this.val = val;
    this.left = null;
    this.right = null;
  }
}
class Tree {
  constructor() {
    this.root = null;
  }
  push(val, ind) {
    const helper = (head) => {
      if (head === null) return new node(val, ind);
      else if (ind < head.ind) head.left = helper(head.left);
      else head.right = helper(head.right);
      return head;
    };
    this.root = helper(this.root);
  }
  find(ind) {
    let d = 0;
    const helper = (head, d) => {
      if (head.ind === ind) return d;
      else if (head.ind > ind) return helper(head.left, d + 1);
      else return helper(head.right, d + 1);
    };
    return helper(this.root, d);
  }
}
const solve = () => {
  let t = getValue();
  while (t--) {
    let n = getValue();
    let arr = iInpArr();
    for (let i = 0; i < n; i++) arr[i] = { val: arr[i], ind: i + 1 };
    arr.sort((a, b) => b.val - a.val);
    let tree = new Tree();
    for (let i = 0; i < n; i++) {
      tree.push(arr[i].val, arr[i].ind);
    }
    let res = "";
    for (let i = 1; i <= n; i++) {
      res += tree.find(i) + " ";
    }
    console.log(res);
  }
};
solve();

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

let i = 0;
let t = NaN;
const N = 101;
const matr = new Array(N);
for (let i = 0; i < N; i++) {
    matr[i] = new Array(N).fill(0);
}

rl.question('', v => {
    t = +v;
    input();
});

function input() {
    rl.question('', v => {
        const n = +v;

        rl.question('', v => {
            const arr = v.trim().split(' ').map(el => +el);
            main(n, arr);

            i++;
            if (i === t) {
                rl.close();
                return;
            }
            input();
        });
    });
}

function createTree(l, r, arr, darr, d = 0) {
    if (r < l) {
        return;
    }

    if (l === r) {
        darr[l] = d;
        return;
    }

    let m = l;
    for (let i = l + 1; i <= r; i++) {
        if (arr[i] > arr[m]) {
            m = i;
        }
    }

    darr[m] = d;
    createTree(l, m - 1, arr, darr, d + 1);
    createTree(m + 1, r, arr, darr, d + 1);
}

function main(n, arr) {
    const darr = new Array(n);
    createTree(0, n - 1, arr, darr);
    console.log(darr.join(' '));
}

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;

const top = s => s[s.length - 1];

function main () {
	let t = rn();
	while (t--) {
		let n = rna();
		let a = rna();

		a[-1] = a[n] = INF;
		let lmx = [], rmx = [];

		let st = [-1];
		for (let i = 0; i < n; i++) {
			while (a[top(st)] < a[i]) st.pop();
			lmx[i] = a[top(st)];
			st.push(i);
		}

		st = [n];
		for (let i = n - 1; i >= 0; i--) {
			while (a[top(st)] < a[i]) st.pop();
			rmx[i] = a[top(st)];
			st.push(i);
		}

		const inx = [];
		for (let i = 0; i < n; i++)
			inx[a[i]] = i;

		const dp = [];
		dp[n] = 0;
		for (let i = n - 1; i > 0; i--) {
			const prnt = Math.min(lmx[inx[i]], rmx[inx[i]]);
			dp[i] = dp[prnt] + 1;
		}

		let ans = [];
		for (i in dp)
			ans[inx[i]] = dp[i];

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

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

// Actual code...

function depth(target, arr, left, right) {
    let maximum = 0;
    let indexOfMax = 0;
    for (let i = left; i < right; i++) {
        if (arr[i] > maximum) {
            maximum = arr[i];
            indexOfMax = i;
        }
    }
    const indexOfTarget = arr.indexOf(target);
    if (target === maximum) {
        return 0;
    } else if (indexOfTarget < indexOfMax) {
        return 1 + depth(target, arr, left, indexOfMax);
    } else {
        return 1 + depth(target, arr, indexOfMax + 1, right);
    }
}

function main() {
    const numCases = parseInt(readline());
    for (let i = 0; i < numCases; i++) {
        const numTerms = parseInt(readline());
        const arr = readline().split(" ").map(str => parseInt(str));
        let result = "";
        for (let v = 0; v < numTerms; v++) {
            const d = depth(arr[v], arr, 0, arr.length);
            if (v != 0) result += " ";
            result += d;
        }
        console.log(result);
    }
}

let lines = require('fs').readFileSync(global.FILE_DESCRIPTOR || 0).toString().split('\n');
let index = 0;
const readline = () => lines[index++] || '';

let n = +readline();
for (let i = 0; i < n; i++) {
  {
    readline();
    let arr = readline().split(' ').map(i => +i);
    let res = {};
    function check(arr, depth = 0) {
      if (arr.length === 0) return;
      let max = Math.max(...arr);
      let index = arr.indexOf(max);
      res[max] = depth;
      check(arr.slice(0, index), depth+1)
      check(arr.slice(index + 1), depth+1)
    }
    check(arr)
    console.log(arr.map(num => res[num]).join(' '))
  }
}

'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 x = parseInt(readline())
        height = new Array(x).fill(0)
        var a = readline().split(' ').map((x, i) => {
            return parseInt(x)
        })

        dfs(a, 0, a.length, 0)
        console.log(height.join(' '))
    })

}

// [l,r)
function dfs(array, l, r, currentHeight) {
    var res = []
    var index = max(array, l, r)
    height[index] = currentHeight

    if (l < index) {
        dfs(array, l, index, currentHeight + 1)

    }
    if (r > index + 1) dfs(array, index + 1, r, currentHeight + 1)
}

function max(array, l, r) {
    var m = array[l]
    var mI = l
    for (var i = l; i < r; i++) {
        if (array[i] > m) {
            m = array[i]
            mI = i
        }
    }
    return mI
}

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

//Don't have to see. end------------------------------------------
function Main(){
	var t = nextInt();
	for(var i = 0; i < t; i++){
		var N = nextInt();
		var list = nextIntArray(N);
		var output = new Array(N).fill(-1);
		var stack = [{list : list, count : 0}];
		while(stack.length > 0){
			var now = stack.pop();
			var max = -1;
			var lastIndex = -1;
			for(var j = 0; j < now.list.length; j++){
				if(max < now.list[j]){
					max = now.list[j];
					lastIndex = j;
				}
			}
			var maxIndex = list.indexOf(max);
			output[maxIndex] = now.count;
			if(now.list.length == 1){
				continue;
			}
			var left = {list : [], count : now.count + 1};
			for(var j = 0; j < lastIndex; j++){
				left.list.push(now.list[j]);
			}
			if(left.list.length > 0){
				stack.push(left);
			}
			var right = {list : [], count : now.count + 1};
			for(var j = lastIndex + 1; j < now.list.length; j++){
				right.list.push(now.list[j]);
			}
			if(right.list.length > 0){
				stack.push(right);
			}
		}
		myout(myconv(output, 8));
	}
}

var row = readline().split(" ").map(function(x) { return parseInt(x); });
while(true) {
    var read = readline();
    if(read == undefined) break;
    var n = read.split(" ").map(function(x) { return parseInt(x); })[0];
    var arr = readline().split(" ").map(function(x) { return parseInt(x); });

    var result = [];
    result = createTree(arr, 0, n - 1, 0, result);

    var resultArr = [];
    for(var i = 0; i < n; i++) {
        resultArr.push(result[arr[i]]);
    }

    write(resultArr.join(" ") + "\n");
}

function createTree(arr, arrStart, arrEnd, level, result) {
    var max = 0;
    var index = 0;
    for(var i = arrStart; i <= arrEnd; i++) {
        index = arr[i] > max ? i : index;
        max = arr[i] > max ? arr[i] : max;
    }
    result[max] = level;
    level++;
    if(arrStart != arrEnd) {
        if(index - 1 >= arrStart)
            result = createTree(arr, arrStart, index - 1, level, result);
        if(index + 1 <= arrEnd)
            result = createTree(arr, index + 1, arrEnd, level, result);
    }

    return result;
}


Monocarp and Bicarp live in Berland, where every bus ticket consists of $$$n$$$ digits ($$$n$$$ is an even number). During the evening walk Monocarp and Bicarp found a ticket where some of the digits have been erased. The number of digits that have been erased is even.Monocarp and Bicarp have decided to play a game with this ticket. Monocarp hates happy tickets, while Bicarp collects them. A ticket is considered happy if the sum of the first $$$\frac{n}{2}$$$ digits of this ticket is equal to the sum of the last $$$\frac{n}{2}$$$ digits.Monocarp and Bicarp take turns (and Monocarp performs the first of them). During each turn, the current player must replace any erased digit with any digit from $$$0$$$ to $$$9$$$. The game ends when there are no erased digits in the ticket.If the ticket is happy after all erased digits are replaced with decimal digits, then Bicarp wins. Otherwise, Monocarp wins. You have to determine who will win if both players play optimally.

The first line contains one even integer $$$n$$$ $$$(2 \le n \le 2 \cdot 10^{5})$$$ — the number of digits in the ticket. The second line contains a string of $$$n$$$ digits and "?" characters — the ticket which Monocarp and Bicarp have found. If the $$$i$$$-th character is "?", then the $$$i$$$-th digit is erased. Note that there may be leading zeroes. The number of "?" characters is even.

If Monocarp wins, print "Monocarp" (without quotes). Otherwise print "Bicarp" (without quotes).

NoteSince there is no question mark in the ticket in the first example, the winner is determined before the game even starts, and it is Bicarp.In the second example, Bicarp also wins. After Monocarp chooses an erased digit and replaces it with a new one, Bicap can choose another position with an erased digit and replace it with the same digit, so the ticket is happy.

const n = Number(readline());
const s = Array.from(readline().substring(0, n), c => Number(c));

function stats(digits) {
  var sum = 0;
  var erased = 0;
  for (var digit of digits)
    if (Number.isNaN(digit)) erased++;
    else sum += digit;
  return [sum, erased];
}

const half = n * 0.5;
const l = stats(s.slice(0, half));
const r = stats(s.slice(half));
const diff = l[0] - r[0];
const le = l[1];
const re = r[1];
print((() => {
  var pe = (le + re) * 0.5;
  var cl = Math.min(le, pe);
  var cr = Math.min(re, pe);
  var nd = diff + cl * 9;
  if (nd < -(le - cl) * 9 || nd > cr * 9) return true;
  nd = diff - cr * 9;
  if (nd > (re - cr) * 9 || nd < -cl * 9) return true;
  return false;
})() ? "Monocarp" : "Bicarp");