Lena is the most economical girl in Moscow. So, when her dad asks her to buy some food for a trip to the country, she goes to the best store  — "PriceFixed". Here are some rules of that store:  The store has an infinite number of items of every product.  All products have the same price: $$$2$$$ rubles per item.  For every product $$$i$$$ there is a discount for experienced buyers: if you buy $$$b_i$$$ items of products (of any type, not necessarily type $$$i$$$), then for all future purchases of the $$$i$$$-th product there is a $$$50\%$$$ discount (so you can buy an item of the $$$i$$$-th product for $$$1$$$ ruble!). Lena needs to buy $$$n$$$ products: she must purchase at least $$$a_i$$$ items of the $$$i$$$-th product. Help Lena to calculate the minimum amount of money she needs to spend if she optimally chooses the order of purchasing. Note that if she wants, she can buy more items of some product than needed.

The first line contains a single integer $$$n$$$ ($$$1 \leq n \leq 100\,000$$$) — the number of products. Each of next $$$n$$$ lines contains a product description. Each description consists of two integers $$$a_i$$$ and $$$b_i$$$ ($$$1 \leq a_i \leq 10^{14}$$$, $$$1 \leq b_i \leq 10^{14}$$$) — the required number of the $$$i$$$-th product and how many products you need to buy to get the discount on the $$$i$$$-th product.  The sum of all $$$a_i$$$ does not exceed $$$10^{14}$$$.

Output the minimum sum that Lena needs to make all purchases.

NoteIn the first example, Lena can purchase the products in the following way:  one item of product $$$3$$$ for $$$2$$$ rubles,  one item of product $$$1$$$ for $$$2$$$ rubles,  one item of product $$$1$$$ for $$$2$$$ rubles,  one item of product $$$2$$$ for $$$1$$$ ruble (she can use the discount because $$$3$$$ items are already purchased),  one item of product $$$1$$$ for $$$1$$$ ruble (she can use the discount because $$$4$$$ items are already purchased). In total, she spends $$$8$$$ rubles. It can be proved that it is impossible to spend less.In the second example Lena can purchase the products in the following way:  one item of product $$$1$$$ for $$$2$$$ rubles,  two items of product $$$2$$$ for $$$2$$$ rubles for each,  one item of product $$$5$$$ for $$$2$$$ rubles,  one item of product $$$3$$$ for $$$1$$$ ruble,  two items of product $$$4$$$ for $$$1$$$ ruble for each,  one item of product $$$1$$$ for $$$1$$$ ruble. In total, she spends $$$12$$$ rubles.

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

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

function main () {
	const n = rn();
	const p = [];
	for (let i = 0; i < n; i++) {
		p[i] = rna();
	}

	p.sort((x, y) => x[1] - y[1]);

	let total = 0;
	for (const [a, b] of p) {
		total += a;
	}

	const regbuy = items => buy(items, 2);
	const disbuy = items => buy(items, 1);
	const buy = (items, price) => {
		bought += items;
		rem -= items;
		spent += items * price;
	}

	let bought = 0, rem = total, spent = 0, i = 0;
	while (rem) {
		let [must, should] = p[i++];
		should = Math.max(0, should - bought);
		if (should) {
			regbuy(Math.min(rem, should));
		}
		disbuy(Math.min(rem, must));
	}

	const ans = spent;
	console.log(ans);
}

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

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

function main () {
	const n = rn();
	const p = [];
	for (let i = 0; i < n; i++) {
		p[i] = rna();
	}

	p.sort((x, y) => x[1] - y[1]);

	let total = 0;
	for (const [a, b] of p) {
		total += a;
	}

	const regbuy = items => buy(items, 2);
	const disbuy = items => buy(items, 1);
	const buy = (items, price) => {
		bought += items;
		rem -= items;
		spent += items * price;
	}

	let bought = 0, rem = total, spent = 0, i = 0;
	while (rem) {
		let [cur, fordisc] = p[i++];
		fordisc = Math.max(0, fordisc - bought);

		if (fordisc == 0) {
			disbuy(Math.min(rem, cur));
		} else {
			regbuy(Math.min(rem, fordisc));
			disbuy(Math.min(rem, cur));
		}
	}

	const ans = spent;
	console.log(ans);
}

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

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

function main () {
	const n = rn();
	const p = [];
	for (let i = 0; i < n; i++) {
		p[i] = rna();
	}

	p.sort((x, y) => x[1] - y[1]);

	let total = 0;
	for (let i = 0; i < n; i++) {
		total += p[i][0];
	}

	let bought = 0, rem = total;
	let spent = 0;
	let i = 0;
	while (rem) {
		//console.log(p[i], {rem, bought, spent})
		const [need, minr] = p[i++];
		const reqfrd = Math.max(minr - bought, 0);

		if (reqfrd == 0) {
			const discbuy = Math.min(rem, need);
			buy(discbuy, 1);
		} else {
			const regbuy = Math.min(rem, reqfrd);
			buy(regbuy, 2);

			const discbuy = Math.min(rem, need);
			buy(discbuy, 1);
			//console.log({i, regbuy, discbuy})
		}
	}

	function buy (items, price) {
		bought += items;
		rem -= items;
		spent += items * price;
	}

	const ans = spent;
	console.log(ans);
}

var readline = require('readline');

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

function solve(n, arr) {
    arr.sort((a, b) => a[1] - b[1])

    let i = 0
    let j = arr.length - 1
    let all = 0
    let pay = 0
    while (i <= j) {
        const [total, limit] = arr[i]
        while (all < limit && j > i) {
            const able = arr[j][0]
            let cost
            if (all + able < limit) {
                cost = able
                arr[j][0] -= cost
                j--
            } else {
                cost = limit - all
                arr[j][0] -= cost
            }
            all += cost
            pay += 2 * cost
        }
// console.log(arr, pay, all)
        if (all < limit) {
            const f = Math.min(total, limit - all)
            pay += f * 2
            all += f
            arr[i][0] -= f
            break
        } else {
            pay += total
            all += total
            arr[i][0] = 0
            i++
        }
    }
    if (i >= n) return pay
    // i == j
    if (all >= arr[i][1]) {
        pay += arr[i][0]
    } else {
        pay += 2 * arr[i][0]
    }
    return pay
}

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
    Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
    o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
    if (mod && mod.__esModule) return mod;
    var result = {};
    if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
    __setModuleDefault(result, mod);
    return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
const fs = __importStar(require("fs"));
// import * as readline from 'readline'
// const rl = readline.createInterface({ input: process.stdin, output: process.stdout })
// const ask = (query: string) => new Promise<string>((resolve) => rl.question(query, resolve))
// // Don't forget `rl.close()`.
const INT = Math.floor;
Array.prototype.last = function () {
    return this.length === 0 ? undefined : this[this.length - 1];
};
Array.prototype.isEmpty = function () {
    return this.length === 0;
};
const less = (a, b) => (a == b ? 0 : a < b ? -1 : 1);
const greater = (a, b) => (a == b ? 0 : a < b ? 1 : -1);
const bigIntMax = (...args) => args.reduce((m, e) => (e > m ? e : m));
const bigIntMin = (...args) => args.reduce((m, e) => (e < m ? e : m));
const bigIntAbs = (arg) => (arg < 0 ? -arg : arg);
function read_stdin() {
    return fs.readFileSync(process.env.NODE_ENV === 'debug' ? stdin : process.stdin.fd, 'utf8');
}
class Input {
    constructor(str) {
        this.index = 0;
        this.inputs = (str ? str : read_stdin()).split(/\s+/);
    }
    number() {
        return Number(this.inputs[this.index++]);
    }
    numbers(n) {
        return this.inputs.slice(this.index, (this.index += n)).map(Number);
    }
    bigint() {
        return BigInt(this.inputs[this.index++]);
    }
    bigints(n) {
        return this.inputs.slice(this.index, (this.index += n)).map(BigInt);
    }
    word() {
        return this.inputs[this.index++];
    }
    words(n) {
        return this.inputs.slice(this.index, (this.index += n));
    }
}
function array(len, init) {
    return Array(len).fill(init);
}
function array2(h, w, init) {
    return array(h, 0).map(() => array(w, init));
}
function main() {
    const input = new Input();
    const N = input.number();
    const products = Array(N);
    for (let i = 0; i < N; i++) {
        const a = input.number();
        const b = input.number();
        products[i] = { a, b };
    }
    products.sort((x, y) => x.b - y.b);
    let head = 0;
    let tail = N - 1;
    let sum = 0;
    let count = 0;
    while (head <= tail) {
        // console.log({ head, tail })
        const p_head = products[head];
        let c = p_head.b - count;
        // console.log({ p_head, count, c })
        if (c > 0) {
            while (head <= tail) {
                // console.log({ head, tail, c })
                const p_tail = products[tail];
                if (p_tail.a > c) {
                    p_tail.a -= c;
                    count += c;
                    sum += 2 * c;
                    break;
                }
                else if (p_tail.a === c) {
                    p_tail.a -= c;
                    count += c;
                    sum += 2 * c;
                    tail--;
                    break;
                }
                else {
                    c -= p_tail.a;
                    count += p_tail.a;
                    sum += 2 * p_tail.a;
                    p_tail.a = 0;
                    tail--;
                }
            }
        }
        // console.log({ p_head })
        if (p_head.a > 0) {
            if (p_head.b <= count) {
                sum += p_head.a;
            }
            else {
                sum += 2 * p_head.a;
            }
            count += p_head.a;
        }
        head++;
    }
    console.log(sum);
}
main();
//# sourceMappingURL=aoj.js.map

function gcd(x, y) {
   if (y === 0) {
      return x;
   }
   return gcd(y, x % y);
}

function div(a, b) {
   return Math.floor(a / b);
}

function solve() {
   var n = Number(read());
   var arr = [];
   for (var i = 0; i < n; i++) {
      arr.push(readArray(BigInt));
   }
   arr.sort((a, b) => {
      if (a[1] > b[1]) {
         return 1;
      }
      if (a[1] < b[1]) {
         return -1;
      }
      return 0;
   });
   var counter = 0n;
   var ans = 0n;
   var l = 0;
   var r = n - 1;
   while (l <= r) {
      var la = arr[l][0];
      var lb = arr[l][1];
      var ra = arr[r][0];

      if (counter >= lb) {
         ans += la;
         counter += la;
         arr[l][0] = 0n;
         l++;
         continue;
      }

      var needForSale = lb - counter;
      if (needForSale >= ra) {
         ans += 2n * ra;
         counter += ra;
         arr[r][0] = 0n;
         r--;
         continue;
      }

      counter += needForSale;
      ans += 2n * needForSale;
      arr[r][0] -= needForSale;
   }
   write(ans);
   /*
   for (var i = 0; i < n; i++) {
      var a = arr[i][0];
      var b = arr[i][1];
      if (counter >= b) {
         counter += a;
         ans += a;
         continue;
      }
      var nextCounter = counter + a;
      if (nextCounter < b) {
         counter = nextCounter;
         ans += a * 2n;
         continue;
      }
      // counter < b <= nextCounter
      ans += (b - counter - 1n) * 2n + (nextCounter - b + 1n);
      counter = nextCounter;
   }
   write(ans);
   */
}

function init() {
   var T;
   T = 1;
   //T = Number(read());
   for (var t = 0; t < T; t++) {
      solve();
   }
}

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

function readArray(f) {
   return read().split(' ').map(f);
}

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

   var inTextName;
   var outTextName;

   var needWriteFile = false;

   var writeResult = '';
   if (process.argv.length === 5) {
      inTextName = process.argv[3];
      outTextName = process.argv[4];
   }

   if (inTextName) {
      fs.readFile(path.join(__dirname, inTextName), 'utf8', (err, data) => {
         MEMORY = data.split('\r\n');
         init();
         if (needWriteFile) {
            fs.writeFile(path.join(__dirname, outTextName), writeResult, (err) => {
               err ? console.error(err) : console.log('good')
            });
         }
      });
   } else {
      MEMORY = fs.readFileSync(0, 'utf-8').split('\r\n');
      init();
   }
} else {
   init();
}

function write(value) {
   if (needWriteFile) {
      writeResult += value + '\n';
      return;
   }
   isNode ? console.log('' + value) : print('' + value);
}
function read() {
   return isNode ? MEMORY[MEMORY_INDEX++] : readline();
}
function readAll() {
   return isNode && MEMORY;
}

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

const getLine = (function () {
    const getLineGen = (async function* () {
        for await (const line of rl) {
            yield line;
        }
    })();
    return async () => ((await getLineGen.next()).value);
})();

let solve = async () => {
    n = parseInt((await getLine()));
    const t = new Array(n);
    for(let i = 0; i < n; i++) {
        let ai, bi;
        [ai, bi] = (await getLine()).split(' ').map(num => BigInt(num));
        t[i] = {
            a: ai,
            b: bi
        };
    }
    let cmpt = (a,b) => {
       let diff = a.b - b.b;
       let zeroBig = BigInt(0);
       if (diff < zeroBig)
           return -1;
       else if (diff > zeroBig)
           return 1;
       else
           return 0;
    }
    t.sort(cmpt);
    let bought = BigInt(0);
    let sum = BigInt(0);
    let last = t.length - 1;
    let first = 0
    while (first <= last) {
        if (t[first].b > bought) {
            while (first <= last) {
               if (t[last].a + bought <= t[first].b){
                  sum += BigInt(2) * t[last].a;
                  bought += t[last].a;
                  last--;
               }
               else {
                   t[last].a -= (t[first].b - bought);
                   sum += t[first].a + BigInt(2) * (t[first].b - bought);
                   bought += t[first].b - bought + t[first].a;
                   first++;
                   break;
               }
            }
        }
        else {
            bought += t[first].a;
            sum += t[first].a;
            first++;
        }
    }
    console.log(sum.toString());
}

solve();

var readline = require('readline');

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

function solve(n, arr) {
    arr.sort((a, b) => a[1] - b[1])

    let i = 0
    let j = arr.length - 1
    let all = 0
    let pay = 0
    while (i < j) {
        const [total, limit] = arr[i]
        while (all < limit && j > i) {
            const able = arr[j][0]
            let cost
            if (all + able < limit) {
                cost = able
                arr[j][0] -= cost
                j--
            } else {
                cost = limit - all
                arr[j][0] -= cost
            }
            all += cost
            pay += 2 * cost
        }
// console.log(arr, pay, all)
        if (all < limit) {
            const f = Math.min(total, limit - all)
            pay += f * 2
            all += f
            arr[i][0] -= f
            break
        } else {
            pay += total
            all += total
            arr[i][0] = 0
            i++
        }
    }
    // i == j
    if (all >= arr[i][1]) {
        pay += arr[i][0]
    } else {
        pay += 2 * arr[i][0]
    }
    return pay
}

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
    Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
    o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
    if (mod && mod.__esModule) return mod;
    var result = {};
    if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
    __setModuleDefault(result, mod);
    return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
const fs = __importStar(require("fs"));
// import * as readline from 'readline'
// const rl = readline.createInterface({ input: process.stdin, output: process.stdout })
// const ask = (query: string) => new Promise<string>((resolve) => rl.question(query, resolve))
// // Don't forget `rl.close()`.
const INT = Math.floor;
Array.prototype.last = function () {
    return this.length === 0 ? undefined : this[this.length - 1];
};
Array.prototype.isEmpty = function () {
    return this.length === 0;
};
const less = (a, b) => (a == b ? 0 : a < b ? -1 : 1);
const greater = (a, b) => (a == b ? 0 : a < b ? 1 : -1);
const bigIntMax = (...args) => args.reduce((m, e) => (e > m ? e : m));
const bigIntMin = (...args) => args.reduce((m, e) => (e < m ? e : m));
const bigIntAbs = (arg) => (arg < 0 ? -arg : arg);
function read_stdin() {
    return fs.readFileSync(process.env.NODE_ENV === 'debug' ? stdin : process.stdin.fd, 'utf8');
}
class Input {
    constructor(str) {
        this.index = 0;
        this.inputs = (str ? str : read_stdin()).split(/\s+/);
    }
    number() {
        return Number(this.inputs[this.index++]);
    }
    numbers(n) {
        return this.inputs.slice(this.index, (this.index += n)).map(Number);
    }
    bigint() {
        return BigInt(this.inputs[this.index++]);
    }
    bigints(n) {
        return this.inputs.slice(this.index, (this.index += n)).map(BigInt);
    }
    word() {
        return this.inputs[this.index++];
    }
    words(n) {
        return this.inputs.slice(this.index, (this.index += n));
    }
}
function array(len, init) {
    return Array(len).fill(init);
}
function array2(h, w, init) {
    return array(h, 0).map(() => array(w, init));
}
function main() {
    const input = new Input();
    const N = input.number();
    const products = Array(N);
    for (let i = 0; i < N; i++) {
        const a = input.number();
        const b = input.number();
        products[i] = { a, b };
    }
    products.sort((x, y) => x.b - y.b);
    let head = 0;
    let tail = N - 1;
    let sum = 0;
    let count = 0;
    while (head <= tail) {
        // console.log({ head, tail })
        const p_head = products[head];
        let c = p_head.b - count;
        // console.log({ p_head, count, c })
        if (c > 0) {
            while (head <= tail) {
                // console.log({ head, tail, c })
                const p_tail = products[tail];
                if (p_tail.a > c) {
                    p_tail.a -= c;
                    count += c;
                    sum += 2 * c;
                    break;
                }
                else if (p_tail.a === c) {
                    p_tail.a -= c;
                    count += c;
                    sum += 2 * c;
                    tail--;
                    break;
                }
                else {
                    c -= p_tail.a;
                    count += p_tail.a;
                    sum += 2 * p_tail.a;
                    tail--;
                }
            }
        }
        // console.log({ p_head })
        if (p_head.a > 0) {
            if (p_head.b <= count) {
                sum += p_head.a;
            }
            else {
                sum += 2 * p_head.a;
            }
            count += p_head.a;
        }
        head++;
    }
    console.log(sum);
}
main();
//# sourceMappingURL=aoj.js.map


A new cottage village called «Flatville» is being built in Flatland. By now they have already built in «Flatville» n square houses with the centres on the Оx-axis. The houses' sides are parallel to the coordinate axes. It's known that no two houses overlap, but they can touch each other.The architect bureau, where Peter works, was commissioned to build a new house in «Flatville». The customer wants his future house to be on the Оx-axis, to be square in shape, have a side t, and touch at least one of the already built houses. For sure, its sides should be parallel to the coordinate axes, its centre should be on the Ox-axis and it shouldn't overlap any of the houses in the village.Peter was given a list of all the houses in «Flatville». Would you help him find the amount of possible positions of the new house?

The first line of the input data contains numbers n and t (1 ≤ n, t ≤ 1000). Then there follow n lines, each of them contains two space-separated integer numbers: xi ai, where xi — x-coordinate of the centre of the i-th house, and ai — length of its side ( - 1000 ≤ xi ≤ 1000, 1 ≤ ai ≤ 1000).

Output the amount of possible positions of the new house.

NoteIt is possible for the x-coordinate of the new house to have non-integer value.

'use strict'

let lll = readline().split(' ')
let N = +lll[0]
let T = +lll[1]

let hoss = []

while (lll = readline()) {
  lll = lll.split(' ')
  let x = +lll[0]
  let a = +lll[1]
  hoss.push([x - a / 2, x + a / 2])
}

let pos = 0

hoss = hoss.sort((a, b) => a[0] - b[0])

hoss.forEach((h, i) => {
  let ph = hoss[i - 1] || [-Infinity, -Infinity]
  let nh = hoss[i + 1] || [Infinity, Infinity]
  if (h[0] - ph[1] >= T) pos++
  if (nh[0] - h[1] > T) pos++
})

print(pos)

const readline = require('readline');

const rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
});
var n, t, cont = [], indicator = 0, temp = [];
rl.on('line', (input) => {
    if (indicator == 0) {
        temp = input.split(' ').map(item => parseInt(item));
        n = temp[0], t = temp[1];
        indicator++;
    }
    else {
        temp = input.split(' ').map(item => parseFloat(item));
        let houseCenter = temp[0];
        let houseLen = temp[1];
        let arr = [houseCenter - houseLen / 2, houseCenter + houseLen / 2];
        cont.push(arr);
    }

}).on('close', function () {
    let ans = 2;
    cont.sort(function (obj1, obj2) {
        return obj1[0] - obj2[0];
        /*
        if(obj1[0] > obj2[0]) return 1;
        return -1;
        */
    });
    // console.log(cont);
    for (let i = 0; i < n - 1; i++) {
        let gap = cont[i + 1][0] - cont[i][1];
        if (gap > t) ans += 2;
        else if (gap == t) ans++;
    }
    console.log(ans);
});

const readline = require('readline');

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

var n, t, ans = 2, cont = [], indicator = 0, temp = [];

rl.on('line', (input) => {
    if (indicator == 0) {
        temp = input.split(' ').map(item => parseInt(item));
        n = temp[0];
        t = temp[1];
        indicator++;
    }
    else {
        temp = input.split(' ').map(item => parseFloat(item));
        let center = temp[0];
        let len = temp[1];
        cont.push([center - len / 2, center + len / 2]);
    }

}).on('close', () => {
    cont.sort((obj1, obj2) => { return obj1[0] - obj2[0] });
    for (let i = 0; i < n - 1; i++) {
        let gap = cont[i + 1][0] - cont[i][1];
        if (gap > t)
            ans += 2;
        else if (gap == t)
            ans++;
    }
    console.log(ans);
});

const readline = require('readline');

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

var n, t, indicator = 0, cont = [], temp = [];
rl.on('line', (input) => {
    if (indicator == 0) {
        temp = input.split(' ').map(item => parseInt(item));
        n = temp[0];
        t = temp[1];
        indicator++;
    }
    else {
        temp = input.split(' ').map(item => parseInt(item));
        let center = temp[0], len = temp[1];
        cont.push([center - len / 2, center + len / 2])
    }
}).on('close', () => {
    //sort array using comparator
    cont.sort((arr1, arr2) => {
        return arr1[0] - arr2[0];
    })

    //console.log(cont);
    let ans = 2;
    for (let i = 0; i < n - 1; i++) {
        let gap = cont[i + 1][0] - cont[i][1];
        if (gap > t) ans += 2;
        else if (gap == t) ans++;
    }
    console.log(ans);
});

const readline = require("readline");

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

function addToArray(items, a, b) {
  var len = items.length;

  for (var i = 0; i < len; i++) {
    if (items[i] == a) {
      items[i] = b;
      return items;
    }
    if (items[i] == b) {
      items[i] = a;
      return items;
    }
  }

  var newArray = [len + 1];

  for (var i = 0; i < len; i++) {
    newArray[i] = items[i];
  }
  newArray[len] = a;
  newArray[len + 1] = b;

  return newArray;
}

function bubbleSort(cont) {
  var swapped,
    len = cont.length;
  if (len === 1) return;

  do {
    swapped = false;
    for (var i = 1; i < len; i++) {
      if (cont[i - 1] > cont[i]) {
        var b = cont[i];
        cont[i] = cont[i - 1];
        cont[i - 1] = b;
        swapped = true;
      }
    }
  } while (swapped);
  return;
}

var array = [];
var mycont = [];
var n = -1;
var t = 0;
var counter = 2;
var coordinat = 0;
var check = false;

rl.on("line", input => {
  if (n == -1) {
    array = input.split(" ");
    n = parseInt(array[0]);
    t = parseInt(array[1]);
  } else if (n != 1) {
    array = input.split(" ");
    var x = parseInt(array[0]);
    var a = parseInt(array[1]);
    mycont = addToArray(mycont, x - a / 2, x + a / 2);

    n--;
  } else if (n == 1) {
    array = input.split(" ");
    var x = parseInt(array[0]);
    var a = parseInt(array[1]);
    mycont = addToArray(mycont, x - a / 2, x + a / 2);

    bubbleSort(mycont);

    for (var i = 2; i < mycont.length - 1; i += 2) {
      if (mycont[i] - mycont[i - 1] == t) counter++;
      else if (mycont[i] - mycont[i - 1] > t) counter += 2;
    }
  }
}).on("close", () => {
  console.log(counter);
});

const readline = require('readline');

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

var n, t, pos, len, indicator = 0,ans = 2,
    cont = [],
    temp = [];

rl.on('line', (input) => {
    if (indicator == 0) {
        temp = input.split(' ').map(item => parseInt(item));
        n = temp[0];
        t = temp[1];
        indicator++;
    } else if (indicator < n) {
        temp = input.split(' ').map(item => parseInt(item));
        pos = temp[0];
        len = temp[1];
        cont.push([pos - len / 2, pos + len / 2]);
        indicator++;
    } else {
        temp = input.split(' ').map(item => parseInt(item));
        pos = temp[0];
        len = temp[1];
        cont.push([pos - len / 2, pos + len / 2]);
        /*our calculations here*/
        cont.sort((a,b) => {return a[0]-b[0]});
        for(i=0;i<cont.length-1;i++){
            var gap = cont[i+1][0] - cont[i][1];
            if(gap > t)
                ans+=2;
            else if(gap == t)
                ans++;

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

});

const readline = require("readline");

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

function addToArray(items, a) {
  var len = items.length;

  for (var i = 0; i < len; i++) {
    if (items[i] == a) return items;
  }

  var newArray = [len];

  for (var i = 0; i < len; i++) {
    newArray[i] = items[i];
  }
  newArray[len] = a;

  return newArray;
}

function bubbleSort(cont) {
  var swapped,
    len = cont.length;
  if (len === 1) return;

  do {
    swapped = false;
    for (var i = 1; i < len; i++) {
      if (cont[i - 1] > cont[i]) {
        var b = cont[i];
        cont[i] = cont[i - 1];
        cont[i - 1] = b;
        swapped = true;
      }
    }
  } while (swapped);
  return;
}

var array = [];
var mycont = [];
var n = -1;
var t = 0;
var counter = 2;
var coordinat = 0;
var check = false;

rl.on("line", input => {
  if (n == -1) {
    array = input.split(" ");
    n = parseInt(array[0]);
    t = parseInt(array[1]);
  } else if (n != 1) {
    array = input.split(" ");
    var x = parseInt(array[0]);
    var a = parseInt(array[1]);
    mycont = addToArray(mycont, x - a / 2);
    mycont = addToArray(mycont, x + a / 2);
    n--;
  } else if (n == 1) {
    array = input.split(" ");
    var x = parseInt(array[0]);
    var a = parseInt(array[1]);
    mycont = addToArray(mycont, x - a / 2);
    mycont = addToArray(mycont, x + a / 2);

    bubbleSort(mycont);
    for (var i = 1; i < mycont.length; i += 2) {
      if (mycont[i + 1] - mycont[i] == t) counter++;
      else if (mycont[i + 1] - mycont[i] > t) counter += 2;
    }

  }
}).on("close", () => {
  console.log(counter);
  //console.log(sleep2);
});

const readline = require("readline");

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

var array = [];
var n = -1;
var t = 0;
var counter = 2;
var coordinat = 0;
var check = false;

rl.on("line", input => {
  if (n++ == -1) {
    array = input.split(" ");
    t = parseInt(array[1]);
  } else {
    array = input.split(" ");
    var x = parseInt(array[0]);
    var a = parseInt(array[1]);
    if (check) {
      if (x - a / 2 - coordinat > t) counter += 2;
      else if (x - a / 2 - coordinat == t) counter++;
    }

    coordinat = x + a / 2;

    check = true;
  }

}).on("close", () => {
    console.log(counter);

  });;

const readline = require("readline");

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

function addToArray(items, a) {
  var len = items.length;

  for (var i = 0; i < len; i++) {
    if (items[i] == a) return items;
  }

  var newArray = [len];

  for (var i = 0; i < len; i++) {
    newArray[i] = items[i];
  }
  newArray[len] = a;

  return newArray;
}

function bubbleSort(cont) {
  var swapped,
    len = cont.length;
  if (len === 1) return;

  do {
    swapped = false;
    for (var i = 1; i < len; i++) {
      if (cont[i - 1] > cont[i]) {
        var b = cont[i];
        cont[i] = cont[i - 1];
        cont[i - 1] = b;
        swapped = true;
      }
    }
  } while (swapped);
  return;
}

var array = [];
var mycont = [];
var n = -1;
var t = 0;
var counter = 2;
var coordinat = 0;
var check = false;

rl.on("line", input => {
  if (n == -1) {
    array = input.split(" ");
    n = parseInt(array[0]);
    t = parseInt(array[1]);
  } else if (n != 0) {
    array = input.split(" ");
    var x = parseInt(array[0]);
    var a = parseInt(array[1]);
    mycont = addToArray(mycont, x - a / 2);
    mycont = addToArray(mycont, x + a / 2);
    n--;
  } else if (n == 0) {
    bubbleSort(mycont);
    for (var i = 1; i < mycont.length; i += 2) {
      if (mycont[i + 1] - mycont[i] == t) counter++;
      else if (mycont[i + 1] - mycont[i] > t) counter += 2;
    }

    console.log(counter);
    rl.close();
  }
});


A new entertainment has appeared in Buryatia — a mathematical circus! The magician shows two numbers to the audience — $$$n$$$ and $$$k$$$, where $$$n$$$ is even. Next, he takes all the integers from $$$1$$$ to $$$n$$$, and splits them all into pairs $$$(a, b)$$$ (each integer must be in exactly one pair) so that for each pair the integer $$$(a + k) \cdot b$$$ is divisible by $$$4$$$ (note that the order of the numbers in the pair matters), or reports that, unfortunately for viewers, such a split is impossible.Burenka really likes such performances, so she asked her friend Tonya to be a magician, and also gave him the numbers $$$n$$$ and $$$k$$$.Tonya is a wolf, and as you know, wolves do not perform in the circus, even in a mathematical one. Therefore, he asks you to help him. Let him know if a suitable splitting into pairs is possible, and if possible, then tell it.

The first line contains one integer $$$t$$$ ($$$1 \leq t \leq 10^4$$$) — the number of test cases. The following is a description of the input data sets. The single line of each test case contains two integers $$$n$$$ and $$$k$$$ ($$$2 \leq n \leq 2 \cdot 10^5$$$, $$$0 \leq k \leq 10^9$$$, $$$n$$$ is even) — the number of integers and the number being added $$$k$$$. It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$2 \cdot 10^5$$$.

For each test case, first output the string "YES" if there is a split into pairs, and "NO" if there is none. If there is a split, then in the following $$$\frac{n}{2}$$$ lines output pairs of the split, in each line print $$$2$$$ numbers — first the integer $$$a$$$, then the integer $$$b$$$.

NoteIn the first test case, splitting into pairs $$$(1, 2)$$$ and $$$(3, 4)$$$ is suitable, same as splitting into $$$(1, 4)$$$ and $$$(3, 2)$$$.In the second test case, $$$(1 + 0) \cdot 2 = 1 \cdot (2 + 0) = 2$$$ is not divisible by $$$4$$$, so there is no partition.

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, k] = input[index].split(" ").map((item) => parseInt(item));
    const testCase = {
      n,
      k,
    };

    testCases.push(testCase);
  }
}

function solution(testCase) {
  const { n, k } = testCase;
  // console.log(n, k);

  if (k % 4 == 0) console.log("NO");
  else {
    console.log("YES");
    const a2 = (4 - (k % 4)) % 4;
    const b1 = 4;
    const s = new Set([1, 2, 3]);
    s.delete(a2);
    const a1 = Array.from(s)[0];
    const b2 = Array.from(s)[1];

    // console.error(a1, b1, a2, b2);

    for (let i = 0; i < Math.floor(n / 4); i++) {
      console.log(
        i * 4 + a1,
        i * 4 + b1
        // ((i * 4 + a1 + k) * (i * 4 + b1)) % 4
      );
      console.log(
        i * 4 + a2,
        i * 4 + b2
        // ((i * 4 + a2 + k) * (i * 4 + b2)) % 4
      );
    }
    if (n % 4 == 2) {
      if (k % 4 == 2)
        console.log(
          n,
          n - 1
          // ((n + k) * (n - 1)) % 4
        );
      else
        console.log(
          n - 1,
          n
          // ((n - 1 + k) * n) % 4
        );
    }
  }
}

parseInput();

testCases.forEach(solution);

'use strict';

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

let inputString = '';
let currentLine = 0;

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

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

    main();
});

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

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

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

    for (let test = 0; test < N; test++) {
        const [n, k] = readline().split(' ').map(Number);

        if (k % 2 === 1) {
            output('YES');
            for (let i = 0; i < (n / 2); i++) {
                let first = i * 2 + 1;
                let second = first + 1;
                output(first + ' ' + second);
            }
            continue;
        } else if (k % 4 === 0) {
            output('NO');
        } else if (k % 4 === 2) {
            let start = 4;
            output('YES');
            let temp = n;
            while (start <= n) {
                output((start - 1) + ' ' + start);
                output((start - 2) + ' ' + (start - 3));
                start += 4;
                temp -= 4;
            }
            if (temp === 2) {
                output((start - 2) + ' ' + (start  - 3));
            }
        }
    }
}

const readline = require('readline')

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

function solve(n, k) {
    // (a + k) * b = 4x
    const h = n / 2
    const ans = []
    if (k & 1) {
        // (odd + k) * even
        for (let i = 1; i < n; i += 2) {
            ans.push([i, i + 1])
        }
    } else {
        const r = k % 4
        if (!r) return 'NO'
        // 4n, 4n - k, with odd
        const ps = [[], [], [], [], []]
        let i = 1
        while (i <= n) {
            for (let j = 1; j <= 4; j++) {
                ps[j].push(i++)
                if (i > n) break
            }
        }
        ps[0] = ps[4] // hack
        let p0 = 0
        let p1 = 0, ps1 = ps[4 - r]
        for (let i = 1; i < n; i += 2) {
            if (p0 < ps[0].length) {
                ans.push([i, ps[0][p0++]])
            } else {
                ans.push([ps1[p1++], i])
            }
        }
    // console.log(ps, ans)
    //     const other = ps[r]
    //     for (let i = 0; i < other.length; i += 2) {
    //         ans.push([other[i], other[i + 1]])
    //     }
    }
    return 'YES\n' + ans.map(x => x.join(' ')).join('\n')
}

'use strict';

function solve(a) {
  const [n, m] = a;
  if (m & 1) {
    const res = ['YES'];
    for (let i = 1; i <= n; i += 2) {
      res.push(`${i} ${i + 1}`);
    }
    return res.join('\n');
  } else if (m % 4 === 2) {
    let res = ['YES'];
    for (let i = 1; i <= n; i += 2) {
      if ((i + 1) / 2 & 1) {
        res.push(`${i + 1} ${i}`);
      } else {
        res.push(`${i} ${i + 1}`);
      }
    }
    return res.join('\n');
  }
  return 'NO';
}

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

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

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

/***
Codeforces Round #814 (Div. 2)
2022-08-16

A. Chip Game
***/

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

  for (let i = 0; i < t; i++) {
    const testCase = readline().split(" ");
    const n = parseInt(testCase[0]);
    const k = parseInt(testCase[1]);

    // k is odd -> pair 1-2, 3-4
    // k is 2 (mod 4) -> pair 2-1, 3-4
    switch (k % 4) {
      case 1:
      case 3:
        console.log("YES");
        for (let startNum = 1; startNum < n; startNum += 2) {
          console.log(startNum + " " + (startNum + 1));
        }
        break;
      case 2:
        console.log("YES");
        for (let startNumB = 3; startNumB < n; startNumB += 4) {
          console.log(startNumB + " " + (startNumB + 1));
        }
        for (let startNumA = 2; startNumA <= n; startNumA += 4) {
          console.log(startNumA + " " + (startNumA - 1));
        }
        break;
      case 0:
        console.log("NO");
        break;
      default:
        console.log(
          "Something went wrong: " +
            k +
            " is in none of the mod 4 residue classes"
        );
        break;
    }
  }
}

let i = '';
process.stdin.on('data', c => i += c)
process.stdin.on('end', () => {
    const {EOL} = require('os');
    const lines = i.split(EOL); /*your input text, split by lines*/
    let cases = parseInt(lines[0])
    //const splitLines = lines.map(x => x.split(" ").map(x => parseInt(x)))
    for (let i = 1; i <= cases; i ++)
    {
        let a = lines[i].split(" ").map(x => parseInt(x))
        let n = a[0];
        let k = a[1];
        switch (k % 4)
        {
            case 0:
                console.log("NO");
                break;
            case 1:
            case 3:
                console.log("YES")
                for (let i = 1; i <= n; i +=2)
                {
                    console.log(i + " " + (i + 1))
                }
                break;
            case 2:
                console.log("YES")
                for (let i = 1; i <= n; i += 2)
                {
                    if (i % 4 == 1)
                    {
                        console.log((i + 1) + " " + i)
                    }
                    else{
                        console.log(i + " " + (i + 1))
                    }
                }
        }
    }
})

var n, k;
    var tests = parseInt(readline());
    for (var t=0; t<tests;t++) {
        var nk = readline().split(' ').map(x=>parseInt(x));
        n = nk[0];
        k = nk[1];
        if (k % 4 == 0) {
            print('NO');
            continue;
        }
        print('YES');
        if (k & 1) {
            for (var i = 1; i <= n; i+=2) {
                print(i + ' ' + (i+1));
            }
        } else {
            for (var i = 2; i <= n; i+=2) {
                if (i % 4 == 0) {
                    print((i-1) + ' ' + i);
                } else {
                    print(i + ' ' + (i-1));
                }
            }
        }
    }

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, k] = input[index].split(" ").map((item) => parseInt(item));
    const testCase = {
      n,
      k,
    };

    testCases.push(testCase);
  }
}

function solution(testCase) {
  const { n, k } = testCase;
  // console.log(n, k);

  if (k % 4 == 0 || (k % 4 == 2 && n % 4 == 2)) console.log("NO");
  else {
    console.log("YES");
    const a2 = (4 - (k % 4)) % 4;
    const b1 = 4;
    const s = new Set([1, 2, 3]);
    s.delete(a2);
    const a1 = Array.from(s)[0];
    const b2 = Array.from(s)[1];

    // console.error(a1, b1, a2, b2);

    for (let i = 0; i < Math.floor(n / 4); i++) {
      console.log(
        i * 4 + a1,
        i * 4 + b1
        // ((i * 4 + a1 + k) * (i * 4 + b1)) % 4
      );
      console.log(
        i * 4 + a2,
        i * 4 + b2
        // ((i * 4 + a2 + k) * (i * 4 + b2)) % 4
      );
    }
    if (n % 4 == 2) console.log(n - 1, n);
  }
}

parseInput();

testCases.forEach(solution);

'use strict';

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

let inputString = '';
let currentLine = 0;

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

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

    main();
});

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

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

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

    for (let test = 0; test < N; test++) {
        const [n, k] = readline().split(' ').map(Number);

        if (k % 2 === 1) {
            output('YES');
            for (let i = 0; i < (n / 2); i++) {
                let first = i * 2 + 1;
                let second = first + 1;
                output(first + ' ' + second);
            }
            continue;
        } else if (k % 4 === 0) {
            output('NO');
        } else if (k % 4 === 2) {
            let start = 4;
            output('YES');
            let temp = n;
            while (start <= n) {
                output((start - 1) + ' ' + start);
                output((start - 2) + ' ' + (start - 3));
                start += 4;
                temp -= 4;
            }
            if (temp === 2) {
                output((start + 2) + ' ' + (start + 1));
            }
        }
    }
}


Recently in Divanovo, a huge river locks system was built. There are now $$$n$$$ locks, the $$$i$$$-th of them has the volume of $$$v_i$$$ liters, so that it can contain any amount of water between $$$0$$$ and $$$v_i$$$ liters. Each lock has a pipe attached to it. When the pipe is open, $$$1$$$ liter of water enters the lock every second.The locks system is built in a way to immediately transfer all water exceeding the volume of the lock $$$i$$$ to the lock $$$i + 1$$$. If the lock $$$i + 1$$$ is also full, water will be transferred further. Water exceeding the volume of the last lock pours out to the river.   The picture illustrates $$$5$$$ locks with two open pipes at locks $$$1$$$ and $$$3$$$. Because locks $$$1$$$, $$$3$$$, and $$$4$$$ are already filled, effectively the water goes to locks $$$2$$$ and $$$5$$$. Note that the volume of the $$$i$$$-th lock may be greater than the volume of the $$$i + 1$$$-th lock.To make all locks work, you need to completely fill each one of them. The mayor of Divanovo is interested in $$$q$$$ independent queries. For each query, suppose that initially all locks are empty and all pipes are closed. Then, some pipes are opened simultaneously. For the $$$j$$$-th query the mayor asks you to calculate the minimum number of pipes to open so that all locks are filled no later than after $$$t_j$$$ seconds.Please help the mayor to solve this tricky problem and answer his queries.

The first lines contains one integer $$$n$$$ ($$$1 \le n \le 200\,000$$$) — the number of locks.  The second lines contains $$$n$$$ integers $$$v_1, v_2, \dots, v_n$$$ ($$$1 \le v_i \le 10^9$$$)) — volumes of the locks.  The third line contains one integer $$$q$$$ ($$$1 \le q \le 200\,000$$$) — the number of queries.  Each of the next $$$q$$$ lines contains one integer $$$t_j$$$ ($$$1 \le t_j \le 10^9$$$) — the number of seconds you have to fill all the locks in the query $$$j$$$.

Print $$$q$$$ integers. The $$$j$$$-th of them should be equal to the minimum number of pipes to turn on so that after $$$t_j$$$ seconds all of the locks are filled. If it is impossible to fill all of the locks in given time, print $$$-1$$$.

NoteThere are $$$6$$$ queries in the first example test. In the queries $$$1, 3, 4$$$ the answer is $$$-1$$$. We need to wait $$$4$$$ seconds to fill the first lock even if we open all the pipes. In the sixth query we can open pipes in locks $$$1$$$, $$$3$$$, and $$$4$$$. After $$$4$$$ seconds the locks $$$1$$$ and $$$4$$$ are full. In the following $$$1$$$ second $$$1$$$ liter of water is transferred to the locks $$$2$$$ and $$$5$$$. The lock $$$3$$$ is filled by its own pipe. Similarly, in the second query one can open pipes in locks $$$1$$$, $$$3$$$, and $$$4$$$.In the fifth query one can open pipes $$$1, 2, 3, 4$$$.

'use strict';

function solve(n, m, a, b) {
  let min = 0,
      sum = 0;
  for (let [i, num] of a.entries()) {
    sum += num;
    min = Math.max(min, Math.ceil(sum / (i + 1)));
  }
  let res = new Array(m);
  for (let [i, num] of b.entries()) {
    if (num < min) {
      res[i] = -1;
    } else {
      res[i] = Math.ceil(sum / num);
    }
  }
  return res.join('\n');
}

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

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


Fishing Prince loves trees, and he especially loves trees with only one centroid. The tree is a connected graph without cycles.A vertex is a centroid of a tree only when you cut this vertex (remove it and remove all edges from this vertex), the size of the largest connected component of the remaining graph is the smallest possible.For example, the centroid of the following tree is $$$2$$$, because when you cut it, the size of the largest connected component of the remaining graph is $$$2$$$ and it can't be smaller.  However, in some trees, there might be more than one centroid, for example:  Both vertex $$$1$$$ and vertex $$$2$$$ are centroids because the size of the largest connected component is $$$3$$$ after cutting each of them.Now Fishing Prince has a tree. He should cut one edge of the tree (it means to remove the edge). After that, he should add one edge. The resulting graph after these two operations should be a tree. He can add the edge that he cut.He wants the centroid of the resulting tree to be unique. Help him and find any possible way to make the operations. It can be proved, that at least one such way always exists.

The input consists of multiple test cases. The first line contains an integer $$$t$$$ ($$$1\leq t\leq 10^4$$$) — the number of test cases. The description of the test cases follows. The first line of each test case contains an integer $$$n$$$ ($$$3\leq n\leq 10^5$$$) — the number of vertices. Each of the next $$$n-1$$$ lines contains two integers $$$x, y$$$ ($$$1\leq x,y\leq n$$$). It means, that there exists an edge connecting vertices $$$x$$$ and $$$y$$$. It's guaranteed that the given graph is a tree. It's guaranteed that the sum of $$$n$$$ for all test cases does not exceed $$$10^5$$$.

For each test case, print two lines. In the first line print two integers $$$x_1, y_1$$$ ($$$1 \leq x_1, y_1 \leq n$$$), which means you cut the edge between vertices $$$x_1$$$ and $$$y_1$$$. There should exist edge connecting vertices $$$x_1$$$ and $$$y_1$$$. In the second line print two integers $$$x_2, y_2$$$ ($$$1 \leq x_2, y_2 \leq n$$$), which means you add the edge between vertices $$$x_2$$$ and $$$y_2$$$. The graph after these two operations should be a tree. If there are multiple solutions you can print any.

NoteNote that you can add the same edge that you cut.In the first test case, after cutting and adding the same edge, the vertex $$$2$$$ is still the only centroid.In the second test case, the vertex $$$2$$$ becomes the only centroid after cutting the edge between vertices $$$1$$$ and $$$3$$$ and adding the edge between vertices $$$2$$$ and $$$3$$$.

let input = '';
let inputResolve;
let inputPromise = new Promise(resolve => inputResolve = resolve);
process.stdin.on('data', c => input += c);
process.stdin.on('end', () => inputResolve());

function For(a, b, cb) {
  let res;
  if (a < b) {
    for (let i = a; i <= b; i++) {
      if ((res = cb(i)) !== undefined) return res;
    }
  } else {
    for (let i = a; i >= b; i--) {
      if ((res = cb(i)) !== undefined) return res;
    }
  }
}

function Arr(a, b, cb, prev) {
  let p = prev || 0;
  if (a < b) return Array(b - a + 1).fill(0).map((v, i) => cb ? (p = cb(a + i, p)) : a + i);
  return Array(a - b + 1).fill(0).map((v, i) => cb ? (p = cb(a - i, p)) : a - i);
}

function FindMin(arr, fn) {
  let min = Math.min(...arr.map((v, i) => fn ? fn(v, i) : v));
  let i = arr.findIndex((v, i) => fn ? fn(v, i) == min : v == min);
  return [i, min];
}

function FindMax(arr, fn) {
  let max = Math.max(...arr.map((v, i) => fn ? fn(v, i) : v));
  let i = arr.findIndex((v, i) => fn ? fn(v, i) == max : v == max);
  return [i, max];
}

Object.defineProperty(Object.prototype, '$k', {
  value: function () { return Object.keys(this) }
});
Object.defineProperty(Object.prototype, '$v', {
  value: function () { return Object.values(this) }
});
Object.defineProperty(Object.prototype, '$kv', {
  value: function () { return Object.entries(this) }
});
Array.prototype.sum = function (fn) { return this.reduce((p, v) => p + (fn ? fn(v) : v), 0) }
Array.prototype.uniq = function (fn) {
  var set = new Set();
  return this.filter(v => {
    var newValue = !set.has(fn ? fn(v) : v);
    set.add(fn ? fn(v) : v);
    return newValue;
  });
}
Array.prototype.toObj = function (fn) {
  return this.map(v => fn(v)).reduce((p, v) => {
    p[v[0]] = v[1];
    return p;
  }, {})
}

function gcd(a, b) {
  if (!b) return a;
  return gcd(b, a % b);
}
function mod(a, n, m) {
  if (n == 0n) return 1n;
  if (n % 2n == 0n) return mod(a * a % m, n / 2n, m);
  return a * mod(a, n - 1n, m) % m;
}
function extendedEuclid(a, b) {
  if (!b) return [1, 0];
  else {
    let [x, y] = extendedEuclid(b, a % b);
    return [y, x - (a / b | 0) * y];
  }
}

(async () => {
  await inputPromise;
  let inp = input.split(/\s+/).map(v => +v); r = 0;
  let t = inp[r++];
  while (t--) {
    let n = inp[r++];
    let edge = Arr(0, n, i => []);
    For(1, n - 1, i => {
      let u = inp[r++], v = inp[r++];
      edge[u].push(v);
      edge[v].push(u);
    });
    let size = Array(n + 1).fill(0);
    let t0 = Array(n + 1).fill(0);
    let t1 = Array(n + 1).fill(0);
    let minComp = 1e10, res = [], t = 0;
    let dfs = async (v, cb) => {
      t0[v] = t++;
      size[v] = 1;
      let comp = 0;
      for (let u of edge[v]) {
        if (size[u]) continue;
        await new Promise(resolve => {
          if (t % 1000 == 0) setTimeout(() => dfs(u, resolve), 0);
          else dfs(u, resolve);
        });
        size[v] += size[u];
        comp = Math.max(comp, size[u]);
      };
      comp = Math.max(comp, n - size[v]);
      if (comp < minComp) {
        minComp = comp;
        res = [v];
      } else if (comp == minComp) res.push(v);
      t1[v] = t++;
      cb();
    }
    await new Promise(resolve => dfs(1, resolve));
    // console.log(size);
    // console.log(res, minComp);
    // console.log(t0,t1);
    if (res.length == 1) {
      let u = Arr(1, n).find(u => edge[u].length);
      console.log(u, edge[u][0]);
      console.log(u, edge[u][0]);
    } else {
      if (t0[res[0]] > t0[res[1]]) res.reverse();
      // console.log(res);
      let i = Arr(1, n).find(i => size[i] == 1 && t0[res[1]] < t0[i] && t1[i] < t1[res[1]]);
      // console.log(i);
      console.log(i, edge[i][0]);
      console.log(i, res[0]);
    }
  }
})();

let input = '';
let inputResolve;
let inputPromise = new Promise(resolve => inputResolve = resolve);
process.stdin.on('data', c => input += c);
process.stdin.on('end', () => inputResolve());

function For(a, b, cb) {
  let res;
  if (a < b) {
    for (let i = a; i <= b; i++) {
      if ((res = cb(i)) !== undefined) return res;
    }
  } else {
    for (let i = a; i >= b; i--) {
      if ((res = cb(i)) !== undefined) return res;
    }
  }
}

function Arr(a, b, cb, prev) {
  let p = prev || 0;
  if (a < b) return Array(b - a + 1).fill(0).map((v, i) => cb ? (p = cb(a + i, p)) : a + i);
  return Array(a - b + 1).fill(0).map((v, i) => cb ? (p = cb(a - i, p)) : a - i);
}

function FindMin(arr, fn) {
  let min = Math.min(...arr.map((v, i) => fn ? fn(v, i) : v));
  let i = arr.findIndex((v, i) => fn ? fn(v, i) == min : v == min);
  return [i, min];
}

function FindMax(arr, fn) {
  let max = Math.max(...arr.map((v, i) => fn ? fn(v, i) : v));
  let i = arr.findIndex((v, i) => fn ? fn(v, i) == max : v == max);
  return [i, max];
}

Object.defineProperty(Object.prototype, '$k', {
  value: function () { return Object.keys(this) }
});
Object.defineProperty(Object.prototype, '$v', {
  value: function () { return Object.values(this) }
});
Object.defineProperty(Object.prototype, '$kv', {
  value: function () { return Object.entries(this) }
});
Array.prototype.sum = function (fn) { return this.reduce((p, v) => p + (fn ? fn(v) : v), 0) }
Array.prototype.uniq = function (fn) {
  var set = new Set();
  return this.filter(v => {
    var newValue = !set.has(fn ? fn(v) : v);
    set.add(fn ? fn(v) : v);
    return newValue;
  });
}
Array.prototype.toObj = function (fn) {
  return this.map(v => fn(v)).reduce((p, v) => {
    p[v[0]] = v[1];
    return p;
  }, {})
}

function gcd(a, b) {
  if (!b) return a;
  return gcd(b, a % b);
}
function mod(a, n, m) {
  if (n == 0n) return 1n;
  if (n % 2n == 0n) return mod(a * a % m, n / 2n, m);
  return a * mod(a, n - 1n, m) % m;
}
function extendedEuclid(a, b) {
  if (!b) return [1, 0];
  else {
    let [x, y] = extendedEuclid(b, a % b);
    return [y, x - (a / b | 0) * y];
  }
}

(async () => {
  await inputPromise;
  let inp = input.split(/\s+/).map(v => +v); r = 0;
  let t = inp[r++];
  For(1, t, i => {
    let n = inp[r++];
    let edge = Arr(0, n, i => []);
    For(1, n - 1, i => {
      let u = inp[r++], v = inp[r++];
      edge[u].push(v);
      edge[v].push(u);
    });
    let size = Array(n + 1).fill(0);
    let bfs = [];
    let q = [1];
    let mark = {};
    while (q.length) {
      let u = q.shift();
      size[u] = 1;
      bfs.push(u);
      edge[u].forEach(v => {
        if (size[v]) return;
        q.push(v);
      })
    }
    let minComp = 1e10, res = [];
    For(n - 1, 0, i => {
      let comp = 0;
      mark[bfs[i]] = i+1;
      edge[bfs[i]].forEach(u => {
        if (!mark[u]) return;
        comp = Math.max(comp, size[u]);
        size[bfs[i]] += size[u];
      });
      comp = Math.max(comp, n - size[bfs[i]]);
      if (comp < minComp) {
        minComp = comp;
        res = [bfs[i]];
      } else if (comp == minComp) res.push(bfs[i]);
    })
    // console.log(size);
    // console.log(res, minComp);
    // console.log(t0,t1);
    if (res.length == 1) {
      let u = Arr(1, n).find(u => edge[u].length);
      console.log(u, edge[u][0]);
      console.log(u, edge[u][0]);
    } else {
      res.reverse();
      // console.log(res);
      let i = Arr(1, n).find(i => size[i] == 1 && mark[res[1]] < mark[i]);
      // console.log(i);
      console.log(i, edge[i][0]);
      console.log(i, res[0]);
    }
  })
})();

let input = '';
let inputResolve;
let inputPromise = new Promise(resolve => inputResolve = resolve);
process.stdin.on('data', c => input += c);
process.stdin.on('end', () => inputResolve());

function For(a, b, cb) {
  let res;
  if (a < b) {
    for (let i = a; i <= b; i++) {
      if ((res = cb(i)) !== undefined) return res;
    }
  } else {
    for (let i = a; i >= b; i--) {
      if ((res = cb(i)) !== undefined) return res;
    }
  }
}

function Arr(a, b, cb, prev) {
  let p = prev || 0;
  if (a < b) return Array(b - a + 1).fill(0).map((v, i) => cb ? (p = cb(a + i, p)) : a + i);
  return Array(a - b + 1).fill(0).map((v, i) => cb ? (p = cb(a - i, p)) : a - i);
}

function FindMin(arr, fn) {
  let min = Math.min(...arr.map((v, i) => fn ? fn(v, i) : v));
  let i = arr.findIndex((v, i) => fn ? fn(v, i) == min : v == min);
  return [i, min];
}

function FindMax(arr, fn) {
  let max = Math.max(...arr.map((v, i) => fn ? fn(v, i) : v));
  let i = arr.findIndex((v, i) => fn ? fn(v, i) == max : v == max);
  return [i, max];
}

Object.defineProperty(Object.prototype, '$k', {
  value: function () { return Object.keys(this) }
});
Object.defineProperty(Object.prototype, '$v', {
  value: function () { return Object.values(this) }
});
Object.defineProperty(Object.prototype, '$kv', {
  value: function () { return Object.entries(this) }
});
Array.prototype.sum = function (fn) { return this.reduce((p, v) => p + (fn ? fn(v) : v), 0) }
Array.prototype.uniq = function (fn) {
  var set = new Set();
  return this.filter(v => {
    var newValue = !set.has(fn ? fn(v) : v);
    set.add(fn ? fn(v) : v);
    return newValue;
  });
}
Array.prototype.toObj = function (fn) {
  return this.map(v => fn(v)).reduce((p, v) => {
    p[v[0]] = v[1];
    return p;
  }, {})
}

function gcd(a, b) {
  if (!b) return a;
  return gcd(b, a % b);
}
function mod(a, n, m) {
  if (n == 0n) return 1n;
  if (n % 2n == 0n) return mod(a * a % m, n / 2n, m);
  return a * mod(a, n - 1n, m) % m;
}
function extendedEuclid(a, b) {
  if (!b) return [1, 0];
  else {
    let [x, y] = extendedEuclid(b, a % b);
    return [y, x - (a / b | 0) * y];
  }
}

(async () => {
  await inputPromise;
  let inp = input.split(/\s+/).map(v => +v); r = 0;
  let t = inp[r++];
  For(1, t, i => {
    let n = inp[r++];
    let edge = Arr(0, n, i => []);
    For(1, n - 1, i => {
      let u = inp[r++], v = inp[r++];
      edge[u].push(v);
      edge[v].push(u);
    });
    let size = Array(n + 1).fill(0);
    let minComp = 1e10, res = [];
    let dfs = v => {
      size[v] = 1;
      let comp = 0;
      edge[v].forEach(u => {
        if (size[u]) return;
        dfs(u);
        size[v] += size[u];
        comp = Math.max(comp, size[u]);
      });
      comp = Math.max(comp, n - size[v]);
      if (comp < minComp) {
        minComp = comp;
        res = [v];
      } else if (comp == minComp) res.push(v);
    }
    dfs(1);
    // console.log(size);
    // console.log(res, minComp);
    if (res.length == 1) {
      let u = Arr(1, n).find(u => edge[u].length);
      console.log(u, edge[u][0]);
      console.log(u, edge[u][0]);
    } else {
      console.log(res[0], res[1]);
      let [i] = FindMax(edge[res[1]], v => v == res[0] ? 0 : size[v]);
      console.log(res[0], edge[res[1]][i]);
    }
  })
})();

let input = '';
let inputResolve;
let inputPromise = new Promise(resolve => inputResolve = resolve);
process.stdin.on('data', c => input += c);
process.stdin.on('end', () => inputResolve());

function For(a, b, cb) {
  let res;
  if (a < b) {
    for (let i = a; i <= b; i++) {
      if ((res = cb(i)) !== undefined) return res;
    }
  } else {
    for (let i = a; i >= b; i--) {
      if ((res = cb(i)) !== undefined) return res;
    }
  }
}

function Arr(a, b, cb, prev) {
  let p = prev || 0;
  if (a < b) return Array(b - a + 1).fill(0).map((v, i) => cb ? (p = cb(a + i, p)) : a + i);
  return Array(a - b + 1).fill(0).map((v, i) => cb ? (p = cb(a - i, p)) : a - i);
}

function FindMin(arr, fn) {
  let min = Math.min(...arr.map((v, i) => fn ? fn(v, i) : v));
  let i = arr.findIndex((v, i) => fn ? fn(v, i) == min : v == min);
  return [i, min];
}

function FindMax(arr, fn) {
  let max = Math.max(...arr.map((v, i) => fn ? fn(v, i) : v));
  let i = arr.findIndex((v, i) => fn ? fn(v, i) == max : v == max);
  return [i, max];
}

Object.defineProperty(Object.prototype, '$k', {
  value: function () { return Object.keys(this) }
});
Object.defineProperty(Object.prototype, '$v', {
  value: function () { return Object.values(this) }
});
Object.defineProperty(Object.prototype, '$kv', {
  value: function () { return Object.entries(this) }
});
Array.prototype.sum = function (fn) { return this.reduce((p, v) => p + (fn ? fn(v) : v), 0) }
Array.prototype.uniq = function (fn) {
  var set = new Set();
  return this.filter(v => {
    var newValue = !set.has(fn ? fn(v) : v);
    set.add(fn ? fn(v) : v);
    return newValue;
  });
}
Array.prototype.toObj = function (fn) {
  return this.map(v => fn(v)).reduce((p, v) => {
    p[v[0]] = v[1];
    return p;
  }, {})
}

function gcd(a, b) {
  if (!b) return a;
  return gcd(b, a % b);
}
function mod(a, n, m) {
  if (n == 0n) return 1n;
  if (n % 2n == 0n) return mod(a * a % m, n / 2n, m);
  return a * mod(a, n - 1n, m) % m;
}
function extendedEuclid(a, b) {
  if (!b) return [1, 0];
  else {
    let [x, y] = extendedEuclid(b, a % b);
    return [y, x - (a / b | 0) * y];
  }
}

(async () => {
  await inputPromise;
  let inp = input.split(/\s+/).map(v => +v); r = 0;
  let t = inp[r++];
  For(1, t, i => {
    let n = inp[r++];
    let edge = Arr(0, n, i => []);
    For(1, n - 1, i => {
      let u = inp[r++], v = inp[r++];
      edge[u].push(v);
      edge[v].push(u);
    });
    let size = Array(n + 1).fill(0);
    let t0 = Array(n + 1).fill(0);
    let t1 = Array(n + 1).fill(0);
    let minComp = 1e10, res = [], t = 0;
    let dfs = v => {
      t0[v] = t++;
      size[v] = 1;
      let comp = 0;
      edge[v].forEach(u => {
        if (size[u]) return;
        dfs(u);
        size[v] += size[u];
        comp = Math.max(comp, size[u]);
      });
      comp = Math.max(comp, n - size[v]);
      if (comp < minComp) {
        minComp = comp;
        res = [v];
      } else if (comp == minComp) res.push(v);
      t1[v] = t++;
    }
    dfs(1);
    // console.log(size);
    // console.log(res, minComp);
    // console.log(t0,t1);
    if (res.length == 1) {
      let u = Arr(1, n).find(u => edge[u].length);
      console.log(u, edge[u][0]);
      console.log(u, edge[u][0]);
    } else {
      if (t0[res[0]] > t0[res[1]]) res.reverse();
      // console.log(res);
      let i = Arr(1,n).find(i => size[i]==1 && t0[res[1]] < t0[i] && t1[i] < t1[res[1]]);
      // console.log(i);
      console.log(i, edge[i][0]);
      let [j] = FindMin(edge[res[0]], v => v == res[1] ? 1e10 : size[v]);
      console.log(i, edge[res[0]][j]);
    }
  })
})();

let input = '';
let inputResolve;
let inputPromise = new Promise(resolve => inputResolve = resolve);
process.stdin.on('data', c => input += c);
process.stdin.on('end', () => inputResolve());

function For(a, b, cb) {
  let res;
  if (a < b) {
    for (let i = a; i <= b; i++) {
      if ((res = cb(i)) !== undefined) return res;
    }
  } else {
    for (let i = a; i >= b; i--) {
      if ((res = cb(i)) !== undefined) return res;
    }
  }
}

function Arr(a, b, cb, prev) {
  let p = prev || 0;
  if (a < b) return Array(b - a + 1).fill(0).map((v, i) => cb ? (p = cb(a + i, p)) : a + i);
  return Array(a - b + 1).fill(0).map((v, i) => cb ? (p = cb(a - i, p)) : a - i);
}

function FindMin(arr, fn) {
  let min = Math.min(...arr.map((v, i) => fn ? fn(v, i) : v));
  let i = arr.findIndex((v, i) => fn ? fn(v, i) == min : v == min);
  return [i, min];
}

function FindMax(arr, fn) {
  let max = Math.max(...arr.map((v, i) => fn ? fn(v, i) : v));
  let i = arr.findIndex((v, i) => fn ? fn(v, i) == max : v == max);
  return [i, max];
}

Object.defineProperty(Object.prototype, '$k', {
  value: function () { return Object.keys(this) }
});
Object.defineProperty(Object.prototype, '$v', {
  value: function () { return Object.values(this) }
});
Object.defineProperty(Object.prototype, '$kv', {
  value: function () { return Object.entries(this) }
});
Array.prototype.sum = function (fn) { return this.reduce((p, v) => p + (fn ? fn(v) : v), 0) }
Array.prototype.uniq = function (fn) {
  var set = new Set();
  return this.filter(v => {
    var newValue = !set.has(fn ? fn(v) : v);
    set.add(fn ? fn(v) : v);
    return newValue;
  });
}
Array.prototype.toObj = function (fn) {
  return this.map(v => fn(v)).reduce((p, v) => {
    p[v[0]] = v[1];
    return p;
  }, {})
}

function gcd(a, b) {
  if (!b) return a;
  return gcd(b, a % b);
}
function mod(a, n, m) {
  if (n == 0n) return 1n;
  if (n % 2n == 0n) return mod(a * a % m, n / 2n, m);
  return a * mod(a, n - 1n, m) % m;
}
function extendedEuclid(a, b) {
  if (!b) return [1, 0];
  else {
    let [x, y] = extendedEuclid(b, a % b);
    return [y, x - (a / b | 0) * y];
  }
}

(async () => {
  await inputPromise;
  let inp = input.split(/\s+/).map(v => +v); r = 0;
  let t = inp[r++];
  For(1, t, i => {
    let n = inp[r++];
    let edge = Arr(0, n, i => []);
    For(1, n - 1, i => {
      let u = inp[r++], v = inp[r++];
      edge[u].push(v);
      edge[v].push(u);
    });
    let size = Array(n + 1).fill(0);
    let t0 = Array(n + 1).fill(0);
    let t1 = Array(n + 1).fill(0);
    let minComp = 1e10, res = [], t = 0;
    let dfs = v => {
      t0[v] = t++;
      size[v] = 1;
      let comp = 0;
      edge[v].forEach(u => {
        if (size[u]) return;
        dfs(u);
        size[v] += size[u];
        comp = Math.max(comp, size[u]);
      });
      comp = Math.max(comp, n - size[v]);
      if (comp < minComp) {
        minComp = comp;
        res = [v];
      } else if (comp == minComp) res.push(v);
      t1[v] = t++;
    }
    dfs(1);
    // console.log(size);
    // console.log(res, minComp);
    // console.log(t0,t1);
    if (res.length == 1) {
      let u = Arr(1, n).find(u => edge[u].length);
      console.log(u, edge[u][0]);
      console.log(u, edge[u][0]);
    } else {
      if (t0[res[0]] > t0[res[1]]) res.reverse();
      // console.log(res);
      let i = Arr(1,n).find(i => size[i]==1 && t0[res[1]] < t0[i] && t1[i] < t1[res[1]]);
      // console.log(i);
      console.log(i, edge[i][0]);
      console.log(i, res[0]);
    }
  })
})();