const readline = require("readline");
const rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
})
let input = [];
rl.on('line', line => {
    input.push(line);
})
rl.on('close', line => {
   for (var m = 1; m < input.length; m++) {
        var arr = input[m].split(" ").map((i) => {
            return Number(i);
        });
        var n = arr[0];
        var list = arr.slice(1);
        var patterns = [];
        for (let num = 0; num < 16; num++) {
            var binary = num.toString(2);
            binary = "0".repeat(4 - binary.length) + binary;
            patterns.push(binary);
        }

        var flag = false;
        for (var pattern of patterns) {
            for (var i = 0; i < list.length; i++) {
                var corner = Number(pattern[i]) + Number(pattern[(i + 1) % list.length]);
                if (list[i] > corner + (n - 2) || list[i] < corner) {
                    break;
                }
            }
            if (i === list.length) {
                flag = true;
                break;
            }
        }
        if (flag) {
            console.log("YES");
        } else {
            console.log("NO");
        }
   }
})

'use-strict'

const { PassThrough } = require("stream");

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

let data = '';
let currentLine = 0;

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

process.stdin.on('end', () =>{
    data = data.replace(/\s*$/, '')
    .split('\n')
    .map(str => str.replace(/\s*$/, ''));

    let testCases = parseInt(data.shift());

    while(testCases--) {

        const [N,U,R,D,L] = readLine().split(' ').map(Number);

        const res = b(N,U,R,D,L);

        console.log(res)
    }
});

function get_ints() {
    return data.shift().split(' ').map(Number);
}

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

function b(N,U,R,D,L){
    let [rU, rR, rD, rL] = [U,R,D,L];
    for(let mask = 0; mask <= 16; mask++){
        [rU, rR, rD, rL] = [U,R,D,L];
        if (mask & 1){
            rU-= 1;
            rL-= 1;
        }
        if (mask & 2){
            rL-= 1;
            rD-= 1;
        }
        if (mask & 4){
            rD-= 1;
            rR-= 1;
        }
        if (mask & 8){
            rR-= 1;
            rU-=1;
        }
        if (Math.min(rU,rR,rD,rL) >= 0 && Math.max(rU,rR,rD,rL) <= N - 2){
            return 'YES'
        }
    }
    return 'NO';
}

module.exports = b;

const checkBit = (n, mask) => {
  return (n & mask) !== 0 ? 1 : 0;
};

const solve = (n, U, R, D, L) => {
  for (let i = 0; i < 2 ** 4; i++) {
    const ul = checkBit(i, 1 << 3);
    const ur = checkBit(i, 1 << 2);
    const dr = checkBit(i, 1 << 1);
    const dl = checkBit(i, 1 << 0);
    const edge = [U - ul - ur, R - ur - dr, D - dr - dl, L - dl - ul];
    if (edge.every(e => e >= 0 && e <= n - 2)) return true;
  }
  return false;
};

const main = () => {
  let test = readInt();
  while (test--) {
    const [n, U, R, D, L] = readListInt();
    if (solve(n, U, R, D, L)) console.log("YES");
    else console.log("NO");
  }
};

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 => string.trim());
  main();
});

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

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

const readListInt = () => {
  return inputString[currentLine++].split(" ").map(s => parseInt(s));
};

'use strict';

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

let inputString = '';
let currentLine = 0;

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

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

    main();
});

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

// Make a Snippet for the code above this and then write your logic in main();
var mod = 1000000000n + 7n
var maxN = 1002

function main() {
    const x = readline();
    //
    Array(Number(x)).fill(1).map((t, iii) => {
        // var n = parseInt(readline())
        var [n, u, r, d, l] = readline().split(' ').map((x, iii) => {
            return parseInt(x)
        })

        if (u === 0 && (r === n || l === n)) return console.log('NO')
        if (l === 0 && (u === n || d === n)) return console.log('NO')
        if (d === 0 && (r === n || l === n)) return console.log('NO')
        if (r === 0 && (u === n || d === n)) return console.log('NO')

        if (u === n && d === n && (l < 2 || r < 2)) return console.log('NO')
        if (l === n && r === n && (u < 2 || d < 2)) return console.log('NO')

        if (n === 2 && (l === 2 || r === 2 || d === 2 || u === 2) && (r + l + u + d) === 5) return console.log('NO')
        if (n === 2 && (l === 0 || r === 0 || d === 0 || u === 0) && (r + l + u + d) === 3) return console.log('NO')
        if (n === 2 && (r + l + u + d) === 1) return console.log('NO')

        if ((n - 1) === u && (l === 0 && r === 0)) return console.log('NO')
        if ((n - 1) === d && (l === 0 && r === 0)) return console.log('NO')
        if ((n - 1) === l && (u === 0 && d === 0)) return console.log('NO')
        if ((n - 1) === r && (u === 0 && d === 0)) return console.log('NO')

        if (u === n && d === (n-1) && (l < 2 && r < 2)) return console.log('NO')
        if (d === n && u === (n-1) && (l < 2 && r < 2)) return console.log('NO')

        if (r === n && l === (n-1) && (u < 2 && d < 2)) return console.log('NO')
        if (l === n && r === (n-1) && (u < 2 && d < 2)) return console.log('NO')

        if ((n - 1) === u && (n - 1) === d && (l+r<2)) return console.log('NO')
        if ((n - 1) === l && (n - 1) === r && (u+d<2)) return console.log('NO')

        // if (l === 0 && (u === n || d === n)) return console.log('NO')
        // if (d === 0 && (r === n || l === n)) return console.log('NO')
        // if (r === 0 && (u === n || d === n)) return console.log('NO')

        console.log('YES')
        // var a = readline().split('').map((x, iii) => {
        //     return x
        // })

    })
}

function checkString(a) {
    // console.log(a)
    var count = 0
    var res = true
    for (let i = 0; i < a.length; i++) {
        if (a[i] === '(') count++
        else {
            count--
            if (count < 0) res = false
        }
    }
    if (count !== 0) res = false

    return res

}

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 [n, U, R, D, L] = rna();

		let ans;
		for (let mask = 1; mask <= 16; mask++) {
			let [rU, rR, rD, rL] = [U, R, D, L];

			if (mask & 1) {
				rU--;
				rL--;
			}
			if (mask & 2) {
				rL--;
				rD--;
			}
			if (mask & 4) {
				rD--;
				rR--;
			}
			if (mask & 8) {
				rR--;
				rU--;
			}
			if (Math.min(rU, rL, rD, rR) >= 0 && Math.max(rU, rL, rD, rR) <= n-2) {
				ans = true;
			}
		}

		console.log(ans ? 'YES' : '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++];
}

// Make a Snippet for the code above this and then write your logic in main();
var mod = 1000000000n + 7n
var maxN = 1002

function main() {
    const x = readline();
    //
    Array(Number(x)).fill(1).map((t, iii) => {
        // var n = parseInt(readline())
        var [n, u, r, d, l] = readline().split(' ').map((x, iii) => {
            return parseInt(x)
        })

        if (u === 0 && (r === n || l === n)) return console.log('NO')
        if (l === 0 && (u === n || d === n)) return console.log('NO')
        if (d === 0 && (r === n || l === n)) return console.log('NO')
        if (r === 0 && (u === n || d === n)) return console.log('NO')

        if (u === n && d === n && (l < 2 || r < 2)) return console.log('NO')
        if (l === n && r === n && (u < 2 || d < 2)) return console.log('NO')

        if (n === 2 && (l === 2 || r === 2 || d === 2 || u === 2) && (r + l + u + d) === 5) return console.log('NO')
        if (n === 2 && (l === 0 || r === 0 || d === 0 || u === 0) && (r + l + u + d) === 3) return console.log('NO')
        if (n === 2 && (r + l + u + d) === 1) return console.log('NO')

        if ((n - 1) === u && (l === 0 && r === 0)) return console.log('NO')
        if ((n - 1) === d && (l === 0 && r === 0)) return console.log('NO')
        if ((n - 1) === l && (u === 0 && d === 0)) return console.log('NO')
        if ((n - 1) === r && (u === 0 && d === 0)) return console.log('NO')

        if (u === n && d === (n-1) && (l < 2 && r < 2)) return console.log('NO')
        if (d === n && u === (n-1) && (l < 2 && r < 2)) return console.log('NO')

        if (r === n && l === (n-1) && (u < 2 && d < 2)) return console.log('NO')
        if (l === n && r === (n-1) && (u < 2 && d < 2)) return console.log('NO')

        // if (l === 0 && (u === n || d === n)) return console.log('NO')
        // if (d === 0 && (r === n || l === n)) return console.log('NO')
        // if (r === 0 && (u === n || d === n)) return console.log('NO')

        console.log('YES')
        // var a = readline().split('').map((x, iii) => {
        //     return x
        // })

    })
}

function checkString(a) {
    // console.log(a)
    var count = 0
    var res = true
    for (let i = 0; i < a.length; i++) {
        if (a[i] === '(') count++
        else {
            count--
            if (count < 0) res = false
        }
    }
    if (count !== 0) res = false

    return res

}

'use strict';

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

let inputString = '';
let currentLine = 0;

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

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

    main();
});

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

// Make a Snippet for the code above this and then write your logic in main();
var mod = 1000000000n + 7n
var maxN = 1002

function main() {
    const x = readline();
    //
    Array(Number(x)).fill(1).map((t, iii) => {
        // var n = parseInt(readline())
        var [n, u, r, d, l] = readline().split(' ').map((x, iii) => {
            return parseInt(x)
        })

        if (u === 0 && (r === n || l === n)) return console.log('NO')
        if (l === 0 && (u === n || d === n)) return console.log('NO')
        if (d === 0 && (r === n || l === n)) return console.log('NO')
        if (r === 0 && (u === n || d === n)) return console.log('NO')

        if (u === n && d === n && (l < 2 || r < 2)) return console.log('NO')
        if (l === n && r === n && (u < 2 || d < 2)) return console.log('NO')

        if (n === 2 && (l === 2 || r === 2 || d === 2 || u === 2) && (r + l + u + d) === 5) return console.log('NO')
        if (n === 2 && (l === 0 || r === 0 || d === 0 || u === 0) && (r + l + u + d) === 3) return console.log('NO')
        if (n === 2 && (r + l + u + d) === 1) return console.log('NO')

        if ((n - 1) === u && (l === 0 && r === 0)) return console.log('NO')
        if ((n - 1) === d && (l === 0 && r === 0)) return console.log('NO')
        if ((n - 1) === l && (u === 0 && d === 0)) return console.log('NO')
        if ((n - 1) === r && (u === 0 && d === 0)) return console.log('NO')

        // if (l === 0 && (u === n || d === n)) return console.log('NO')
        // if (d === 0 && (r === n || l === n)) return console.log('NO')
        // if (r === 0 && (u === n || d === n)) return console.log('NO')

        console.log('YES')
        // var a = readline().split('').map((x, iii) => {
        //     return x
        // })

    })
}

function checkString(a) {
    // console.log(a)
    var count = 0
    var res = true
    for (let i = 0; i < a.length; i++) {
        if (a[i] === '(') count++
        else {
            count--
            if (count < 0) res = false
        }
    }
    if (count !== 0) res = false

    return res

}

'use strict';

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

let inputString = '';
let currentLine = 0;

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

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

    main();
});

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

// Make a Snippet for the code above this and then write your logic in main();
var mod = 1000000000n + 7n
var maxN = 1002

function main() {
    const x = readline();
    //
    Array(Number(x)).fill(1).map((t, iii) => {
        // var n = parseInt(readline())
        var [n, u, r, d, l] = readline().split(' ').map((x, iii) => {
            return parseInt(x)
        })

        if (u === 0 && (r === n || l === n)) return console.log('NO')
        if (l === 0 && (u === n || d === n)) return console.log('NO')
        if (d === 0 && (r === n || l === n)) return console.log('NO')
        if (r === 0 && (u === n || d === n)) return console.log('NO')

        if (u === n && d === n && (l < 2 || r < 2)) return console.log('NO')
        if (l === n && r === n && (u < 2 || d < 2)) return console.log('NO')

        if (n === 2 && (l === 2 || r === 2 || d === 2 || u === 2) && (r + l + u + d) === 5) return console.log('NO')
        if (n === 2 && (l === 0 || r === 0 || d === 0 || u === 0) && (r + l + u + d) === 3) return console.log('NO')

        // if (l === 0 && (u === n || d === n)) return console.log('NO')
        // if (d === 0 && (r === n || l === n)) return console.log('NO')
        // if (r === 0 && (u === n || d === n)) return console.log('NO')

        console.log('YES')
        // var a = readline().split('').map((x, iii) => {
        //     return x
        // })

    })
}

function checkString(a) {
    // console.log(a)
    var count = 0
    var res = true
    for (let i = 0; i < a.length; i++) {
        if (a[i] === '(') count++
        else {
            count--
            if (count < 0) res = false
        }
    }
    if (count !== 0) res = false

    return res

}

'use strict';

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

let inputString = '';
let currentLine = 0;

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

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

    main();
});

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

// Make a Snippet for the code above this and then write your logic in main();
var mod = 1000000000n + 7n
var maxN = 1002

function main() {
    const x = readline();
    //
    Array(Number(x)).fill(1).map((t, iii) => {
        // var n = parseInt(readline())
        var [n, u, r, d, l] = readline().split(' ').map((x, iii) => {
            return parseInt(x)
        })

        if (u === 0 && (r === n || l === n)) return console.log('NO')
        if (l === 0 && (u === n || d === n)) return console.log('NO')
        if (d === 0 && (r === n || l === n)) return console.log('NO')
        if (r === 0 && (u === n || d === n)) return console.log('NO')

        if (u === n && d === n && (l < 2 || r < 2)) return console.log('NO')
        if (l === n && r === n && (u < 2 || d < 2)) return console.log('NO')

        if (n === 2 && (l === 2 || r === 2 || d === 2 || u === 2) && r + l + u + d === 5) return console.log('NO')

        // if (l === 0 && (u === n || d === n)) return console.log('NO')
        // if (d === 0 && (r === n || l === n)) return console.log('NO')
        // if (r === 0 && (u === n || d === n)) return console.log('NO')

        console.log('YES')
        // var a = readline().split('').map((x, iii) => {
        //     return x
        // })

    })
}

function checkString(a) {
    // console.log(a)
    var count = 0
    var res = true
    for (let i = 0; i < a.length; i++) {
        if (a[i] === '(') count++
        else {
            count--
            if (count < 0) res = false
        }
    }
    if (count !== 0) res = false

    return res

}

'use strict';

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

let inputString = '';
let currentLine = 0;

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

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

    main();
});

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

// Make a Snippet for the code above this and then write your logic in main();
var mod = 1000000000n + 7n
var maxN = 1002

function main() {
    const x = readline();
    //
    Array(Number(x)).fill(1).map((t, iii) => {
        // var n = parseInt(readline())
        var [n, u, r, d, l] = readline().split(' ').map((x, iii) => {
            return parseInt(x)
        })

        if (u === 0 && (r === n || l === n)) return console.log('NO')
        if (l === 0 && (u === n || d === n)) return console.log('NO')
        if (d === 0 && (r === n || l === n)) return console.log('NO')
        if (r === 0 && (u === n || d === n)) return console.log('NO')

        if (u === n && d === n && (l<2 || r<2)) return console.log('NO')
        if (l === n && r === n && (u<2 || d<2)) return console.log('NO')

        // if (l === 0 && (u === n || d === n)) return console.log('NO')
        // if (d === 0 && (r === n || l === n)) return console.log('NO')
        // if (r === 0 && (u === n || d === n)) return console.log('NO')

        console.log('YES')
        // var a = readline().split('').map((x, iii) => {
        //     return x
        // })

    })
}

function checkString(a) {
    // console.log(a)
    var count = 0
    var res = true
    for (let i = 0; i < a.length; i++) {
        if (a[i] === '(') count++
        else {
            count--
            if (count < 0) res = false
        }
    }
    if (count !== 0) res = false

    return res

}

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 [n, U, R, D, L] = rna();

		let l = 0, r = 0, u = 0, d = 0, lr = 0, ud = 0;

		if (U == n) l++, r++;
		if (U == n-1) lr++;

		if (D == n) l++, r++;
		if (D == n-1) lr++;

		if (L == n) u++, d++;
		if (L == n-1) ud++;

		if (R == n) u++, d++;
		if (R == n-1) ud++;

		const ok = L >= l && R >= r && U >= u && D >= d && L+R >= lr && U+D >= ud && U+L+R+D <= 4*(n-1);

		console.log(ok ? 'YES' : 'NO');
	}
}

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 [n, U, R, D, L] = rna();

		let l = 0, r = 0, u = 0, d = 0, lr = 0, ud = 0;

		if (U == n) l++, r++;
		if (U == n-1) lr++;

		if (D == n) l++, r++;
		if (D == n-1) lr++;

		if (L == n) u++, d++;
		if (L == n-1) ud++;

		if (R == n) u++, d++;
		if (R == n-1) ud++;

		const ok = L >= l && R >= r && U >= u && D >= d && L+R >= lr && U+D >= ud;

		console.log(ok ? 'YES' : 'NO');
	}
}

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 [n, u, r, d, l] = rna();

		function check(u, l, r) {
			let ok = true;
			if (u == n) ok = ok && l > 0 && r > 0;
			if (u == n-1) ok = ok && l + r > 0;
			return ok;
		}

		let ok = check(u, l, r) &&
			check(l, u, d) &&
			check(r, u, d) &&
			check(d, l, r);

		console.log(ok ? 'YES' : 'NO');
	}
}

'use-strict'

const { PassThrough } = require("stream");

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

let data = '';
let currentLine = 0;

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

process.stdin.on('end', () =>{
    data = data.replace(/\s*$/, '')
    .split('\n')
    .map(str => str.replace(/\s*$/, ''));

    let testCases = parseInt(data.shift());

    while(testCases--) {

        const [N,U,R,D,L] = readLine().split(' ').map(Number);

        const res = b(N,U,R,D,L);

        console.log(res)
    }
});

function get_ints() {
    return data.shift().split(' ').map(Number);
}

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

function b(N,U,R,D,L){
    let [rU, rR, rD, rL] = [U,R,D,L];
    console.log(rU, rR, rD, rL)
    for(let mask = 0; mask <= 16; mask++){
        [rU, rR, rD, rL] = [U,R,D,L];
        console.log(rU, rR, rD, rL, mask)
        if (mask & 1){
            rU-= 1;
            rL-= 1;
        }
        if (mask & 2){
            rL-= 1;
            rD-= 1;
        }
        if (mask & 4){
            rD-= 1;
            rR-= 1;
        }
        if (mask & 8){
            rR-= 1;
            rU-=1;
        }
        if (Math.min(rU,rR,rD,rL) >= 0 && Math.max(rU,rR,rD,rL) <= N - 2){
            return 'YES'
        }
    }
    return 'NO';
}

module.exports = b;

'use-strict'

const { PassThrough } = require("stream");

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

let data = '';
let currentLine = 0;

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

process.stdin.on('end', () =>{
    data = data.replace(/\s*$/, '')
    .split('\n')
    .map(str => str.replace(/\s*$/, ''));

    let testCases = parseInt(data.shift());

    while(testCases--) {

        const [N,U,R,D,L] = get_ints();

        const res = b(N,U,R,D,L);

        console.log(res)
    }
});

function get_ints() {
    return data.shift().split(' ').map(Number);
}

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

function b(N,U,R,D,L){
    const u = U - 2;
    const r = R - 2;
    const d = D - 2;
    const l = L - 2;
    if(u>= 0 && u<= N - 2 && r >= 0 && r <= N - 2 && d >= 0 && d <= N- 2 && l >= 0 && l <= N - 2){
        return 'YES'
    } else{
        return 'NO';
    }
}

const solve = (n, U, R, D, L) => {
  const edge = [U, R, D, L];
  if (edge.some(e => e > n)) return false;
  if (edge.every(e => e < n)) return true;

  let cU = 0,
    cR = 0,
    cD = 0,
    cL = 0;

  [U, D].forEach(e => {
    if (e === n) {
      cL += 1;
      cR += 1;
    }
  });

  [L, R].forEach(e => {
    if (e === n) {
      cU += 1;
      cD += 1;
    }
  });

  return U >= cU && D >= cD && L >= cL && R >= cR;
};

const main = () => {
  let test = readInt();
  while (test--) {
    const [n, U, R, D, L] = readListInt();
    if (solve(n, U, R, D, L)) console.log("YES");
    else console.log("NO");
  }
};

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 => string.trim());
  main();
});

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

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

const readListInt = () => {
  return inputString[currentLine++].split(" ").map(s => parseInt(s));
};


nm = readline().split(' ').map(Number);
A = readline().split(' ').map(Number);
B = readline().split(' ').map(Number);
Ar = [];
ans = 0;
for(var i = 0;i<nm[0];i++) {
	Ar.push(Array(A[i],B[i],A[i]-B[i]));
}
Ar.sort((x,y) => {
	if(x[2] < y[2]) return -1;
	if(x[2] == y[2]) return 0;
	if(x[2] > y[2]) return 1;
});
for(var i=0;i<nm[1];i++) {
	ans += Ar[i][0];
}
for(var i=nm[1];i<nm[0];i++) {
	ans += ((a,b) => {if(a < b) return a; return b;})(Ar[i][0],Ar[i][1]);
}
print(ans);

var tmp = readline().split(' ');
var n = parseInt(tmp[0]);
var k = parseInt(tmp[1]);
var a = readline().split(' ').map(function(x) {
  return parseInt(x);
});
var b = readline().split(' ').map(function(x) {
  return parseInt(x);
});
var c = a.map(function(x, i) {
  return {
    i: i,
    d: a[i] - b[i]
  };
}).sort(function(a, b) {
  return a.d - b.d;
});
var r = 0;
for(var i = 0; i < n; i += 1) {
  if(i < k) {
    r += a[c[i].i];
  } else {
    r += Math.min(a[c[i].i], b[c[i].i]);
  }
}

print(r);


Array.prototype.in_array = function(p_val) {
	for(var i = 0, l = this.length; i < l; i++)	{
		if(this[i] == p_val) {
			return true;
		}
	}
	return false;
}

var inp = readline().split(' ');
var n = inp[0];
var m = inp[1];

var m_arr = [];
for(var i = 1; i <= n; i++) {
    var n_arr = readline().split(' ');
    for (var j = 1; j <= n_arr[0]; j++) {
        m_arr.push(n_arr[j]);
    }
}
var f;
for(var k = 1; k <= m; k++) {
    if (m_arr.in_array(k)) {
        f = true;
    } else {
        f = false;
        break;
    }
}
if(f) {
    print("YES");
} else {
    print("NO");
}

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

rl.on('line', (d) => {
  if (c === 0) {
    [n, m] = d.split(' ').map(Number);
    c++;
    return;
  }

  let temp = d.split(' ');
  temp.shift();

  arr = arr.concat(temp);

  c++;
});

rl.on('close', () => {
  const ans = new Set(arr);

  if (ans.size === m) {
    console.log('YES');
  }
  else {
    console.log('NO');
  }
});

//const nums = line.trim().split(' ').map(s => parseInt(s))

var numLines = 0;

var buttons = 0;
var bulbs = 0;

var allBulbs = [];

require('readline').createInterface({
    input: process.stdin,
}).on('line', (line) => {
    numLines++;
    let nums = line.trim().split(' ');
    for(let i = 0; i<nums.length; i++){
        nums[i] = parseInt(nums[i]);
    }

    if(numLines === 1){
        buttons = nums[0];
        bulbs = nums[1];

        return;
    }

    let numBulbsInLine = nums[0];

    for(let i = 1; i<=numBulbsInLine; i++){
        if(allBulbs.indexOf(nums[i]) === -1){
            allBulbs.push(nums[i]);
        }
    }

    if(numLines - 1 === buttons){
        let flag = true;
        for(let i = 1; i <= bulbs; i++){
            if(allBulbs.indexOf(i) === -1){
                flag = false;
                break;
            }
        }

        process.stdout.write(flag ? 'YES' : 'NO' + '\n');
        process.exit();
    }
})

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

for(var i = 0; i < n; i++){
    input = readline().split(" ").map(Number);
    var x = input[0];
    var y = input.slice(1);
    for(var j = 0; j < x; j++){
        lamps[y[j]-1] = true;
    }
}

var ans = lamps.every( function(a){ return a; } );

if(ans){
    write("YES");
}else{
    write("NO");
}

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

rl.on('line', (d) => {
  if (c === 0) {
    [n, m] = d.split(' ').map(Number);
    c++;
    return;
  }

  arr = arr.concat(d.split(' '));

  c++;
});

rl.on('close', () => {
  const ans = new Set(arr);

  if (ans.size === m) {
    console.log('YES');
  }
  else {
    console.log('NO');
  }
});


let readline = require("readline");

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

let input = [];
rl.on("line", function (line) {
  input.push(line);

  if (input.length === +input[0] + 1) {
    // call your function here
    solve(input);
    rl.close();
  }
});

let solve = (input) => {
  for (let i = 1; i < input.length; i++) {
    while (+input[i] % 2 === 0) {
      input[i] = +input[i] / 2;
    }
    if (+input[i] > 1) console.log("YES");
    else console.log("NO");
  }
};

var cnt = +readline();
var arr = [];
for(var i = 0; i < cnt; i++) {
    arr.push(readline());
}

function oddDivisor(n) {
  if (n !== 1 && n % 2 === 1) {
    return 'YES';
  }
  if (n === 1) {
    return 'NO';
  }
  return oddDivisor(Math.floor(n / 2));
}

for (var i = 0; i < arr.length; i++) {
  print(oddDivisor(arr[i]))
}

var t = readline();
    for(var i = 0 ; i < t ; ++i){
        var n = readline();
        while(n > 1){
            if(n%2 === 0){
                n = n /2;
            }
            else{
                print("YES");
                break;
            }
        }
        if(n == 1){
            print("NO");
        }
    }

var n = +readline();
for(var i = 0; i < n; i++) {
  var val = +readline(), temp = 2;
  while(val > temp) {
    temp = temp * 2;
  }
  print(val === temp ? 'NO' : 'YES');
}

"use strict"
let iter = parseInt(readline());

while(iter--){
let ch=false;
let input=parseInt(readline());
for(var i =input;i>1;i/=2){
if(i%2!==0){
ch=true;

}

}
(ch===true)?print("YES"):print("NO");
}

"use strict"

let iter = parseInt(readline());

while(iter--){
    let res = "NO";
    let input = parseInt(readline());
    for(let i = input; input > 1; input /= 2){
        if(input % 2 === 1){
            res = "YES";
            break;
        }
    }
    print(res);
}

//  var gcd = function(a, b) {
//   if (!b) {
//     return a;
//   }

//   return gcd(b, a % b);
// }
let ryan = '';//.map(Number).sort(function(a, b){return a - b})
process.stdin.on('data', c => ryan += c);
process.stdin.on('end', () => {
    const {EOL} = require('os');
    const lines = ryan.split(EOL);
    var n = lines[0]
    for(j = 1; j <= n; j++){
        var k = lines[j]
        if(k % 2 == 1){
            console.log('YES')
            continue;
        }
        while(k % 2 === 0){
            k /= 2
        }
        console.log(k > 1 ? 'YES' : 'NO')
    }
});

const nextString = (function() {
  const l = [], s = [], p = process.stdin
  let q = ''
  p.setEncoding('utf8')
  p.on('readable', () => {
    let c
    while ((c = p.read()) !== null) {
      c = (q + c).split(/\r\n|\r|\n/)
      q = c[c.length - 1]
      for (let i = 0; i < c.length - 1; ++i) {
        if (c[i].length > 0) {
          if (l.length > 0) {
            l.shift(1)(c[i])
          }
          else {
            s.push(c[i])
          }
        }
      }
    }
  })
  const f = r => {
    if (s.length > 0) {
      r(s.shift(1))
    }
    else {
      l.push(r)
    }
  }
  return () => new Promise(f)
})()

async function main() {
  let t = +await nextString()
  let one = BigInt(1)
  let two = BigInt(2)
  let zero = BigInt(0)
  for (let i = 0; i < t; ++i) {
    let n = BigInt(await nextString())
    while (n % two === zero) {
      n = n >> one
    }
    if (n > one) {
      console.log('YES')
    }
    else {
      console.log('NO')
    }
  }
  process.exit(0)
}

main()

const nextString = (function() {
  const listeners = [], strings = [], ps = process.stdin
  let last = ''
  ps.setEncoding('utf8')
  ps.on('readable', () => {
    let chunk
    while ((chunk = ps.read()) !== null) {
      chunk = (last + chunk).split(/\r\n|\r|\n/)
      last = chunk[chunk.length - 1]
      for (let i = 0; i < chunk.length - 1; ++i) {
        if (chunk[i].length > 0) {
          if (listeners.length > 0) {
            listeners.shift(1)(chunk[i])
          }
          else {
            strings.push(chunk[i])
          }
        }
      }
    }
  })
  const fn = resolve => {
    if (strings.length > 0) {
      resolve(strings.shift(1))
    }
    else {
      listeners.push(resolve)
    }
  }
  return () => new Promise(fn)
})()

async function main() {
  let t = +await nextString()
  let one = BigInt(1)
  let two = BigInt(2)
  let zero = BigInt(0)
  for (let i = 0; i < t; ++i) {
    let n = BigInt(await nextString())
    while (n % two === zero) {
      n = n >> one
    }
    if (n > one) {
      console.log('YES')
    }
    else {
      console.log('NO')
    }
  }
  process.exit(0)
}

main()

process.stdin.resume();
process.stdin.setEncoding("utf8");
let standardInputString = "";
let currentLine = 0;
function readLine() {
  return standardInputString[currentLine++];
}
process.stdin.on("data", (rawData) => {
  standardInputString += rawData;
});
process.stdin.on("end", (_) => {
  standardInputString = standardInputString
    .trim()
    .split("\n")
    .map((line) => {
      return line.trim();
    });
  main();
});

function main() {
  const cl = console.log,
    rl = readLine,
    tc = rl();

  for (let i = 0; i < tc; i++) {
    let N = +rl();
    while (N % 2 === 0) N /= 2;
    N > 1 ? cl("Yes") : cl("NO");
  }
}

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

// utils
const MOD = 1e9 + 7;
const mod = (n) => ((n % MOD) + MOD) % MOD;
const add = (a, b) => mod(mod(a) + mod(b));
const sub = (a, b) => mod(mod(a) - mod(b));
function mul() {
	for (var a = arguments, r = a[0], i = a.length; --i; )
		r = ((((r >> 16) * a[i]) % MOD) * 65536 + (r & 65535) * a[i]) % MOD;
	return r;
}
function inv(b) {
	for (var a = MOD, u = 0, v = 1, t; b; v = t)
		(t = (a / b) | 0), (a -= t * b), (u -= t * v), (t = a), (a = b), (b = t), (t = u), (u = v);
	u %= MOD;
	return u < 0 ? u + MOD : u;
}
function pow(base, n) {
	if (n === 0) return 1;
	let p = pow(base, Math.floor(n / 2));
	let res = mul(mod(p), mod(p));
	if (n % 2 === 1) res = mul(mod(res), base);
	return res;
}
function highestOneBit(i) {
	i |= i >> 1;
	i |= i >> 2;
	i |= i >> 4;
	i |= i >> 8;
	i |= i >> 16;
	return i - (i >>> 1);
}
function permutation(arr, len, store = '', permutations = []) {
	if (store.length === len) {
		permutations.push(store);
		return;
	}
	for (let i = 0; i < arr.length; i++) {
		const newArr = [...arr];
		const newChar = newArr.splice(i, 1);
		permutation(newArr, len, store.concat(newChar), permutations);
	}
	return permutations;
}
function gcd(a, b) {
	if (b === 0) return a;
	return gcd(b, a % b);
}

function main() {
	let t = +readLine();
	const map = new Map();
	while (t--) {
		let n = +readLine();
		if (map.has(n)) {
			console.log(map.get(n));
		} else {
			if (n % 2 !== 0) {
				map.set(n, 'YES');
				console.log('YES');
			} else {
				let found = false;
				let div = Math.floor(n / 2);
				while (div > 1) {
					if (div % 2 !== 0) {
						found = true;
						console.log('YES');
						map.set(n, 'YES');
						break;
					}
					div = Math.floor(div / 2);
				}
				if (!found) {
					map.set(n, 'NO');
					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++];
}

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

function main() {
    const x = readline();
    var answer = []

    // console.log(Number(x))
    // 1 1 7
    // 6 9, 15, 18
    Array(Number(x)).fill(1).map((t, i) => {
        var n = Number(readline());
        var d = n + 1
        console.log(isPrime(n))
        // if (n % 2 !== 0) return console.log('YES')
        // if (!isPrime(n)) return console.log(n)
        // console.log('NO')
    })
}

function isPrime(num) {
    var result = true
    while (num !== 1 && num % 2 === 0) {
        num = num / 2
    }
return     num !== 1 ? 'YES' :'NO'
    console.log(num)
}

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

//Don't have to see. end------------------------------------------
function Main(){
	var t = nextInt();
	for(var i = 0; i < t; i++){
		var N = nextInt();
		var isOK = false;
		while(N > 1){
			if(N % 2 == 0){
				N /= 2;
			}else{
				isOK = true;
				break;
			}
		}
		myout((isOK) ? "YES" : "NO");
	}
}

let stop = '';
process.stdin.on('data', c => stop += c);
process.stdin.on('end', () => {
    const {EOL} = require('os');
    const lines = stop.split(EOL);
    var t = lines[0];
    for(i = 1; i <= t; i++){
        var n = lines[i];
        if(n % 2 == 1){
            console.log('YES');
            continue;
        }
        while(n % 2 === 0){
            n /= 2;
        }
        console.log(n > 1 ? 'YES' : '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.split("\n");
    main();
});

/********** Utility Function Start **********/
/**
 *  read row Input
 * @returns string
 */
function _readRawLine() {
    return inputString[currentLine++];
}
function readLine(){
    // return _readRawLine().replace(/\s+$/g, '');
    return _readRawLine().replace('\r', '');
}

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

function readSingleInt() {
    const p = readLine();
    return parseInt(p);
}
function readIntArray() {
    return readLine().split(" ").map((v) => parseInt(v));
}
function readArray() {
    return readLine().split(" ");
}
function int(n) {
    return parseInt(n);
}
/********** Utility Function End **********/
/**
 * Don't Touch this fucntion at all unless you know what are you doing!
 */
function main() {
    solve();
}

// ********** Code Start **********

function solve() {
    let tc = readSingleInt();
    // console.log(BigInt(readLine()));
    const two = BigInt(2);
    while(tc--){
        let bgi = BigInt(readLine());
        let cnt = 0;
        while(bgi%two==0){
            bgi = bgi / two;
        }
        if(bgi===BigInt(1)){
            print("NO");
        }else{
            print("YES")
        }
    }

}

process.stdin.resume();

process.stdin.setEncoding('utf8');

var input = '';

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

function main(input) {
    input = input.split("\n");
    let z = 0;
    let testCases = +input[z++];

    while(testCases--){
        let num = +input[z++];
        if(num % 2){
            console.log("YES");
        }
        else{
            if(Math.log2(num) % 2 === 0 || Math.log2(num) % 2 === 1){
                console.log("NO");
            }
            else{
                console.log("YES");
            }
        }
    }
}

//https://codeforces.com/problemset/problem/1475/A
const readline = require("readline");
const scanner = readline.createInterface({
	input: process.stdin,
	output: process.stdout
});

isOne = true;
scanner.on("line", input => {
	if (isOne)
	{
		isOne = false;
	}
	else
	{
		console.log(oddDivisor(+input));
	}
});

//Oh lmao if everything is even divisor then it would just be 2^x
//A odd divisor is the only thing that jams this
const oddDivisor = num => Math.log2(num) % 1 != 0 ? "YES" : "NO";

// define file test.inp
process.stdin.resume();
process.stdin.setEncoding("utf8");

var jsin = "";
var jscur = 0;

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

readLine = () => jsin[jscur++];
readLines = () => readLine().split(' ');
readInt = () => parseInt(readLine());
readInts = () => readLine().split(' ').map(x => parseInt(x));

function main(){
    // code goes here!!
    var numTest = readInt();
    for(let i = 0;i < numTest;++i){
        let n = readInt();
        while(n % 2 == 0){
            n /= 2;
        }
        if(n > 1){
            console.log("YES");
        } else {
            console.log("NO");
        }
    }
}

//  var gcd = function(a, b) {
//   if (!b) {
//     return a;
//   }

//   return gcd(b, a % b);
// }
let ryan = '';//.map(Number).sort(function(a, b){return a - b})
process.stdin.on('data', c => ryan += c);
process.stdin.on('end', () => {
    const {EOL} = require('os');
    const lines = ryan.split(EOL);
    var n = lines[0]
    for(j = 1; j <= n; j++){
        var k = lines[j]
            console.log(k % 2 ==1 ? 'YES' : 'NO')
            continue;

    }
});

//  var gcd = function(a, b) {
//   if (!b) {
//     return a;
//   }

//   return gcd(b, a % b);
// }
let ryan = '';//.map(Number).sort(function(a, b){return a - b})
process.stdin.on('data', c => ryan += c);
process.stdin.on('end', () => {
    const {EOL} = require('os');
    const lines = ryan.split(EOL);
    var n = lines[0]
    for(j = 1; j <= n; i++){
        var k = lines[j]
            console.log(k % 2 ==1 ? 'YES' : 'NO')
            break;;

    }
});

let i = '';
process.stdin.on('data', c => i += c);
process.stdin.on('end', () => {
    const {EOL} = require('os');
    const lines = i.split(EOL);
    var n = lines[0];
    for(j = 1; j <= n; j++){
    var k = Number(lines[j])
    e = k / 2
    if(k % 2 === 0 && e % 2 != 1){
        console.log('NO')
    }else{
        console.log('YES')
    }
    }
});

let i = '';
process.stdin.on('data', c => i += c);
process.stdin.on('end', () => {
    const {EOL} = require('os');
    const lines = i.split(EOL);
    var n = lines[0];
    for(j = 1; j <= n; j++){
    var k = Number(lines[j])
    e = k / 2
    if(k % 2 === 0 || e % 2 != 1){
        console.log('NO')
    }else{
        console.log('YES')
    }
    }
});

let i = '';
process.stdin.on('data', c => i += c);
process.stdin.on('end', () => {
    const {EOL} = require('os');
    const lines = i.split(EOL);
    var n = lines[0];
    for(j = 1; j <= n; j++){
    var k = Number(lines[j])
    e = k / 2
    if(k % 2 === 0 || e % 2 == 1){
        console.log('NO')
    }else{
        console.log('YES')
    }
    }
});

let i = '';
process.stdin.on('data', c => i += c);
process.stdin.on('end', () => {
    const {EOL} = require('os');
    const lines = i.split(EOL);
    var n = lines[0];
    for(j = 1; j <= n; j++){
    var k = Number(lines[j])
    if(k % 2 === 0){
        console.log('NO')
    }else{
        console.log('YES')
    }
    }
});

let i = '';
process.stdin.on('data', c => i += c);
process.stdin.on('end', () => {
    const {EOL} = require('os');
    const lines = i.split(EOL);
    var n = lines[0];
    for(j = 1; j <= n; j++){
    var k = lines[j]
    if(k % 2 === 0){
        console.log('NO')
    }else{
        console.log('YES')
    }
    }
});

let i = '';
process.stdin.on('data', c => i += c);
process.stdin.on('end', () => {
    const {EOL} = require('os');
    const lines = i.split(EOL);
    var n = lines[0];
    for(j = 1; j <= n; j++){
    var k = lines[j]
    if(j % 2 === 0){
        console.log('NO')
    }else{
        console.log('YES')
    }
    }
});

let i = '';
process.stdin.on('data', c => i += c);
process.stdin.on('end', () => {
    const {EOL} = require('os');
    const lines = i.split(EOL);
    var n = lines[0];
    if(n % 2 === 0){
        console.log('NO')
    }else{
        console.log('YES')
    }
});

const nextString = (function() {
  const l = [], s = [], p = process.stdin
  p.setEncoding('utf8')
  p.on('readable', () => {
    for (let c; (c = p.read()) !== null;) {
      c = c.split(/\r\n|\r|\n/)
      for (let i = 0; i < c.length; ++i) {
        if (c[i].length > 0) {
          if (l.length > 0) {
            l.shift(1)(c[i])
          }
          else {
            s.push(c[i])
          }
        }
      }
    }
  })
  const f = r => {
    if (s.length > 0) {
      r(s.shift(1))
    }
    else {
      l.push(r)
    }
  }
  return () => new Promise(f)
})()

async function main() {
  let t = +await nextString()
  let one = BigInt(1)
  let two = BigInt(2)
  let zero = BigInt(0)
  for (let i = 0; i < t; ++i) {
    let n = BigInt(await nextString())
    while (n % two === zero) {
      n = n >> one
    }
    if (n > one) {
      console.log('YES')
    }
    else {
      console.log('NO')
    }
  }
  process.exit(0)
}

main()

const nextString = (function() {
  const l = [], s = [], p = process.stdin
  p.setEncoding('utf8')
  p.on('readable', () => {
    for (let c; (c = p.read()) !== null;) {
      c = c.split(/\r\n|\r|\n/)
      for (let i = 0; i < c.length; ++i) {
        if (c[i].length > 0) {
          if (l.length > 0) {
            l.shift(1)(c[i])
          }
          else {
            s.push(c[i])
          }
        }
      }
    }
  })
  const f = r => {
    if (s.length > 0) {
      r(s.shift(1))
    }
    else {
      l.push(r)
    }
  }
  return () => new Promise(f)
})()

async function main() {
  let t = +await nextString()
  for (let i = 0; i < t; ++i) {
    let n = +await nextString()
    while (n % 2 === 0) {
      n = Math.round(n / 2)
    }
    if (n > 1) {
      console.log('YES')
    }
    else {
      console.log('NO')
    }
  }
  process.exit(0)
}

main()

process.stdin.resume();
process.stdin.setEncoding("utf8");
let standardInputString = "";
let currentLine = 0;
function readLine() {
  return standardInputString[currentLine++];
}
process.stdin.on("data", (rawData) => {
  standardInputString += rawData;
});
process.stdin.on("end", (_) => {
  standardInputString = standardInputString
    .trim()
    .split("\n")
    .map((line) => {
      return line.trim();
    });
  main();
});

function main() {
  const cl = console.log,
    rl = readLine,
    tc = rl();

  for (let i = 0; i < tc; i++) {
    const n = +rl();
    if (n & (n - 1)) cl("Yes");
    else cl("NO");
  }
}

process.stdin.resume();
process.stdin.setEncoding("utf8");
let standardInputString = "";
let currentLine = 0;
function readLine() {
  return standardInputString[currentLine++];
}
process.stdin.on("data", (rawData) => {
  standardInputString += rawData;
});
process.stdin.on("end", (_) => {
  standardInputString = standardInputString
    .trim()
    .split("\n")
    .map((line) => {
      return line.trim();
    });
  main();
});

function main() {
  const cl = console.log,
    rl = readLine,
    tc = rl();

  for (let i = 0; i < tc; i++) {
    const n = rl();
    if (n & (n - 1)) cl("Yes");
    else cl("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++];
}

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

function main() {
    const x = readline();
    var answer = []

    // console.log(Number(x))
    // 1 1 7
    // 6 9, 15, 18
    Array(Number(x)).fill(1).map((t, i) => {
        var n = Number(readline());
        var d = n + 1
        if (n % 2 !== 0) return  console.log('YES')
        // if (!isPrime(n)) return console.log(n)
        console.log('NO')
    })

}

function sumDivisors(n, d) {
    var sum = 0;
    var nn = 1 + d
    while (!isPrime(nn)) nn++
    var nn2 = nn + d
    while (!isPrime(nn2)) nn2++

    console.log(nn2 * nn)
}

function isPrime(num) {
    for (var i = 2; i < num; i++)
        if (num % i === 0) return false;
    return num > 1;
}


const readline = require('readline');

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

const preprocess = input => {
  let l = 0;
  let r = input.length;
  while (input[l] === 'o') {
    l++;
  }
  while (input[r - 1] === 'o') {
    r--;
  }
  return input.substring(l, r);
};

rl.question('', (input) => {
  const before = [];
  const after = [];
  let count = 0;
  let numw = 0;

  const rep = preprocess(input);
  for (let i = 0; i < rep.length; i++) {
    let c = rep[i];
    if (c === 'v') {
      count++;
    } else {
      numw += (count - 1);
      before.push(numw > 0 ? numw : 0);
      count = 0;
      while (c && c !== 'v') {
        c = rep[++i];
      }
      --i;
    }
  }
  count = 0;
  numw = 0;
  for (let i = 0; i < rep.length; i++) {
    let c = rep[rep.length - i - 1];
    if (c === 'v') {
      count++;
    } else {
      numw += (count - 1);
      after.push(numw > 0 ? numw : 0);
      count = 0;
      while (c && c !== 'v') {
        i += 1;
        c = rep[rep.length - i - 1];
      }
      --i;
    }
  }

  const ogroup = rep.split('v').filter(c => c !== '').map(group => group.length);

  let res = 0;
  for (let i = 0; i < before.length; i++) {
    res += (ogroup[i] * before[i] * after[after.length - 1 - i]);
  }
  console.log(res);

  rl.close();
});

const readline = require('readline');

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

rl.question('', (input) => {
  const before = [];
  const after = [];
  let count = 0;
  let numw = 0;

  let l = 0;
  let r = input.length;
  while (input[l] === 'o') {
    l++;
  }
  while (input[r - 1] === 'o') {
    r--;
  }

  const rep = input.substring(l, r);
  for (let i = 0; i < rep.length; i++) {
    let c = rep[i];
    if (c === 'v') {
      count++;
    } else {
      numw += (count - 1);
      before.push(numw > 0 ? numw : 0);
      count = 0;
      while (c && c !== 'v') {
        c = rep[++i];
      }
      --i;
    }
  }
  count = 0;
  numw = 0;
  for (let i = 0; i < rep.length; i++) {
    let c = rep[rep.length - i - 1];
    if (c === 'v') {
      count++;
    } else {
      numw += (count - 1);
      after.push(numw > 0 ? numw : 0);
      count = 0;
      while (c && c !== 'v') {
        i += 1;
        c = rep[rep.length - i - 1];
      }
      --i;
    }
  }

  const ogroup = rep.split('v').filter(c => c !== '').map(group => group.length);

  let res = 0;
  for (let i = 0; i < before.length; i++) {
    res += (ogroup[i] * before[i] * after[after.length - 1 - i]);
  }
  console.log(res);

  rl.close();
});

const readline = require('readline');

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

rl.question('', (input) => {
  const before = [];
  const after = [];
  const rep = input.split('v');
  let count = 0;
  rep.forEach((c) => {
    if (c === '') {
      count++
    } else {
      before.push((count - 1) * c.length);
    }
  });
  count = 0;
  for (let i = rep.length - 1; i >= 0 ; i--) {
    let c = rep[i];
    if (c === '') {
      count++
    } else {
      after.push(count - 1);
    }
  }

  let res = 0;
  for (let i = 0; i < before.length; i++) {
    res += (before[i] * after[after.length - 1 - i]);
  }
  console.log(res);

  rl.close();
});

const readline = require('readline');

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

rl.question('', (input) => {
  const before = [];
  const after = [];
  const rep = input.split('v');
  let count = 0;
  rep.forEach((c) => {
    if (c === '') {
      count++
    } else {
      before.push((count - 1) * c.length);
    }
  });
  count = 0;
  for (let i = rep.length - 1; i >= 0 ; i--) {
    let c = rep[i];
    if (c === '') {
      count++
    } else {
      after.push(count - 1);
    }
  }

  let res = 0;
  for (let i = 0; i < before.length; i++) {
    res += (before[i] * after[after.length - 1 - i]);
  }
  if (res <= 0) {
    console.log(0);
  } else {
    console.log(res);
  }

  rl.close();
});


var lines = parseInt(readline());

var steps = new Array(1000);
steps[0] = 0;
for (var i = 1; i < 1000; i++) {
  if (steps[i - 1] != undefined) {
    var step = steps[i - 1];
    for (var j = 1; j <= i; j++) {
      var inc = Math.floor(i / j);
      if (
        i + inc - 1 < 1000 &&
        (steps[i + inc - 1] == undefined || steps[i + inc - 1] > step + 1)
      )
        steps[i + inc - 1] = step + 1;
    }
  }
}

for (var i = 0; i < lines; i++) {
  var line = readline().split(" ");
  var n = parseInt(line[0]);
  var k = parseInt(line[1]);
  var b = readline()
    .split(" ")
    .map((i) => parseInt(i));
  var c = readline()
    .split(" ")
    .map((i) => parseInt(i));

  var weights = [];
  for (var j = 0; j < b.length; j++) {
    weights.push([c[j], steps[b[j] - 1]]);
  }

  weights.sort((a, b) => b[0] / (b[1] + 0.00001) - a[0] / (a[1] + 0.00001));
  var dict = {};
  print(best(dict, weights, k, 0));
}

function best(dict, w, k, i, opt) {
  if (i >= w.length) return 0;
  if (dict[k + "," + i] != undefined) return dict[k + "," + i];
  var take = 0;
  opt = opt || 0;
  if (w[i][1] <= k)
    take = best(dict, w, k - w[i][1], i + 1, opt - w[i][0]) + w[i][0];
  if (opt > take) console.log(take, opt);
  take = Math.max(take, opt);
  if (w[i][1] == 0) {
    dict[k + "," + i] = take;
    return take;
  }

  var bestSub = 0;
  var kTemp = k;
  for (var j = i + 1; j < w.length && kTemp > 0; j++) {
    if (kTemp >= w[j][1]) bestSub += w[j][0];
    else bestSub += Math.floor((kTemp * w[j][0]) / w[j][1], take);
    kTemp -= w[j][1];
  }
  if (bestSub <= take) {
    dict[k + "," + i] = take;
    return take;
  }

  take = Math.max(best(dict, w, k, i + 1), take);
  dict[k + "," + i] = take;
  return take;
}

var pre=[];
for(var i=0;i<=2000;i++){
    pre[i]=10000000;
}
pre[0]=0;
pre[1]=0;

for(var i=1;i<=1000;i++){
    for(var j=1;j<=1000;j++){
        var next=i+Math.floor(i/j);
        pre[next]= Math.min(pre[next],pre[i]+1);
    }
}

var t=readline();
while(t--){
    var temp=readline().split(" ").map(x => parseInt(x));
    var n=temp[0];
    var k=temp[1];

    var brr=readline().split(" ").map(x => parseInt(x));
    var crr=readline().split(" ").map(x => parseInt(x));

    for(var i=0;i<n;i++){
        brr[i]=pre[brr[i]];
    }
    k=Math.min(k,brr.reduce((a, b) => a + b, 0));
    var dp=[];
    for(var i=0;i<=k;i++){
        dp[i]=0;
    }

    for(var i=0;i<n;i++){
        for(var j=k;j>=brr[i];j--){
            dp[j]=Math.max(dp[j],crr[i]+dp[j-brr[i]]);
        }
    }
    print(dp[k]);

}

var pre=[];
for(var i=0;i<=2000;i++){
    pre[i]=10000000;
}
pre[0]=0;
pre[1]=0;

for(var i=1;i<=1000;i++){
    for(var j=1;j<=1000;j++){
        var next=i+Math.floor(i/j);
        pre[next]= Math.min(pre[next],pre[i]+1);
    }
}

var t=readline();
while(t-- >0){
    var temp=readline().split(" ").map(x => parseInt(x));
    var n=temp[0];
    var k=temp[1];
    k=Math.min(k,15000);
    var brr=readline().split(" ").map(x => parseInt(x));
    var crr=readline().split(" ").map(x => parseInt(x));

    for(var i=0;i<n;i++){
        brr[i]=pre[brr[i]];
    }
    var dp=[];
    for(var i=0;i<=k;i++){
        dp[i]=0;
    }

    for(var i=0;i<n;i++){
        for(var j=k;j>=brr[i];j--){
            dp[j]=Math.max(dp[j],crr[i]+dp[j-brr[i]]);
        }
    }
    print(dp[k]);

}

const readline = require('readline')

const rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
})
const lines = []
    const dp = Array(1001).fill(Infinity)
    dp[1] = 0
    for (let i = 1; i <= 1000; i++) {
        for (let j = 1; j <= i; j++) {
            const d = Math.floor(i / j)
            if (d <= 0) break
            const other = i + d
            if (other < dp.length) {
                dp[other] = Math.min(dp[other], dp[i] + 1)
            }
        }
    }
    // console.log(dp.join(','))
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)
        const c = lines[l++].trim().split(' ').map(Number)
        output[i] = solve(n, k, arr, c)
    }
    console.log(output.join('\n'))
// })()
})

function solve(n, k, arr, c) {
// console.log(arr.map(x => dp[x]))
    let prev
    for (let i = 0; i < arr.length; i++) {
        const f = Array(12 * arr.length + 1).fill(0)
        const cost = dp[arr[i]]
        for (let j = 0; j <= 12 * arr.length; j++) {
            if (i) {
                f[j] = j < cost
                    ? prev[j] : Math.max(prev[j - cost] + c[i], prev[j])
            } else {
                f[j] = j < cost ? 0 : c[i]
            }
        }
        prev = f
// console.log(cost, c[i], prev)
    }
    return prev[Math.min(k, 12 * arr.length)]
}

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

const N = 1001;

function countSetBits (n) {
	let cnt = 0;
	for (let i = 0; i < 10; i++) {
		cnt += (n & 1 << i) > 0;
	}
	return cnt;
}

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

		const d = Array(N).fill(100);
		d[1] = 0;
		for (let i = 1; i < N; i++) {
			for (let x = 1; x <= i; x++) {
				const nxt = i + Math.floor(i/x);
				if (nxt < N) {
					d[nxt] = Math.min(d[nxt], d[i] + 1);
				}
			}
		}

		const w = [];
		for (let i = 0; i < n; i++) {
			w[i] = d[b[i]];
		}

		k = Math.min(k, 12*n);
		const dp = Array.from(Array(n+1), _ => Array(k+1).fill(0));
		for (let i = 1; i <= n; i++) {
			for (let j = 0; j <= k; j++) {
				dp[i][j] = dp[i-1][j];
				if (j - w[i-1] >= 0) {
					dp[i][j] = Math.max(dp[i][j], dp[i-1][j-w[i-1]] + c[i-1]);
				}
			}
		}

		console.log(dp[n][k]);
	}
}

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

const N = 1001;

function countSetBits (n) {
	let cnt = 0;
	for (let i = 0; i < 10; i++) {
		cnt += (n & 1 << i) > 0;
	}
	return cnt;
}

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

		const d = Array(N).fill(100);
		d[1] = 0;
		for (let i = 1; i < N; i++) {
			for (let x = 1; x <= i; x++) {
				const nxt = i + Math.floor(i/x);
				d[nxt] = Math.min(d[nxt], d[i] + 1);
			}
		}

		const w = [];
		for (let i = 0; i < n; i++) {
			w[i] = d[b[i]];
		}

		k = Math.min(k, 20000);
		const dp = Array.from(Array(n+1), _ => Array(k+1).fill(0));
		for (let i = 1; i <= n; i++) {
			for (let j = 0; j <= k; j++) {
				dp[i][j] = dp[i-1][j];
				if (j - w[i-1] >= 0) {
					dp[i][j] = Math.max(dp[i][j], dp[i-1][j-w[i-1]] + c[i-1]);
				}
			}
		}

		console.log(dp[n][k]);
	}
}

const readline = require('readline')

const rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
})
const lines = []
    const dp = Array(1001).fill(Infinity)
    dp[1] = 0
    for (let i = 1; i <= 1000; i++) {
        for (let j = 1; j <= i; j++) {
            const d = Math.floor(i / j)
            if (d <= 0) break
            const other = i + d
            if (other < dp.length) {
                dp[other] = Math.min(dp[other], dp[i] + 1)
            }
        }
    }
    // console.log(dp.join(','))
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)
        const c = lines[l++].trim().split(' ').map(Number)
        output[i] = solve(n, k, arr, c)
    }
    console.log(output.join('\n'))
// })()
})

function solve(n, k, arr, c) {
// console.log(arr.map(x => dp[x]))
    let prev
    for (let i = 0; i < arr.length; i++) {
        const f = Array(12 * arr.length + 1).fill(0)
        const cost = dp[arr[i]]
        for (let j = 0; j <= 12 * arr.length; j++) {
            if (i) {
                f[j] = j < cost
                    ? prev[j] : Math.max(prev[j - cost] + c[i], prev[j])
            } else {
                f[j] = j < cost ? 0 : c[i]
            }
        }
        prev = f
// console.log(cost, c[i], prev)
    }
    return prev[k]
}

const readline = require('readline')

const rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
})
const lines = []
    const dp = Array(1001).fill(Infinity)
    dp[1] = 0
    for (let i = 1; i <= 1000; i++) {
        for (let j = 1; j <= i; j++) {
            const d = Math.floor(i / j)
            if (d <= 0) break
            const other = i + d
            dp[other] = Math.min(dp[other], dp[i] + 1)
        }
    }
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)
        const c = lines[l++].trim().split(' ').map(Number)
        output[i] = solve(n, k, arr, c)
    }
    console.log(output.join('\n'))
// })()
})

function solve(n, k, arr, c) {
    const sorted = arr.map((x, i) => ({ i, cost: dp[x], point: c[i] }))
        .sort((a, b) => {
            // p1 / c1 > p2 / c2
            return a.cost * b.point - b.cost * a.point
        })
// console.log(arr.map(x => dp[x]))
    let ans = 0
    let now = 0
    let i = 0
    while (now < k && i < sorted.length) {
        if (now + sorted[i].cost <= k) {
            now += sorted[i].cost
            ans += sorted[i].point
        }
        i++
    }
    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 = 1//+lines[l++]
    const output = []
    for (let i = 0; i < t; i++) {
        const n = +lines[l++]
        const str = lines[l++]
        output[i] = solve(n, str)
    }
    console.log(output.join('\n'))
// })()
})

function solve(n, str) {
    let now = { val: 0 }
    let head = now
    for (let i = 0; i < str.length; i++) {
        const item = { val: i + 1 }
        if (str[i] === 'L') {
            if (now.prev) {
                now.prev.next = item
                item.prev = now.prev
                item.next = now
                now.prev = item
            } else {
                now.prev = item
                item.next = now
                head = item
            }
        } else {
            if (now.next) {
                now.next.prev = item
                item.next = now.next
                now.next = item
                item.prev = now
            } else {
                now.next = item
                item.prev = now
            }
        }
        now = item
    }
    const ans = Array(str.length)
    let p = 0
    while (head) {
        ans[p++] = head.val
        head = head.next
    }
    // const ans = [0]
    // let p = 0
    // for (let i = 0; i < str.length; i++) {
    //     if (str[i] === 'L') {
    //         ans.splice(p, 0, i + 1)
    //     } else {
    //         ans.splice(p + 1, 0, i + 1)
    //         p = p + 1
    //     }
    // }
    return ans.join(' ')
}

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 countSetBits (n) {
	let cnt = 0;
	for (let i = 0; i < 10; i++) {
		cnt += (n & 1 << i) > 0;
	}
	return cnt;
}

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

		const w = [];
		for (let i = 0; i < n; i++) {
			w[i] = Math.floor(Math.log2(b[i])) + countSetBits(b[i]) - 1;
			//console.log({i}, b[i], w[i], countSetBits(b[i]));
		}

		k = Math.min(20000, k);
		const dp = Array.from(Array(n+1), _ => Array(k+1).fill(0));
		for (let i = 1; i <= n; i++) {
			for (let j = 0; j <= k; j++) {
				dp[i][j] = dp[i-1][j];
				if (j - w[i-1] >= 0) {
					dp[i][j] = Math.max(dp[i][j], dp[i-1][j-w[i-1]] + c[i-1]);
				}
			}
		}

		console.log(dp[n][k]);
	}
}

var lines = parseInt(readline());

var steps = new Array(1000);
steps[0] = 0;
for (var i = 1; i < 1000; i++) {
  if (steps[i - 1] != undefined) {
    var step = steps[i - 1];
    for (var j = 1; j <= i; j++) {
      var inc = Math.floor(i / j);
      if (
        i + inc - 1 < 1000 &&
        (steps[i + inc - 1] == undefined || steps[i + inc - 1] > step + 1)
      )
        steps[i + inc - 1] = step + 1;
    }
  }
}

for (var i = 0; i < lines; i++) {
  var line = readline().split(" ");
  var n = parseInt(line[0]);
  var k = parseInt(line[1]);
  var b = readline()
    .split(" ")
    .map((i) => parseInt(i));
  var c = readline()
    .split(" ")
    .map((i) => parseInt(i));

  var weights = [];
  for (var j = 0; j < b.length; j++) {
    weights.push([c[j], steps[b[j] - 1]]);
  }

  weights.sort((a, b) => b[0] / (b[1] + 0.00001) - a[0] / (a[1] + 0.00001));
  print(best(weights, k, 0));
}

function best(w, k, i) {
  if (i >= w.length) return 0;
  var take = 0;
  if (w[i][1] <= k) take = best(w, k - w[i][1], i + 1) + w[i][0];
  if (w[i][1] == 0) return take;

  var bestSub = 0;
  var kTemp = k;
  for (var j = i + 1; j < w.length && kTemp > 0; j++) {
    if (kTemp >= w[j][1]) bestSub += w[j][0];
    else bestSub += Math.ceil(w[j][0] / w[j][1]);
    kTemp -= w[j][1];
  }
  if (bestSub <= take) return take;
  return Math.max(best(w, k, i + 1), take);
}

var lines = parseInt(readline());

var steps = new Array(1000);
steps[0] = 0;
for (var i = 1; i < 1000; i++) {
  if (steps[i - 1] != undefined) {
    var step = steps[i - 1];
    for (var j = 1; j <= i; j++) {
      var inc = Math.floor(i / j);
      if (
        i + inc - 1 < 1000 &&
        (steps[i + inc - 1] == undefined || steps[i + inc - 1] > step + 1)
      )
        steps[i + inc - 1] = step + 1;
    }
  }
}

for (var i = 0; i < lines; i++) {
  var line = readline().split(" ");
  var n = parseInt(line[0]);
  var k = parseInt(line[1]);
  var b = readline()
    .split(" ")
    .map((i) => parseInt(i));
  var c = readline()
    .split(" ")
    .map((i) => parseInt(i));

  var weights = [];
  for (var j = 0; j < b.length; j++) {
    weights.push([c[j], steps[b[j] - 1]]);
  }

  weights.sort((a, b) => b[0] / (b[1] + 0.00001) - a[0] / (a[1] + 0.00001));
  print(best(weights, k, 0));
}

function best(w, k, i) {
  if (i >= w.length || k == 0) return 0;
  var take = 0;
  if (w[i][1] <= k) take = best(w, k - w[i][1], i + 1) + w[i][0];
  if (
    w[i][1] == 0 ||
    (i < w.length - 2 && k > w[i + 1][1] + w[i + 2][1]) ||
    w.reduce((a, b) => a + b[1], 0) <= k
  )
    return take;
  var bestSub = 0;
  var kTemp = k;
  for (var j = i + 1; j < w.length && kTemp > 0; j++) {
    bestSub += w[j][0];
    kTemp -= w[j][1];
  }
  if (bestSub <= take) return take;
  return Math.max(best(w, k, i + 1), take);
}


var arr = readline().split(' ');
var n = parseInt(arr[0]);
var s = parseInt(arr[1]);
var smax = 0;
var v = [];
var arr = readline().split(' ');
var maxpossible = 0;
for (var i = 0; i < n; i ++)
{
    var val = parseInt(arr[i]);
    maxpossible += val + n*(i+1);
    v.push(val);
}
smax = Math.min(s,maxpossible);

var vs = Array(n);
var solve = function(k)
{
    for (var i = 0; i < n; i ++)
    {
        vs[i]=(v[i] + (i+1)*k);
    }
    vs.sort(function(a,b){return a-b;});
    // print(vs);
    var mins = 0;
    for (var i = 0; i < k; i ++)
    {
        mins += vs[i];
    }
    return mins;
}
var maxk = {};
var low = 0;
var up = n;
while(true)
{
    var k = parseInt((low+up)/2);
    var val = solve(k);
    // print(low,k,up);
    //print(k, val);
    if (val <= s)
    {
        maxk[k] = val;
    }
    if (up-low == 0)
    {
        k = 0;
        for(var key in maxk)
        {
            if (parseInt(key) >= k)
            {
            // print(key, maxk[key]);
                k = key;
                val = maxk[k];
            }
        }
        print(k, val);
        break;
    }

    if (val <= s)
    {
        low = k;
        if (up-low==1)
        {
            low ++
        }
    }
    else
    {
        up = k;
    }
}

function cmp(a,b)
{
    return a-b;
}

var s=readline().split(' ')
var n=+s[0]
var budget=+s[1]
var a=readline().split(' ').map(function(x){return +x;})
var l=0;
var r=n+1;
if (r>1261){r=1261;}
var x=0;
while(l+1<r)
{
    var m=(l+r);
    if (m%2==0){m/=2;}
    else{m=(m-1)/2;}
    var dubler=[];
    for (var i=0;i<n;i++)
    {
        dubler.push(a[i]+(i+1)*m);
    }
    dubler.sort(cmp);
    var sm=0;
    for (var i=0;i<m;i++)
    {
        sm+=dubler[i];
    }
    if (sm<=budget)
    {
        l=m;
        x=sm;
    }
    else
    {
        r=m;
    }
}
print(l+' '+x)

var str = readline().split(" ").map(x=>+x);
var n = str[0];
var S = str[1];
var arr = readline().split(" ").map(x=>+x);
var sum = [];
var ans =0;

var l=0,r=n;
while(l != r){
	var mid = (l+r+1)>>1;
	var ret = 0;
	for(var i = 0; i < n; i++){
		sum[i] = arr[i]+mid*(i+1);
	}
	sum.sort(cmp);
	for(var i=0; i < mid; i++){
		ret += sum[i];
	}
	if(ret <= S){
		l = mid;
		ans = ret;
	}
	else r = mid-1;
}
print(l+" "+ans);
function cmp(value1, value2){
	return value1-value2;
}

var ns = readline().trim().split(' ').map((x)=>parseInt(x))
var n=ns[0],s=ns[1];
var a =readline().trim().split(' ').map((x,i)=>[parseInt(x),i+1])

var k=1;
var somme=0;
var maxi=0;
var maxiK=0;
var l=1,r=n;
while(l<=r){
    k=parseInt((l+r)/2)
    somme=0;
    a.sort((_a,_b)=>(_a[0]+k*_a[1])-(_b[0]+k*_b[1]))

    for(var i=0;i<n;i++){
        if(i<k)
        somme+=a[i][0]+k*a[i][1]
    }

    if(somme>s){
        r=k-1;
    }else{
        maxi=somme;
        maxiK=k;
        l = k+1;
    }

}
print(maxiK,maxi)

var ns = readline().trim().split(' ').map((x)=>parseInt(x))
var n=ns[0],s=ns[1];
var a =readline().trim().split(' ').map((x,i)=>[parseInt(x),i+1])

var k=1;
var somme;
var maxi=0;
var maxiK=0;

a.sort((_a,_b)=>(_a[0]+_a[1])-(_b[0]+_b[1]))
while(k<=n){
    somme=0;
    var minDiff = 0;

    for(var i=0;i<n;i++){
        if(i<k)
            somme+=a[i][0]+k*a[i][1]

        if(i>0){
            if((a[i][0]+(k+1)*a[i][1] -(a[i-1][0]+(k+1)*a[i-1][1]))<0){
               var x = [a[i][0],a[i][1]];
               a[i]=[a[i-1][0],a[i-1][1]];
               a[i-1]=x;
            }
        }
    }
    if(somme>s)
    break

    maxi=somme
    maxiK=k
    if(somme==s)
    break;
    k++;
}
print(maxiK,maxi)

var ns = readline().trim().split(' ').map((x)=>parseInt(x))
var n=ns[0],s=ns[1];
var a =readline().trim().split(' ').map((x,i)=>[parseInt(x),i+1])

var k=1;
var somme;
var maxi=0;
var maxiK=0;
var need = true
while(k<=n){
    somme=0;
    var minDiff = 0;
    if(need)
        a.sort((_a,_b)=>(_a[0]+k*_a[1])-(_b[0]+k*_b[1]))

    need = false
    for(var i=0;i<n;i++){
        if(i>0){
            if((a[i][0]+k*a[i][1] -(a[i-1][0]+k*a[i-1][1]))<0){
                need = true
            }
        }
        if(i<k)
        somme+=a[i][0]+k*a[i][1]
    }
    if(somme>s)
    break

    maxi=somme
    maxiK=k
    if(somme==s)
    break;
    k++;
}
print(maxiK,maxi)

var ns = readline().trim().split(' ').map((x)=>parseInt(x))
var n=ns[0],s=ns[1];
var a =readline().trim().split(' ').map((x,i)=>[parseInt(x),i+1])

var k=1;
var somme;
var maxi=0;
var maxiK=0;
var need = true
while(k<=n){
    somme=0;
    var minDiff = 0;
    if(need)
        a.sort((_a,_b)=>(_a[0]+k*_a[1])-(_b[0]+k*_b[1]))

    need = false
    for(var i=0;i<n;i++){
        if(i>0){
            if((a[i][0]+k*a[i][1] -(a[i-1][0]+k*a[i-1][1]))<0){
                need = true
            }
        }
        if(i<k)
        somme+=a[i][0]+k*a[i][1]
    }
    if(somme>=s)
    break
    maxi=somme
    maxiK=k
    k++;
}
print(maxiK,maxi)

var ns = readline().trim().split(' ').map((x)=>parseInt(x))
var n=ns[0],s=ns[1];
var a =readline().trim().split(' ').map((x,i)=>[parseInt(x),i+1])

var k=1;
var somme;
var maxi=0;
var maxiK=0;
var need = true
while(k<=n){
    somme=0;
    var minDiff = 0;
    if(need)
        a.sort((_a,_b)=>(_a[0]+k*_a[1])-(_b[0]+k*_b[1]))

    need = false
    for(var i=0;i<n;i++){
        if(i>0){
            if((a[i][0]+k*a[i][1] -(a[i-1][0]+k*a[i-1][1]))<0){
                need = true
            }
        }
        if(i<k)
        somme+=a[i][0]+k*a[i][1]
    }
    if(somme>s)
    break
    maxi=somme
    maxiK=k
    k++;
}
print(maxiK,maxi)

var arr = readline().split(' ');
var n = parseInt(arr[0]);
var s = parseInt(arr[1]);
var smax = 0;
var v = [];
var arr = readline().split(' ');
var maxpossible = 0;
for (var i = 0; i < n; i ++)
{
    var val = parseInt(arr[i]);
    maxpossible += val + n*(i+1);
    v.push(val);
}
smax = Math.min(s,maxpossible);
var tried = {};
var k = 0;
var lastK = 0;
while (true)
{
    // print("trying "+k);
    var dp = Array(smax+1).fill(0);
    var dps = Array(smax+1).fill(0);
    for (var i = 0; i < n; i ++)
    {
        var vi = v[i] + (i+1)*k;
        for (var j = smax; j >= vi; j --)
        {
            dp[j] = Math.max(dp[j], dp[j-vi] + 1);
            dps[j] = Math.max(dps[j], dps[j-vi] + vi);
        }
    }
    // print(dp[smax]);
    // print(JSON.stringify(dp));
    if (k == dp[smax] || (tried[k] && k > dp[smax]))
    {
        print(dp[smax],dps[smax]);
        break;
    }
    tried[k] = true;
    var kk = k;
    k = parseInt((lastK + dp[smax])/2);//k+1;//dp[n][s];
    if (kk == k)
    {
        k ++;
    }
    lastK = kk;
}
// v.sort(function(a,b){return b-a;});

var arr = readline().split(' ');
var n = parseInt(arr[0]);
var s = parseInt(arr[1]);
var smax = 0;
var v = [];
var arr = readline().split(' ');
var maxpossible = 0;
for (var i = 0; i < n; i ++)
{
    var val = parseInt(arr[i]);
    maxpossible += val + n*(i+1);
    v.push(val);
}
smax = Math.min(s,maxpossible);

var vs = Array(n);
var solve = function(k)
{
    for (var i = 0; i < n; i ++)
    {
        vs[i]=(v[i] + (i+1)*k);
    }
    vs.sort(function(a,b){return a-b;});
    // print(vs);
    var mins = 0;
    for (var i = 0; i < k; i ++)
    {
        mins += vs[i];
    }
    return mins;
}
var maxk = {};
var low = 0;
var up = n;
while(true)
{
    var k = parseInt((low+up)/2);
    var val = solve(k);
    // print(low,k,up);
    if (val <= smax)
    {
        maxk[k] = val;
    }
    if (up-low == 0)
    {
        k = 0;
        for(var key in maxk)
        {
            if (key >= k)
            {
                k = key;
                val = maxk[k];
            }
        }
        print(k, val);
        break;
    }

    if (val <= smax)
    {
        low = k;
        if (up-low==1)
        {
            low ++
        }
    }
    else
    {
        up = k;
    }
}

var arr = readline().split(' ');
var n = parseInt(arr[0]);
var s = parseInt(arr[1]);
var smax = 0;
var v = [];
var arr = readline().split(' ');
var maxpossible = 0;
for (var i = 0; i < n; i ++)
{
    var val = parseInt(arr[i]);
    maxpossible += val + n*(i+1);
    v.push(val);
}
smax = Math.min(s,maxpossible);

var vs = Array(n);
var solve = function(k)
{
    for (var i = 0; i < n; i ++)
    {
        vs[i]=(v[i] + (i+1)*k);
    }
    vs.sort(function(a,b){return a-b;});
    // print(vs);
    var mins = 0;
    for (var i = 0; i < k; i ++)
    {
        mins += vs[i];
    }
    return mins;
}
var maxk = {};
var low = 0;
var up = n;
while(true)
{
    var k = parseInt((low+up)/2);
    var val = solve(k);
    // print(low,k,up);
    if (val <= s)
    {
        maxk[k] = val;
    }
    if (up-low == 0)
    {
        k = 0;
        for(var key in maxk)
        {
            if (key >= k)
            {
                k = key;
                val = maxk[k];
            }
        }
        print(k, val);
        break;
    }

    if (val <= s)
    {
        low = k;
        if (up-low==1)
        {
            low ++
        }
    }
    else
    {
        up = k;
    }
}

var arr = readline().split(' ');
var n = parseInt(arr[0]);
var s = parseInt(arr[1]);
var smax = 0;
var v = [];
var arr = readline().split(' ');
var maxpossible = 0;
for (var i = 0; i < n; i ++)
{
    var val = parseInt(arr[i]);
    maxpossible += val + n*(i+1);
    v.push(val);
}
smax = Math.min(s,maxpossible);

var vs = Array(n);
var solve = function(k)
{
    for (var i = 0; i < n; i ++)
    {
        vs[i]=(v[i] + (i+1)*k);
    }
    vs.sort(function(a,b){return a-b;});
    // print(vs);
    var mins = 0;
    for (var i = 0; i < k; i ++)
    {
        mins += vs[i];
    }
    return mins;
}
var maxk = {};
var low = 0;
var up = n;
var count = 0;
while(true)
{
    var k = parseInt((low+up)/2);
    var val = solve(k);
    // print(low,k,up);
    count ++;
    if (val <= smax)
    {
        maxk[k] = val;
    }
    if (up-low == 0)
    {
        k = 0;
        for(var key in maxk)
        {
            if (key > k)
            {
                k = key;
                val = maxk[k];
            }
        }
        print(k, val);
        break;
    }

    if (val <= smax)
    {
        low = k;
        if (up-low==1)
        {
         low ++
        }
    }
    else
    {
        up = k;
    }
}

var arr = readline().split(' ');
var n = parseInt(arr[0]);
var s = parseInt(arr[1]);
var smax = 0;
var v = [];
// var arr = readline().split(' ');
var maxpossible = 0;
for (var i = 0; i < n; i ++)
{
    var val = 100000;//parseInt(arr[i]);
    maxpossible += val + n*(i+1);
    v.push(val);
}
smax = Math.min(s,maxpossible);

var vs = Array(n);
var solve = function(k)
{
    for (var i = 0; i < n; i ++)
    {
        vs[i]=(v[i] + (i+1)*k);
    }
    vs.sort(function(a,b){return a-b;});
    // print(vs);
    var mins = 0;
    for (var i = 0; i < k; i ++)
    {
        mins += vs[i];
    }
    return mins;
}
var maxk = {};
var low = 0;
var up = n;
while(true)
{
    var k = parseInt((low+up)/2);
    var val = solve(k);
    // print(low,k,up);
    //print(k, val);
    if (val <= s)
    {
        maxk[k] = val;
    }
    if (up-low == 0)
    {
        k = 0;
        for(var key in maxk)
        {
            if (parseInt(key) >= k)
            {
            // print(key, maxk[key]);
                k = key;
                val = maxk[k];
            }
        }
        print(k, val);
        break;
    }

    if (val <= s)
    {
        low = k;
        if (up-low==1)
        {
            low ++
        }
    }
    else
    {
        up = k;
    }
}


var minCost = function(airports, a, b) {
  if ( airports[ a ] === airports[ b ] ) {
    return 0;
  } else {
    return 1;
  }
}

var input = readline().split( " " ).map( i => parseInt( i, 10 ) );
var a = input[ 1 ] - 1;
var b = input[ 2 ] - 1;
var airports = readline().split( "" );
print( minCost( airports, a, b) );

var functionVadic = function(str, b, e)
    {
        if (str[b] === str[e]) return 0;
        else return 1;
    }
var input1 = readline();
var input2 = readline();
input1 = input1.split(' ');
print(functionVadic(input2, +input1[1] - 1, +input1[2] - 1));

function ansa(n,a,b,s){

  a -= 1;
  b -= 1;

  print(((s[a] - '0') ^ (s[b] - '0')));

}

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

var str  = readline();

ansa(line[0],line[1],line[2],str);

function main() {

    var arr = readline().split(' ').map(Number);
    var n = arr[0];
    var home = arr[1];
    var olympiad = arr[2];

    var airports = readline();

    if(airports[home - 1] == airports[olympiad - 1]) {
        print(0);
    }else {
        print(1);
    }

}

main();

function sa(a,b,data){

       if(data[a] == data[b]){
        return 0;
    } else {
        return 1;
    }

    }

    var f = readline().split(" ").map(Number);
    var n = f[0];
    var a = f[1]-1;
    var b = f[2]-1;
    var data = readline();

    print(sa(a,b,data));

function main() {

    var arr = readline().split(' ').map(Number);
    var n = arr[0];
    var home = arr[1];
    var olympiad = arr[2];

    var airports = readline();

    if(airports[home - 1] == airports[olympiad - 1]){
        print(0);
    }else {
        if (home == olympiad) {
            print(0);
        } else if (home < olympiad) {

            for (var i = home; i < olympiad; i++) {
                if (airports[i] == airports[home - 1]) {
                    continue;
                }
                if (airports[i] != airports[home - 1]) {
                    print(i - (home - 1));
                    break;
                }
            }
        } else if(home > olympiad){
            for (var i = olympiad; i < home; i++) {
                if (airports[i] == airports[olympiad - 1]) {
                    continue;
                }
                if (airports[i] != airports[olympiad - 1]) {
                    print(i - (olympiad - 1));
                    break;
                }
            }
        }
    }

}

main();

function main() {

    var arr = readline().split(' ').map(Number);
    var n = arr[0];
    var home = arr[1];
    var olympiad = arr[2];

    var airports = readline();

    var r_route,
        l_route;

    var nr_route,
        nl_route,
        route;

    if(airports[home - 1] == airports[olympiad - 1]){
        print(0);
    }else {
        if (home == olympiad) {
            print(0);
        } else {
            for(var i = home;i<n;i++){
                if (airports[i] == airports[home - 1]) {
                    continue;
                }
                if (airports[i] != airports[home - 1]) {
                    r_route = i - (home - 1);
                    break;
                }
            }

            for(var j = home-2;j>0;j--){
                if (airports[j] == airports[home - 1]) {
                    continue;
                }
                if (airports[j] != airports[home - 1]) {
                    l_route = (home - 1) - j;
                    break;
                }
            }

            nr_route = Number(r_route);
            nl_route = Number(l_route);
            route = Math.min(nr_route,nl_route);

            print(route);

        }
    }

}

main();

function main() {

    var arr = readline().split(' ').map(Number);
    var n = arr[0];
    var home = arr[1];
    var olympiad = arr[2];

    var airports = readline();

    var r_route,
        l_route;

    if(airports[home - 1] == airports[olympiad - 1]){
        print(0);
    }else {
        if (home == olympiad) {
            print(0);
        } else {
            for(var i = home;i<n;i++){
                if (airports[i] == airports[home - 1]) {
                    continue;
                }
                if (airports[i] != airports[home - 1]) {
                    r_route = i - (home - 1);
                    break;
                }
            }

            for(var j = home-2;j>0;j--){
                if (airports[j] == airports[home - 1]) {
                    continue;
                }
                if (airports[j] != airports[home - 1]) {
                    l_route = (home - 1) - j;
                    break;
                }
            }

            print(Math.min(r_route,l_route));

        }
    }

}

main();

function main() {

    var arr = readline().split(' ').map(Number);
    var n = arr[0];
    var home = arr[1];
    var olympiad = arr[2];

    var airports = readline();

    var r_route,
        l_route;

    if(airports[home - 1] == airports[olympiad - 1]){
        print(0);
    }else {
        if (home == olympiad) {
            print(0);
        } else {
            for(var i = home;i<n;i++){
                if (airports[i] == airports[home - 1]) {
                    continue;
                }
                if (airports[i] != airports[home - 1]) {
                    r_route = i - (home - 1);
                    break;
                }
            }

            for(var j = home-2;j>0;j--){
                if (airports[j] == airports[home - 1]) {
                    continue;
                }
                if (airports[j] != airports[home - 1]) {
                    l_route = (home - 1) - j;
                    break;
                }
            }

            print(Math.min(Number(r_route),Number(l_route)));

        }
    }

}

main();

function sa(a,b,data){

       if(data[a] == data[b]){
        return 0;
    } else {
        var g = Number.MAX_VALUE;
        var t = Number.MAX_VALUE;
        for(var i=1;i<data.length;i++){
            if(a-i >= 0 && data[a-i]!== data[a]){
                g= i;
                break;
            }
            if(a+i <data.length && data[a+i]!==data[a]){
                g= i;
                break;
            }
        }
        for(var i=1;i<data.length;i++){
            if(b-i >= 0 && data[b-i]!== data[b]){
                t= i;
                break;
            }
            if(b+i <data.length && data[b+i]!==data[b]){
                t= i;
                break;
            }
        }
        return Math.min(g,t);
    }

    }

    var f = readline().split(" ").map(Number);
    var n = f[0];
    var a = f[1]-1;
    var b = f[2]-1;
    var data = readline();

    print(sa(a,b,data));


print(function(s) {
	var ans = [],
		j = 0;
	for (var i = 0, l = s.length; i < l; i++) {
		if (j === 0 || ans[j - 1] === s[i]) {
			ans.push(s[i]);
			j++;
		} else {
			ans.pop();
			j--;
		}
	}
	return ans.join('');
}(readline()));

print(function(s) {
	var q = [];
	for (var i = 0; i < s.length; i++) {
		if (s[i] === 'x' && s[i + 1] === 'y') {
			i++;
		} else if (q.length === 0 || q[q.length - 1] == s[i]) {
			q.push(s[i]);
		} else{
			q.pop();
		}
	}
	return q.join('');
}(readline()));

print(function(s) {
	s = s.replace(/xy/g, '');
	s = s.replace(/yx/g, '');
	return s;
}(readline()));