Little boy Petya loves stairs very much. But he is bored from simple going up and down them — he loves jumping over several stairs at a time. As he stands on some stair, he can either jump to the next one or jump over one or two stairs at a time. But some stairs are too dirty and Petya doesn't want to step on them.Now Petya is on the first stair of the staircase, consisting of n stairs. He also knows the numbers of the dirty stairs of this staircase. Help Petya find out if he can jump through the entire staircase and reach the last stair number n without touching a dirty stair once.One has to note that anyway Petya should step on the first and last stairs, so if the first or the last stair is dirty, then Petya cannot choose a path with clean steps only.

The first line contains two integers n and m (1 ≤ n ≤ 109, 0 ≤ m ≤ 3000) — the number of stairs in the staircase and the number of dirty stairs, correspondingly. The second line contains m different space-separated integers d1, d2, ..., dm (1 ≤ di ≤ n) — the numbers of the dirty stairs (in an arbitrary order).

Print "YES" if Petya can reach stair number n, stepping only on the clean stairs. Otherwise print "NO".

print(function(n, m) {
	if (m === 0) return 'YES';

	var d = readline().split(' ').map(Number).sort(function(a, b) {
		return a - b;
	});

	if (d[m - 1] === n || d[0] === 1) return 'NO';

	for (var i = 2; i < m; i++)
		if (d[i] - d[i - 2] === 2) return 'NO';

	return 'YES';

} .apply(0, readline().split(' ').map(Number)));

;(function () { // 362B

	print(function (n, m) {
		if (m === 0) return 'YES';
		var d = readline().split(' ').map(Number).sort(function (a, b) { return a - b; }), dl = d.length;
		if (d[0] === 1 || d[dl - 1] === n) return 'NO';
		for (var i = 2, k = 0; i < dl; i++)
			if ( d[i] === d[i-1] + 1 && d[i] === d[i-2] + 2 ) return 'NO';
		return 'YES';
	}.apply(null, readline().split(' ').map(Number)));

}).call(this);

print(function(n, m) {
	if (m === 0) return 'YES';

	var d = readline().split(' ').map(Number).sort(function(a, b) {
		return a - b;
	});

	if (d[m - 1] === n) return 'NO';

	for (var i = 2; i < m; i++)
		if (d[i] - d[i - 2] === 2) return 'NO';

	return 'YES';

} .apply(0, readline().split(' ').map(Number)));

print(function(n, m) {
	if (m === 0) return 'NO';

	var d = readline().split(' ').map(Number).sort(function(a, b) {
		return a - b;
	});

	if (d[m - 1] === n) return 'NO';

	for (var i = 2; i < m; i++)
		if (d[i] - d[i - 2] === 2) return 'NO';

	return 'YES';

} .apply(0, readline().split(' ').map(Number)));

;(function () { // 362B

	print(function (n, m) {
		var d = readline().split(' ').map(Number).sort(function (a, b) { return a - b; }), dl = d.length;
		if (d[0] === 1 && d[dl - 1] === n) return 'NO';
		for (var i = 2, k = 0; i < dl; i++)
			if ( d[i] === d[i-1] + 1 && d[i] === d[i-2] + 2 ) return 'NO';
		return 'YES';
	}.apply(null, readline().split(' ').map(Number)));

}).call(this);


Wilbur the pig is tinkering with arrays again. He has the array a1, a2, ..., an initially consisting of n zeros. At one step, he can choose any index i and either add 1 to all elements ai, ai + 1, ... , an or subtract 1 from all elements ai, ai + 1, ..., an. His goal is to end up with the array b1, b2, ..., bn. Of course, Wilbur wants to achieve this goal in the minimum number of steps and asks you to compute this value.

The first line of the input contains a single integer n (1 ≤ n ≤ 200 000) — the length of the array ai. Initially ai = 0 for every position i, so this array is not given in the input. The second line of the input contains n integers b1, b2, ..., bn ( - 109 ≤ bi ≤ 109).

Print the minimum number of steps that Wilbur needs to make in order to achieve ai = bi for all i.

NoteIn the first sample, Wilbur may successively choose indices 1, 2, 3, 4, and 5, and add 1 to corresponding suffixes.In the second sample, Wilbur first chooses indices 1 and 2 and adds 1 to corresponding suffixes, then he chooses index 4 and subtract 1.

function rda(){ return readline().split(" ").map(Number); }
function rdn(){ return Number(readline()); }

var n = rdn(), b = rda();

var ans = 0;
var now = 0;
for(var i = 0; i < n; i++){
    if(now < b[i]){
        ans += b[i] - now;
        now = b[i];
    }else if(now > b[i]){
        ans += now - b[i];
        now = b[i];
    }else{
        continue;
    }
}

write(ans);

var n = parseInt(readline());
var a = readline().split(" ").map(Number);
var ans = 0;
var x = 0;

for (var i = 0; i < n; i++) {
	if (x != a[i]) {
		ans += Math.abs(a[i]-x);
		x = a[i];
	}
}

print(ans);

n = +readline();
a = readline().split(" ").map(Number);
var res = 0 , add = 0;
for (i = 0 ; i < n ; i ++){
    a[i] -= add;
    add += a[i];
    res += Math.abs(a[i]);

}

write(res);

var n = parseInt(readline());
var x = readline().split(' ');
var a = []
for(var i = 0;i < n; i++) {
    a[i] = parseInt(x[i]);
}
var ans = Math.abs(a[0]);
for(var i=1;i<n;i++) {
    ans += Math.abs(a[i] - a[i-1]);
}
print(ans);

'use strict';

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

let inputString = '';
let currentLine = 0;

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

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

    main();
});

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

function toIntArr(arr) {
    const r = arr.map((item) => {
        return parseInt(item);
    });

    return r;
}

////////////////////////////////

function main() {
    let n = parseInt(readline());
    let arr = toIntArr(readline().split(' '));

    let r = 0;
    let p = 0;

    for (let i = 0; i < n; i++) {
        r += Math.abs(arr[i] - p);
        p = arr[i];
    }

    console.log(r);
}

var n = parseInt(readline());
var x = readline().split(' ');
var a = []
for(var i = 0;i < n; i++) {
    a[i] = parseInt(x[i]);
}
var ans = a[0];
for(var i=1;i<n;i++) {
    ans += Math.abs(a[i] - a[i-1]);
}
print(ans);

'use strict';

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

let inputString = '';
let currentLine = 0;

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

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

    main();
});

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

function toIntArr(arr) {
    const r = arr.map((item) => {
        return parseInt(item);
    });

    return r;
}

////////////////////////////////

function main() {
    let n = parseInt(readline());
    let arr = toIntArr(readline().split(' '));

    let r = 0;
    let k = 0;

    for (let i = 1; i < n; i++) {
        r += Math.abs(arr[i] - k);
        k = arr[i];
    }

    console.log(r);
}


You have $$$a$$$ coins of value $$$n$$$ and $$$b$$$ coins of value $$$1$$$. You always pay in exact change, so you want to know if there exist such $$$x$$$ and $$$y$$$ that if you take $$$x$$$ ($$$0 \le x \le a$$$) coins of value $$$n$$$ and $$$y$$$ ($$$0 \le y \le b$$$) coins of value $$$1$$$, then the total value of taken coins will be $$$S$$$.You have to answer $$$q$$$ independent test cases.

The first line of the input contains one integer $$$q$$$ ($$$1 \le q \le 10^4$$$) — the number of test cases. Then $$$q$$$ test cases follow. The only line of the test case contains four integers $$$a$$$, $$$b$$$, $$$n$$$ and $$$S$$$ ($$$1 \le a, b, n, S \le 10^9$$$) — the number of coins of value $$$n$$$, the number of coins of value $$$1$$$, the value $$$n$$$ and the required total value.

For the $$$i$$$-th test case print the answer on it — YES (without quotes) if there exist such $$$x$$$ and $$$y$$$ that if you take $$$x$$$ coins of value $$$n$$$ and $$$y$$$ coins of value $$$1$$$, then the total value of taken coins will be $$$S$$$, and NO otherwise. You may print every letter in any case you want (so, for example, the strings yEs, yes, Yes and YES will all be recognized as positive answer).

//DONE:
process.stdin.resume()
process.stdin.setEncoding('utf-8')

var arr = ''
process.stdin.on('data', (i) => {
  arr += i
})

process.stdin.on('end', () => {
  arr = arr.split('\n')
  const q = parseInt(arr.shift())

  for(let i = 0; i < q; i++) {
    const arrq = arr[i].split(' ')
    const a = arrq[0],
      b = arrq[1],
      n = arrq[2],
      s = arrq[3]

    const ax = Math.min(a, Math.floor(s / n))
    if(s - ax * n <= b) console.log('YES')
    else console.log('NO')
  }
})

'use strict';

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

let inputString = '';
let currentLine = 0;

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

const readline = () => {
    return inputString[currentLine++];
}

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

const main = () => {
    let q = parseInt(readline());
    let ans = '';
    for (let i = 0; i < q; i++) {
        let [a, b, n, s] = readline().split(' ').map(Number);
        const h = Math.min(Math.floor(s / n), a);
        const bk = s - (n * h);
        if (bk <= b) {
            ans += "YES\n";
        } else {
            ans += "NO\n";
        }
        // console.log(h, bk);
        // console.log(a,b,n,s);
    }
    console.log(ans);
}

let inputString = '';
let currentLine = 0;
process.stdin.on('data', data => {
	inputString += data;
});
process.stdin.on('end', function () {
	inputString = inputString
		.trim()
		.split('\n')
		.map(str => str.trim());
	main();
});

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

function main() {
	let t = readLine() >> 0;

	while (t--) {
		let [a, b, n, s] = readLine()
			.split(' ')
			.map(x => x >> 0);

		let ta = Math.floor(s / n);
		let tn;

		if (ta <= a) {
			tn = ta * n;
		} else {
			tn = a * n;
		}

		if (s - tn <= b) {
			console.log('YES');
		} else {
			console.log('NO');
		}
	}
}

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

//please ignore the lines above this

function main() {
    let noOftestCases = +(readLine());

    while(noOftestCases--)
    {

         let inp = readLine();
         var testCases = inp.split(" ");
        let noCoinsN = testCases[0];
        let noCoins1 = testCases[1];
        let ValueN = testCases[2];
        let total = testCases[3];

        let biggestValuewithN = Math.floor(total/ValueN);

        let maxValuePossible = Math.min(biggestValuewithN,noCoinsN)*ValueN;

        let noOf1coinsreq = total - maxValuePossible;

        if(noOf1coinsreq <= noCoins1 )
        {
            console.log("YES");
        }
        else { console.log("NO");

    }
}
}

let fs = require('fs');
let txt = fs.readFileSync(0, "utf-8").split("\n").filter(data => {
    return data.length > 0
});
txt.shift();

txt.forEach(data => {
    let info = data.split(" ");
    payment(info[0] * 1, info[1] * 1, info[2] * 1, info[3] * 1);
});

function payment(a, b, n, s) {
    if (b >= s) {
        console.log("YES");
        return;
    } else {
        let r = Math.floor(s / n);
        if(r>a){
            if (a * n + b < s) {
                console.log("NO");
            } else {
                console.log("YES");
            }
        }else{
            if (r * n == s) {
                console.log("YES");
            } else {
                if (r * n + b < s) {
                    console.log("NO");
                } else {
                    console.log("YES");
                }
            }
        }
    }
}

let data = '';
process.stdin.on('data', c => data += c);

function* nextLine() {
	let lines = data.trim().split(/\n/g);
	for(let l of lines){
		yield l.trim();
	}
}

let nl = nextLine();

nl.elem = function(funParse) {
		return funParse(this.next().value);
	};

nl.array = function(funParse) {
		return this.next().value.split(/\s/g).map(funParse||(x => x));
	};

nl.num = function() {
		return nl.elem(Number);
	};

nl.nums = function() {
		return nl.array(Number);
	};

nl.line = function() {
		return this.next().value;
	};

const sol = () => {
	let q = nl.num();
  let ans = [];
  for(let i = 0; i < q; i++){
    let [a, b, n, s] = nl.nums();
    let an = Math.trunc(s/n);
    let x = ((an < a)?an:a)*n;
    ans.push((x + b) >= s?"YES":"NO");
  }
	console.log(ans.join('\n'));

};

process.stdin.on('end', sol);

'use strict'
 let n = readline();
for( let i=0;i<n;i++)
{
    isok();
}
function isok()
{
    var a = readline().split(' ').map(Number);
    var ans=0;
    ans+=(Math.min(a[0],Math.trunc(a[3]/a[2]))*a[2]);
    if(a[3]-ans<=a[1])print('YES');
    else print('NO');
}

'use strict'
let input = readline();
while(input > 0) {
    const abnS = readline().split(' ').map(Number);
    print(calculate(abnS));
    input--
}
function calculate(input){
    let a = input[0];
    let b = input[1];
    let n = input[2];
    let s = input[3];
    let div = Math.trunc(s/n);
    let multi = a < div ? n * a : div * n;
    let diff  = s - multi;
    if(diff <= b){
        return "YES";
    }else return "NO";
}

'use strict'

const problem = (a, b, n, S) => (S - (Math.min(S/n|0, a))*n <= b) ? 'YES' : 'NO'
let q = +readline();

while(q--) {
    const abnS = readline().split(' ').map(Number);
    print(problem(abnS[0], abnS[1], abnS[2], abnS[3]));
}

function myin(){return require("fs").readFileSync("/dev/stdin", "utf8").trim();}
function myout(t){print(t);}//standard output
function myerr(t){console.log(t);}//standard error
//[no]param
//0:何もしない  1:数値へ変換  2:半角SPで分割  3:改行で分割  4:半角SPで分割し、数値配列へ
//5:改行で分割し、数値配列へ  6:1文字に分割  7:1文字に分割し、数値配列へ
function myconv(i,no){switch(no){case 0:return i;case 1:return parseInt(i);case 2:return i.split(" ");case 3:return i.split("\n");case 4:return i.split(" ").map((a)=>Number(a));case 5:return i.split("\n").map((a)=>Number(a));case 6:return i.split("");case 7:return i.split("").map((a)=>Number(a));}}

function Main() {
  var N = myconv(readline(),1);
  var output = [];
  for(var i = 1; i <= N; i++){
    var tmp = myconv(readline(),4);
    var a = tmp[0];
    var b = tmp[1];
    var n = tmp[2];
    var S = tmp[3];
    var other;//bの必要分
    if(S >= a * n){
       other = S - a * n;
    }else{
       other = S % n;
    }
    if(other - b <= 0){
       output.push("YES");
    }else{
      output.push("NO");
    }
  }
  myout(output.join("\n"));
}

Main();

function main() {
  var testCasesNum = +readline();
  var testCases = [];
  for (var i = 0; i < testCasesNum; i++) {
    (function (i) {
      testCases[i] = readline();
      canPay(testCases[i]);
    })(i)
  }
}

function canPay(testCase) {
  var caseArr = testCase.split(' ').map(Number);
  print(Math.min(caseArr[0] * caseArr[2], Math.floor(caseArr[3] / caseArr[2]) * caseArr[2]) + caseArr[1] >= caseArr[3] ? 'YES' : 'NO');
}
main();

  var lines = parseInt(readline(), 10);

  function min(a, b) {
    return a < b ? a : b;
  }

  for (var i = 0; i < lines; i++) {
    var tmpArr = readline()
      .split(" ")
      .map(function(val) {
        return parseInt(val, 10);
      });
    var a = tmpArr[0];
    var b = tmpArr[1];
    var n = tmpArr[2];
    var S = tmpArr[3];

    var maxA = Math.floor(S / n);
    var tail = S - min(maxA, a) * n;
    print(tail > b ? "NO": "YES");
  }

//A. Payment Without Change
var attempts = Number(readline());
var PaymentWithoutChange = () => {
    do {
        attempts--;
        var numbers = readline().split(' ').map(x => Number(x));
        var a = numbers[0], b = numbers[1], n = numbers[2], s = numbers[3];
        if ((a * n) + b >= s) {
            var a_needed = Math.floor(s / n);
            // var b_rem = s % n;
            if (a_needed > a && b >= s - a * n || a_needed < a && b >= s - a_needed * n || a_needed == a)
                print('YES');
            else
                print('NO');
        }
        else
            print('NO');

    } while (attempts > 0);
}
PaymentWithoutChange();

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

//please ignore the lines above this

function main() {
    let noOftestCases = +(readLine());

    while(noOftestCases--)
    {

         let inp = readLine();
         var testCases = inp.split(" ");
        let noCoinsN = testCases[0];
        let noCoins1 = testCases[1];
        let ValueN = testCases[2];
        let total = testCases[3];

        let biggestValuewithN = total/ValueN;

        let maxValuePossible = Math.min(biggestValuewithN,noCoinsN)*ValueN;

        let noOf1coinsreq = total - maxValuePossible;

        if(noOf1coinsreq > noCoins1 )
        {
            console.log("YES");
        }
        else { console.log("NO");

    }
}
}

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

//please ignore the lines above this

function main() {
    let noOftestCases = +(readLine());

    while(noOftestCases--)
    {

         let inp = readLine();
         var testCases = inp.split(" ");
        let noCoinsN = testCases[0];
        let noCoins1 = testCases[1];
        let ValueN = testCases[2];
        let total = testCases[3];

        let biggestValuewithN = total/ValueN;

        let maxValuePossible = Math.min(biggestValuewithN,noCoinsN)*ValueN;

        let noOf1coinsreq = total - maxValuePossible;

        if(noOf1coinsreq < noCoins1 )
        {
            console.log("YES");
        }
        else { console.log("NO");

    }
}
}

let fs = require("fs")

let txt = fs.readFileSync(0, "utf-8").split("\r\n").filter(data => {
    return data.length > 0
})
txt.shift()

txt.forEach(element => {
    let info = element.split(" ")
    football(info[0] * 1, info[1] * 1, info[2] * 1, info[3] * 1)
});

function football(a, b, n, s) {
    if (a * n == s) {
        console.log("YES");
    } else if (a * n < s) {
        if (a * n + b < s) {
            console.log("NO");
        } else {
            console.log("YES");
        }
    } else {
       console.log("YES");

    }
}

let fs = require("fs")

let txt = fs.readFileSync(0, "utf-8").split("\r\n").filter(data => {
    return data.length > 0
})
txt.shift()

txt.forEach(element => {
    let info = element.split(" ")
    football(info[0] * 1, info[1] * 1, info[2] * 1, info[3] * 1)
});

function football(a, b, n, s) {
    if (a * n == s) {
        console.log("YES");
    } else if (a * n < s) {
        if (a * n + b < s) {
            console.log("NO");
        } else {
            console.log("YES");
        }
    } else {
       for (let index = a; index >0; index--) {
           if(index*n==s){
            console.log("YES");
            return;
           }else if(index*n<s && index*n+b>=s){
            console.log("YES");
            return;
           }
       }
       console.log("NO");
    }
}

function payment(a,b,n,s){
    if(b>=s){
        console.log("YES")
        return;
    }else{
        let total=0;
        for(let i=0;i<a;i++){
            total+=a*n;
            if(total==s){
                console.log("YES")
                return;
            }else if(total>s){
                total-=a*n;
                if(total+b<s){
                    console.log("NO")
                }else{
                    console.log("YES")
                }
                return;
            }
        }
        if(total+b<s){
            console.log("NO")
        }else{
            console.log("YES")
        }

    }
}

let fs=require('fs');
let txt=fs.readFileSync(0,"utf-8").split("\n").filter(data=>{return data.length>0});
txt.shift();

txt.forEach(data=>{
    let info=data.split(" ");
    payment(info[0]*1,info[1]*1,info[2]*1,info[3]*1);
});
function payment(a,b,n,s){
    if(b>=s){
        console.log("YES");
        return;
    }else{
        let total=0;
        for(let i=0;i<a;i++){
            total+=a*n;
            if(total==s){
                console.log("YES");
                return;
            }else if(total>s){
                total-=a*n;
                if(total+b<s){
                    console.log("NO");
                }else{
                    console.log("YES");
                }
                return;
            }
        }
        if(total+b<s){
            console.log("NO");
        }else{
            console.log("YES");
        }

    }
}

let data = '';
process.stdin.on('data', c => data += c);

function* nextLine() {
	let lines = data.trim().split(/\n/g);
	for(let l of lines){
		yield l.trim();
	}
}

let nl = nextLine();

nl.elem = function(funParse) {
		return funParse(this.next().value);
	};

nl.array = function(funParse) {
		return this.next().value.split(/\s/g).map(funParse||(x => x));
	};

nl.num = function() {
		return nl.elem(Number);
	};

nl.nums = function() {
		return nl.array(Number);
	};

nl.line = function() {
		return this.next().value;
	};

const sol = () => {
	let q = nl.num();
  let ans = [];
  for(let i = 0; i < q; i++){
    let [a, b, n, s] = nl.nums();
    let an = Math.trunc(s/n);
    let bn = (an < a)?s%n:s-(a*n);
    ans.push((an >= a && bn <= b)?"YES":"NO");
  }
	console.log(ans.join('\n'));

};

process.stdin.on('end', sol);

let data = '';
process.stdin.on('data', c => data += c);

function* nextLine() {
	let lines = data.trim().split(/\n/g);
	for(let l of lines){
		yield l.trim();
	}
}

let nl = nextLine();

nl.elem = function(funParse) {
		return funParse(this.next().value);
	};

nl.array = function(funParse) {
		return this.next().value.split(/\s/g).map(funParse||(x => x));
	};

nl.num = function() {
		return nl.elem(Number);
	};

nl.nums = function() {
		return nl.array(Number);
	};

nl.line = function() {
		return this.next().value;
	};

const sol = () => {
	let q = nl.num();
  let ans = [];
  for(let i = 0; i < q; i++){
    let [a, b, n, s] = nl.nums();
    let an = Math.trunc(s/n);
    let bn = (an < a)?s%n:s-(a*n);
    ans.push((an <= a && bn <= b)?"YES":"NO");
  }
	console.log(ans.join('\n'));

};

process.stdin.on('end', sol);

'use strict'
 let n = readline();
while(n>0)
{
    isok();
     n--
}
function isok()
{
    var a = readline().split(' ').map(Number);
    var ans=0;
    ans+=(Math.min(a[0],a[3]/a[2])*a[2]);
    if(a[3]-ans<=a[1])print('YES');
    else print('NO');
}

'use strict'
let input = readline();
while(input > 0) {
    const abnS = readline().split(' ').map(Number);
    print(calculate(abnS));
    input--
}
function calculate(input){
    let a = input[0];
    let b = input[1];
    let n = input[2];
    let s = input[3];
    if(a * n <= s && (s - (a * n)) <= b){
        return "YES";
    }else return "NO";
}

'use strict'
let input = readline();
while(input > 0) {
    const abnS = readline().split(' ').map(Number);
    print(calculate(abnS));
    input--
}
function calculate(input){
    let a = input[0];
    let b = input[1];
    let n = input[2];
    let s = input[3];
    if((a * n) <= s && (s - (a * n)) <= b){
        return "YES";
    }else return "NO";
}

//A. Payment Without Change
var attempts = Number(readline());
var PaymentWithoutChange = () => {
    do {
        attempts--;
        var numbers = readline().split(' ').map(x => Number(x));
        var a = numbers[0], b = numbers[1], n = numbers[2], s = numbers[3];
        if ((a * n) + b >= s) {
            var a_needed = Math.floor(s / n);
            var b_rem = s % n;
            if (a_needed <= a && b_rem <= b || b>= s-a*n)
                print('YES');
            else
                print('NO');
        }
        else
            print('NO');

    } while (attempts > 0);
}
PaymentWithoutChange();

//A. Payment Without Change
var attempts = Number(readline());
var PaymentWithoutChange = () => {
    do {
        attempts--;
        var numbers = readline().split(' ').map(x => Number(x));
        var a = numbers[0], b = numbers[1], n = numbers[2], s = numbers[3];
        if ((a * n) + b >= s) {
            var a_needed = Math.floor(s / n);
            var b_rem = s % n;
            if (a_needed <= a && b_rem <= b || b>=a*n)
                print('YES');
            else
                print('NO');
        }
        else
            print('NO');

    } while (attempts > 0);
}
PaymentWithoutChange();

//A. Payment Without Change
var attempts = Number(readline());
var PaymentWithoutChange = () => {
    do {
        attempts--;
        var numbers = readline().split(' ').map(x => Number(x));
        var a = numbers[0], b = numbers[1], n = numbers[2], s = numbers[3];
        if ((a * n) + b >= s) {
            var a_needed = Math.floor(s / n);
            var b_rem = s % n;
            if (a_needed <= a && b_rem <= b)
                print('YES');
            else
                print('NO');
        }
        else
            print('NO');

    } while (attempts > 0);
}
PaymentWithoutChange();


You are given an array $$$a$$$ consisting of $$$n$$$ integers. You can perform the following operations arbitrary number of times (possibly, zero):  Choose a pair of indices $$$(i, j)$$$ such that $$$|i-j|=1$$$ (indices $$$i$$$ and $$$j$$$ are adjacent) and set $$$a_i := a_i + |a_i - a_j|$$$;  Choose a pair of indices $$$(i, j)$$$ such that $$$|i-j|=1$$$ (indices $$$i$$$ and $$$j$$$ are adjacent) and set $$$a_i := a_i - |a_i - a_j|$$$. The value $$$|x|$$$ means the absolute value of $$$x$$$. For example, $$$|4| = 4$$$, $$$|-3| = 3$$$.Your task is to find the minimum number of operations required to obtain the array of equal elements and print the order of operations to do it.It is guaranteed that you always can obtain the array of equal elements using such operations.Note that after each operation each element of the current array should not exceed $$$10^{18}$$$ by absolute value.

The first line of the input contains one integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) — the number of elements in $$$a$$$. The second line of the input contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$0 \le a_i \le 2 \cdot 10^5$$$), where $$$a_i$$$ is the $$$i$$$-th element of $$$a$$$.

In the first line print one integer $$$k$$$ — the minimum number of operations required to obtain the array of equal elements. In the next $$$k$$$ lines print operations itself. The $$$p$$$-th operation should be printed as a triple of integers $$$(t_p, i_p, j_p)$$$, where $$$t_p$$$ is either $$$1$$$ or $$$2$$$ ($$$1$$$ means that you perform the operation of the first type, and $$$2$$$ means that you perform the operation of the second type), and $$$i_p$$$ and $$$j_p$$$ are indices of adjacent elements of the array such that $$$1 \le i_p, j_p \le n$$$, $$$|i_p - j_p| = 1$$$. See the examples for better understanding. Note that after each operation each element of the current array should not exceed $$$10^{18}$$$ by absolute value. If there are many possible answers, you can print any.

const readline = require('readline');

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

function readLines(number, cb) {
    const lines = [];
    rl.on('line', function(line) {
        lines.push(line);
        if (lines.length === number) {
            rl.close();
            cb(lines);
        }
    });
};

function doIt(lines) {
    const n = parseInt(lines[0]);
    const numbers = lines[1].split(" ").map(x => parseInt(x));
    const mode = findMode(numbers);
    const max = mode[0];
    const pos = mode[1];
    console.log(numbers.length - max);
    for (let i=pos-1;i>=0;i--) {
        if (numbers[i] < numbers[pos]) {
            console.log(1, i+1, i+2 )
        } else if (numbers[i] > numbers[pos]) {
            console.log(2, i+1, i+2)
        }
    }
    for (let i=pos+1;i<numbers.length;i++) {
        if (numbers[i] < numbers[pos]) {
            console.log(1, i+1, i )
        } else if (numbers[i] > numbers[pos]) {
            console.log(2, i+1, i)
        }
    }
    function findMode(numbers) {
        const counts = {};
        let max = 0;
        let pos = 0;
        numbers.forEach((x, idx) =>{
            counts[x] = (counts[x] || 0) + 1;
            if (counts[x] > max) {
                max = counts[x];
                pos = idx;
            }
        })
        return [max, pos];
    }
}

readLines(2, doIt);


Beroffice text editor has a wide range of features that help working with text. One of the features is an automatic search for typos and suggestions of how to fix them.Beroffice works only with small English letters (i.e. with 26 letters from a to z). Beroffice thinks that a word is typed with a typo if there are three or more consonants in a row in the word. The only exception is that if the block of consonants has all letters the same, then this block (even if its length is greater than three) is not considered a typo. Formally, a word is typed with a typo if there is a block of not less that three consonants in a row, and there are at least two different letters in this block.For example:  the following words have typos: "hellno", "hackcerrs" and "backtothefutttture";  the following words don't have typos: "helllllooooo", "tobeornottobe" and "oooooo". When Beroffice editor finds a word with a typo, it inserts as little as possible number of spaces in this word (dividing it into several words) in such a way that each of the resulting words is typed without any typos.Implement this feature of Beroffice editor. Consider the following letters as the only vowels: 'a', 'e', 'i', 'o' and 'u'. All the other letters are consonants in this problem.

The only line contains a non-empty word consisting of small English letters. The length of the word is between 1 and 3000 letters.

Print the given word without any changes if there are no typos. If there is at least one typo in the word, insert the minimum number of spaces into the word so that each of the resulting words doesn't have any typos. If there are multiple solutions, print any of them.

var word = readline();

var vowels = 'aeiou';
var amount = 0;

for( var i = 0; i < word.length; i++ ) {

  if( ~vowels.indexOf(word[i]) ) {
    amount = 0;
    continue;
  };

  amount++;

  if( amount < 3 ) continue;
  if( word[i] == word[i-1] && word[i] == word[i-2] ) continue;

  wordNew = [word.slice(0, i), word.slice(i)];
  word = wordNew[0] + ' ' + wordNew[1];
  amount = 1;
  i++;
};
print( word );


Alice and Bob play the following game. Alice has a set $$$S$$$ of disjoint ranges of integers, initially containing only one range $$$[1, n]$$$. In one turn, Alice picks a range $$$[l, r]$$$ from the set $$$S$$$ and asks Bob to pick a number in the range. Bob chooses a number $$$d$$$ ($$$l \le d \le r$$$). Then Alice removes $$$[l, r]$$$ from $$$S$$$ and puts into the set $$$S$$$ the range $$$[l, d - 1]$$$ (if $$$l \le d - 1$$$) and the range $$$[d + 1, r]$$$ (if $$$d + 1 \le r$$$). The game ends when the set $$$S$$$ is empty. We can show that the number of turns in each game is exactly $$$n$$$.After playing the game, Alice remembers all the ranges $$$[l, r]$$$ she picked from the set $$$S$$$, but Bob does not remember any of the numbers that he picked. But Bob is smart, and he knows he can find out his numbers $$$d$$$ from Alice's ranges, and so he asks you for help with your programming skill.Given the list of ranges that Alice has picked ($$$[l, r]$$$), for each range, help Bob find the number $$$d$$$ that Bob has picked.We can show that there is always a unique way for Bob to choose his number for a list of valid ranges picked by Alice.

Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 1000$$$). Description of the test cases follows. The first line of each test case contains a single integer $$$n$$$ ($$$1 \le n \le 1000$$$). Each of the next $$$n$$$ lines contains two integers $$$l$$$ and $$$r$$$ ($$$1 \le l \le r \le n$$$), denoting the range $$$[l, r]$$$ that Alice picked at some point. Note that the ranges are given in no particular order. It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$1000$$$, and the ranges for each test case are from a valid game.

For each test case print $$$n$$$ lines. Each line should contain three integers $$$l$$$, $$$r$$$, and $$$d$$$, denoting that for Alice's range $$$[l, r]$$$ Bob picked the number $$$d$$$. You can print the lines in any order. We can show that the answer is unique. It is not required to print a new line after each test case. The new lines in the output of the example are for readability only.

NoteIn the first test case, there is only 1 range $$$[1, 1]$$$. There was only one range $$$[1, 1]$$$ for Alice to pick, and there was only one number $$$1$$$ for Bob to pick.In the second test case, $$$n = 3$$$. Initially, the set contains only one range $$$[1, 3]$$$.   Alice picked the range $$$[1, 3]$$$. Bob picked the number $$$1$$$. Then Alice put the range $$$[2, 3]$$$ back to the set, which after this turn is the only range in the set.  Alice picked the range $$$[2, 3]$$$. Bob picked the number $$$3$$$. Then Alice put the range $$$[2, 2]$$$ back to the set.  Alice picked the range $$$[2, 2]$$$. Bob picked the number $$$2$$$. The game ended. In the fourth test case, the game was played with $$$n = 5$$$. Initially, the set contains only one range $$$[1, 5]$$$. The game's turn is described in the following table.  Game turnAlice's picked rangeBob's picked numberThe range set afterBefore the game start$$$ \{ [1, 5] \} $$$1$$$[1, 5]$$$$$$3$$$$$$ \{ [1, 2], [4, 5] \}$$$2$$$[1, 2]$$$$$$1$$$$$$ \{ [2, 2], [4, 5] \} $$$3$$$[4, 5]$$$$$$5$$$$$$ \{ [2, 2], [4, 4] \} $$$4$$$[2, 2]$$$$$$2$$$$$$ \{ [4, 4] \} $$$5$$$[4, 4]$$$$$$4$$$$$$ \{ \} $$$ (empty set)

'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 Queue() {
    this.length = 0;
}

Queue.prototype.push = function (item) {
  var node = {item: item};
  if (this.last) {
    this.last = this.last.next = node;
  } else {
    this.last = this.first = node;
  }
  this.length++;
};

Queue.prototype.shift = function () {
  var node = this.first;
  if (node) {
    this.first = node.next;
    if (!(--this.length)) {
      this.last = undefined;
    }
    return node.item;
  }
};

Queue.prototype.slice = function (start, end) {
  start = typeof start === 'undefined' ? 0 : start;
  end = typeof end === 'undefined' ? Infinity : end;

  var output = [];

  var i = 0;
  for (var node = this.first; node; node = node.next) {
    if (--end < 0) {
      break;
    } else if (++i > start) {
      output.push(node.item);
    }
  }
  return output;
}

class Logger {

  constructor() {
    this.enabled = false;
  }

  enable() {
    this.enabled = true;
  }

  disable() {
    this.enabled = false;
  }

  log(...str) {
    if (this.enabled) {
      console.error(...str);
    }
  }
}

let logger = new Logger();
// logger.enable();

function main() {

  let t = +readline();

  let a = 0;

  let dfs = (array, max) => {
    let res = [];

    let stack = [];
    for (let i = array[0][0]; i <= array[0][1]; ++i) {
      stack.push([i]);
    }

    while(stack.length > 0) {
      ++a;
      logger.log("stack:", stack)
      let current = stack.pop();
      let arrayIndex = current.length;

      // logger.log(current, max, arrayIndex);
      // logger.log(array[arrayIndex]);

      if (arrayIndex >= max) {
        res = current;
        break;
      }

      for (let i = array[arrayIndex][0]; i <= array[arrayIndex][1]; ++i) {
        if (current.includes(i)) continue;
        let newelem = current.slice(0)
        newelem.push(i);
        // logger.log("newelem : ",newelem)
        stack.push(newelem);
      }
    }

    return res;
  }

  for (let i = 0; i < t; ++i) {
    let n = +readline();
    let array = [];

    // Register inputs
    for (let j = 0; j < n; ++j) {
      let [l, r] = readline().split(' ').map((a) => +a);
      array.push([l, r])
    }

    logger.log(array);
    array.sort((a,b) => {
      return (a[1]-a[0])-(b[1]-b[0]);
    })
    logger.log(array)

    let res = dfs(array, n)

    for (let i = 0; i < array.length; ++i) {
      console.log(array[i][0], array[i][1], res[i]);
    }
    console.log()

  }

  logger.log(a);

}

const solve = (arr1)=>{
   let arr = [...arr1],obj={},obj1 = {};
     arr.sort((a,b)=>Math.abs(a[0]-a[1]) - Math.abs(b[0]-b[1]));
     for(let i=0;i<arr.length;i++){
          if(arr[i][0]===arr[i][1]) {
               obj[arr[i]] = arr[i][0];
               obj1[arr[i][0]] = 1;
          }
          else{
               for(let j=arr[i][0];j<=arr[i][1];j++)
                    if(!obj1[j]){
                         obj1[j] = 1;
                         obj[arr[i]] = j;
                         break;
                    }
          }
     }
     for(let i=0;i<arr1.length;i++){
          let res = arr1[i].reduce((s,r)=>s+r+" ","")+obj[arr1[i]];
          console.log(res);
     }
}

function main() {
  const fs = require("fs");
  const input = fs.readFileSync(0, "utf8").trim().split("\n");
  let line = 0;
  function readline() {
    return input[line++];
  }
  let t = parseInt(readline());
  for(let i=0;i<t;i++){
       let n = parseInt(readline());
       let arr = [];
       for(let j=0;j<n;j++)
          arr.push(readline().trim().split(" ").map(cur=>parseInt(cur)));
       solve(arr);
  }
}
main();

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

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

const INF = 1e9;

function main () {
	let T = rn();
	while (T--) {
		const n = rn();
		const rng = [];
		for (let i = 0; i < n; i++) {
			rng.push([...rna(), i]);
		}

		rng.sort(comp);
		function comp (x, y) {
			if (x[0] == y[0])
				return y[1] - x[1];
			else
				return x[0] - y[0];
		}
		rng.push([INF, INF, INF]);

		for (let i = 0; i < n; i++) {
			const [l, r, indx] = rng[i];
			const [lnxt, rnxt, indxnxt] = rng[i+1];
			if (lnxt == l)
				console.log(l, r, rnxt + 1);
			else
				console.log(l, r, l);
		}
		console.log('');
	}
}

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++) {
      if (sc > 0)
          console.log('');
      const n = parseInt(await getLine());
      const segs = new Array(n);
      for(let i = 0; i < n; i++) {
          const [l, r] = (await getLine()).split(' ').map(num => parseInt(num));
          segs[i] = {
              l, r
          }
      }
     segs.sort((a,b) => (a.r-a.l) - (b.r-b.l));
     for(let i = 0; i < segs.length; i++) {
         const cur = segs[i];
         let a = undefined, b = undefined;
         if (cur.l === cur.r) {
             console.log(`${cur.l} ${cur.r} ${cur.l}`);
         } else {
             for(let j = 0; j < i; j++) {
                 if (!segs[j].used && segs[j].l >= cur.l && segs[j].r <= cur.r) {
                     if (!a) a = segs[j];
                     else {
                         b = segs[j];
                         break;
                     }
                 }
             }
             a.used = true;
             if (b)
                 b.used = true;
            if (!b) {
               if (a.l > cur.l) {
                   console.log(`${cur.l} ${cur.r} ${cur.l}`);
               } else {
                   console.log(`${cur.l} ${cur.r} ${cur.r}`);
               }
            } else {
                if (a.l < b.l) {
                    console.log(`${cur.l} ${cur.r} ${a.r + 1}`);
                } else {
                    console.log(`${cur.l} ${cur.r} ${b.r + 1}`);
                }
            }
         }
     }
  }
}

solve();


Several days ago you bought a new house and now you are planning to start a renovation. Since winters in your region can be very cold you need to decide how to heat rooms in your house.Your house has $$$n$$$ rooms. In the $$$i$$$-th room you can install at most $$$c_i$$$ heating radiators. Each radiator can have several sections, but the cost of the radiator with $$$k$$$ sections is equal to $$$k^2$$$ burles.Since rooms can have different sizes, you calculated that you need at least $$$sum_i$$$ sections in total in the $$$i$$$-th room. For each room calculate the minimum cost to install at most $$$c_i$$$ radiators with total number of sections not less than $$$sum_i$$$.

The first line contains single integer $$$n$$$ ($$$1 \le n \le 1000$$$) — the number of rooms. Each of the next $$$n$$$ lines contains the description of some room. The $$$i$$$-th line contains two integers $$$c_i$$$ and $$$sum_i$$$ ($$$1 \le c_i, sum_i \le 10^4$$$) — the maximum number of radiators and the minimum total number of sections in the $$$i$$$-th room, respectively.

For each room print one integer — the minimum possible cost to install at most $$$c_i$$$ radiators with total number of sections not less than $$$sum_i$$$.

NoteIn the first room, you can install only one radiator, so it's optimal to use the radiator with $$$sum_1$$$ sections. The cost of the radiator is equal to $$$(10^4)^2 = 10^8$$$.In the second room, you can install up to $$$10^4$$$ radiators, but since you need only one section in total, it's optimal to buy one radiator with one section.In the third room, there $$$7$$$ variants to install radiators: $$$[6, 0]$$$, $$$[5, 1]$$$, $$$[4, 2]$$$, $$$[3, 3]$$$, $$$[2, 4]$$$, $$$[1, 5]$$$, $$$[0, 6]$$$. The optimal variant is $$$[3, 3]$$$ and it costs $$$3^2+ 3^2 = 18$$$.

'use strict'
 let n = readline();
for( let i=0;i<n;i++)
{
    isok();
}
function isok()
{
    var a = readline().split(" ").map(Number);
    var id=Math.trunc(a[1]/a[0]);
    var les=(a[1]%a[0]);
    let ok  = a[0]-les;
    let ans = id*id*ok;
    id+=1;
    ans+= (id*id*les);
    print(ans);

}

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

var arr = ''
process.stdin.on('data', (i) => {
  arr += i
})

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

  const n = parseInt(arr.shift())

  for(let i = 0; i < n; i++) {
    const [c, s] = arr[i].split(' ').map(a => parseInt(a))
    let cost = 0
    if(s > c) {
      let mod = s % c
      let div = Math.floor(s / c)
      cost += (div ** 2) * (c - mod)
      cost += ((div + 1) ** 2 ) * mod
    }
    else {
      cost += s
    }
    wr(cost)
  }
})

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

function max(...x) {
  return Math.max(...x)
}

function min(...x) {
  return Math.min(...x)
}

process.stdin.setEncoding('utf-8').on('data', input => {
    input.split('\r\n').filter((_, i) => i >= 1).filter(l => l && l.length > 0)
        .forEach(line => {
            const [c, s] = line.split(' ');
            const k = s / c << 0;
            const m = s - k * c;
            console.log(((k + 1) ** 2) * m + (k **2) * (c - m));
        });
});

process.stdin.setEncoding('utf-8').on('data', input => {
    input.split('\r\n').filter((_, i) => i >= 1).filter(l => l && l.length > 0)
        .forEach(line => {
            const [radiators, minSections] = line.split(' ').map(Number);
            const solution = new Array(radiators);
            solution.fill(0);
            let sections = 0;
            while(sections < minSections) {
                for (let i = 0; i < radiators && sections < minSections; i++) {
                    solution[i] += 1;
                    sections += 1;
                }
            }
            console.log(solution.map(v => v*v).reduce((sum, v) => sum + v, 0));
        });
});

process.stdin.setEncoding('utf-8').on('data', input => {
    input.split('\r\n').filter((_, i) => i >= 1).filter(l => l && l.length > 0)
        .forEach(line => {
            const [r, s] = line.split(' ').map(Number);
             // Math.floor replaced with << operator
            console.log(((s / r) << 0) * ((s / r) << 0) * (r - (s - ((s / r) << 0) * r)) + (((s / r) << 0) + 1) * (((s / r) << 0) + 1) * (s - ((s / r) << 0) * r));
        });
});

process.stdin.setEncoding('utf-8').on('data', input => {
    input.split('\r\n').filter((_, i) => i >= 1).filter(l => l && l.length > 0)
        .forEach(line => {
            const [radiators, minSections] = line.split(' ').map(Number);
            const v = Math.floor(minSections / radiators);
            const vPlus1Number = minSections - v * radiators;
            const vNumber = radiators - vPlus1Number;
            const result = v * v * vNumber + (v + 1) * (v + 1) * vPlus1Number;
            console.log(result);
        });
});

process.stdin.setEncoding('utf-8').on('data', input => {
    input.split('\r\n').filter((_, i) => i >= 1).filter(l => l && l.length > 0)
        .forEach(line => {
            const [c, s] = line.split(' ').map(Number);
            const k = s / c << 0;
            const m = s - k * c;
            console.log(((k + 1) ** 2) * m + (k **2) * (c - m));
        });
});

process.stdin.setEncoding('utf-8').on('data', input => {
    input.split('\r\n').filter((_, i) => i >= 1).filter(l => l && l.length > 0)
        .forEach(line => {
            const [radiators, minSections] = line.split(' ').map(Number);
            const v = (minSections / radiators) << 0; // Math.floor
            const result = v * v * (radiators - (minSections - v * radiators)) + (v + 1) * (v + 1) * (minSections - v * radiators);
            console.log(result);
        });
});

process.stdin.setEncoding('utf-8').on('data', input => {
    input.split('\r\n').filter((_, i) => i >= 1).filter(l => l && l.length > 0)
        .forEach(line => {
            const [r, m] = line.split(' ').map(Number);
            console.log(Math.floor(m / r) * Math.floor(m / r) * (r - (m - Math.floor(m / r) * r)) + (Math.floor(m / r) + 1) * (Math.floor(m / r) + 1) * (m - Math.floor(m / r) * r));
        });
});

process.stdin.setEncoding('utf-8').on('data', input => {
    input.split('\r\n').filter((_, i) => i >= 1).filter(l => l && l.length > 0)
        .forEach(line => {
            const [radiators, minSections] = line.split(' ').map(Number);
            const solution = new Array(radiators);
            const startValue = Math.floor(minSections / radiators);
            solution.fill(startValue);
            let sections = startValue * radiators;
            for (let i = 0; i < radiators && sections < minSections; i++) {
                solution[i] += 1;
                sections += 1;
            }
            console.log(solution.map(v => v * v).reduce((sum, v) => sum + v, 0));
        });
});

var n = Number(readline);
for( i=0;i<n;i++)
{
    print(isok());
}
function isok()
{
    var a=readline().split(" ").map(l>=Number(l));
    var id=a[1]/a[0];
    var les=(a[1]%a[0]);
    ok  = a[0]-les;
    ans = id*id*ok;
    id++;
    ans+= (id*id*les);
    return ans;

}

'use strict'
 let n = readline();
for( let i=0;i<n;i++)
{
    isok();
}
function isok()
{
    var a = readline().split(" ").map(Number);
    var id=a[1]/a[0];
    var les=(a[1]%a[0]);
    let ok  = a[0]-les;
    let ans = id*id*ok;
    id+=1;
    ans+= (id*id*les);
    print(ans);

}

'use strict'
 let n = readline;
for( let i=0;i<n;i++)
{
    isok();
}
function isok()
{
    var a = readLine().split(" ").map(Number);
    var id=a[1]/a[0];
    var les=(a[1]%a[0]);
    let ok  = a[0]-les;
    let ans = id*id*ok;
    id+=1;
    ans+= (id*id*les);
    print(ans);

}

process.stdin.setEncoding('utf-8').on('data', input => {
    input.split('\r\n').filter((_, i) => i >= 1)
        .forEach(line => {
            const [radiators, minSections] = line.split(' ').map(Number);
            const solution = new Array(radiators);
            solution.fill(0);
            let sections = 0;
            while(sections < minSections) {
                for (let i = 0; i < radiators && sections < minSections; i++) {
                    solution[i] += 1;
                    sections += 1;
                }
            }
            console.log(solution.map(v => v*v).reduce((sum, v) => sum + v, 0));
        });
});

process.stdin.setEncoding('utf-8').on('data', input => {
    input.split('\r\n').filter((_, i) => i >= 1).filter(l => l && l.length > 0)
        .forEach(line => {
            const [radiators, minSections] = line.split(' ').map(Number);
            const solution = new Array(radiators);
            solution.fill(minSections >= radiators ? Math.floor(radiators / minSections) : 0);
            let sections = 0;
            while(sections < minSections) {
                for (let i = 0; i < radiators && sections < minSections; i++) {
                    solution[i] += 1;
                    sections += 1;
                }
            }
            console.log(solution.map(v => v*v).reduce((sum, v) => sum + v, 0));
        });
});


Vasya's telephone contains n photos. Photo number 1 is currently opened on the phone. It is allowed to move left and right to the adjacent photo by swiping finger over the screen. If you swipe left from the first photo, you reach photo n. Similarly, by swiping right from the last photo you reach photo 1. It takes a seconds to swipe from photo to adjacent.For each photo it is known which orientation is intended for it — horizontal or vertical. Phone is in the vertical orientation and can't be rotated. It takes b second to change orientation of the photo.Vasya has T seconds to watch photos. He want to watch as many photos as possible. If Vasya opens the photo for the first time, he spends 1 second to notice all details in it. If photo is in the wrong orientation, he spends b seconds on rotating it before watching it. If Vasya has already opened the photo, he just skips it (so he doesn't spend any time for watching it or for changing its orientation). It is not allowed to skip unseen photos.Help Vasya find the maximum number of photos he is able to watch during T seconds.

The first line of the input contains 4 integers n, a, b, T (1 ≤ n ≤ 5·105, 1 ≤ a, b ≤ 1000, 1 ≤ T ≤ 109) — the number of photos, time to move from a photo to adjacent, time to change orientation of a photo and time Vasya can spend for watching photo. Second line of the input contains a string of length n containing symbols 'w' and 'h'.  If the i-th position of a string contains 'w', then the photo i should be seen in the horizontal orientation. If the i-th position of a string contains 'h', then the photo i should be seen in vertical orientation.

Output the only integer, the maximum number of photos Vasya is able to watch during those T seconds.

NoteIn the first sample test you can rotate the first photo (3 seconds), watch the first photo (1 seconds), move left (2 second), rotate fourth photo (3 seconds), watch fourth photo (1 second). The whole process takes exactly 10 seconds.Note that in the last sample test the time is not enough even to watch the first photo, also you can't skip it.

/* TEST CASE
input
4 2 3 10
wwhw
output
2

input
5 2 4 1000
hhwhh
output
5

input
3 1 100 10
whw
output
0

input
5 2 4 13
hhwhh
output
4

Input
5 2 4 13
hhhwh
Output
3
Answer
4

*/
var n;
var swipeTime;
var rotateTime;
var needRotate;

function maxViewedPicture(totalTime) {
	var ret;
	var i;
	var viewCount = 0;
	var timeSpent = 0;
	var rev = n - 1, last;
	var t = 0;

	for (i = 0; i < n && timeSpent + t <= totalTime; i++) {
		timeSpent += t;
		t = 1;
		if (i > 0) {
			t += swipeTime;
		}

		if (needRotate[i]) {
			t += rotateTime;
		}

		if (timeSpent + t <= totalTime) {
			last = i;
			viewCount++;
		}
	}

	ret = viewCount;
	if (ret > 0 && ret < n) {
		for (var terminal = last + 1; terminal > 0; terminal--) {
			// decrement
			if (terminal <= last) {
				viewCount--;
				timeSpent -= 1 + swipeTime;
				if (needRotate[terminal]) {
					timeSpent -= rotateTime;
				}
			}
			// go reverse
			t = 1 + swipeTime;
			if (needRotate[rev]) {
				t += rotateTime;
			}
			//DEBUG:print("terminal - 1 =", terminal - 1, "n - rev = ", n - rev);
			while (timeSpent + swipeTime * Math.min(terminal - 1, n - rev) + t <= totalTime) {
				viewCount++;
				timeSpent += t;
				t = 1 + swipeTime;
				rev--;
				if (needRotate[rev]) {
					t += rotateTime;
				}
			}

			if (viewCount > ret) {
				ret = viewCount;
			}
		}
	}

	return ret;
}

function main() {
	var splitted = readline().split(' ');
	n = parseInt(splitted[0]);
	swipeTime = parseInt(splitted[1]);
	rotateTime = parseInt(splitted[2]);
	totalTime = parseInt(splitted[3]);
	splitted = readline();
	needRotate = new Array(n);
	for (var i = 0; i < n; i++) {
		needRotate[i] = (splitted[i] == 'w');
	}

	var answer = maxViewedPicture(totalTime);
	print(answer);
}

main();

var arr = readline().split(" ", 4).map(Number);
var n = arr[0], a = arr[1], b = arr[2], T = arr[3];
var str = readline();

var change = [];
for (var i = 0; i < n; ++i) {
    change[i] = Number(str[i] === "w");
}

function calc() {
    var maxPhotoCount = 1, left = [], right = [], i, tmp;
    left[0] = right[0] = 0;
    for (i = 1; i < n; ++i) {
        tmp = left[i - 1] + a + change[i] * b + 1;
        if (tmp + useTime > T) {
            break;
        }
        left[i] = tmp;
    }
    maxPhotoCount = Math.max(maxPhotoCount, left.length);
    if (maxPhotoCount === n) {
        return n;
    }
    for (i = 1; i < n; ++i) {
        tmp = right[i - 1] + a + change[n - i] * b + 1;
        if (tmp + useTime > T) {
            break;
        }
        right[i] = tmp;
    }
    maxPhotoCount = Math.max(maxPhotoCount, right.length);
    if (maxPhotoCount === n) {
        return n;
    }

    var time, beg, end, mid;
    end = right.length - 1;
    for (i  = 1; i < left.length; ++i) {
        time = T - useTime - left[i] - i * a;
        if (right[1] > time) {
            break;
        }
        beg = 1;
        while (true) {
            if (right[end] <= time) {
                break;
            }
            mid = Math.ceil((beg + end) / 2);
            if (right[mid] <= time) {
                beg = mid;
            } else {
                end = mid - 1;
            }
        }

        maxPhotoCount = Math.max(maxPhotoCount, i + end + 1);
        if (maxPhotoCount === n) {
            return n;
        }
    }
    end = left.length - 1;
    for (i  = 1; i < right.length; ++i) {
        time = T - useTime - right[i] - i * a;
        if (left[1] > time) {
            break;
        }
        beg = 1;
        while (true) {
            if (left[end] <= time) {
                break;
            }
            mid = Math.ceil((beg + end) / 2);
            if (left[mid] <= time) {
                beg = mid;
            } else {
                end = mid - 1;
            }
        }
        maxPhotoCount = Math.max(maxPhotoCount, i + end + 1);
        if (maxPhotoCount === n) {
            return n;
        }
    }
    return maxPhotoCount;
}

var useTime = change[0] * b + 1;
if (useTime > T) {
    print(0);
} else {
    print(calc());
}

var arr = readline().split(" ", 4).map(Number);
var n = arr[0], a = arr[1], b = arr[2], T = arr[3];
var str = readline();

function calc() {
    var maxPhotoCount = 1, left = [], right = [], i, tmp;
    left[0] = right[0] = 0;
    for (i = 1; i < n; ++i) {
        tmp = left[i - 1] + a + (str[i] === "w" ? b : 0) + 1;
        if (tmp + useTime > T) {
            break;
        }
        left[i] = tmp;
    }
    maxPhotoCount = Math.max(maxPhotoCount, left.length);
    if (maxPhotoCount === n) {
        return n;
    }
    for (i = 1; i < n; ++i) {
        tmp = right[i - 1] + a + (str[n - i] === "w" ? b : 0) + 1;
        if (tmp + useTime > T) {
            break;
        }
        right[i] = tmp;
    }
    maxPhotoCount = Math.max(maxPhotoCount, right.length);
    if (maxPhotoCount === n) {
        return n;
    }

    var time, beg, end, mid;
    end = right.length - 1;
    for (i  = 1; i < left.length; ++i) {
        time = T - useTime - left[i] - i * a;
        if (right[1] > time) {
            break;
        }
        beg = 1;
        while (true) {
            if (right[end] <= time) {
                break;
            }
            mid = Math.ceil((beg + end) / 2);
            if (right[mid] <= time) {
                beg = mid;
            } else {
                end = mid - 1;
            }
        }

        maxPhotoCount = Math.max(maxPhotoCount, i + end + 1);
    }
    end = left.length - 1;
    for (i  = 1; i < right.length; ++i) {
        time = T - useTime - right[i] - i * a;
        if (left[1] > time) {
            break;
        }
        beg = 1;
        while (true) {
            if (left[end] <= time) {
                break;
            }
            mid = Math.ceil((beg + end) / 2);
            if (left[mid] <= time) {
                beg = mid;
            } else {
                end = mid - 1;
            }
        }
        maxPhotoCount = Math.max(maxPhotoCount, i + end + 1);
    }
    return maxPhotoCount;
}

var useTime = 1 + (str[0] === "w" ? b : 0);
if (useTime > T) {
    print(0);
} else {
    print(calc());
}

/* TEST CASE
input
4 2 3 10
wwhw
output
2

input
5 2 4 1000
hhwhh
output
5

input
3 1 100 10
whw
output
0

input
5 2 4 13
hhwhh
output
4

*/
var n;
var swipeTime;
var rotateTime;
var needRotate;

function maxViewedPicture(totalTime) {
	var ret;
	var i;
	var viewCount = 0;
	var timeSpent = 0;
	var rev = n - 1, last;
	var t = 0;

	for (i = 0; i < n && timeSpent + t < totalTime; i++) {
		t = 1;
		if (i > 0) {
			t += swipeTime;
		}

		if (needRotate[i]) {
			t += rotateTime;
		}

		if (timeSpent + t <= totalTime) {
			timeSpent += t;
			last = i;
			viewCount++;
		}
	}

	ret = viewCount;
	if (ret > 0 && ret < n) {
		for (var terminal = last; terminal > 0; terminal--) {
			// decrement
			viewCount--;
			timeSpent -= 1 + swipeTime;
			if (needRotate[terminal]) {
				timeSpent -= rotateTime;
			}
			// long move to left
			var timeSwipeBack = (terminal - 1) * swipeTime;

			// go reverse
			t = 1 + swipeTime;
			if (needRotate[rev]) {
				t += rotateTime;
			}
			while (rev > terminal && timeSpent + timeSwipeBack + t <= totalTime) {
				viewCount++;
				timeSpent += t;
				rev--;
				t = 1 + swipeTime;
				if (needRotate[rev]) {
					t += rotateTime;
				}
			}

			if (viewCount > ret) {
				ret = viewCount;
			}
		}
	}

	return ret;
}

function main() {
	var splitted = readline().split(' ');
	n = parseInt(splitted[0]);
	swipeTime = parseInt(splitted[1]);
	rotateTime = parseInt(splitted[2]);
	totalTime = parseInt(splitted[3]);
	splitted = readline();
	needRotate = new Array(n);
	for (var i = 0; i < n; i++) {
		needRotate[i] = (splitted[i] == 'w');
	}

//	var answer = maxViewedPicture_BRUTEFORCE(0, 0, 0, totalTime);
	var answer = maxViewedPicture(totalTime);
	print(answer);
}

main();

/* TEST CASE
input
4 2 3 10
wwhw
output
2

input
5 2 4 1000
hhwhh
output
5

input
3 1 100 10
whw
output
0

input
5 2 4 13
hhwhh
output
4

*/
var n;
var swipeTime;
var rotateTime;
var needRotate;

function maxViewedPicture(totalTime) {
	var ret;
	var i;
	var viewCount = 0;
	var timeSpent = 0;
	var rev = n - 1, last;
	var t = 0;

	for (i = 0; i < n && timeSpent + t < totalTime; i++) {
		t = 1;
		if (i > 0) {
			t += swipeTime;
		}

		if (needRotate[i]) {
			t += rotateTime;
		}

		if (timeSpent + t <= totalTime) {
			timeSpent += t;
			last = i;
			viewCount++;
		}
	}

	ret = viewCount;
	if (ret > 0 && ret < n) {
		for (var terminal = last; terminal > 0; terminal--) {
			// decrement
			viewCount--;
			timeSpent -= 1 + swipeTime;
			if (needRotate[terminal]) {
				timeSpent -= rotateTime;
			}
			// long move to left
			var timeSwipeBack = (terminal - 1) * swipeTime;

			// go reverse
			t = 1 + swipeTime;
			if (needRotate[rev]) {
				t += rotateTime;
			}
			while (timeSpent + timeSwipeBack + t <= totalTime) {
				viewCount++;
				timeSpent += t;
				rev--;
				t = 1 + swipeTime;
				if (needRotate[rev]) {
					t += rotateTime;
				}
			}

			if (viewCount > ret) {
				ret = viewCount;
			}
		}
	}

	return ret;
}

function main() {
	var splitted = readline().split(' ');
	n = parseInt(splitted[0]);
	swipeTime = parseInt(splitted[1]);
	rotateTime = parseInt(splitted[2]);
	totalTime = parseInt(splitted[3]);
	splitted = readline();
	needRotate = new Array(n);
	for (var i = 0; i < n; i++) {
		needRotate[i] = (splitted[i] == 'w');
	}

//	var answer = maxViewedPicture_BRUTEFORCE(0, 0, 0, totalTime);
	var answer = maxViewedPicture(totalTime);
	print(answer);
}

main();

/* TEST CASE
input
4 2 3 10
wwhw
output
2

input
5 2 4 1000
hhwhh
output
5

input
3 1 100 10
whw
output
0

input
5 2 4 13
hhwhh
output
4

*/
var n;
var swipeTime;
var rotateTime;
var needRotate;

function maxViewedPicture(totalTime) {
	var ret;
	var i;
	var viewCount = 0;
	var timeSpent = 0;
	var rev = n - 1, last;
	var t = 0;

	for (i = 0; i < n && timeSpent + t <= totalTime; i++) {
		timeSpent += t;
		t = 1;
		if (i > 0) {
			t += swipeTime;
		}

		if (needRotate[i]) {
			t += rotateTime;
		}

		if (timeSpent + t <= totalTime) {
			last = i;
			viewCount++;
		}
	}

	ret = viewCount;
	if (ret > 0 && ret < n) {
		for (var terminal = last; terminal > 0; terminal--) {
			// decrement
			viewCount--;
			timeSpent -= 1 + swipeTime;
			if (needRotate[terminal]) {
				timeSpent -= rotateTime;
			}
			// long move to left
			var timeSwipeBack = (terminal - 1) * swipeTime;

			// go reverse
			t = 1 + swipeTime;
			if (needRotate[rev]) {
				t += rotateTime;
			}
			while (timeSpent + timeSwipeBack + t <= totalTime) {
				viewCount++;
				timeSpent += t;
				t = 1 + swipeTime;
				rev--;
				if (needRotate[rev]) {
					t += rotateTime;
				}
			}

			if (viewCount > ret) {
				ret = viewCount;
			}
		}
	}

	return ret;
}

function main() {
	var splitted = readline().split(' ');
	n = parseInt(splitted[0]);
	swipeTime = parseInt(splitted[1]);
	rotateTime = parseInt(splitted[2]);
	totalTime = parseInt(splitted[3]);
	splitted = readline();
	needRotate = new Array(n);
	for (var i = 0; i < n; i++) {
		needRotate[i] = (splitted[i] == 'w');
	}

	var answer = maxViewedPicture(totalTime);
	print(answer);
}

main();

/* TEST CASE
input
4 2 3 10
wwhw
output
2

input
5 2 4 1000
hhwhh
output
5

input
3 1 100 10
whw
output
0

input
5 2 4 13
hhwhh
output
4

*/
var n;
var swipeTime;
var rotateTime;
var orientations;

function maxViewedPicture_BRUTEFORCE(index1, index2, currentIndex, t) {
	if (index1 != index2 && ((n + index1) % n == index2 % n)) {
		return 0;
	}

	var ret = 0;
	var timeSpent = 1;
	if (orientations[(n + currentIndex) % n] == 'w') {
		timeSpent += rotateTime;
	}
	if (t - timeSpent >= 0) {
		ret = 1
			+ Math.max( maxViewedPicture_BRUTEFORCE(index1, index2 + 1, index2 + 1
										, t - timeSpent
											- swipeTime * (currentIndex == index2 ? 1 : (index2 - index1 + 1)))
					   ,maxViewedPicture_BRUTEFORCE(index1 - 1, index2, index1 - 1
										, t - timeSpent
											- swipeTime * (currentIndex == index1 ? 1 : (index2 - index1 + 1)))
					);
	}

	return ret;
}

function maxViewedPicture(totalTime) {
	var ret = 0;
	var viewCount;
	var i;
	var timeRemain;
	for (var terminal = n - 1; terminal >= 0 && ret < n; terminal--) {
		viewCount = 0;
		timeRemain = totalTime;

		for (i = 0; i <= terminal && timeRemain > 0; i++) {
			if (orientations[i] == 'w') {
				timeRemain -= rotateTime;
			}
			if (--timeRemain >= 0) {
				viewCount++;
			}
			timeRemain -= swipeTime;
		}

		timeRemain -= (terminal + 1) * swipeTime;
		for (i = n - 1; i > terminal + 1 && timeRemain > 0; i--) {
			if (orientations[i] == 'w') {
				timeRemain -= rotateTime;
			}
			if (--timeRemain >= 0) {
				viewCount++;
			}
			timeRemain -= swipeTime;
		}

		if (viewCount > ret) {
			ret = viewCount;
		}
	}

	return ret;
}

function main() {
	var splitted = readline().split(' ');
	n = parseInt(splitted[0]);
	swipeTime = parseInt(splitted[1]);
	rotateTime = parseInt(splitted[2]);
	totalTime = parseInt(splitted[3]);
	orientations = readline();

//	var answer = maxViewedPicture_BRUTEFORCE(0, 0, 0, totalTime);
	var answer = maxViewedPicture(totalTime);
	print(answer);
}

main();

var arr = readline().split(" ", 4).map(Number);
var n = arr[0], a = arr[1], b = arr[2], T = arr[3];
var str = readline();

var photoCount = 0, useTime = 0, maxPhotoCount;
if (str[0] === "w") {
    useTime += b;
}
++useTime;
if (useTime > T) {
    print(0);
} else {
    ++photoCount;
    maxPhotoCount = 1;

    for (var i = 1; i < n; ++i) {
        useTime += a + 1;
        if (str[i] === "w") {
            useTime += b;
        }
        if (useTime <= T) {
            ++photoCount;
        } else {
            break;
        }
        var photoOut = 0;
        if ((i + 1) * a + 1 <= T - useTime) {
            var timeOut = T - useTime - i * a;
            for (var j = n - 1; j > i; --j) {
                timeOut -= a + 1;
                if (str[j] === "w") {
                    timeOut -= b;
                }
                if (timeOut >= 0) {
                    ++photoOut;
                } else {
                    break;
                }
            }
        }
        maxPhotoCount = Math.max(maxPhotoCount, photoCount + photoOut);
        if (maxPhotoCount === n) {
            break;
        }
    }
    print(maxPhotoCount);
}

var arr = readline().split(" ", 4).map(Number);
var n = arr[0], a = arr[1], b = arr[2], T = arr[3];
var str = readline();

var change = [];
for (var i = 0; i < n; ++i) {
    change[i] = Number(str[i] === "w");
}

function calc() {
    var maxPhotoCount = 1, left = [], right = [], i, tmp;
    left[0] = right[0] = useTime;
    for (i = 1; i < n; ++i) {
        tmp = left[i - 1] + a + change[i] * b + 1;
        if (tmp > T) {
            break;
        }
        left[i] = tmp;
    }
    maxPhotoCount = Math.max(maxPhotoCount, left.length);
    if (maxPhotoCount === n) {
        return n;
    }
    for (i = 1; i < n; ++i) {
        tmp = right[i - 1] + a + change[n - i] * b + 1;
        if (tmp > T) {
            break;
        }
        right[i] = tmp;
    }
    maxPhotoCount = Math.max(maxPhotoCount, right.length);
    if (maxPhotoCount === n) {
        return n;
    }

    var time, beg, end, mid;
    end = right.length - 1;
    for (i  = 1; i < left.length; ++i) {
        time = T - left[i] - i * a;
        if (right[1] > time) {
            break;
        }
        beg = 1;
        while (true) {
            if (right[end] <= time) {
                break;
            }
            mid = Math.ceil((beg + end) / 2);
            if (right[mid] <= time) {
                beg = mid;
            } else {
                end = mid - 1;
            }
        }
        maxPhotoCount = Math.max(maxPhotoCount, i + end + 1);
        if (maxPhotoCount === n) {
            return n;
        }
    }
    end = left.length - 1;
    for (i  = 1; i < right.length; ++i) {
        time = T - right[i] - i * a;
        if (left[1] > time) {
            break;
        }
        beg = 1;
        while (true) {
            if (left[end] <= time) {
                break;
            }
            mid = Math.ceil((beg + end) / 2);
            if (left[mid] <= time) {
                beg = mid;
            } else {
                end = mid - 1;
            }
        }
        maxPhotoCount = Math.max(maxPhotoCount, i + end + 1);
        if (maxPhotoCount === n) {
            return n;
        }
    }
    return maxPhotoCount;
}

var useTime = change[0] * b + 1;
if (useTime > T) {
    print(0);
} else {
    print(calc());
}


Vlad likes to eat in cafes very much. During his life, he has visited cafes n times. Unfortunately, Vlad started to feel that his last visits are not any different from each other. To fix that Vlad had a small research.First of all, Vlad assigned individual indices to all cafes. Then, he wrote down indices of cafes he visited in a row, in order of visiting them. Now, Vlad wants to find such a cafe that his last visit to that cafe was before his last visits to every other cafe. In other words, he wants to find such a cafe that he hasn't been there for as long as possible. Help Vlad to find that cafe.

In first line there is one integer n (1 ≤ n ≤ 2·105) — number of cafes indices written by Vlad. In second line, n numbers a1, a2, ..., an (0 ≤ ai ≤ 2·105) are written — indices of cafes in order of being visited by Vlad. Vlad could visit some cafes more than once. Note that in numeration, some indices could be omitted.

Print one integer — index of the cafe that Vlad hasn't visited for as long as possible.

NoteIn first test, there are three cafes, and the last visits to cafes with indices 1 and 2 were after the last visit to cafe with index 3; so this cafe is the answer. In second test case, there are also three cafes, but with indices 1, 2 and 4. Cafes with indices 1 and 4 were visited after the last visit of cafe with index 2, so the answer is 2. Note that Vlad could omit some numbers while numerating the cafes.

main();

function main(){

    visits = new Array(200002);
    visits.fill(0);

    n = parseInt(readline());
    input = readline().split(' ');
    for(var i=0; i<input.length; i++) {
        input[i] = parseInt(input[i]);
        visits[input[i]]++;
    }

    for(var i=0; i<input.length; i++) {
        visits[input[i]]--;
        if(visits[input[i]]==0){
            print(input[i]);
            return;
        }
    }

}

var n = parseInt(readline());

var a = readline().split(' ');
var b = [];
var was = [];
var active;

for (var i = 0; i < n; i++) {
  b.push(parseInt(a[i]));
}

for (var i = n-1; i >= 0; i--) {
  if (!was[b[i]]) {
    was[b[i]] = true;
    active = b[i];
  }
}

print(active);

var n = Number(readline());

var data = readline().split(" ");

var map = {};
for(var i = 0; i < n; i++) {
    map[data[i]] = i;
}

var min = n;
var minNumber = null;
Object.keys(map).forEach(function(number) {
    if (map[number] < min) {
        min = map[number];
        minNumber = number;
    }
});
print(minNumber);

readline() // ignore # of cafes
var shistory = readline().split(' ')
// var history = '1 3 2 1 2'.split(' ')
// var history = '2 1 2 2 4 1'.split(' ')

var cafes = {}
for (var i = 0; i < shistory.length; i++)
  cafes[shistory[i]] = i
var order = Object.getOwnPropertyNames(cafes).sort(function(a,b) { return cafes[a] - cafes[b] })
print(order[0])
// console.log(order[0])

main();

function main(){

    visits = new Array(20002);
    visits.fill(0);

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

    ans = 0;
    for(var i=0; i<input.length; i++) {
        if(visits[input[i]]==1)
            break;
        else{
            ans = i+1;
            visits[input[i]]=1;
        }
    }
    print(ans);
}

main();

function main(){

    visits = new Array(20002);
    visits.fill(0);

    n = parseInt(readline());
    input = readline().split(' ');
    for(var i=0; i<input.length; i++) {
        input[i] = parseInt(input[i]);
        visits[input[i]]++;
    }

    for(var i=0; i<input.length; i++) {
        visits[input[i]]--;
        if(visits[input[i]]==0){
            print(input[i]);
            return;
        }
    }

}


Bessie has way too many friends because she is everyone's favorite cow! Her new friend Rabbit is trying to hop over so they can play! More specifically, he wants to get from $$$(0,0)$$$ to $$$(x,0)$$$ by making multiple hops. He is only willing to hop from one point to another point on the 2D plane if the Euclidean distance between the endpoints of a hop is one of its $$$n$$$ favorite numbers: $$$a_1, a_2, \ldots, a_n$$$. What is the minimum number of hops Rabbit needs to get from $$$(0,0)$$$ to $$$(x,0)$$$? Rabbit may land on points with non-integer coordinates. It can be proved that Rabbit can always reach his destination.Recall that the Euclidean distance between points $$$(x_i, y_i)$$$ and $$$(x_j, y_j)$$$ is $$$\sqrt{(x_i-x_j)^2+(y_i-y_j)^2}$$$.For example, if Rabbit has favorite numbers $$$1$$$ and $$$3$$$ he could hop from $$$(0,0)$$$ to $$$(4,0)$$$ in two hops as shown below. Note that there also exists other valid ways to hop to $$$(4,0)$$$ in $$$2$$$ hops (e.g. $$$(0,0)$$$ $$$\rightarrow$$$ $$$(2,-\sqrt{5})$$$ $$$\rightarrow$$$ $$$(4,0)$$$).    Here is a graphic for the first example. Both hops have distance $$$3$$$, one of Rabbit's favorite numbers. In other words, each time Rabbit chooses some number $$$a_i$$$ and hops with distance equal to $$$a_i$$$ in any direction he wants. The same number can be used multiple times.

The input consists of multiple test cases. The first line contains an integer $$$t$$$ ($$$1 \le t \le 1000$$$)  — the number of test cases. Next $$$2t$$$ lines contain test cases — two lines per test case. The first line of each test case contains two integers $$$n$$$ and $$$x$$$ ($$$1 \le n \le 10^5$$$, $$$1 \le x \le 10^9$$$)  — the number of favorite numbers and the distance Rabbit wants to travel, respectively. The second line of each test case contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$1 \le a_i \le 10^9$$$)  — Rabbit's favorite numbers. It is guaranteed that the favorite numbers are distinct. It is guaranteed that the sum of $$$n$$$ over all the test cases will not exceed $$$10^5$$$.

For each test case, print a single integer — the minimum number of hops needed.

NoteThe first test case of the sample is shown in the picture above. Rabbit can hop to $$$(2,\sqrt{5})$$$, then to $$$(4,0)$$$ for a total of two hops. Each hop has a distance of $$$3$$$, which is one of his favorite numbers.In the second test case of the sample, one way for Rabbit to hop $$$3$$$ times is: $$$(0,0)$$$ $$$\rightarrow$$$ $$$(4,0)$$$ $$$\rightarrow$$$ $$$(8,0)$$$ $$$\rightarrow$$$ $$$(12,0)$$$.In the third test case of the sample, Rabbit can hop from $$$(0,0)$$$ to $$$(5,0)$$$.In the fourth test case of the sample, Rabbit can hop: $$$(0,0)$$$ $$$\rightarrow$$$ $$$(5,10\sqrt{2})$$$ $$$\rightarrow$$$ $$$(10,0)$$$.

Main();
function myout(t){print(t);}//standard output
function next(){return readline();}
//[no]要素の扱い。数値型
//不明値、異常時:引数そのまま返す
//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((a)=>Number(a));case 6:return i.split("");case 7:return i.split("").map((a)=>Number(a));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 = myconv(next(),1);
    var output = new Array(t);
    for(var i = 0; i < t; i++){
        var one = myconv(next(),4);
        var n = one[0];
        var x = one[1];
        var list = myconv(next(),4);
        var hop = 1000000007;
        for(var j = 0; j < n; j++){
            var tmp;
            if(x < list[j]){
                tmp = 2;
            }else{
                tmp = Math.ceil(x / list[j]);
            }
            hop = Math.min(hop,tmp);
        }
        output[i] = hop;
    }
    myout(myconv(output,9));
}

Main();
function myout(t){print(t);}//standard output
function next(){return readline();}
//[no]要素の扱い。数値型
//不明値、異常時:引数そのまま返す
//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((a)=>Number(a));case 6:return i.split("");case 7:return i.split("").map((a)=>Number(a));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 = myconv(next(),1);
    var output = new Array(t);
    for(var i = 0; i < t; i++){
        var one = myconv(next(),4);
        var n = one[0];
        var x = one[1];
        var list = myconv(next(),4);
        var max = Math.max.apply(null,list);
        if(x < max){
            output[i] = 2;
        }else{
            output[i] = Math.ceil(x / max);
        }
    }
    myout(myconv(output,9));
}