You are given an integer array $$$a_1, a_2, \dots, a_n$$$ and integer $$$k$$$.In one step you can   either choose some index $$$i$$$ and decrease $$$a_i$$$ by one (make $$$a_i = a_i - 1$$$);  or choose two indices $$$i$$$ and $$$j$$$ and set $$$a_i$$$ equal to $$$a_j$$$ (make $$$a_i = a_j$$$). What is the minimum number of steps you need to make the sum of array $$$\sum\limits_{i=1}^{n}{a_i} \le k$$$? (You are allowed to make values of array negative).

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 two integers $$$n$$$ and $$$k$$$ ($$$1 \le n \le 2 \cdot 10^5$$$; $$$1 \le k \le 10^{15}$$$) — the size of array $$$a$$$ and upper bound on its sum. The second line of each test case contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 10^9$$$) — the array itself. It's guaranteed that the sum of $$$n$$$ over all test cases doesn't exceed $$$2 \cdot 10^5$$$.

For each test case, print one integer — the minimum number of steps to make $$$\sum\limits_{i=1}^{n}{a_i} \le k$$$.

NoteIn the first test case, you should decrease $$$a_1$$$ $$$10$$$ times to get the sum lower or equal to $$$k = 10$$$.In the second test case, the sum of array $$$a$$$ is already less or equal to $$$69$$$, so you don't need to change it.In the third test case, you can, for example:   set $$$a_4 = a_3 = 1$$$;  decrease $$$a_4$$$ by one, and get $$$a_4 = 0$$$.  As a result, you'll get array $$$[1, 2, 1, 0, 1, 2, 1]$$$ with sum less or equal to $$$8$$$ in $$$1 + 1 = 2$$$ steps.In the fourth test case, you can, for example:   choose $$$a_7$$$ and decrease in by one $$$3$$$ times; you'll get $$$a_7 = -2$$$;  choose $$$4$$$ elements $$$a_6$$$, $$$a_8$$$, $$$a_9$$$ and $$$a_{10}$$$ and them equal to $$$a_7 = -2$$$.  As a result, you'll get array $$$[1, 2, 3, 1, 2, -2, -2, -2, -2, -2]$$$ with sum less or equal to $$$1$$$ in $$$3 + 4 = 7$$$ steps.

"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 isPossible(op, sum, arr, n, k) {
	var pref = 0;
	for (let i = n - 1; i > 0; i--) {
		var extra = arr[i] - arr[0];
		pref += extra;
		if (sum - 1 <= k) return true;
		op--;
		var minSumPossible = sum - pref - op * (n - i + 1);
		if (minSumPossible <= k) return true;
		if (op == 0) return false;
	}
	return false;
}

function solve() {
	var [n, k] = readLine().trim().split(" ").map(Number);
	var arr = readLine().trim().split(" ").map(Number);
	arr.sort((a, b) => a - b);
	var sum = arr.reduce((ac, now) => ac + now, 0);
	if (sum <= k) return 0;
	if (n == 1) {
		return arr[0] - k;
	}
	//sorry that line was written by mistake, wondering how it worked then?
	//var have a global lexical scope
	var l = 1,
		r = 1e12;
	while (l < r) {
		var mid = Math.floor((l + r) / 2);
		if (isPossible(mid, sum, arr, n, k)) {
			r = mid;
		} else {
			l = mid + 1;
		}
	}
	return r;
}

function main() {
	var t = +readLine();
	while (t--) {
		console.log(solve());
	}
}

"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 isPossible(op, sum, arr, n, k) {
	var pref = 0;
	for (let i = n - 1; i > 0; i--) {
		var extra = arr[i] - arr[0];
		pref += extra;
		if (sum - 1 <= k) return true;
		op--;
		var minSumPossible = sum - pref - op * (n - i + 1);
		if (minSumPossible <= k) return true;
		if (op == 0) return false;
	}
	return false;
}

function solve() {
	var [n, k] = readLine().trim().split(" ").map(Number);
	var arr = readLine().trim().split(" ").map(Number);
	arr.sort((a, b) => a - b);
	var sum = arr.reduce((ac, now) => ac + now, 0);
	if (sum <= k) return 0;
	if (n == 1) {
		return arr[0] - k;
	}
	if (sum - 1)
		var l = 1,
			r = 1e12;
	while (l < r) {
		var mid = Math.floor((l + r) / 2);
		if (isPossible(mid, sum, arr, n, k)) {
			r = mid;
		} else {
			l = mid + 1;
		}
	}
	return r;
}

function main() {
	var t = +readLine();
	while (t--) {
		console.log(solve());
	}
}

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

function solve(n, k, arr) {
    arr.sort((a, b) => a - b)
// console.log(arr)
    const sum = arr.reduce((s, x) => s + x, 0)
    if (sum <= k) return 0

    let b = 0
    let s = 0
    let ans = sum - k
    for (let i = arr.length - 1; i >= 1; i--) {
        b++
        s += arr[i] - arr[0]
        const d = sum - k - s
        // a + ab + s >= sum - k
        const a = d <= 0 ? 0 : Math.ceil(d / (b + 1))
        // console.log(s, d, a, b, (a + a * b + s))
        ans = Math.min(ans, a + b)
    }
    return ans
}

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

const ra = ()=>readline().split(' ').map(a=>+a);

function div(val, by){
    return (val - val % by) / by;
}

const cnk = (n, k) => {
    let res = 1;
    for (let i = 1; i <= k; i++)
        res = res * (n - k + i) / i;
    return Math.round(res + 0.01);
}

const sumab = (a, b) => {
    let x = (b - a + 1);
    let y = a + b;
    if (x % 2 === 0) {
        x = Math.round(x / 2);
    } else {
        y = Math.round(y / 2);
    }
    return BigInt(x) * BigInt(y);
}

const calc = (n, k, a) => {
    a = a.sort((x, y) => x - y);
    let sum = 0;
    let pref = new Array(n).fill(0);
    let min = a[0];
    pref[0] = a[0];
    for (let i = 0; i < n; i++) {
        sum += a[i];
        if (i > 0) pref[i] = pref[i - 1] + a[i];
    }

    if (sum <= k) return 0;
    let result = sum - k;
    if (n === 1) return result;

    for (let swaps = 0; swaps < n; swaps++) {
        let firstSwapped = n - swaps;
        let othersum = pref[firstSwapped - 1] - pref[0];
        let targetNum = Math.floor((k - othersum) / (swaps + 1) + 0.0001);
        let minusops = a[0] - targetNum;
        result = Math.min(result, Math.max(minusops, 0) + swaps);
    }
    return result;
};

function main() {
    let T = +readline();
    for (let t = 1; t <= T; t++){
        let [n, k] = ra();
        let a = ra();
        console.log(`${calc(n, k, a)}`);
    }
}

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

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

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

function main () {
	let T = rn();
	while (T--) {
		const [n, k] = rna();
		const a = rna();

		let sum = 0;
		for (let i = 0; i < n; i++) sum += a[i];
		const excess = Math.max(0, sum - k);
		a.sort((x, y) => y - x);

		let ans = 1e18;
		for (let i = 1, vcur = 0; i <= n; i++) {
			const d = Math.max(0, Math.ceil((excess - vcur) / i));
			ans = Math.min(ans, d + i - 1);
			vcur += a[i-1] - a[n-1];
		}

		console.log(ans);
	}
}

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 () => {
        let next;
        do {
            next = (await getLineGen.next());
        } while (!next.done && next.value === '');
        return next.value;
    };
})();

let solve = async () => {
    const nsc = parseInt(await getLine());
    for(let sc = 0; sc < nsc; sc++) {
        const [n,k] = (await getLine()).split(' ').map(num => parseInt(num));
        const a = (await getLine()).split(' ').map(num => parseInt(num));
        a.sort((a,b) => (a - b));
        const sum = new Array(n);
        for(let i = 0; i < n; i++) {
            sum[i] = a[i];
            if (i > 0)
                sum[i] += sum[i - 1];
        }
        if (sum[n - 1] <= k) {
            console.log('0');
            continue;
        }
        let best = sum[n - 1] - k;
        for(let i = 1; i < n; i++) {
            let left = sum[i-1] - sum[0];
            let leftCount = n - (i - 1);
            let need = Math.floor((k - left) / leftCount);
            let try1 = 0;
            if (a[0] > need)
                try1 = a[0] - need;
            best = Math.min(best, try1 + n - i);
        }

        console.log(best);
    }
}

solve();

"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 isPossible(op, sum, arr, n, k) {
	var pref = 0;
	for (let i = n - 1; i > 0; i--) {
		var extra = arr[i] - arr[0];
		pref += extra;
		if (sum - 1 <= k) return true;
		op--;
		var minSumPossible = sum - pref - op * (n - i + 1);
		if (minSumPossible <= k) return true;
		if (op == 0) return false;
	}
	return false;
}

function solve() {
	var [n, k] = readLine().trim().split(" ").map(Number);
	var arr = readLine().trim().split(" ").map(Number);
	arr.sort((a, b) => a - b);
	var sum = arr.reduce((ac, now) => ac + now, 0);
	if (sum <= k) return 0;
	if (n == 1) {
		return arr[0] - k;
	}
	if (sum - 1)
		var l = 1,
			r = 1e9;
	while (l < r) {
		var mid = Math.floor((l + r) / 2);
		if (isPossible(mid, sum, arr, n, k)) {
			r = mid;
		} else {
			l = mid + 1;
		}
	}
	return r;
}

function main() {
	var t = +readLine();
	while (t--) {
		console.log(solve());
	}
}

"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 isPossible(op, sum, arr, n, k) {
	var pref = 0;
	for (let i = n - 1; i > 0; i--) {
		var extra = arr[i] - arr[0];
		pref += extra;
		op--;
		var minSumPossible = sum - pref - op * (n - i + 1);

		if (minSumPossible <= k) return true;
		if (op == 0) return false;
	}
	return false;
}

function solve() {
	var [n, k] = readLine().trim().split(" ").map(Number);
	var arr = readLine().trim().split(" ").map(Number);
	arr.sort((a, b) => a - b);
	var sum = arr.reduce((ac, now) => ac + now, 0);
	if (sum <= k) return 0;
	if (n == 1) {
		return arr[0] - k;
	}
	var l = 1,
		r = 1e9;
	while (l < r) {
		var mid = Math.floor((l + r) / 2);
		if (isPossible(mid, sum, arr, n, k)) {
			r = mid;
		} else {
			l = mid + 1;
		}
	}
	return r;
}

function main() {
	var t = +readLine();
	while (t--) {
		console.log(solve());
	}
}

"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 isPossible(op, sum, arr, n, k) {
	var pref = 0;
	for (let i = n - 1; i > 0; i--) {
		var extra = arr[i] - arr[0];
		pref += extra;
		op--;
		var minSumPossible = sum - pref - op * (n - i + 1);

		if (minSumPossible <= k) return true;
		if (op == 0) return false;
	}
	return false;
}

function solve() {
	var [n, k] = readLine().trim().split(" ").map(Number);
	var arr = readLine().trim().split(" ").map(Number);
	arr.sort((a, b) => a - b);
	var sum = arr.reduce((ac, now) => ac + now, 0);
	if (sum <= k) return 0;

	var l = 1,
		r = 1e9;
	while (l < r) {
		var mid = Math.floor((l + r) / 2);
		if (isPossible(mid, sum, arr, n, k)) {
			r = mid;
		} else {
			l = mid + 1;
		}
	}
	return r;
}

function main() {
	var t = +readLine();
	while (t--) {
		console.log(solve());
	}
}

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

function solve(n, k, arr) {
    arr.sort((a, b) => a - b)
// console.log(arr)
    const sum = arr.reduce((s, x) => s + x, 0)
    if (sum <= k) return 0

    let b = 0
    let s = 0
    let ans = sum - k
    for (let i = arr.length - 1; i >= 1; i--) {
        b++
        s += arr[i] - arr[0]
        const d = sum - k - s
        // a + ab + s >= sum - k
        const a = Math.ceil(d / (b + 1))
        // console.log(s, d, a, b, (a + a * b + s))
        ans = Math.min(ans, a + b)
    }
    return ans
}

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

function solve(n, k, arr) {
    arr.sort((a, b) => a - b)
// console.log(arr)
    const sum = arr.reduce((s, x) => s + x, 0)
    if (sum <= k) return 0

    let b = 0
    let s = 0
    let ans = sum - k
    for (let i = arr.length - 1; i >= 1; i--) {
        b++
        const d = sum - k - s
        // a + ab + s >= sum - k
        const a = Math.floor(d / (b + 1))
        // console.log(s, d, a, b)
        ans = Math.min(ans, a + b)

        s += arr[i] - arr[0]
    }
    return ans
}

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

const ra = ()=>readline().split(' ').map(a=>+a);

function div(val, by){
    return (val - val % by) / by;
}

const cnk = (n, k) => {
    let res = 1;
    for (let i = 1; i <= k; i++)
        res = res * (n - k + i) / i;
    return Math.round(res + 0.01);
}

const sumab = (a, b) => {
    let x = (b - a + 1);
    let y = a + b;
    if (x % 2 === 0) {
        x = Math.round(x / 2);
    } else {
        y = Math.round(y / 2);
    }
    return BigInt(x) * BigInt(y);
}

const calc = (n, k, a) => {
    a = a.sort((x, y) => x - y);
    let sum = 0;
    let pref = new Array(n).fill(0);
    let min = a[0];
    pref[0] = a[0];
    for (let i = 0; i < n; i++) {
        sum += a[i];
        if (i > 0) pref[i] = pref[i - 1] + a[i];
    }

    if (sum <= k) return 0;
    let result = sum - k;
    if (n === 1) return result;

    for (let swaps = 0; swaps < n; swaps++) {
        let firstSwapped = n - swaps;
        let othersum = pref[firstSwapped - 1] - pref[0];
        let targetNum = Math.floor((k - othersum) / (swaps + 1) + 0.0001);
        let minusops = a[0] - targetNum;
        result = Math.min(result, minusops + swaps);
    }
    return result;
};

function main() {
    let T = +readline();
    for (let t = 1; t <= T; t++){
        let [n, k] = ra();
        let a = ra();
        console.log(`${calc(n, k, a)}`);
    }
}


You are given two integers $$$l$$$ and $$$r$$$, where $$$l < r$$$. We will add $$$1$$$ to $$$l$$$ until the result is equal to $$$r$$$. Thus, there will be exactly $$$r-l$$$ additions performed. For each such addition, let's look at the number of digits that will be changed after it.For example:   if $$$l=909$$$, then adding one will result in $$$910$$$ and $$$2$$$ digits will be changed;  if you add one to $$$l=9$$$, the result will be $$$10$$$ and $$$2$$$ digits will also be changed;  if you add one to $$$l=489999$$$, the result will be $$$490000$$$ and $$$5$$$ digits will be changed. Changed digits always form a suffix of the result written in the decimal system.Output the total number of changed digits, if you want to get $$$r$$$ from $$$l$$$, adding $$$1$$$ each time.

The first line contains an integer $$$t$$$ ($$$1 \le t \le 10^4$$$). Then $$$t$$$ test cases follow. Each test case is characterized by two integers $$$l$$$ and $$$r$$$ ($$$1 \le l < r \le 10^9$$$).

For each test case, calculate the total number of changed digits if you want to get $$$r$$$ from $$$l$$$, adding one each time.

'use strict';

function solve(n, m) {
  const dp = [1, 11];
  for (let i = 2; i <= 9; i++) {
    dp[i] = dp[i - 1] * 10 + 1;
  }
  let res = 0,
      t = m;
  for (let i = 9; i >= 0; i--) {
    const j = Math.floor(t / 10 ** i);
    res += dp[i] * j;
    t -= 10 ** i * j;
  }
  t = n;
  for (let i = 9; i >= 0; i--) {
    const j = Math.floor(t / 10 ** i);
    res -= dp[i] * j;
    t -= 10 ** i * j;
  }
  return res;
}

async function main(read) {
  try {
    let t = Number(await read());
    let res = new Array(t);
    for (let i = 0; i < t; i++) {
      const [n, m] = (await read()).split(' ').map(Number);
      res[i] = solve(n, m);
    }
    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);
});

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

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

function main () {
	let T = rn();
	while (T--) {
		const [l, r] = rna();

		function countChanges (n) {
			let res = 0, k = 0;
			while (n) {
				k = k * 10 + 1;
				res += n % 10 * k;
				n = Math.floor(n / 10);
			}
			return res;
		}

		const ans = countChanges(r) - countChanges(l);
		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 t = parseInt(lines[0]);
    var l = 1;
    for (var i = 0; i < t; i++) {
        console.log(solve(lines[l++].split(' ')));
    }
});

function solve([a, b]) {
    return f(b) - f(a)
}

function f(str) {
    const chs = str.split('').reverse().map(Number)
    let base = 10 + 1
    const factor = [0] // for 10^i
    for (let i = 0; i < chs.length; i++) {
        factor.push(base)
        base = base * 10 + 1
    }

    let sum = 0
    for (let i = 0; i < chs.length; i++) {
        const x = chs[i]
        if (i) {
            sum += x * factor[i]
        } else {
            sum += x
        }
    }
    return sum
}

function readStringArray() {
  return readline().split(" ");
}
function readNumArray() {
  return readStringArray().map(Number);
}

function main(){
	var numberOfLines = parseInt(readline(), 10);

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

		var lr = readNumArray();

		var n1 = lr[0];
		var n2 = lr[1];

		var digits = 0;

		while(n1 !== 0 || n2 !== 0){
			digits = digits + (n2 - n1);
			n1 = Math.floor(n1/10);
			n2 = Math.floor(n2/10);
		}

		print(digits);

	}
}

main();


Ashish and Vivek play a game on a matrix consisting of $$$n$$$ rows and $$$m$$$ columns, where they take turns claiming cells. Unclaimed cells are represented by $$$0$$$, while claimed cells are represented by $$$1$$$. The initial state of the matrix is given. There can be some claimed cells in the initial state.In each turn, a player must claim a cell. A cell may be claimed if it is unclaimed and does not share a row or column with any other already claimed cells. When a player is unable to make a move, he loses and the game ends.If Ashish and Vivek take turns to move and Ashish goes first, determine the winner of the game if both of them are playing optimally.Optimal play between two players means that both players choose the best possible strategy to achieve the best possible outcome for themselves.

The first line consists of a single integer $$$t$$$ $$$(1 \le t \le 50)$$$ — the number of test cases. The description of the test cases follows. The first line of each test case consists of two space-separated integers $$$n$$$, $$$m$$$ $$$(1 \le n, m \le 50)$$$ — the number of rows and columns in the matrix. The following $$$n$$$ lines consist of $$$m$$$ integers each, the $$$j$$$-th integer on the $$$i$$$-th line denoting $$$a_{i,j}$$$ $$$(a_{i,j} \in \{0, 1\})$$$.

For each test case if Ashish wins the game print "Ashish" otherwise print "Vivek" (without quotes).

NoteFor the first case: One possible scenario could be: Ashish claims cell $$$(1, 1)$$$, Vivek then claims cell $$$(2, 2)$$$. Ashish can neither claim cell $$$(1, 2)$$$, nor cell $$$(2, 1)$$$ as cells $$$(1, 1)$$$ and $$$(2, 2)$$$ are already claimed. Thus Ashish loses. It can be shown that no matter what Ashish plays in this case, Vivek will win. For the second case: Ashish claims cell $$$(1, 1)$$$, the only cell that can be claimed in the first move. After that Vivek has no moves left.For the third case: Ashish cannot make a move, so Vivek wins.For the fourth case: If Ashish claims cell $$$(2, 3)$$$, Vivek will have no moves left.

var t = parseInt(readline());
for (var tc = 0; tc < t; tc++) {
  var nm = readline()
    .split(" ")
    .map((val) => parseInt(val));
  var n = nm[0],
    m = nm[1];
  var cells = [];
  var rows = new Array(n).fill(1);
  var col = new Array(m).fill(1);
  for (var i = 0; i < n; i++) {
    var r = readline()
      .split(" ")
      .map((val, ind) => {
        val = parseInt(val);
        if (val == 1) {
          rows[i] = 0;
          col[ind] = 0;
          return val;
        }
      });
  }

  var myCount1 = 0;
  for (var i = 0; i < n; i++) {
    if (rows[i] == 1) myCount1++;
  }

  var myCount2 = 0;
  for (var i = 0; i < m; i++) {
    if (col[i] == 1) myCount2++;
  }

  if (Math.min(myCount1, myCount2) % 2 == 0) print("Vivek");
  else print("Ashish");
}

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

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

  for(var i1 = 0; i1 < n; i1++){
    rows [i1] = 0;
  }
  for(var j1 = 0; j1 < m; j1++){
    columns[j1] = 0;
  }

  for(var i = 0; i < n; i++){
    var row = readline().split(" ").map(function(x) { return parseInt(x); });
    for(var j = 0; j < m; j++){
      if(row[j] == 1){
        columns[j] = 1;
        rows[i] = 1;
      }
    }
  }

  var freeRows = rows.reduce((p, c) => c == 1 ? p : p+1, 0);
  var freeColumnss = columns.reduce((p, c) => c == 1 ? p : p+1, 0);

  var minV = Math.min(freeColumnss, freeRows);

  if(minV % 2 == 0){
    print("Vivek")
  }
  else{
    print("Ashish")
  }

}

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

function readStringArray() {
  return readline().split(" ");
}
function readNumArray() {
  return readStringArray().map(Number);
}

function main() {
  var testCasesNum = +readline();
  for (var i = 0; i < testCasesNum; i++) {
    var nm = readNumArray();
    var n = nm[0];
    var m = nm[1];
    var nC = new Set();
    var mC = new Set();
    for (var j = 0; j < n; j++) {
      var currN = readNumArray();
      for (var k = 0; k < m; k++) {
        if (currN[k]) {
          mC.add(k);
          nC.add(j);
        }
      }
    }
    var steps = Math.min(n - nC.size, m - mC.size);

    print(steps % 2 ? "Ashish" : "Vivek");
  }
}

main();

// const bg = require('big-integer')
process.stdin.resume()
process.stdin.setEncoding('utf-8')
const MOD1 = 1000000007

function alpha(c = 'A') {
  return [...{
    _b: c === 'A' ? 65 : 97,
    _i: -1,
    [Symbol.iterator]() {
      return this
    },
    next() {
      this._i++
      if (this._i === 26) return {done: true}
      else return {done: false, value: String.fromCharCode(this._i + this._b)}
    }
  }]
}

class rc {
  static construct() {
    this.input = ''
    this.ptr = 0
  }
  static readString() {
    return this.input[this.ptr++]
  }

  static readStrings() {
    return this.input[this.ptr++].split(' ')
  }

  static readInt() {
    return +this.readString()
  }

  static readInts() {
    return this.readStrings().map(a => +a)
  }

  static readBigInteger() {
    return bg(this.readString())
  }

  static readBigIntegers() {
    return this.readStrings().map(a => bg(a))
  }
}

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

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

rc.construct()
// bc.construct()
process.stdin.on('data', (i) => {
  rc.input += i
})

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

function main() {
  let t = rc.readInt()
  while (t--) {
    const [n, m] = rc.readInts()
    const a = new Array(n)
    let count1 = 0
    for(let i = 0; i < n; i++) {
      a[i] = rc.readInts()
      let x = a[i].includes(1)
      if(x) count1++
    }

    let count2 = 0
    for(let i = 0; i < m; i++) {
      for(let j = 0; j < n; j++) {
        if(a[j][i] === 1) {
          count2++
          break
        }
      }
    }

    let diff = Math.min(n - count1, m - count2)

    // wr(count1, count2)

    if((diff & 1) === 0) wr('Vivek')
    else wr('Ashish')
  }

}

//↓見なくていいよ！ここから--------------------------------------------------
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);
  myerr("-----start-----");
  var start = new Date();
  Main();
  var end = new Date() - start;
  myerr("----- end -----");
  myerr("time : " + (end) + "ms");
  myerr("memory : " + Math.round(process.memoryUsage().heapTotal / 1024) + "KB");
});
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){
  var returnObj = {
    list : input, index : 0, max : input.length,
    hasNext : function(){return (this.index < this.max);},
    next : function(){if(!this.hasNext()){throw "ArrayIndexOutOfBoundsException これ以上ないよ";}else{var returnInput = this.list[this.index];this.index++;return returnInput;}}
  };
  return returnObj;
}
function myout(s){console.log(s);}
function myerr(s){console.error("debug:" + require("util").inspect(s,false,null));}
//[no]要素の扱い。数値型
//不明値、異常時:引数そのまま返す 1:数値へ変換
//2:半角SPで分割 4:半角SPで分割し、数値配列へ
//6:1文字で分割  7:1文字で分割し、数値配列へ
//8:半角SPで結合 9:改行で結合 0:文字なしで結合
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;}}

//↑見なくていいよ！ここまで--------------------------------------------------
function Main(){
	var t = nextInt();
	var output = new Array(t);
	for(var i = 0; i < t; i++){
		var one = nextIntArray();
		var N = one[0];
		var M = one[1];
		var list = new Array(N);
		var used = new Set();
		for(var j = 0; j < N; j++){
			list[j] = nextStrArray();
		}
		var turn = true;//true:Asish,false:Vivek
		while(true){
			if(turn){
				var isChange = false;
				for(var j = 0; j < N; j++){
					if(isChange){
						break;
					}
					for(var k = 0; k < M; k++){
						if(isChange){
							break;
						}
						if(list[j][k] == "0"){
							var isNG = false;
							for(var l = 0; l < N; l++){
								if(list[l][k] == "1"){
									isNG = true;
									break;
								}
							}
							for(var l = 0; l < M; l++){
								if(list[j][l] == "1"){
									isNG = true;
									break;
								}
							}
							if(!isNG){
								list[j][k] = "1";
								isChange = true;
							}
						}
					}
				}
				if(isChange){
					turn = false;
				}else{
					break;
				}
			}else{
				var isChange = false;
				for(var j = 0; j < N; j++){
					if(isChange){
						break;
					}
					for(var k = 0; k < M; k++){
						if(isChange){
							break;
						}
						if(list[j][k] == "0"){
							var isNG = false;
							for(var l = 0; l < N; l++){
								if(list[l][k] == "1"){
									isNG = true;
									break;
								}
							}
							for(var l = 0; l < M; l++){
								if(list[j][l] == "1"){
									isNG = true;
									break;
								}
							}
							if(!isNG){
								list[j][k] = "1";
								isChange = true;
							}
						}
					}
				}
				if(isChange){
					turn = true;
				}else{
					break;
				}
			}
		}
		if(turn){
			output[i] = "Vivek";
		}else{
			output[i] = "Ashish";
		}
	}
	myout(myconv(output,9));
}

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

let stdinInput = '';

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

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

function main(data) {
  data = data.split('\n');
  const testCases = data.shift() * 1;
  let i = 0;
  while (i < testCases) {
    let int = data.shift().split(' ');
    let col = int[1] * 1;
    let row = int[0] * 1;
    let arr = [];
    let player = 0;
    let idxC = {};
    for (let j = 0; j < row; j += 1) arr.push(data.shift().slice(0, -1).split(' '));
    for (let j = 0; j < arr.length; j += 1) {
      let idx = arr[j].indexOf('1');
      if (idx < 0) {
        let k = 0;
        i1:
        while (k < col) {
          if (!idxC[k]) {
            let check = true;
            for (let r = 0; r < row; r += 1) {
              if (arr[r][k] === '1') {idxC[k] = 1; k += 1; continue i1;}
            }
            arr[j][k] = '1';
            idxC[k] = 1;
            player += 1;
            break;
          }
          k += 1;
        }
      } else idxC[idx] = 1;
    }
    const result = (player & 1) === 0 ? 'Vivek' : 'Ashish';
    console.log(result);
    i += 1;
  }
}

const processData = (lines) => {
  let acc = 0
  const n = +lines[acc]
  acc++
  for (let i=0; i<n; i++) {
    const [n, m] = lines[acc].split(' ').map(x => +x)
    const l = {x: new Array(m).fill(0), y: new Array(n).fill(0)}
    let it = 0
    acc++
    while(it<n) {
      const arr = lines[acc].split(' ').map(x => +x)
      for (let i =0; i<arr.length; i++) {
        if (arr[i] === 1) {
          l.y[it] = 1
          l.x[i] = 1
        }
      }
      it++
      acc++
    }
    const sumX = l.x.reduce((r, x) => r+x, 0)
    const sumY = l.y.reduce((r, x) => r+x, 0)
    const pos = Math.min(n - sumY, m - sumX)
    console.log(pos % 2 === 0? 'Vivek' : 'Ashish')
  }
}

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

'use strict';
// node.js
process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';
let currentLine = 0;

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

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

    main();
});

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

function main() {
    var testCases = parseInt(readLine());

    for (var i = 0; i < testCases; i++) {
        var numbers = readLine()
            .split(" ")
            .map(num => parseInt(num));

        var rows = numbers[0];
        var columns = numbers[1];
        var rowsAvaiable = Array(rows).fill(true);
        var columnsAvaiable = Array(columns).fill(true);

        for (let j = 0; j < rows; j++) {
            readLine()
                .split(" ")
                .map(num => parseInt(num))
                .forEach((number, index) => {
                    // console.log(number, index);
                    if (number == 1) {
                        rowsAvaiable[j] = false;
                        columnsAvaiable[index] = false;
                    }
                });
        }
        console.log(
            Math.min(
                rowsAvaiable.filter(value => value == true).length,
                columnsAvaiable.filter(value => value == true).length
            ) % 2 ? "Ashish" : "Vivek"
        );
    }
}

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

var N = null,
    init = true,
    n = 0,
    m = 0,
    r, u, w

function initMatrix(line) {
    const size = line.split(" ").map(x => parseInt(x,10))
    u = new Set()
    w = new Set()
    n = size[0]
    m = size[1]
    r = 0
    init = false
}

function inputRow(line) {
    for (let c=0;c<2*m;c=c+2) {
        if (line[c] == "1") {
            u.add(r)
            w.add(c)
        }
    }
    if (++r == n) {
        n -= u.size
        m -= w.size

        console.log((m < n ? m : n)%2 == 1 ? "Ashish":"Vivek")
        init = --N == 0 ? rl.close() : true
    }
}

function loop(line) {
    if (line.trim() == "") return
    (init ? initMatrix : inputRow)(line)
}

rl.question("", line => {
    N = parseInt(line,10)
    rl.on("line", loop)
})

var t = parseInt(readline());
for (var tc = 0; tc < t; tc++) {
  var nm = readline()
    .split(" ")
    .map((val) => parseInt(val));
  var n = nm[0],
    m = nm[1];
  var cells = [];
  var rows = new Array(n).fill(1);
  var col = new Array(m).fill(1);
  for (var i = 0; i < n; i++) {
    var r = readline()
      .split(" ")
      .map((val, ind) => {
        val = parseInt(val);
        if (val == 1) {
          rows[i] = 0;
          col[ind] = 0;
          return val;
        }
      });
  }

  var myCount1 = 0;
  for (var i = 0; i < n; i++) {
    if (rows[i] == 1) myCount1++;
  }

  var myCount2 = 0;
  for (var i = 0; i < n; i++) {
    if (col[i] == 1) myCount2++;
  }

  if (Math.min(myCount1, myCount2) % 2 == 0) print("Vivek");
  else print("Ashish");
}

var t = parseInt(readline());
for (var tc = 0; tc < t; tc++) {
  var nm = readline()
    .split(" ")
    .map((val) => parseInt(val));
  var n = nm[0],
    m = nm[1];
  var cells = [];
  var rows = new Array(n).fill(1);
  var col = new Array(m).fill(1);
  for (var i = 0; i < n; i++) {
    var r = readline()
      .split(" ")
      .map((val, ind) => {
        val = parseInt(val);
        if (val == 1) {
          rows[i] = 0;
          col[ind] = 0;
          return val;
        }
      });
  }

  if (n <= m) {
    var myCount = 0;
    for (var i = 0; i < n; i++) {
      if (rows[i] == 1) myCount++;
    }
  } else {
    var myCount = 0;
    for (var i = 0; i < n; i++) {
      if (col[i] == 1) myCount++;
    }
  }
  if (n == 1 || m == 1) {
    if (myCount == 0) print("Vivek");
    else print("Ashish");
  } else {
    if (myCount % 2 == 0) print("Vivek");
    else print("Ashish");
  }
}

var t = parseInt(readline());
for (var tc = 0; tc < t; tc++) {
  var nm = readline()
    .split(" ")
    .map((val) => parseInt(val));
  var n = nm[0],
    m = nm[1];
  var cells = [];
  var rows = new Array(n).fill(1);
  var col = new Array(m).fill(1);
  for (var i = 0; i < n; i++) {
    var r = readline()
      .split(" ")
      .map((val, ind) => {
        val = parseInt(val);
        if (val == 1) {
          rows[i] = 0;
          col[ind] = 0;
          return val;
        }
      });
  }
  if (n >= m) {
    var myCount = 0;
    for (var i = 0; i < n; i++) {
      if (rows[i] == 1) myCount++;
    }
  } else {
    var myCount = 0;
    for (var i = 0; i < n; i++) {
      if (col[i] == 1) myCount++;
    }
  }

  if (myCount % 2 == 0) print("Vivek");
  else print("Ashish");
}

var t = parseInt(readline());
for (var tc = 0; tc < t; tc++) {
  var nm = readline()
    .split(" ")
    .map((val) => parseInt(val));
  var n = nm[0],
    m = nm[1];
  var cells = [];
  var rows = new Array(n).fill(1);
  var col = new Array(m).fill(1);
  for (var i = 0; i < n; i++) {
    var r = readline()
      .split(" ")
      .map((val, ind) => {
        val = parseInt(val);
        if (val == 1) {
          rows[i] = 0;
          col[ind] = 0;
          return val;
        }
      });
  }
  if (n <= m) {
    var myCount = 0;
    for (var i = 0; i < n; i++) {
      if (rows[i] == 1) myCount++;
    }
  } else {
    var myCount = 0;
    for (var i = 0; i < n; i++) {
      if (col[i] == 1) myCount++;
    }
  }

  if (myCount % 2 == 0) print("Vivek");
  else print("Ashish");
}

var t = parseInt(readline());
for (var tc = 0; tc < t; tc++) {
  var nm = readline()
    .split(" ")
    .map((val) => parseInt(val));
  var n = nm[0],
    m = nm[1];
  var cells = [];
  var rows = new Array(n).fill(1);
  var col = new Array(m).fill(1);
  for (var i = 0; i < n; i++) {
    var r = readline()
      .split(" ")
      .map((val, ind) => {
        val = parseInt(val);
        if (val == 1) {
          rows[i] = 0;
          col[ind] = 0;
          return val;
        }
      });
  }
  var count1 = 0;
  for (var i = 0; i < n; i++) {
    if (rows[i] == 1) count1++;
  }
  var count2 = 0;
  for (var i = 0; i < n; i++) {
    if (col[i] == 1) count2++;
  }
  var myCount = Math.min(count1, count2);
  if (myCount % 2 == 0) print("Vivek");
  else print("Ashish");
}

// const bg = require('big-integer')
process.stdin.resume()
process.stdin.setEncoding('utf-8')
const MOD1 = 1000000007

function alpha(c = 'A') {
  return [...{
    _b: c === 'A' ? 65 : 97,
    _i: -1,
    [Symbol.iterator]() {
      return this
    },
    next() {
      this._i++
      if (this._i === 26) return {done: true}
      else return {done: false, value: String.fromCharCode(this._i + this._b)}
    }
  }]
}

class rc {
  static construct() {
    this.input = ''
    this.ptr = 0
  }
  static readString() {
    return this.input[this.ptr++]
  }

  static readStrings() {
    return this.input[this.ptr++].split(' ')
  }

  static readInt() {
    return +this.readString()
  }

  static readInts() {
    return this.readStrings().map(a => +a)
  }

  static readBigInteger() {
    return bg(this.readString())
  }

  static readBigIntegers() {
    return this.readStrings().map(a => bg(a))
  }
}

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

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

rc.construct()
// bc.construct()
process.stdin.on('data', (i) => {
  rc.input += i
})

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

function main() {
  let t = rc.readInt()
  while (t--) {
    const [n, m] = rc.readInts()
    const a = new Array(n)
    let count = 0
    for(let i = 0; i < n; i++) {
      a[i] = rc.readInts()
      let x = a[i].includes(1)
      if(x) count++
    }

    let diff = n - count

    // wr(count)

    if((diff & 1) === 0) wr('Vivek')
    else wr('Ashish')
  }

}

//↓見なくていいよ！ここから--------------------------------------------------
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);
  myerr("-----start-----");
  var start = new Date();
  Main();
  var end = new Date() - start;
  myerr("----- end -----");
  myerr("time : " + (end) + "ms");
  myerr("memory : " + Math.round(process.memoryUsage().heapTotal / 1024) + "KB");
});
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){
  var returnObj = {
    list : input, index : 0, max : input.length,
    hasNext : function(){return (this.index < this.max);},
    next : function(){if(!this.hasNext()){throw "ArrayIndexOutOfBoundsException これ以上ないよ";}else{var returnInput = this.list[this.index];this.index++;return returnInput;}}
  };
  return returnObj;
}
function myout(s){console.log(s);}
function myerr(s){console.error("debug:" + require("util").inspect(s,false,null));}
//[no]要素の扱い。数値型
//不明値、異常時:引数そのまま返す 1:数値へ変換
//2:半角SPで分割 4:半角SPで分割し、数値配列へ
//6:1文字で分割  7:1文字で分割し、数値配列へ
//8:半角SPで結合 9:改行で結合 0:文字なしで結合
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;}}

//↑見なくていいよ！ここまで--------------------------------------------------
function Main(){
	var t = nextInt();
	var output = new Array(t);
	for(var i = 0; i < t; i++){
		var one = nextIntArray();
		var N = one[0];
		var M = one[1];
		var list = new Array(N);
		var used = new Set();
		for(var j = 0; j < N; j++){
			list[j] = nextStrArray();
		}
		var turn = true;//true:Asish,false:Vivek
		while(true){
			if(turn){
				var isChange = false;
				for(var j = 0; j < N; j++){
					if(isChange){
						break;
					}
					for(var k = 0; k < M; k++){
						if(isChange){
							break;
						}
						if(list[j][k] == "0"){
							var isNG = false;
							for(var l = 0; l < N; l++){
								if(list[l][k] == "1"){
									isNG = true;
									break;
								}
							}
							for(var l = 0; l < M; l++){
								if(list[j][l] == "1"){
									isNG = true;
									break;
								}
							}
							if(!isNG){
								list[j][k] = "1";
								isChange = true;
							}
						}
					}
				}
				if(isChange){
					turn = false;
				}else{
					break;
				}
			}else{
				var isChange = false;
				for(var j = 0; j < N; j++){
					if(isChange){
						break;
					}
					for(var k = 0; k < M; k++){
						if(isChange){
							break;
						}
						if(list[j][k] == "0"){
							var isNG = false;
							for(var l = 0; l < N; l++){
								if(list[l][k] == "1"){
									isNG = true;
									break;
								}
							}
							for(var l = 0; l < M; l++){
								if(list[j][l] == "1"){
									isNG = true;
									break;
								}
							}
							if(!isNG){
								list[j][k] = "1";
								isChange = true;
							}
						}
					}
				}
				if(isChange){
					turn = true;
				}else{
					break;
				}
			}
		}
		if(turn){
			output[i] = "Vivek";
		}else{
			output[i] = "Asish";
		}
	}
	myout(myconv(output,9));
}

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

var N = null,
    init = true,
    n = 0,
    m = 0,
    r, u, w

function initMatrix(line) {
    const size = line.split(" ").map(x => parseInt(x,10))
    u = new Set()
    w = new Set()
    n = size[0]
    m = size[1]
    r = 0
    init = false
}

function inputRow(line) {
    for (let c=0;c<2*m;c=c+2) {
        if (line[c] == "1") {
            u.add(r)
            w.add(c)
        }
    }
    if (++r == n) {
        n -= u.size
        m -= w.size
        console.log(n == 1 || m == 1 || (n-n%m)%2 == 1 ? "Ashish":"Vivek")
        init = --N == 0 ? rl.close() : true
    }
}

function loop(line) {
    if (line.trim() == "") return
    (init ? initMatrix : inputRow)(line)
}

rl.question("", line => {
    N = parseInt(line,10)
    rl.on("line", loop)
})

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

var N = null,
    init = true,
    n = 0,
    m = 0,
    r, u, w

function initMatrix(line) {
    const size = line.split(" ").map(x => parseInt(x,10))
    u = new Set()
    w = new Set()
    n = size[0]
    m = size[1]
    r = 0
    init = false
}

function inputRow(line) {
    for (let c=0;c<2*m;c=c+2) {
        if (line[c] == "1") {
            u.add(r)
            w.add(c)
        }
    }
    if (++r == n) {
        n -= u.size
        m -= w.size
        console.log(n != 0 && m != 0 && (n == 1 || m == 1 || (n-n%m)%2 == 1) ? "Ashish":"Vivek")
        init = --N == 0 ? rl.close() : true
    }
}

function loop(line) {
    if (line.trim() == "") return
    (init ? initMatrix : inputRow)(line)
}

rl.question("", line => {
    N = parseInt(line,10)
    rl.on("line", loop)
})


The sequence $$$a$$$ is sent over the network as follows:  sequence $$$a$$$ is split into segments (each element of the sequence belongs to exactly one segment, each segment is a group of consecutive elements of sequence);  for each segment, its length is written next to it, either to the left of it or to the right of it;  the resulting sequence $$$b$$$ is sent over the network. For example, we needed to send the sequence $$$a = [1, 2, 3, 1, 2, 3]$$$. Suppose it was split into segments as follows: $$$[\color{red}{1}] + [\color{blue}{2, 3, 1}] + [\color{green}{2, 3}]$$$. Then we could have the following sequences:   $$$b = [1, \color{red}{1}, 3, \color{blue}{2, 3, 1}, \color{green}{2, 3}, 2]$$$,  $$$b = [\color{red}{1}, 1, 3, \color{blue}{2, 3, 1}, 2, \color{green}{2, 3}]$$$,  $$$b = [\color{red}{1}, 1, \color{blue}{2, 3, 1}, 3, 2, \color{green}{2, 3}]$$$,  $$$b = [\color{red}{1}, 1,\color{blue}{2, 3, 1}, 3, \color{green}{2, 3}, 2]$$$. If a different segmentation had been used, the sent sequence might have been different.The sequence $$$b$$$ is given. Could the sequence $$$b$$$ be sent over the network? In other words, is there such a sequence $$$a$$$ that converting $$$a$$$ to send it over the network could result in a sequence $$$b$$$?

The first line of input data contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. Each test case consists of two lines. The first line of the test case contains an integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) — the size of the sequence $$$b$$$. The second line of test case contains $$$n$$$ integers $$$b_1, b_2, \dots, b_n$$$ ($$$1 \le b_i \le 10^9$$$) — the sequence $$$b$$$ itself. It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$2 \cdot 10^5$$$.

For each test case print on a separate line:   YES if sequence $$$b$$$ could be sent over the network, that is, if sequence $$$b$$$ could be obtained from some sequence $$$a$$$ to send $$$a$$$ over the network.  NO otherwise.  You can output YES and NO in any case (for example, strings yEs, yes, Yes and YES will be recognized as positive response).

NoteIn the first case, the sequence $$$b$$$ could be obtained from the sequence $$$a = [1, 2, 3, 1, 2, 3]$$$ with the following partition: $$$[\color{red}{1}] + [\color{blue}{2, 3, 1}] + [\color{green}{2, 3}]$$$. The sequence $$$b$$$: $$$[\color{red}{1}, 1, \color{blue}{2, 3, 1}, 3, 2, \color{green}{2, 3}]$$$.In the second case, the sequence $$$b$$$ could be obtained from the sequence $$$a = [12, 7, 5]$$$ with the following partition: $$$[\color{red}{12}] + [\color{green}{7, 5}]$$$. The sequence $$$b$$$: $$$[\color{red}{12}, 1, 2, \color{green}{7, 5}]$$$.In the third case, the sequence $$$b$$$ could be obtained from the sequence $$$a = [7, 8, 9, 10, 3]$$$ with the following partition: $$$[\color{red}{7, 8, 9, 10, 3}]$$$. The sequence $$$b$$$: $$$[5, \color{red}{7, 8, 9, 10, 3}]$$$.In the fourth case, there is no sequence $$$a$$$ such that changing $$$a$$$ for transmission over the network could produce a sequence $$$b$$$.

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

function solve(n, arr) {
    const m = Array(n).fill(0)
        .map(() => [])
    for (let i = 0; i < arr.length; i++) {
        const x = arr[i]
        const y = i + x
        // m[y] = m[y] || []
        if (i + x < n) {
            m[y].push(x)
        }
    }
    const dp = Array(n).fill(0)
    if (arr[0] < n) dp[arr[0]] = 1
// console.log(m)
    for (let i = 0; i < arr.length; i++) {
        if (arr[i] === i) {
            dp[i] = 1
            continue
        }
        // dp[i] |= dp[i - arr[i]] || 0
        dp[i] |= dp[i - arr[i] - 1] || 0
        for (let j = 0; j < m[i].length; j++) {
            // dp[i] |= dp[m[i][j]] || 0
            dp[i] |= dp[i - m[i][j] - 1] || 0
            // console.log(i, dp[i - m[i][j] - 1], i - m[i][j] - 1)
        }
    }
// console.log(dp)
    return dp[n - 1] ? 'YES' : 'NO'
}

const fs = require("fs");
const input = fs.readFileSync(0, 'utf8').trim().split('\r\n');
let currentline = 0;
function readline(){
      return input[currentline++];
}

function alph() {
  var f = 'abcdefghijklmnopqrstuvwxyz';
  return f;
}
function Alph() {
  var f = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
  return f;
}
function max(x,y) {
  return x >=y ? x : y;
}
function min(x,y) {
  return x <=y ? x : y;
}
function abs(x) {
  return x < 0 ? x*(-1) : x;
}

var T = readline();
var inf = 1000000000000;
for(var tc=1;tc<=T;tc++) {
	var n = readline();
	var a = readline().split(" ").map(w => parseInt(w));
	var dp = [];
	for(var i=0;i<=n;i++) dp[i] = 0;
	dp[0] = 1;
	for(var i=1;i<=n;i++) {
		if(i-a[i-1] > -1 && dp[i-a[i-1]-1]) dp[i] = 1;
		if(i+a[i-1] <= n && dp[i-1]) dp[i+a[i-1]] = 1;
	}
	console.log(dp[n] ? "Yes" : "No")
}

'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 = [];
  for (let i = 0; i < n; i++) {
    a[i + 1] = rn();
  }
  const dp = new Array(n + 1).fill(false);
  dp[0] = true;
  for (let i = 1; i <= n; i++) {
    dp[i] = dp[i] || !!dp[i - a[i] - 1];
    if (dp[i - 1] && i + a[i] <= n) dp[i + a[i]] = true;
  }
  if (dp[n]) return 'YES';
  return 'NO';
}
function convertInput(read) {
  const rn = () => Number(read());
  const rb = () => BigInt(read());
  const rns = n => {
    let res = new Array(n);
    for (let i = 0; i < n; i++) res[i] = rn();
    return res;
  };
  const re = n => {
    let res = new Array(n);
    for (let i = 0; i < n; i++) res[i] = rn() - 1;
    return res;
  };
  const rbs = n => {
    let res = new Array(n);
    for (let i = 0; i < n; i++) res[i] = rb();
    return res;
  };
  return [rn, rb, rns, re, rbs];
}
function main(r) {
  const [rn, rb, rns, re, rbs] = convertInput(r);
  try {
    let t = rn();
    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(/\s+/);
void function () {
  const read = ((i = 0) => () => inputs[i++])();
  const output = main(read);
  process.stdout.write(output);
}();

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

function solve(n, arr) {
    const m = Array(n).fill(0)
        .map(() => [])
    for (let i = 0; i < arr.length; i++) {
        const x = arr[i]
        const y = i + x
        // m[y] = m[y] || []
        if (i + x < n) {
            m[y].push(x)
        }
    }
    const dp = Array(n).fill(0)
    if (arr[0] < n) dp[arr[0]] = 1
// console.log(m)
    for (let i = 0; i < arr.length; i++) {
        if (arr[i] === i) {
            dp[i] = 1
            continue
        }
        dp[i] |= dp[i - arr[i]] || 0
        for (let j = 0; j < m[i].length; j++) {
            dp[i] |= dp[m[i][j]]
        }
    }
// console.log(dp)
    return dp[n - 1] ? 'YES' : 'NO'
}


Vasya owns a cornfield which can be defined with two integers $$$n$$$ and $$$d$$$. The cornfield can be represented as rectangle with vertices having Cartesian coordinates $$$(0, d), (d, 0), (n, n - d)$$$ and $$$(n - d, n)$$$.    An example of a cornfield with $$$n = 7$$$ and $$$d = 2$$$. Vasya also knows that there are $$$m$$$ grasshoppers near the field (maybe even inside it). The $$$i$$$-th grasshopper is at the point $$$(x_i, y_i)$$$. Vasya does not like when grasshoppers eat his corn, so for each grasshopper he wants to know whether its position is inside the cornfield (including the border) or outside.Help Vasya! For each grasshopper determine if it is inside the field (including the border).

The first line contains two integers $$$n$$$ and $$$d$$$ ($$$1 \le d < n \le 100$$$). The second line contains a single integer $$$m$$$ ($$$1 \le m \le 100$$$) — the number of grasshoppers. The $$$i$$$-th of the next $$$m$$$ lines contains two integers $$$x_i$$$ and $$$y_i$$$ ($$$0 \le x_i, y_i \le n$$$) — position of the $$$i$$$-th grasshopper.

Print $$$m$$$ lines. The $$$i$$$-th line should contain "YES" if the position of the $$$i$$$-th grasshopper lies inside or on the border of the cornfield. Otherwise the $$$i$$$-th line should contain "NO". You can print each letter in any case (upper or lower).

NoteThe cornfield from the first example is pictured above. Grasshoppers with indices $$$1$$$ (coordinates $$$(2, 4)$$$) and $$$4$$$ (coordinates $$$(4, 5)$$$) are inside the cornfield.The cornfield from the second example is pictured below. Grasshoppers with indices $$$1$$$ (coordinates $$$(4, 4)$$$), $$$3$$$ (coordinates $$$(8, 1)$$$) and $$$4$$$ (coordinates $$$(6, 1)$$$) are inside the cornfield.

var dn = readline().split(" ").map(e=>+e);var n =dn[1];var f = Number(readline());

for(var i=0;i<f;i++){
var t = readline().split(" ").map(e=>+e)
var y1 = Math.abs(t[0]-n);
var y2 = t[0]+n;
if(y2>dn[0]){y2= dn[0] - (y2-dn[0])}

if((t[1]<y1)||(t[1]>y2)){print("NO");}else{print("YES");}
}

var input = readline().split(' ');

var n = Number(input[0]);
var d = Number(input[1]);

var points = [];
points.push([d,0]);
points.push([n, Math.abs(n-d)]);
points.push([Math.abs(n-d), n]);
points.push([0,d]);

var b = FindLength(points[0][0], points[1][0], points[0][1], points[1][1]);
var l = FindLength(points[1][0], points[2][0], points[1][1], points[2][1]);

var RectArea = Math.round(b*l);

function FindLength(x1, x2, y1, y2) {
  return Math.sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));
}

function FindTriArea(p1, p2, p3) {
  return Math.abs(((p1[0]-p3[0])*(p2[1]-p1[1]) - (p1[0]-p2[0])*(p3[1]-p1[1]))/2);
}

var m = Number(readline());

for(var i=0; i<m; i++) {
  var gp = (readline().split(' ')).map(function(x){ return Number(x);});
  var TriArea = FindTriArea(points[0], gp, points[1])+
                FindTriArea(points[1], gp, points[2])+
                FindTriArea(points[2], gp, points[3])+
                FindTriArea(points[3], gp, points[0]);

  if(parseFloat(RectArea.toFixed(7)) == parseFloat(TriArea.toFixed(7))) {
    print("YES");
  }
  else {
    print("NO");
  }
}

var input = readline().split(" ").map(function(el) {return parseInt(el)});
var n = input[0];
var d = input[1];
var m = parseInt(readline());
for (var i = 0; i < m; i++) {
    var point = readline().split(" ").map(function(el) {return parseInt(el)});
    var x = point[0];
    var y = point[1];
    if (y <= x + d && y <= (x*(-1)+2*n-d) && y >= x-d && y >= d-x)
        print("YES");
    else
        print("NO");
}


Igor the analyst fell asleep on the work and had a strange dream. In the dream his desk was crowded with computer mice, so he bought a mousetrap to catch them.The desk can be considered as an infinite plane, then the mousetrap is a rectangle which sides are parallel to the axes, and which opposite sides are located in points (x1, y1) and (x2, y2).Igor wants to catch all mice. Igor has analysed their behavior and discovered that each mouse is moving along a straight line with constant speed, the speed of the i-th mouse is equal to (vix, viy), that means that the x coordinate of the mouse increases by vix units per second, while the y coordinates increases by viy units. The mousetrap is open initially so that the mice are able to move freely on the desk. Igor can close the mousetrap at any moment catching all the mice that are strictly inside the mousetrap.Igor works a lot, so he is busy in the dream as well, and he asks you to write a program that by given mousetrap's coordinates, the initial coordinates of the mice and their speeds determines the earliest time moment in which he is able to catch all the mice. Please note that Igor can close the mousetrap only once.

The first line contains single integer n (1 ≤ n ≤ 100 000) — the number of computer mice on the desk. The second line contains four integers x1, y1, x2 and y2 (0 ≤ x1 ≤ x2 ≤ 100 000), (0 ≤ y1 ≤ y2 ≤ 100 000) — the coordinates of the opposite corners of the mousetrap. The next n lines contain the information about mice. The i-th of these lines contains four integers rix, riy, vix and viy, (0 ≤ rix, riy ≤ 100 000,  - 100 000 ≤ vix, viy ≤ 100 000), where (rix, riy) is the initial position of the mouse, and (vix, viy) is its speed.

In the only line print minimum possible non-negative number t such that if Igor closes the mousetrap at t seconds from the beginning, then all the mice are strictly inside the mousetrap. If there is no such t, print -1. Your answer is considered correct if its absolute or relative error doesn't exceed 10 - 6.  Formally, let your answer be a, and the jury's answer be b. Your answer is considered correct if .

NoteHere is a picture of the first samplePoints A, B, C, D - start mice positions, segments are their paths.Then, at first time when all mice will be in rectangle it will be looks like this:Here is a picture of the second samplePoints A, D, B will never enter rectangle.

 var n = parseInt(readline());
  var tmp = readline().split(' ').map(x => parseInt(x));
  var x1 = tmp[0];
  var y1 = tmp[1];
  var x2 = tmp[2];
  var y2 = tmp[3];
  var itvf = [0, Infinity];
  var intersect = (itv0, itv1) => {
    var l = Math.max(itv0[0], itv1[0]);
    var r = Math.min(itv0[1], itv1[1]);
    return l < r ? [l, r] : null;
  };
  var fail = false;
  for(var i = 0; i < n; i += 1) {
    tmp = readline().split(' ').map(x => parseInt(x));
    if(fail) {
      continue;
    }
    var rx = tmp[0];
    var ry = tmp[1];
    var vx = tmp[2];
    var vy = tmp[3];
    var itvm = intersect([(x1 - rx) / vx, (x2 - rx) / vx].sort((a, b) => a - b), [(y1 - ry) / vy, (y2 - ry) / vy].sort((a, b) => a - b));
    if(itvm === null || itvm[1] < 0) {
      fail = true;
    } else {
      itvm[0] = Math.max(0, itvm[0]);
      itvf = intersect(itvf, itvm);
      if(itvf === null) {
        fail = true;
      }
    }
  }
  if(fail) {
    print(-1);
  } else {
    print(itvf[0]);
  }


You are given $$$n$$$ rectangles, each of height $$$1$$$. Each rectangle's width is a power of $$$2$$$ (i. e. it can be represented as $$$2^x$$$ for some non-negative integer $$$x$$$). You are also given a two-dimensional box of width $$$W$$$. Note that $$$W$$$ may or may not be a power of $$$2$$$. Moreover, $$$W$$$ is at least as large as the width of the largest rectangle.You have to find the smallest height of this box, such that it is able to fit all the given rectangles. It is allowed to have some empty space left in this box after fitting all the rectangles.You cannot rotate the given rectangles to make them fit into the box. Moreover, any two distinct rectangles must not overlap, i. e., any two distinct rectangles must have zero intersection area.See notes for visual explanation of sample input.

The first line of input contains one integer $$$t$$$ ($$$1 \le t \le 5 \cdot 10^3$$$) — the number of test cases. Each test case consists of two lines. For each test case:  the first line contains two integers $$$n$$$ ($$$1 \le n \le 10^5$$$) and $$$W$$$ ($$$1 \le W \le 10^9$$$); the second line contains $$$n$$$ integers $$$w_1, w_2, \dots, w_n$$$ ($$$1 \le w_i \le 10^6$$$), where $$$w_i$$$ is the width of the $$$i$$$-th rectangle. Each $$$w_i$$$ is a power of $$$2$$$; additionally, $$$\max\limits_{i=1}^{n} w_i \le W$$$.  The sum of $$$n$$$ over all test cases does not exceed $$$10^5$$$.

Output $$$t$$$ integers. The $$$i$$$-th integer should be equal to the answer to the $$$i$$$-th test case — the smallest height of the box.

NoteFor the first test case in the sample input, the following figure shows one way to fit the given five rectangles into the 2D box with minimum height:  In the figure above, the number inside each rectangle is its width. The width of the 2D box is $$$16$$$ (indicated with arrow below). The minimum height required for the 2D box in this case is $$$2$$$ (indicated on the left).In the second test case, you can have a minimum height of three by keeping two blocks (one each of widths eight and two) on each of the three levels.

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

function main() {
    let testCases = readline()
    while (testCases--)
        solve()
}

// function to solve problems
function solve() {
    let [n, m] = readline().split(' ')
    let counts = Array(20).fill(0)
    readline().split(' ').map(x => {
        counts[Math.log2(x)] += 1
    })
    let ans = [m],
        maxNum = 0,
        index = 0
    // console.log('Counts = ', counts)
    while (n) {
        // better approach would be to store the maximum in order in the best possible way
        // greedy approach
        index = findGoodIndex(counts, ans[ans.length - 1])
        maxNum = Math.pow(2, index)
        if (index == -1) {
            index = findGoodIndex(counts, m)
            maxNum = Math.pow(2, index)
            ans.push(m - maxNum)
        } else {
            ans[ans.length - 1] -= maxNum
        }
        counts[index]--
        n--
    }
    console.log(ans.length)
}

function sortAscending(a, b) {
    return a - b
}

function findGoodIndex(counts, leftOver) {
    let index = 20
    while (index >= 0) {
        if (counts[index] > 0 && Math.pow(2, index) <= leftOver) {
            return index
        } else {
            index--
        }
    }
    return index
}

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

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

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

// PriorityQueue implementated using array based binary heap
// PriorityQueue methods
//  push(...values)
// 	peek()
//  pop()
//  size()
//  replace(value)

class PriorityQueue {

	constructor(comparator = (a, b) => a > b) {
		this.top = 0;
		this._heap = [];
		this._comparator = comparator;
	}
	size() {
		return this._heap.length;
	}
	isEmpty() {
		return this.size() == 0;
	}
	peek() {
		return this._heap[this.top];
	}
	push(...values) {
		values.forEach(value => {
				this._heap.push(value);
				this._siftUp();
				});
		return this.size();
	}
	pop() {
		const poppedValue = this.peek();
		const bottom = this.size() - 1;
		if (bottom > this.top) {
			this._swap(this.top, bottom);
		}
		this._heap.pop();
		this._siftDown();
		return poppedValue;
	}
	replace(value) {
		const replacedValue = this.peek();
		this._heap[this.top] = value;
		this._siftDown();
		return replacedValue;
	}
	_greater(i, j) {
		return this._comparator(this._heap[i], this._heap[j]);
	}
	_swap(i, j) {
		[this._heap[i], this._heap[j]] = [this._heap[j], this._heap[i]];
	}
	_siftUp() {
		const parent = i => ((i + 1) >>> 1) - 1;
		let node = this.size() - 1;
		while (node > this.top && this._greater(node, parent(node))) {
			this._swap(node, parent(node));
			node = parent(node);
		}
	}
	_siftDown() {
		const left = i => (i << 1) + 1;
		const right = i => (i + 1) << 1;
		let node = this.top;
		while (
				(left(node) < this.size() && this._greater(left(node), node)) ||
				(right(node) < this.size() && this._greater(right(node), node))
			  ) {
			let maxChild = (right(node) < this.size() && this._greater(right(node), left(node))) ? right(node) : left(node);
			this._swap(node, maxChild);
			node = maxChild;
		}
	}
}

function main () {
	let T = rn();
	while (T--) {
		const [n, W] = rna();
		const w = rna();

		const cnt = Array(20).fill(0);
		for (let i = 0; i < n; i++) {
			cnt[Math.log2(w[i])]++;
		}

		let ans = 0, placed = 0;
		w.sort((x, y) => y - x);
		while (placed < n) {
			++ans;
			let avl = W;
			while(1) {
				let j;
				for (j = 20; j >= 0; j--) {
					if (cnt[j] && 2**j <= avl) break;
				}
				if (j >= 0) avl -= 2**j, cnt[j]--, placed++; else break;
			}
		}

		console.log(ans);
	}
}

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

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

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

// PriorityQueue implementated using array based binary heap
// PriorityQueue methods
//  push(...values)
// 	peek()
//  pop()
//  size()
//  replace(value)

class PriorityQueue {

	constructor(comparator = (a, b) => a > b) {
		this.top = 0;
		this._heap = [];
		this._comparator = comparator;
	}
	size() {
		return this._heap.length;
	}
	isEmpty() {
		return this.size() == 0;
	}
	peek() {
		return this._heap[this.top];
	}
	push(...values) {
		values.forEach(value => {
				this._heap.push(value);
				this._siftUp();
				});
		return this.size();
	}
	pop() {
		const poppedValue = this.peek();
		const bottom = this.size() - 1;
		if (bottom > this.top) {
			this._swap(this.top, bottom);
		}
		this._heap.pop();
		this._siftDown();
		return poppedValue;
	}
	replace(value) {
		const replacedValue = this.peek();
		this._heap[this.top] = value;
		this._siftDown();
		return replacedValue;
	}
	_greater(i, j) {
		return this._comparator(this._heap[i], this._heap[j]);
	}
	_swap(i, j) {
		[this._heap[i], this._heap[j]] = [this._heap[j], this._heap[i]];
	}
	_siftUp() {
		const parent = i => ((i + 1) >>> 1) - 1;
		let node = this.size() - 1;
		while (node > this.top && this._greater(node, parent(node))) {
			this._swap(node, parent(node));
			node = parent(node);
		}
	}
	_siftDown() {
		const left = i => (i << 1) + 1;
		const right = i => (i + 1) << 1;
		let node = this.top;
		while (
				(left(node) < this.size() && this._greater(left(node), node)) ||
				(right(node) < this.size() && this._greater(right(node), node))
			  ) {
			let maxChild = (right(node) < this.size() && this._greater(right(node), left(node))) ? right(node) : left(node);
			this._swap(node, maxChild);
			node = maxChild;
		}
	}
}

function main () {
	let T = rn();
	while (T--) {
		const [n, W] = rna();
		const w = rna();

		let ans = 0;
		const mxq = new PriorityQueue((a, b) => a > b);
		w.sort((x, y) => y-x);
		for (let i = 0; i < n; i++) {
			const avl = mxq.peek();
			if (avl >= w[i]) {
				mxq.pop();
				mxq.push(avl-w[i]);
			} else {
				mxq.push(W-w[i]);
				ans++;
			}
		}

		console.log(ans);
	}
}

///////////////////////////////// pre-define /////////////////////////////////////
const pr = console.log;
const mi = Math.min;
///////////////////////////////////////////////////////////////////////////////////

const solve = (n, w, a) => {
    a.sort((x, y) => x - y);
    let uc = uniqcount(a);
    let h = 0;
    while (1) {
        let end = 1;
        for (const e of uc) {
            if (e[1] != 0) end = 0;
        }
        if (end) break;
        h++;
        let rem = w;
        for (let i = uc.length - 1; ~i; i--) {
            let w = uc[i][0];
            let use = mi(rem / w >> 0, uc[i][1]);
            rem -= use * w;
            uc[i][1] -= use;
        }
    }
    pr(h);
};

const uniqcount = (a) => {
    let n = a.length;
    let p = 0;
    let b = Array(n).fill(null);
    for (let i = 0; i < n; i++) {
        if (i == 0 || a[i] != a[i - 1]) b[p++] = [a[i], 0];
        b[p - 1][1]++;
    }
    return b.slice(0, p);
};

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

main()

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

function main() {
  const x = readline();
  var toPrint = ''

  Array(Number(x)).fill(1).map((t, i) => {
    // const a = parseInt(readline());
    var [n, w] = readline().split(' ').map((x, iii) => {
      return parseInt(x)
    });

    var b = new Array(1001).fill(0)
    var a = readline().split(' ').map((x, iii) => {
      return parseInt(x)
    });
    // console.log(a)
    for (let j = 0; j < n; j++) {
      var count = 0
      while (a[j] > 1) {
        a[j] = Math.floor(a[j] / 2)
        count++
      }
      b[count] = b[count] + 1
    }

    var res = 0
    while (true) {
      var sum = w
      for (let j = b.length - 1; j >= 0; j--) {
        if (b[j] === 0) continue
        var val = Math.pow(2, j)
        var x = Math.floor(sum / val)
        var take = Math.min(b[j], x)
        b[j] = b[j] - take
        sum = sum - take * val
      }
      if (sum === w) break
      res++
    }
    toPrint = toPrint + res + '\n'
  })
  console.log(toPrint)

  // var b = a.sort((a, b) => Math.abs(a) - Math.abs(b))

}

function SUMnUMBER(x, y) {
  return Math.log(y) / Math.log(x);
}

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

function main() {
    let testCases = readline()
    while (testCases--)
        solve()
}

// function to solve problems
function solve() {
    let [n, m] = readline().split(' ')
    let counts = Array(20).fill(0)
    readline().split(' ').map(x => {
        counts[Math.log2(x)] += 1
    })
    let ans = [m],
        maxNum = 0,
        index = 0
    // console.log('Counts = ', counts)
    while (n) {
        // better approach would be to store the maximum in order in the best possible way
        // greedy approach
        index = findGoodIndex(counts, ans[ans.length - 1])
        maxNum = Math.pow(2, index)
        if (index == -1) {
            maxNum = Math.pow(2, findGoodIndex(counts, m))
            ans.push(m - maxNum)
        } else {
            ans[ans.length - 1] -= maxNum
        }
        counts[index]--
        n--
    }
    console.log(ans.length)
}

function sortAscending(a, b) {
    return a - b
}

function findGoodIndex(counts, leftOver) {
    let index = 20
    while (index >= 0) {
        if (counts[index] > 0 && Math.pow(2, index) <= leftOver) {
            return index
        } else {
            index--
        }
    }
    return index
}

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

function main() {
    let testCases = readline()
    while (testCases--)
        solve()
}

// function to solve problems
function solve() {
    let [n, m] = readline().split(' ')
    let counts = Array(20).fill(0)
    readline().split(' ').map(x => {
        counts[Math.log2(x)] += 1
    })
    let ans = [m],
        maxNum = 0,
        index = 0
    // console.log('Counts = ', counts)
    while (n) {
        // better approach would be to store the maximum in order in the best possible way
        // greedy approach
        index = findGoodIndex(counts, ans[ans.length - 1])
        maxNum = Math.pow(2, index)
        if (index == -1) {
            ans.push(m - maxNum)
        } else {
            ans[ans.length - 1] -= maxNum
        }
        counts[index]--
        n--
    }
    console.log(ans.length)
}

function sortAscending(a, b) {
    return a - b
}

function findGoodIndex(counts, leftOver) {
    let index = 20
    while (index >= 0) {
        if (counts[index] > 0 && Math.pow(2, index) <= leftOver) {
            return index
        } else {
            index--
        }
    }
    return index
}

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

function main() {
    let testCases = readline()
    while (testCases--)
        solve()
}

// function to solve problems
function solve() {
    let [n, m] = readline().split(' ')
    let counts = Array(20).fill(0)
    readline().split(' ').map(x => {
        counts[Math.log2(x)] += 1
    })
    let ans = [m],
        maxNum = 0,
        index = 0
    console.log('Counts = ', counts)
    while (n) {
        // better approach would be to store the maximum in order in the best possible way
        // greedy approach
        index = findGoodIndex(counts, ans[ans.length - 1])
        maxNum = Math.pow(2, index)
        if (index == -1) {
            ans.push(m - maxNum)
        } else {
            ans[ans.length - 1] -= maxNum
        }
        counts[index]--
        n--
    }
    console.log(ans.length)
}

function sortAscending(a, b) {
    return a - b
}

function findGoodIndex(counts, leftOver) {
    let index = 20
    while (index >= 0) {
        if (counts[index] > 0 && Math.pow(2, index) <= leftOver) {
            return index
        } else {
            index--
        }
    }
    return index
}

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

function main() {
    let testCases = readline()
    while (testCases--)
        solve()
}

// function to solve problems
function solve() {
    let [n, m] = readline().split(' ')
    let arr = readline().split(' ').map(x => +x)
    let ans = [],
        maxNum = 0,
        index = 0
    arr.sort(sortAscend)
    console.log('arr = ', ...arr)
    while (arr.length) {
        // find current max in arr => always the last
        maxNum = arr[arr.length - 1]
        // console.log('maxNum = ', maxNum)
        // better approach would be to store the maximum in order in the best possible way
        // greedy approach
        index = findGoodIndex(maxNum, ans, m)
        if (index == ans.length) {
            ans.push(m - maxNum)
        } else {
            ans[index] -= maxNum
        }
        // console.log('ans = ', ans)
        arr.pop()
    }
    console.log(ans.length)
}

function sortAscend(a, b) {
    return a - b
}

function findGoodIndex(maxNum, arr, m) {
    let index = 0
    while (index < arr.length) {
        if (arr[index] >= maxNum) {
            return index
        }
        index++
    }
    return index
}

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

function main() {
    let testCases = readline()
    while (testCases--)
        solve()
}

// function to solve problems
function solve() {
    let [n, m] = readline().split(' ')
    let arr = readline().split(' ').map(x => +x)
    let ans = [],
        maxNum = 0,
        index = 0
    arr.sort()
    while (arr.length) {
        // find current max in arr - always the last
        maxNum = arr[arr.length - 1]
        // better approach would be to store the maximum in order in the best possible way
        // greedy approach
        index = findGoodIndex(maxNum, ans, m)
        if (index == ans.length) {
            ans.push(m - maxNum)
        } else {
            ans[index] -= maxNum
        }
        arr.pop()
    }
    console.log(ans.length)
}

function findGoodIndex(maxNum, arr, m) {
    let index = 0
    while (index < arr.length) {
        if (arr[index] >= maxNum) {
            return index
        }
        index++
    }
    return index
}

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

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

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

// PriorityQueue implementated using array based binary heap
// PriorityQueue methods
//  push(...values)
// 	peek()
//  pop()
//  size()
//  replace(value)

class PriorityQueue {

	constructor(comparator = (a, b) => a > b) {
	    this.top = 0;
		this._heap = [];
		this._comparator = comparator;
	}
	size() {
		return this._heap.length;
	}
	isEmpty() {
		return this.size() == 0;
	}
	peek() {
		return this._heap[this.top];
	}
	push(...values) {
		values.forEach(value => {
				this._heap.push(value);
				this._siftUp();
				});
		return this.size();
	}
	pop() {
		const poppedValue = this.peek();
		const bottom = this.size() - 1;
		if (bottom > this.top) {
			this._swap(this.top, bottom);
		}
		this._heap.pop();
		this._siftDown();
		return poppedValue;
	}
	replace(value) {
		const replacedValue = this.peek();
		this._heap[this.top] = value;
		this._siftDown();
		return replacedValue;
	}
	_greater(i, j) {
		return this._comparator(this._heap[i], this._heap[j]);
	}
	_swap(i, j) {
		[this._heap[i], this._heap[j]] = [this._heap[j], this._heap[i]];
	}
	_siftUp() {
	    const parent = i => ((i + 1) >>> 1) - 1;
		let node = this.size() - 1;
		while (node > this.top && this._greater(node, parent(node))) {
			this._swap(node, parent(node));
			node = parent(node);
		}
	}
	_siftDown() {
	    const left = i => (i << 1) + 1;
	    const right = i => (i + 1) << 1;
		let node = this.top;
		while (
				(left(node) < this.size() && this._greater(left(node), node)) ||
				(right(node) < this.size() && this._greater(right(node), node))
			  ) {
			let maxChild = (right(node) < this.size() && this._greater(right(node), left(node))) ? right(node) : left(node);
			this._swap(node, maxChild);
			node = maxChild;
		}
	}
}

const mxq = new PriorityQueue((a, b) => a > b);

function main () {
	let T = rn();
	while (T--) {
		const [n, W] = rna();
		const w = rna();

		w.sort((x, y) => y-x);

		let ans = 0;
		for (let i = 0; i < n; i++) {
			const avl = mxq.peek();
			if (avl >= w[i]) {
				avl && mxq.pop();
				mxq.push(avl-w[i]);
			} else {
				mxq.push(W-w[i]);
				ans++;
			}
		}
		console.log(ans);
	}
}

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

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

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

// PriorityQueue implementated using array based binary heap
// PriorityQueue methods
//  push(...values)
// 	peek()
//  pop()
//  size()
//  replace(value)

class PriorityQueue {

	constructor(comparator = (a, b) => a > b) {
	    this.top = 0;
		this._heap = [];
		this._comparator = comparator;
	}
	size() {
		return this._heap.length;
	}
	isEmpty() {
		return this.size() == 0;
	}
	peek() {
		return this._heap[this.top];
	}
	push(...values) {
		values.forEach(value => {
				this._heap.push(value);
				this._siftUp();
				});
		return this.size();
	}
	pop() {
		const poppedValue = this.peek();
		const bottom = this.size() - 1;
		if (bottom > this.top) {
			this._swap(this.top, bottom);
		}
		this._heap.pop();
		this._siftDown();
		return poppedValue;
	}
	replace(value) {
		const replacedValue = this.peek();
		this._heap[this.top] = value;
		this._siftDown();
		return replacedValue;
	}
	_greater(i, j) {
		return this._comparator(this._heap[i], this._heap[j]);
	}
	_swap(i, j) {
		[this._heap[i], this._heap[j]] = [this._heap[j], this._heap[i]];
	}
	_siftUp() {
	    const parent = i => ((i + 1) >>> 1) - 1;
		let node = this.size() - 1;
		while (node > this.top && this._greater(node, parent(node))) {
			this._swap(node, parent(node));
			node = parent(node);
		}
	}
	_siftDown() {
	    const left = i => (i << 1) + 1;
	    const right = i => (i + 1) << 1;
		let node = this.top;
		while (
				(left(node) < this.size() && this._greater(left(node), node)) ||
				(right(node) < this.size() && this._greater(right(node), node))
			  ) {
			let maxChild = (right(node) < this.size() && this._greater(right(node), left(node))) ? right(node) : left(node);
			this._swap(node, maxChild);
			node = maxChild;
		}
	}
}

const mxq = new PriorityQueue((a, b) => a > b);

function main () {
	let T = rn();
	while (T--) {
		const [n, W] = rna();
		const w = rna();

		w.sort((x, y) => y-x);

		let ans = 0;
		for (let i = 0; i < n; i++) {
			const avl = mxq.peek();
			if (avl >= w[i]) {
				mxq.pop();
				mxq.push(avl-w[i]);
			} else {
				mxq.push(W-w[i]);
				ans++;
			}
		}
		console.log(ans);
	}
}

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

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

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

// PriorityQueue implementated using array based binary heap
// PriorityQueue methods
//  push(...values)
// 	peek()
//  pop()
//  size()
//  replace(value)

class PriorityQueue {

	constructor(comparator = (a, b) => a > b) {
	    this.top = 0;
		this._heap = [];
		this._comparator = comparator;
	}
	size() {
		return this._heap.length;
	}
	isEmpty() {
		return this.size() == 0;
	}
	peek() {
		return this._heap[this.top];
	}
	push(...values) {
		values.forEach(value => {
				this._heap.push(value);
				this._siftUp();
				});
		return this.size();
	}
	pop() {
		const poppedValue = this.peek();
		const bottom = this.size() - 1;
		if (bottom > this.top) {
			this._swap(this.top, bottom);
		}
		this._heap.pop();
		this._siftDown();
		return poppedValue;
	}
	replace(value) {
		const replacedValue = this.peek();
		this._heap[this.top] = value;
		this._siftDown();
		return replacedValue;
	}
	_greater(i, j) {
		return this._comparator(this._heap[i], this._heap[j]);
	}
	_swap(i, j) {
		[this._heap[i], this._heap[j]] = [this._heap[j], this._heap[i]];
	}
	_siftUp() {
	    const parent = i => ((i + 1) >>> 1) - 1;
		let node = this.size() - 1;
		while (node > this.top && this._greater(node, parent(node))) {
			this._swap(node, parent(node));
			node = parent(node);
		}
	}
	_siftDown() {
	    const left = i => (i << 1) + 1;
	    const right = i => (i + 1) << 1;
		let node = this.top;
		while (
				(left(node) < this.size() && this._greater(left(node), node)) ||
				(right(node) < this.size() && this._greater(right(node), node))
			  ) {
			let maxChild = (right(node) < this.size() && this._greater(right(node), left(node))) ? right(node) : left(node);
			this._swap(node, maxChild);
			node = maxChild;
		}
	}
}

const mxq = new PriorityQueue((a, b) => a > b);

function main () {
	let T = rn();
	while (T--) {
		const [n, W] = rna();
		const w = rna();

		w.sort((x, y) => y-x);

		let ans = 0;
		for (let i = 0; i < n; i++) {
			const avl = mxq.pop();
			if (avl >= w[i]) {
				mxq.push(avl-w[i]);
			} else {
				mxq.push(W-w[i]);
				ans++;
			}
		}
		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 pow (b, i) {
	if (!i) return 1;
	return b * pow(b, i - 1);
}

function indx (n) {
	for (let i = 0; i <= 30; i++) {
		const pw = 1 << i;
		if (n & pw) return i;
	}
}

function main () {
	let T = rn();
	while (T--) {
		const [n, W] = rna();
		const w = rna();

		w.sort((x, y) => y - x);

		const used = Array(31).fill(-1);
		for (let i = 0; i <= 30; i++) {
			const pw = 1 << i;
			if (W & pw) {
				used[i] = 0;
			}
		}

		for (let i = 0; i < n; i++) {
			let b = indx(w[i]);
			let done = false;
			for (let j = 30; j >= 0; j--) {
				if (used[j] >= 0) {
					if (w[i] <= used[j] % pow(2, j)) {
						used[j] += w[i];
						done = true;
						break;
					}
				}
			}
			if (!done) {
				if (used[b] >= 0) {
					used[b] += w[i];
				} else {
					for (let j = 30; j >= 0; j--) {
						if (used[j] >= 0) {
							used[j] += w[i];
							break;
						}
					}
				}
			}
		}

		let ans = 0;
		for (let i = 0; i <= 30; i++) {
			ans = Math.max(ans, Math.ceil(used[i] / pow(2, i)));
		}

		console.log(ans);
	}
}

///////////////////////////////// pre-define /////////////////////////////////////
const pr = console.log;
const mx = Math.max;
///////////////////////////////////////////////////////////////////////////////////

const solve = (n, w, a) => {
    let m = new Map();
    for (const e of a) m.set(e, m.get(e) + 1 || 1);
    let max = mx.apply(Math, a);
    pr(m.get(max))
};

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

main()

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

const solve = (n, w, a) => {
    let sum = a.reduce((x, y) => x + y);
    pr(ce(sum / w))
};

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

main()


The legend of the foundation of Vectorland talks of two integers $$$x$$$ and $$$y$$$. Centuries ago, the array king placed two markers at points $$$|x|$$$ and $$$|y|$$$ on the number line and conquered all the land in between (including the endpoints), which he declared to be Arrayland. Many years later, the vector king placed markers at points $$$|x - y|$$$ and $$$|x + y|$$$ and conquered all the land in between (including the endpoints), which he declared to be Vectorland. He did so in such a way that the land of Arrayland was completely inside (including the endpoints) the land of Vectorland.Here $$$|z|$$$ denotes the absolute value of $$$z$$$.Now, Jose is stuck on a question of his history exam: "What are the values of $$$x$$$ and $$$y$$$?" Jose doesn't know the answer, but he believes he has narrowed the possible answers down to $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$. Now, he wants to know the number of unordered pairs formed by two different elements from these $$$n$$$ integers such that the legend could be true if $$$x$$$ and $$$y$$$ were equal to these two values. Note that it is possible that Jose is wrong, and that no pairs could possibly make the legend true.

The first line contains a single integer $$$n$$$ ($$$2 \le n \le 2 \cdot 10^5$$$)  — the number of choices. The second line contains $$$n$$$ pairwise distinct integers $$$a_1, a_2, \dots, a_n$$$ ($$$-10^9 \le a_i \le 10^9$$$) — the choices Jose is considering.

Print a single integer number — the number of unordered pairs $$$\{x, y\}$$$ formed by different numbers from Jose's choices that could make the legend true.

NoteConsider the first sample. For the pair $$$\{2, 5\}$$$, the situation looks as follows, with the Arrayland markers at $$$|2| = 2$$$ and $$$|5| = 5$$$, while the Vectorland markers are located at $$$|2 - 5| = 3$$$ and $$$|2 + 5| = 7$$$:  The legend is not true in this case, because the interval $$$[2, 3]$$$ is not conquered by Vectorland. For the pair $$$\{5, -3\}$$$ the situation looks as follows, with Arrayland consisting of the interval $$$[3, 5]$$$ and Vectorland consisting of the interval $$$[2, 8]$$$:  As Vectorland completely contains Arrayland, the legend is true. It can also be shown that the legend is true for the pair $$$\{2, -3\}$$$, for a total of two pairs.In the second sample, the only pair is $$$\{3, 6\}$$$, and the situation looks as follows:  Note that even though Arrayland and Vectorland share $$$3$$$ as endpoint, we still consider Arrayland to be completely inside of Vectorland.

(function () {
    var read = {
        number: function () {
            return +readline();
        },
        arr: function (divider) {
            return readline().split(divider ? divider : '');
        },
        arrNumber: function (divider) {
            return readline()
                .split(divider ? divider : '')
                .map(item => Math+item);
        }
    }

    var n = read.number();
    var s = read.arr(' ')
        .map(item => Math.abs(+item))
        .sort((a, b) => a - b);

    var res= 0;
    var index = 0;
    for(var i = 0; i < n; i++) {
        while(2 * s[index] < s[i])
            index++;

        res += i - index;
    }
    print(res);
}());