This time Baby Ehab will only cut and not stick. He starts with a piece of paper with an array $$$a$$$ of length $$$n$$$ written on it, and then he does the following:  he picks a range $$$(l, r)$$$ and cuts the subsegment $$$a_l, a_{l + 1}, \ldots, a_r$$$ out, removing the rest of the array.  he then cuts this range into multiple subranges.  to add a number theory spice to it, he requires that the elements of every subrange must have their product equal to their least common multiple (LCM). Formally, he partitions the elements of $$$a_l, a_{l + 1}, \ldots, a_r$$$ into contiguous subarrays such that the product of every subarray is equal to its LCM. Now, for $$$q$$$ independent ranges $$$(l, r)$$$, tell Baby Ehab the minimum number of subarrays he needs.

The first line contains $$$2$$$ integers $$$n$$$ and $$$q$$$ ($$$1 \le n,q \le 10^5$$$) — the length of the array $$$a$$$ and the number of queries. The next line contains $$$n$$$ integers $$$a_1$$$, $$$a_2$$$, $$$\ldots$$$, $$$a_n$$$ ($$$1 \le a_i \le 10^5$$$) — the elements of the array $$$a$$$. Each of the next $$$q$$$ lines contains $$$2$$$ integers $$$l$$$ and $$$r$$$ ($$$1 \le l \le r \le n$$$) — the endpoints of this query's interval.

For each query, print its answer on a new line.

NoteThe first query asks about the whole array. You can partition it into $$$[2]$$$, $$$[3,10,7]$$$, and $$$[5,14]$$$. The first subrange has product and LCM equal to $$$2$$$. The second has product and LCM equal to $$$210$$$. And the third has product and LCM equal to $$$70$$$. Another possible partitioning is $$$[2,3]$$$, $$$[10,7]$$$, and $$$[5,14]$$$.The second query asks about the range $$$(2,4)$$$. Its product is equal to its LCM, so you don't need to partition it further.The last query asks about the range $$$(3,5)$$$. You can partition it into $$$[10,7]$$$ and $$$[5]$$$.

"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const fs_1 = __importDefault(require("fs"));
//////////// LIBS
class IO {
    constructor() {
        this.i = 0;
        this.out = '';
        this.text = require('fs').readFileSync(0, 'utf8');
    }
    nextToken() {
        let ret = '';
        while (this.text[this.i].charCodeAt(0) <= 32) {
            this.i++;
        }
        while (this.i < this.text.length && this.text[this.i].charCodeAt(0) > 32) {
            ret += this.text[this.i];
            this.i++;
        }
        return ret;
    }
    nextNum() {
        return Number(this.nextToken());
    }
    nextNumArray(n) {
        let ret = [];
        while (n--) {
            ret.push(this.nextNum());
        }
        return ret;
    }
    _write(x) {
        this.out += x;
    }
    write(x) {
        this._write(x + ' ');
    }
    writeLine(x) {
        this._write(x + '\n');
    }
    flush() {
        fs_1.default.writeFileSync(1, this.out);
        this.out = '';
    }
}
function binarySearch(array, pred) {
    let lo = -1, hi = array.length;
    while (1 + lo < hi) {
        const mi = lo + ((hi - lo) >> 1);
        if (pred(array[mi])) {
            hi = mi;
        }
        else {
            lo = mi;
        }
    }
    return hi;
}
function lowerBound(array, item) {
    return binarySearch(array, (j) => item <= j);
}
function upperBound(array, item) {
    return binarySearch(array, (j) => item < j);
}
//////////// LIBS
const io = new IO();
function sieve(max) {
    let arr = [];
    for (let i = 2; i <= max; i++) {
        arr[i] = 1;
    }
    for (let i = 2; i <= max; i++) {
        if (arr[i]) {
            for (let j = 2 * i; j <= max; j += i) {
                arr[j] = 0;
            }
        }
    }
    let ret = [];
    for (let i = 2; i <= max; i++) {
        if (arr[i]) {
            ret.push(i);
        }
    }
    return ret;
}
function getPrimeFactors(val, primes) {
    let ret = [];
    for (let j = 0; j < primes.length && val >= primes[j]; j++) {
        let p = primes[j];
        if (val % p == 0) {
            ret.push(p);
        }
    }
    return ret;
}
function hasSortedIntersection(tab1, tab2) {
    let i = 0;
    let j = 0;
    while (i < tab1.length && j < tab2.length) {
        let v1 = tab1[i];
        let v2 = tab2[j];
        if (v1 === v2) {
            return true;
        }
        if (v1 < v2) {
            i++;
        }
        else {
            j++;
        }
    }
    return false;
}
function mergeSorted(tab1, tab2) {
    let i = 0;
    let j = 0;
    let ret = [];
    while (i < tab1.length && j < tab2.length) {
        let v1 = tab1[i];
        let v2 = tab2[j];
        if (v1 < v2) {
            ret.push(v1);
            i++;
        }
        else {
            ret.push(v2);
            j++;
        }
    }
    ret.push(...tab1.slice(i), ...tab2.slice(j));
    return ret;
}
function getDividers(max) {
    const ret = [];
    for (let i = 1; i <= max; i++) {
        ret[i] = [];
    }
    for (let i = 2; i <= max; i++) {
        if (!ret[i].length) {
            for (let j = i; j <= max; j += i) {
                ret[j].push(i);
            }
        }
    }
    return ret;
}
function solve(tab, queries) {
    let dividers = getDividers(100000);
    let n = tab.length;
    let up = Array.from({ length: n + 1 }).map(() => []);
    let next = [];
    up[n][0] = n;
    for (let i = n - 1; i >= 0; i--) {
        let val = tab[i];
        let factors = dividers[val];
        let nextIndex = n;
        for (let factor of factors) {
            if (next[factor]) {
                nextIndex = Math.min(nextIndex, next[factor]);
            }
            next[factor] = i;
        }
        up[i][0] = Math.min(nextIndex, up[i + 1][0]);
    }
    for (let k = 1; k < 20; k++) {
        for (let i = 0; i <= n; i++) {
            let parent = up[i][k - 1];
            up[i][k] = up[parent][k - 1];
        }
    }
    queries.forEach(([l, r]) => {
        l--;
        r--;
        let ret = 1;
        for (let k = 19; k >= 0; k--) {
            if (up[l][k] <= r) {
                l = up[l][k];
                ret += 1 << k;
            }
        }
        io.writeLine(ret);
    });
}
function main() {
    try {
        let n = io.nextNum();
        let q = io.nextNum();
        let tab = io.nextNumArray(n);
        let queries = [];
        while (q--) {
            queries.push([io.nextNum(), io.nextNum()]);
        }
        solve(tab, queries);
        io.flush();
    }
    catch (e) {
        console.log(e.stack);
    }
}
main();

"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const fs_1 = __importDefault(require("fs"));
//////////// LIBS
class IO {
    constructor() {
        this.i = 0;
        this.out = '';
        this.text = require('fs').readFileSync(0, 'utf8');
    }
    nextToken() {
        let ret = '';
        while (this.text[this.i].charCodeAt(0) <= 32) {
            this.i++;
        }
        while (this.i < this.text.length && this.text[this.i].charCodeAt(0) > 32) {
            ret += this.text[this.i];
            this.i++;
        }
        return ret;
    }
    nextNum() {
        return Number(this.nextToken());
    }
    nextNumArray(n) {
        let ret = [];
        while (n--) {
            ret.push(this.nextNum());
        }
        return ret;
    }
    _write(x) {
        this.out += x;
    }
    write(x) {
        this._write(x + ' ');
    }
    writeLine(x) {
        this._write(x + '\n');
    }
    flush() {
        fs_1.default.writeFileSync(1, this.out);
        this.out = '';
    }
}
function binarySearch(array, pred) {
    let lo = -1, hi = array.length;
    while (1 + lo < hi) {
        const mi = lo + ((hi - lo) >> 1);
        if (pred(array[mi])) {
            hi = mi;
        }
        else {
            lo = mi;
        }
    }
    return hi;
}
function lowerBound(array, item) {
    return binarySearch(array, (j) => item <= j);
}
function upperBound(array, item) {
    return binarySearch(array, (j) => item < j);
}
//////////// LIBS
const io = new IO();
function sieve(max) {
    let arr = [];
    for (let i = 2; i <= max; i++) {
        arr[i] = 1;
    }
    for (let i = 2; i <= max; i++) {
        if (arr[i]) {
            for (let j = 2 * i; j <= max; j += i) {
                arr[j] = 0;
            }
        }
    }
    let ret = [];
    for (let i = 2; i <= max; i++) {
        if (arr[i]) {
            ret.push(i);
        }
    }
    return ret;
}
function getPrimeFactors(val, primes) {
    let ret = [];
    for (let j = 0; j < primes.length && val >= primes[j]; j++) {
        let p = primes[j];
        if (val % p == 0) {
            ret.push(p);
        }
    }
    return ret;
}
function hasSortedIntersection(tab1, tab2) {
    let i = 0;
    let j = 0;
    while (i < tab1.length && j < tab2.length) {
        let v1 = tab1[i];
        let v2 = tab2[j];
        if (v1 === v2) {
            return true;
        }
        if (v1 < v2) {
            i++;
        }
        else {
            j++;
        }
    }
    return false;
}
function mergeSorted(tab1, tab2) {
    let i = 0;
    let j = 0;
    let ret = [];
    while (i < tab1.length && j < tab2.length) {
        let v1 = tab1[i];
        let v2 = tab2[j];
        if (v1 < v2) {
            ret.push(v1);
            i++;
        }
        else {
            ret.push(v2);
            j++;
        }
    }
    ret.push(...tab1.slice(i), ...tab2.slice(j));
    return ret;
}
function getDividers(max) {
    const ret = [];
    for (let i = 1; i <= max; i++) {
        ret[i] = [];
    }
    for (let i = 2; i <= max; i++) {
        if (!ret[i].length) {
            for (let j = i; j <= max; j += i) {
                ret[j].push(i);
            }
        }
    }
    return ret;
}
function solve(tab, queries) {
    // let primes = sieve(100000);
    let dividers = getDividers(100000);
    let n = tab.length;
    let up = Array.from({ length: n + 1 }).map(() => []);
    let next = [];
    // console.log(getDividers(40).map((x, i) => [i, x]));
    up[n][0] = n;
    for (let i = n - 1; i >= 0; i--) {
        let val = tab[i];
        // const factors = getPrimeFactors(val, primes);
        let factors = dividers[val];
        let nextIndex = n;
        factors.forEach((factor) => {
            if (next[factor]) {
                nextIndex = Math.min(nextIndex, next[factor]);
            }
            next[factor] = i;
        });
        up[i][0] = Math.min(nextIndex, up[i + 1][0]);
    }
    for (let k = 1; k < 20; k++) {
        for (let i = 0; i <= n; i++) {
            let parent = up[i][k - 1];
            up[i][k] = up[parent][k - 1];
        }
    }
    queries.forEach(([l, r]) => {
        l--;
        r--;
        let ret = 1;
        for (let k = 19; k >= 0; k--) {
            if (up[l][k] <= r) {
                l = up[l][k];
                ret += 1 << k;
            }
        }
        io.writeLine(ret);
    });
}
function main() {
    try {
        let n = io.nextNum();
        let q = io.nextNum();
        let tab = io.nextNumArray(n);
        let queries = [];
        while (q--) {
            queries.push([io.nextNum(), io.nextNum()]);
        }
        solve(tab, queries);
        io.flush();
    }
    catch (e) {
        console.log(e.stack);
    }
}
main();

"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const fs_1 = __importDefault(require("fs"));
//////////// LIBS
class IO {
    constructor() {
        this.i = 0;
        this.out = '';
        this.text = require('fs').readFileSync(0, 'utf8');
    }
    nextToken() {
        let ret = '';
        while (this.text[this.i].charCodeAt(0) <= 32) {
            this.i++;
        }
        while (this.i < this.text.length && this.text[this.i].charCodeAt(0) > 32) {
            ret += this.text[this.i];
            this.i++;
        }
        return ret;
    }
    nextNum() {
        return Number(this.nextToken());
    }
    nextNumArray(n) {
        let ret = [];
        while (n--) {
            ret.push(this.nextNum());
        }
        return ret;
    }
    _write(x) {
        this.out += x;
    }
    write(x) {
        this._write(x + ' ');
    }
    writeLine(x) {
        this._write(x + '\n');
    }
    flush() {
        fs_1.default.writeFileSync(1, this.out);
        this.out = '';
    }
}
function binarySearch(array, pred) {
    let lo = -1, hi = array.length;
    while (1 + lo < hi) {
        const mi = lo + ((hi - lo) >> 1);
        if (pred(array[mi])) {
            hi = mi;
        }
        else {
            lo = mi;
        }
    }
    return hi;
}
function lowerBound(array, item) {
    return binarySearch(array, (j) => item <= j);
}
function upperBound(array, item) {
    return binarySearch(array, (j) => item < j);
}
//////////// LIBS
const io = new IO();
function sieve(max) {
    let arr = [];
    for (let i = 2; i <= max; i++) {
        arr[i] = 1;
    }
    for (let i = 2; i <= max; i++) {
        if (arr[i]) {
            for (let j = 2 * i; j <= max; j += i) {
                arr[j] = 0;
            }
        }
    }
    let ret = [];
    for (let i = 2; i <= max; i++) {
        if (arr[i]) {
            ret.push(i);
        }
    }
    return ret;
}
function getPrimeFactors(val, primes) {
    let ret = [];
    for (let j = 0; j < primes.length && val >= primes[j]; j++) {
        let p = primes[j];
        if (val % p == 0) {
            ret.push(p);
        }
    }
    return ret;
}
function hasSortedIntersection(tab1, tab2) {
    let i = 0;
    let j = 0;
    while (i < tab1.length && j < tab2.length) {
        let v1 = tab1[i];
        let v2 = tab2[j];
        if (v1 === v2) {
            return true;
        }
        if (v1 < v2) {
            i++;
        }
        else {
            j++;
        }
    }
    return false;
}
function mergeSorted(tab1, tab2) {
    let i = 0;
    let j = 0;
    let ret = [];
    while (i < tab1.length && j < tab2.length) {
        let v1 = tab1[i];
        let v2 = tab2[j];
        if (v1 < v2) {
            ret.push(v1);
            i++;
        }
        else {
            ret.push(v2);
            j++;
        }
    }
    ret.push(...tab1.slice(i), ...tab2.slice(j));
    return ret;
}
function getDividers(max) {
    const ret = [];
    for (let i = 2; i <= max; i++) {
        ret[i] = [];
    }
    for (let i = 2; i <= max; i++) {
        if (!ret[i].length) {
            for (let j = i; j <= max; j += i) {
                ret[j].push(i);
            }
        }
    }
    return ret;
}
function solve(tab, queries) {
    // let primes = sieve(100000);
    let dividers = getDividers(100000 + 2);
    let n = tab.length;
    let up = Array.from({ length: n + 1 }).map(() => []);
    let next = [];
    // console.log(getDividers(40).map((x, i) => [i, x]));
    up[n][0] = n;
    for (let i = n - 1; i >= 0; i--) {
        let val = tab[i];
        // const factors = getPrimeFactors(val, primes);
        let factors = dividers[val];
        let nextIndex = n;
        factors.forEach((factor) => {
            if (next[factor]) {
                nextIndex = Math.min(nextIndex, next[factor]);
            }
            next[factor] = i;
        });
        up[i][0] = Math.min(nextIndex, up[i + 1][0]);
    }
    for (let k = 1; k < 20; k++) {
        for (let i = 0; i <= n; i++) {
            let parent = up[i][k - 1];
            up[i][k] = up[parent][k - 1];
        }
    }
    queries.forEach(([l, r]) => {
        l--;
        r--;
        let ret = 1;
        for (let k = 19; k >= 0; k--) {
            if (up[l][k] <= r) {
                l = up[l][k];
                ret += 1 << k;
            }
        }
        io.writeLine(ret);
    });
}
function main() {
    try {
        let n = io.nextNum();
        let q = io.nextNum();
        let tab = io.nextNumArray(n);
        let queries = [];
        while (q--) {
            queries.push([io.nextNum(), io.nextNum()]);
        }
        solve(tab, queries);
        io.flush();
    }
    catch (e) {
        console.log(e.stack);
    }
}
main();

"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const fs_1 = __importDefault(require("fs"));
//////////// LIBS
class IO {
    constructor() {
        this.i = 0;
        this.out = '';
        this.text = require('fs').readFileSync(0, 'utf8');
    }
    nextToken() {
        let ret = '';
        while (this.text[this.i].charCodeAt(0) <= 32) {
            this.i++;
        }
        while (this.i < this.text.length && this.text[this.i].charCodeAt(0) > 32) {
            ret += this.text[this.i];
            this.i++;
        }
        return ret;
    }
    nextNum() {
        return Number(this.nextToken());
    }
    nextNumArray(n) {
        let ret = [];
        while (n--) {
            ret.push(this.nextNum());
        }
        return ret;
    }
    _write(x) {
        this.out += x;
    }
    write(x) {
        this._write(x + ' ');
    }
    writeLine(x) {
        this._write(x + '\n');
    }
    flush() {
        fs_1.default.writeFileSync(1, this.out);
        this.out = '';
    }
}
function binarySearch(array, pred) {
    let lo = -1, hi = array.length;
    while (1 + lo < hi) {
        const mi = lo + ((hi - lo) >> 1);
        if (pred(array[mi])) {
            hi = mi;
        }
        else {
            lo = mi;
        }
    }
    return hi;
}
function lowerBound(array, item) {
    return binarySearch(array, (j) => item <= j);
}
function upperBound(array, item) {
    return binarySearch(array, (j) => item < j);
}
//////////// LIBS
const io = new IO();
function sieve(max) {
    let arr = [];
    for (let i = 2; i <= max; i++) {
        arr[i] = 1;
    }
    for (let i = 2; i <= max; i++) {
        if (arr[i]) {
            for (let j = 2 * i; j <= max; j += i) {
                arr[j] = 0;
            }
        }
    }
    let ret = [];
    for (let i = 2; i <= max; i++) {
        if (arr[i]) {
            ret.push(i);
        }
    }
    return ret;
}
function getPrimeFactors(val, primes) {
    let ret = [];
    for (let j = 0; j < primes.length && val >= primes[j]; j++) {
        let p = primes[j];
        if (val % p == 0) {
            ret.push(p);
        }
    }
    return ret;
}
function hasSortedIntersection(tab1, tab2) {
    let i = 0;
    let j = 0;
    while (i < tab1.length && j < tab2.length) {
        let v1 = tab1[i];
        let v2 = tab2[j];
        if (v1 === v2) {
            return true;
        }
        if (v1 < v2) {
            i++;
        }
        else {
            j++;
        }
    }
    return false;
}
function mergeSorted(tab1, tab2) {
    let i = 0;
    let j = 0;
    let ret = [];
    while (i < tab1.length && j < tab2.length) {
        let v1 = tab1[i];
        let v2 = tab2[j];
        if (v1 < v2) {
            ret.push(v1);
            i++;
        }
        else {
            ret.push(v2);
            j++;
        }
    }
    ret.push(...tab1.slice(i), ...tab2.slice(j));
    return ret;
}
function getDividers(max) {
    const ret = [];
    for (let i = 2; i <= max; i++) {
        ret[i] = [];
    }
    for (let i = 2; i <= max; i++) {
        if (!ret[i].length) {
            for (let j = i; j <= max; j += i) {
                ret[j].push(i);
            }
        }
    }
    return ret;
}
function solve(tab, queries) {
    // let primes = sieve(100000);
    let dividers = getDividers(100000);
    let n = tab.length;
    let up = Array.from({ length: n + 1 }).map(() => []);
    let next = [];
    // console.log(getDividers(40).map((x, i) => [i, x]));
    up[n][0] = n;
    for (let i = n - 1; i >= 0; i--) {
        let val = tab[i];
        // const factors = getPrimeFactors(val, primes);
        let factors = dividers[val];
        let nextIndex = n;
        factors.forEach((factor) => {
            if (next[factor]) {
                nextIndex = Math.min(nextIndex, next[factor]);
            }
            next[factor] = i;
        });
        up[i][0] = Math.min(nextIndex, up[i + 1][0]);
    }
    for (let k = 1; k < 20; k++) {
        for (let i = 0; i <= n; i++) {
            let parent = up[i][k - 1];
            up[i][k] = up[parent][k - 1];
        }
    }
    queries.forEach(([l, r]) => {
        l--;
        r--;
        let ret = 1;
        for (let k = 19; k >= 0; k--) {
            if (up[l][k] <= r) {
                l = up[l][k];
                ret += 1 << k;
            }
        }
        io.writeLine(ret);
    });
}
function main() {
    try {
        let n = io.nextNum();
        let q = io.nextNum();
        let tab = io.nextNumArray(n);
        let queries = [];
        while (q--) {
            queries.push([io.nextNum(), io.nextNum()]);
        }
        solve(tab, queries);
        io.flush();
    }
    catch (e) {
        console.log(e.stack);
    }
}
main();

"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const fs_1 = __importDefault(require("fs"));
//////////// LIBS
class IO {
    constructor() {
        this.i = 0;
        this.out = '';
        this.text = require('fs').readFileSync(0, 'utf8');
    }
    nextToken() {
        let ret = '';
        while (this.text[this.i].charCodeAt(0) <= 32) {
            this.i++;
        }
        while (this.i < this.text.length && this.text[this.i].charCodeAt(0) > 32) {
            ret += this.text[this.i];
            this.i++;
        }
        return ret;
    }
    nextNum() {
        return Number(this.nextToken());
    }
    nextNumArray(n) {
        let ret = [];
        while (n--) {
            ret.push(this.nextNum());
        }
        return ret;
    }
    _write(x) {
        this.out += x;
    }
    write(x) {
        this._write(x + ' ');
    }
    writeLine(x) {
        this._write(x + '\n');
    }
    flush() {
        fs_1.default.writeFileSync(1, this.out);
        this.out = '';
    }
}
function binarySearch(array, pred) {
    let lo = -1, hi = array.length;
    while (1 + lo < hi) {
        const mi = lo + ((hi - lo) >> 1);
        if (pred(array[mi])) {
            hi = mi;
        }
        else {
            lo = mi;
        }
    }
    return hi;
}
function lowerBound(array, item) {
    return binarySearch(array, (j) => item <= j);
}
function upperBound(array, item) {
    return binarySearch(array, (j) => item < j);
}
//////////// LIBS
const io = new IO();
function sieve(max) {
    let arr = [];
    for (let i = 2; i <= max; i++) {
        arr[i] = 1;
    }
    for (let i = 2; i <= max; i++) {
        if (arr[i]) {
            for (let j = 2 * i; j <= max; j += i) {
                arr[j] = 0;
            }
        }
    }
    let ret = [];
    for (let i = 2; i <= max; i++) {
        if (arr[i]) {
            ret.push(i);
        }
    }
    return ret;
}
function getPrimeFactors(val, primes) {
    let ret = [];
    for (let j = 0; j < primes.length && val >= primes[j]; j++) {
        let p = primes[j];
        if (val % p == 0) {
            ret.push(p);
        }
    }
    return ret;
}
function hasSortedIntersection(tab1, tab2) {
    let i = 0;
    let j = 0;
    while (i < tab1.length && j < tab2.length) {
        let v1 = tab1[i];
        let v2 = tab2[j];
        if (v1 === v2) {
            return true;
        }
        if (v1 < v2) {
            i++;
        }
        else {
            j++;
        }
    }
    return false;
}
function mergeSorted(tab1, tab2) {
    let i = 0;
    let j = 0;
    let ret = [];
    while (i < tab1.length && j < tab2.length) {
        let v1 = tab1[i];
        let v2 = tab2[j];
        if (v1 < v2) {
            ret.push(v1);
            i++;
        }
        else {
            ret.push(v2);
            j++;
        }
    }
    ret.push(...tab1.slice(i), ...tab2.slice(j));
    return ret;
}
function solve(tab, queries) {
    let primes = sieve(10000);
    let n = tab.length;
    let up = Array.from({ length: n + 1 }).map(() => []);
    let next = [];
    up[n][0] = n;
    for (let i = n - 1; i >= 0; i--) {
        let val = tab[i];
        const factors = getPrimeFactors(val, primes);
        let nextIndex = n;
        factors.forEach((factor) => {
            if (next[factor]) {
                nextIndex = Math.min(nextIndex, next[factor]);
            }
            next[factor] = i;
        });
        up[i][0] = Math.min(nextIndex, up[i + 1][0]);
    }
    for (let k = 1; k < 20; k++) {
        for (let i = 0; i <= n; i++) {
            let parent = up[i][k - 1];
            up[i][k] = up[parent][k - 1];
        }
    }
    queries.forEach(([l, r]) => {
        l--;
        r--;
        let ret = 1;
        for (let k = 19; k >= 0; k--) {
            if (up[l][k] <= r) {
                l = up[l][k];
                ret += 1 << k;
            }
        }
        io.writeLine(ret);
    });
}
function main() {
    try {
        let n = io.nextNum();
        let q = io.nextNum();
        let tab = io.nextNumArray(n);
        let queries = [];
        while (q--) {
            queries.push([io.nextNum(), io.nextNum()]);
        }
        solve(tab, queries);
        io.flush();
    }
    catch (e) {
        console.log(e.stack);
    }
}
main();

"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const fs_1 = __importDefault(require("fs"));
//////////// LIBS
class IO {
    constructor() {
        this.i = 0;
        this.out = '';
        this.text = require('fs').readFileSync(0, 'utf8');
    }
    nextToken() {
        let ret = '';
        while (this.text[this.i].charCodeAt(0) <= 32) {
            this.i++;
        }
        while (this.i < this.text.length && this.text[this.i].charCodeAt(0) > 32) {
            ret += this.text[this.i];
            this.i++;
        }
        return ret;
    }
    nextNum() {
        return Number(this.nextToken());
    }
    nextNumArray(n) {
        let ret = [];
        while (n--) {
            ret.push(this.nextNum());
        }
        return ret;
    }
    _write(x) {
        this.out += x;
    }
    write(x) {
        this._write(x + ' ');
    }
    writeLine(x) {
        this._write(x + '\n');
    }
    flush() {
        fs_1.default.writeFileSync(1, this.out);
        this.out = '';
    }
}
function binarySearch(array, pred) {
    let lo = -1, hi = array.length;
    while (1 + lo < hi) {
        const mi = lo + ((hi - lo) >> 1);
        if (pred(array[mi])) {
            hi = mi;
        }
        else {
            lo = mi;
        }
    }
    return hi;
}
function lowerBound(array, item) {
    return binarySearch(array, (j) => item <= j);
}
function upperBound(array, item) {
    return binarySearch(array, (j) => item < j);
}
//////////// LIBS
const io = new IO();
function sieve(max) {
    let arr = [];
    for (let i = 2; i <= max; i++) {
        arr[i] = 1;
    }
    for (let i = 2; i <= max; i++) {
        if (arr[i]) {
            for (let j = 2 * i; j <= max; j += i) {
                arr[j] = 0;
            }
        }
    }
    let ret = [];
    for (let i = 2; i <= max; i++) {
        if (arr[i]) {
            ret.push(i);
        }
    }
    return ret;
}
function getPrimeFactors(val, primes) {
    let ret = [];
    for (let j = 0; j < primes.length && val >= primes[j]; j++) {
        let p = primes[j];
        if (val % p == 0) {
            ret.push(p);
        }
    }
    return ret;
}
function hasSortedIntersection(tab1, tab2) {
    let i = 0;
    let j = 0;
    while (i < tab1.length && j < tab2.length) {
        let v1 = tab1[i];
        let v2 = tab2[j];
        if (v1 === v2) {
            return true;
        }
        if (v1 < v2) {
            i++;
        }
        else {
            j++;
        }
    }
    return false;
}
// console.log(hasSortedIntersection([1, 4, 5, 9], [1, 2, 2]));
function mergeSorted(tab1, tab2) {
    let i = 0;
    let j = 0;
    let ret = [];
    while (i < tab1.length && j < tab2.length) {
        let v1 = tab1[i];
        let v2 = tab2[j];
        if (v1 < v2) {
            ret.push(v1);
            i++;
        }
        else {
            ret.push(v2);
            j++;
        }
    }
    ret.push(...tab1.slice(i), ...tab2.slice(j));
    return ret;
}
function solve(tab, queries) {
    let primes = sieve(10000);
    // console.log(primes);
    let n = tab.length;
    let up = Array.from({ length: n + 1 }).map(() => []);
    let next = [];
    up[n][0] = n;
    for (let i = n - 1; i >= 0; i--) {
        let val = tab[i];
        const factors = getPrimeFactors(val, primes);
        let nextIndex = n;
        factors.forEach((factor) => {
            if (next[factor]) {
                nextIndex = Math.min(nextIndex, next[factor]);
            }
            next[factor] = i;
        });
        up[i][0] = Math.min(nextIndex, up[i + 1][0]);
        // console.log({ i, nextIndex, ranges: up, next, factors });
    }
    for (let k = 1; k < 20; k++) {
        for (let i = 0; i <= n; i++) {
            let parent = up[i][k - 1];
            // console.log({ i, k, parent });
            up[i][k] = up[parent][k - 1];
        }
        let ret = [];
        for (let i = 0; i <= n; i++) {
            ret.push(up[i][k]);
        }
        // console.log({ k, ret });
        // console.log(up);
    }
    queries.forEach(([l, r]) => {
        l--;
        r--;
        let ret = 1;
        for (let k = 20; k >= 0; k--) {
            if (up[l][k] <= r) {
                l = up[l][k];
                ret += 1 << k;
            }
        }
        io.writeLine(ret);
    });
    // console.log(up);
    // let prevFactors: number[] = [];
    // let currentFactors: number[] = [];
    // let n = tab.length;
    // ranges[n] = n + 1;
    // for (let i = n - 1; i >= 0; i--) {
    //   let val = tab[i];
    //   const factors = getPrimeFactors(val, primes);
    // }
    // for (let i = 0; i < tab.length; i++) {
    //   let val = tab[i];
    //   const factors = getPrimeFactors(val, primes);
    //   // console.log({ i, val, factors, prevFactors });
    //   if (prevFactors.length && !hasSortedIntersection(prevFactors, factors)) {
    //     // console.log('----');
    //     ranges.push(i + 1);
    //   }
    //   prevFactors = mergeSorted(prevFactors, factors);
    // }
    // console.log(ranges);
    // for (let [l, r] of queries) {
    //   l--;
    //   r--;
    //   let lower = upperBound(ranges, l);
    //   console.log('----');
    //   console.log({
    //     lower_l: lowerBound(ranges, l),
    //     upper_l: upperBound(ranges, l),
    //     lower_r: lowerBound(ranges, r),
    //     upper_r: upperBound(ranges, r),
    //   });
    //   let upper = upperBound(ranges, r);
    //   console.log({ l, r, lower, upper });
    //   io.writeLine(upper - lower + 1);
    // }
    // console.log(ranges);
}
function main() {
    try {
        let n = io.nextNum();
        let q = io.nextNum();
        let tab = io.nextNumArray(n);
        let queries = [];
        while (q--) {
            queries.push([io.nextNum(), io.nextNum()]);
        }
        solve(tab, queries);
        io.flush();
    }
    catch (e) {
        console.log(e.stack);
    }
}
main();


Cat Furrier Transform is a popular algorithm among cat programmers to create longcats. As one of the greatest cat programmers ever exist, Neko wants to utilize this algorithm to create the perfect longcat.Assume that we have a cat with a number $$$x$$$. A perfect longcat is a cat with a number equal $$$2^m - 1$$$ for some non-negative integer $$$m$$$. For example, the numbers $$$0$$$, $$$1$$$, $$$3$$$, $$$7$$$, $$$15$$$ and so on are suitable for the perfect longcats.In the Cat Furrier Transform, the following operations can be performed on $$$x$$$:  (Operation A): you select any non-negative integer $$$n$$$ and replace $$$x$$$ with $$$x \oplus (2^n - 1)$$$, with $$$\oplus$$$ being a bitwise XOR operator. (Operation B): replace $$$x$$$ with $$$x + 1$$$. The first applied operation must be of type A, the second of type B, the third of type A again, and so on. Formally, if we number operations from one in the order they are executed, then odd-numbered operations must be of type A and the even-numbered operations must be of type B.Neko wants to produce perfect longcats at industrial scale, thus for each cat Neko only wants to perform at most $$$40$$$ operations. Can you help Neko writing a transformation plan?Note that it is not required to minimize the number of operations. You just need to use no more than $$$40$$$ operations.

The only line contains a single integer $$$x$$$ ($$$1 \le x \le 10^6$$$).

The first line should contain a single integer $$$t$$$ ($$$0 \le t \le 40$$$) — the number of operations to apply. Then for each odd-numbered operation print the corresponding number $$$n_i$$$ in it. That is, print $$$\lceil \frac{t}{2} \rceil$$$ integers $$$n_i$$$ ($$$0 \le n_i \le 30$$$), denoting the replacement $$$x$$$ with $$$x \oplus (2^{n_i} - 1)$$$ in the corresponding step. If there are multiple possible answers, you can print any of them. It is possible to show, that there is at least one answer in the constraints of this problem.

NoteIn the first test, one of the transforms might be as follows: $$$39 \to 56 \to 57 \to 62 \to 63$$$. Or more precisely: Pick $$$n = 5$$$. $$$x$$$ is transformed into $$$39 \oplus 31$$$, or $$$56$$$.  Increase $$$x$$$ by $$$1$$$, changing its value to $$$57$$$.  Pick $$$n = 3$$$. $$$x$$$ is transformed into $$$57 \oplus 7$$$, or $$$62$$$.  Increase $$$x$$$ by $$$1$$$, changing its value to $$$63 = 2^6 - 1$$$. In the second and third test, the number already satisfies the goal requirement.

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

    var x = read.number();
    var x2b = x.toString(2);
    var res = [];
    var t = 0;
    while(x2b.indexOf(0) !== -1) {
        if(t%2==0) {
            x2b = x2b.replace(/^0+/, '');
            x2b = ((+('0b' +x2b))^((Math.pow(2, x2b.length))-1)).toString(2);
            res.push(x2b.length);
        }
        else {
            x2b = (+('0b' + x2b) + 1).toString(2)
        }
        t++;
    }

    print(t);
    if(res.length)
        print(res.join(' '));
}());

var x = parseInt(readline())
var q = [{ x:x, s:0}];

var vis = {}, lastx = x, res=[], count = 0;
while( q.length > 0) {

    var cur = q.shift();

    if ( cur.s > 40) continue;
    count = cur.s;
    var t = (cur.x+1);
    var check = t.toString(2).split('').filter(d=>(d==='1')).length === 1;
    if (check) break;

    lastx = cur.x;
    if (cur.s%2 === 0) {
        var a = cur.x.toString(2);
        n = a.length - a.indexOf('0')
        res.push(n)
        q.push({
            x: cur.x ^ (Math.pow(2, n) - 1),
            s: (cur.s+1)
        });
    } else {
        q.push({
            x: cur.x+1,
            s: (cur.s+1)
        });
    }

}

print(count)
print(res.join(' '))

var x = parseInt(readline())

var q = [{ x, s:0}];

var vis = {}, lastx = x, res=[];
while( q.length > 0) {

    var cur = q.shift();

    if ( vis[cur.x] || cur.s > 40) continue;
    vis[cur.x] = true;

    var check = (cur.x+1).toString(2).split('').filter(d=>(d==='1')).length === 1;
    if (check) break;

    lastx = cur.x;
    if (cur.s%2 === 0) {
        var a = cur.x.toString(2);
        n = a.length - a.indexOf('0')
        res.push(n)
        q.push({
            x: cur.x ^ (Math.pow(2, n) - 1),
            s: (cur.s+1)%2
        });
    } else {
        q.push({
            x: cur.x+1,
            s: (cur.s+1)%2
        });
    }

}

print(res.length)
if (res.length > 0) {
    print(res.join(' '))
}

var x = parseInt(readline())

var q = [{ x, s:0}];

var vis = {}, lastx = x, res=[];
while( q.length > 0) {

    var cur = q.shift();

    if ( vis[cur.x] || cur.s > 40) continue;
    vis[cur.x] = true;

    var check = (cur.x+1).toString(2).split('').filter(d=>(d==='1')).length === 1;
    if (check) break;

    lastx = cur.x;
    if (cur.s%2 === 0) {
        var a = cur.x.toString(2);
        n = a.length - a.indexOf('0')
        res.push(n)
        q.push({
            x: cur.x ^ (Math.pow(2, n) - 1),
            s: (cur.s+1)
        });
    } else {
        q.push({
            x: cur.x+1,
            s: (cur.s+1)
        });
    }

}

print(res.length)
if (res.length > 0) {
    print(res.join(' '))
}


Polycarp is writing the prototype of a graphic editor. He has already made up his mind that the basic image transformations in his editor will be: rotate the image 90 degrees clockwise, flip the image horizontally (symmetry relative to the vertical line, that is, the right part of the image moves to the left, and vice versa) and zooming on the image. He is sure that that there is a large number of transformations that can be expressed through these three.He has recently stopped implementing all three transformations for monochrome images. To test this feature, he asked you to write a code that will consecutively perform three actions with a monochrome image: first it will rotate the image 90 degrees clockwise, then it will flip the image horizontally and finally, it will zoom in twice on the image (that is, it will double all the linear sizes).Implement this feature to help Polycarp test his editor.

The first line contains two integers, w and h (1 ≤ w, h ≤ 100) — the width and height of an image in pixels. The picture is given in h lines, each line contains w characters — each character encodes the color of the corresponding pixel of the image. The line consists only of characters "." and "*", as the image is monochrome.

Print 2w lines, each containing 2h characters — the result of consecutive implementing of the three transformations, described above.

var pair = readline().split(' '),
    w = +pair[0],
    h = +pair[1],
    img = [],
    i = 0,
    string;
for (; i < h; i++) {
    img[i] = readline();
}
for (i = 0; i < w; i++) {
    string = img.map(function(str) {
        return str[i] + str[i];
    }).join('');
    print(string);
    print(string);
}

/*//deb
var lines = [];
lines[0] = "3 2";
lines[1] = ".*.";
lines[2] = ".*.";
var line = 0;
function readline() {
	return lines[line++];
}*/

function readn() {
	return +readline();
}
function parsens(s) {
	return 	s.split(" ").map(function(x) { return +x; });
}
function sortNumbers(a,b) {
	return a-b;
}

var numbers = parsens(readline());
var w = numbers[0];
var h = numbers[1];

var a = [];
for (var i = 0; i < h; i++) {
	a[i] = [];
	var s = readline();
	for (var j = 0; j < w; j++) {
		if (s.charAt(j) == ".") {
			a[i][j] = 0;
		} else {
			a[i][j] = 1;
		}
	}
}

var b = [];
for (var i = 0; i < w; i++) {
	b[i] = [];
}

for (var i = 0; i < h; i++) {
	for (var j = 0; j < w; j++) {
		b[j][i] = a[i][j];
	}
}

for (var i = 0; i < w; i++) {
	var s = "";
	for (var j = 0; j < h; j++) {
		s += b[i][j] == 0 ? ".." : "**";
	}
	print(s);
	print(s);
}

var size = readline().split(' ');
var w = size[0];
var h = size[1];
var img = [];

for (var i = 0; i < h; i++) {
	img[i] = readline().split('');
}

var rotate = [];

for (var i = 0; i < h; i++) {
	for (var j = 0; j < w; j++) {
		if (!rotate[j]) {
			rotate[j] = [];
		}
		rotate[j][h - i] = img[i][j];
	}
}

var reflection = [];
var height = w;
var width = h;

for (var i = 0; i < height; i++) {
	reflection[i] = [];
	for (var j = 0; j < width; j++) {
		reflection[i][j] = rotate[i][width-j];
	}
}

var scale = [];

for (var i = 0; i < height; i++) {
	scale[2*i] = [];
	scale[2*i + 1] = [];
	for (var j = 0; j < width; j++) {
		var pixel = reflection[i][j];
		scale[2*i][2*j] = pixel;
		scale[2*i][2*j + 1] = pixel;
		scale[2*i + 1][2*j] = pixel;
		scale[2*i + 1][2*j + 1] = pixel;
	}
}

for (var i = 0; i < scale.length; i++) {
	print(scale[i].join(''));
}

var size = readline().split(' ');
var w = size[0];
var h = size[1];
var img = [];

for (var i = 0; i < h; i++) {
	img[i] = readline().split('');
}

var rotate = [];

for (var i = 0; i < h; i++) {
	for (var j = 0; j < w; j++) {
		if (!rotate[j]) {
			rotate[j] = [];
		}
		rotate[j][h - i] = img[i][j];
	}
}

var reflection = [];
var height = w;
var width = h;

for (var i = 0; i < height; i++) {
	reflection[i] = [];
	for (var j = 0; j < width; j++) {
		reflection[i][j] = rotate[i][width-j];
	}
}

var scale = [];

for (var i = 0; i < height; i++) {
	scale[2*i] = [];
	scale[2*i + 1] = [];
	for (var j = 0; j < width; j++) {
		var pixel = reflection[i][j];
		scale[2*i][2*j] = pixel;
		scale[2*i][2*j + 1] = pixel;
		scale[2*i + 1][2*j] = pixel;
		scale[2*i + 1][2*j + 1] = pixel;
	}
}
print(reflection.length);
print(reflection[0].length);
print(scale.length);
print(scale[0].length);

for (var i = 0; i < scale.length; i++) {
	print(scale[i].join(''));
}

var size = readline().split(' ');
var w = size[0];
var h = size[1];
var img = [];

for (var i = 0; i < h; i++) {
	img[i] = readline().split('');
}

var rotate = [];

for (var i = 0; i < h; i++) {
	for (var j = 0; j < w; j++) {
		if (!rotate[j]) {
			rotate[j] = [];
		}
		rotate[j][h - i] = img[i][j];
	}
}

var reflection = [];
var height = w;
var width = h;
var halfWidth = Math.floor(h/2);

for (var i = 0; i < height; i++) {
	reflection[i] = [];
	for (var j = 0; j < halfWidth; j++) {
		reflection[i][j] = rotate[i][width-j];
		reflection[i][width-j] = rotate[i][j];
	}
}

var scale = [];

for (var i = 0; i < height; i++) {
	scale[2*i] = [];
	scale[2*i + 1] = [];
	for (var j = 0; j < width; j++) {
		var pixel = reflection[i][j];
		scale[2*i][2*j] = pixel;
		scale[2*i][2*j + 1] = pixel;
		scale[2*i + 1][2*j] = pixel;
		scale[2*i + 1][2*j + 1] = pixel;
	}
}

for (var i = 0; i < scale.length; i++) {
	print(scale[i].join(''));
}


There is a string $$$s$$$ of length $$$3$$$, consisting of uppercase and lowercase English letters. Check if it is equal to "YES" (without quotes), where each letter can be in any case. For example, "yES", "Yes", "yes" are all allowable.

The first line of the input contains an integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of testcases. The description of each test consists of one line containing one string $$$s$$$ consisting of three characters. Each character of $$$s$$$ is either an uppercase or lowercase English letter.

For each test case, output "YES" (without quotes) if $$$s$$$ satisfies the condition, and "NO" (without quotes) otherwise. You can output "YES" and "NO" in any case (for example, strings "yES", "yes" and "Yes" will be recognized as a positive response).

10

YES

yES

yes

Yes

YeS

Noo

orZ

yEz

Yas

XES

NoteThe first five test cases contain the strings "YES", "yES", "yes", "Yes", "YeS". All of these are equal to "YES", where each character is either uppercase or lowercase.

var n = parseInt(readline());

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

    if (str.toUpperCase() === "YES") {
        print("YES");
    } else {
        print("NO");
    }
}

        var t = readline();
        for (var i=0; i<t; i++){
            var s = readline();
            var result = s.toLowerCase()
            if (result == 'yes'){
                print('YES');
            }else{
                print('NO');
            }
        }

var t = readline();
for(var i =0 ; i < t ; i++){
    var yes = readline().toUpperCase();
    if (yes === 'YES') {
        print('YES');
    } else {
        print('NO');
    }
}

    var limit = parseInt(readline());
    for (var i = 0; i < limit; i++)
    {
        var input = readline();
        if ((input[0] === 'y' || input[0] === 'Y') &&
                (input[1] === 'e' || input[1] === 'E') &&
                (input[2] === 's' || input[2] === 'S'))
                    { print("YES");}
                    else {print("NO");}
    }

const length = Number(readline())

const input = ((length) => Array.from({ length: length }, () => readline()))(length)

const solution = (input) => {
  const result = input.map(str => str.toUpperCase() === 'YES' ? 'YES' : 'NO')
  return result.join('\n')
}

print(solution(input))

var a = readline();
var arr = [];
for(var i = 0; i < a; i++){
    arr[i] = readline().toUpperCase();
    if(arr[i][0]=="Y" && arr[i][1]=="E" && arr[i][2]=="S"){
        print("YES");
    }else{
        print("NO");
    }
}

var test = readline();
for (var i = 1; i <= test; i++) {
    var s = readline();
    if (s.toUpperCase() == 'YES') {
        print('YES');
    } else print('NO')
}

var testCase = +readline()
var dataStruct = [{
    u: "Y",
    l: "y"
  }, {
    u: "E",
    l: "e"
  },
  {
    u: "S",
    l: "s"
  }
]

loop0:
for(var i=0;i<testCase;i++){
    var sequence=readline(),counter=0
    loop1:
    for(var j=0;j<sequence.length;j++){
        loop2:
        for(var k=0;k<dataStruct.length;k++){
            if((sequence[j]===dataStruct[k]["u"]||sequence[j]===dataStruct[k]["l"])&&j===k){
            counter++
            break loop2
            }

        }
    }
    counter===3?print("Yes"):print("No")
}

w = readline();
str = "YES"
for (i = 0; i < w; i++){
    strE = readline().toUpperCase();
if  (str === strE){
    print ("YES");
} else {
  print ("NO");
}
}

var t = readline();
var input ;
for(var i = 0 ; i < t ; i++) {
input = readline().toLowerCase();
if(input == 'yes'){
    print('YES');
}
else{
    print('NO');
}
}

t = readline();
while(t--){
    x = readline().toLowerCase();
    if(x === 'yes')
        print('YES');
    else
        print("NO");
}

var tests = parseInt(readline());
    for (var t=0; t<tests;t++) {
        var yes = readline();
        if (/^YES$/i.test(yes)) {
            print('YES');
        } else {
            print('NO');
        }
    }

n = parseInt(readline());

for(i = 0; i < n; i++) {
    var word = readline();
    var modWord = word.toLowerCase();
    if(modWord === "yes") {
        print('YES');
    } else {
        print('NO');
    }
}

var t = +readline();

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

    var t2 = readline();
    if (checkStr(t2)){
          print('YES')
    }else {
          print('NO')
    }

}

function checkStr(str) {

  return str[0].toLowerCase() == 'y' && str[1].toLowerCase() == 'e' && str[2].toLowerCase() == 's'

}

T = readline()

while(T--){
      ans = 'NO'
      str  = readline().toUpperCase()
      if(str === 'YES')
            ans = "YES"

      print(ans)
}

process.stdin.on("data", (data) => {
  const [testCount, ...lines] = data.toString().trim().split("\n");
  for (let line of lines) {
    console.log(line.toLowerCase().trim() == "yes" ? "YES" : "NO");
  }
});

process.stdin.resume();
process.stdin.setEncoding("ascii");

_input = "";
process.stdin.on("data", function (input) {
   _input += input;
});

process.stdin.on("end", function () {
    processData(_input);
});

function processData(input) {
    const lines = input.split("\n");
    for (let i = 1; i <= lines[0]; i++) {
        processTC(lines, i);
    }
}

function processTC(lines, startLine) {
    const str = lines[startLine];
    console.log((str.trim().toLowerCase() === "yes") ? "YES" : "NO");
}

function Solution() {
  const arr = lines.slice(1);
  const res = [];
  for (let i = 0; i < arr.length; i++) {
    if (arr[i].toUpperCase() === 'YES') res.push('YES')
    else res.push('NO');
  }
  return res.join('\n');
}

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', () => {
  console.log(Solution());
});

function Solution() {
  const strArr = lines.slice(1);
  const res = [];
  for (let str of strArr) {
    if (str.toUpperCase() === 'YES') res.push('YES');
    else res.push('NO');
  }
  return res.join('\n');
}

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', () => {
  console.log(Solution());
});

function Solution() {
  const N = Number(lines[0]);
  const strArr = lines.slice(1);
  const res = [];
  for (let i = 0; i < N; i++) {
    const [a, b, c] = strArr[i];
    if ((a === 'y' || a === 'Y')
    && (b === 'e' || b === 'E')
    && (c === 's' || c === 'S')) {
      res.push('YES');
    } else {
      res.push('No');
    }
  }
  return res.join('\n');
}

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', () => {
  console.log(Solution());
});

const readline = require("readline");

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

rl.on("line", line => {
    if (!isNaN(Number(line))) {
        // do nothing
    } else if (line.toLowerCase() === "yes") {
        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++];
}
function main(){
    let t = readline()-0
    while(t--){
        let s = readline()
        if(s.toLowerCase() === "yes")
            console.log("YES")
        else
            console.log("NO")
    }
}

// Parsing input: https://codeforces.com/blog/entry/78878
process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';
let currentLine = 0;

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

function main() {
    // Actual body code
    var T = parseInt(readLine());

    for (var t = 0; t < T; ++t) {
        var s = readLine();
        console.log((s.trim().toLowerCase() == "yes") ? "YES" : "NO");
    }
}

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

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

    main();
});

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

let c = 0;

rl.on("line", (d) => {
  if (c === 0) {
    c++;
    return;
  }
  const ans = d.toLowerCase() === "yes" ? "YES" : "NO";
  console.log(ans);
  c++;
});

rl.on("close", () => {});

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

const myWordsArray = [];

const transformWord = (longWord)=>{
    const FirstLetter = longWord.charAt(0);
    const lastLetter = longWord.charAt(longWord.length -1);
    const middle = longWord.length - 2;
    console.log(`${FirstLetter}${middle}${lastLetter}`);
}

const validateWords = (word)=>{
    if(word.length > 10){
        transformWord(word)
    }else{
        console.log(word)
    }
}

function main() {
    let number = parseInt(readLine());
    while(number--)
    {
        let string = readLine();
        string.toLowerCase() == 'yes' ? console.log("YES") : console.log("NO");
    }
}

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

let input = [];
let ans = [];

readline.on('line', line => {
    input.push(line);
}).on('close', ()=>{
    for (let i = 1; i < input.length; i++) {
        ans.push(input[i].toLowerCase() === 'yes' ? 'YES' : 'NO');
    }
    console.log(ans.join('\n'));
});

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

let lines = []

const createReadLine = () => {
  i = 0;
  return () => lines[i++]
}

rl.on('line', line => lines.push(line))

rl.on('close', () => {
  const readLine = createReadLine();
  let t = parseInt(readLine())
  while (t--) {
    let str = readLine();
    console.log(str.toLowerCase() === 'yes' ? 'yes' : 'no');
  }
})

const { readFileSync, writeFileSync } = require("fs")

let a = readFileSync("./input.fd0138e687.txt","utf-8").match(/[a-z]+/gi)

for (let i = 0; i < a.length; ++i) {
    a[i] = /^yes$/i.test(a[i]) ? "YES" : "NO"
}

console.log( a.join("\r\n") )

/*
** Template
*/

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

let inputString = "";
let currentLine = 0;

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

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

    main();
});

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

// LIBRARY START //

const isOdd = (x) => { return x & 1 }
const isEven = (x) => { return !(x & 1) }

const reverseText = (s) => { return s.split('').reverse().join('') }
const hasDuplicates = (str) => (/([a-z])\1/i).test(str)

const hasDuplicateChar = (str, char) => str.indexOf(char) !== str.lastIndexOf(char)

const isSorted = arr => arr.every((v, i, a) => !i || a[i - 1] <= v);

const findAllIndicesOfChar = (str, char) => {
    str = str.split('')
    let indices = [];
    for (let i = 0; i < str.length; i++) {
        if (str[i] === char) indices.push(i);
    }
    return indices
}

const splitAt = index => x => [x.slice(0, index), x.slice(index)]

const isUpper = str => !/[a-z]/.test(str) && /[A-Z]/.test(str)

const escapeRegExp = (string) => string.replace(/[.*+\-?^${}()|[\]\\]/g, '\\$&')

const replaceAll = (str, find, replace) => str.replace(new RegExp(escapeRegExp(find), 'g'), replace)

const findUnique = (str) => {
    return [...str].reduce((acc, curr) => {
        return acc.includes(curr) ? acc : acc + curr;
    }, "")
}

// LIBRARY END

const getresult = (str) => {

    str = str.toLowerCase()

    return str === 'yes' ? 'YES' : 'NO'
}

function main() {
    let testcases = parseInt( readline() )
    while( testcases-- ){

        let str = readline()
        console.log( getresult( str ) )
    }
}
//*/

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 e = false
        var s = lines[j].split('')
        if(s[0] == 'y' || s[0] == 'Y'){
            if(s[1] == 'e' || s[1] == 'E'){
                if(s[2] == 's' || s[2] == 'S'){
                    e = true
                }
            }
        }
        if(e === true){
            console.log('YES')
        }else{
            console.log('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 a = lines[i].split('');
        var y = a[0], e = a[1], s = a[2];
        var check = 0;
        if(y == 'y' || y == 'Y'){
            check++;
        }
        if(e == 'e' || e == 'E'){
            check++;
        }
        if(s == 's' || s == 'S'){
            check++;
        }
        console.log(check == 3 ? 'YES' : 'NO');
    }
});

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 = () => {
	//your code this
	let t = nl.num();
	let ans = [];
	for(let i = 0; i < t; i++){
		let a = nl.line().toLowerCase();
		ans.push(a === 'yes');
	}
	console.log(ans.map(x => x?'YES':'NO').join('\n'));
};

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

'use strict';

const fs = require('fs');

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

let inputString = '';
let currentLine = 0;

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

process.stdin.on('end', function() {
    inputString = inputString.split('\n');

    main();
});

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

function isPossible(n, x, heights) {
    heights.sort();
    heights.sort(function(a, b) {
        return a - b;
      });
    // //console.log(heights)

    let front = []
    let back = []

    for (let i = 0; i < heights.length; i++) {
        if (i < n) {
            front.push(heights[i])
        } else {
            back.push(heights[i])
        }
    }

    // //console.log(front)
    // //console.log(back)
    for (let j = 0; j < front.length; j++) {
        if (back[j] - front[j] < x) {
            // //console.log(back[j] + " " + front[j])
            return "NO";
        }
    }

    return "YES";
}

function calc(a, m) {
    let s = "";
    for (let index = 0; index < m; index++) {
        s += "B"
    }

   for (let index = 0; index < a.length; index++) {
        let ai = a[index];

        if (ai < (m + 1 - ai)) {
            let _s = s.replaceAt(ai - 1, "A");
            if (compare(_s, s) < 0) {
                s = _s;
                continue;
            } else if (compare(_s, s) >= 0) {
                    let __ss = s.replaceAt(m + 1 - ai - 1, "A");
                    if (compare(__ss, s) < 0) {
                        s = __ss;
                        continue;
                    }
            }
         }  else {
            let _s = s.replaceAt(m + 1 - ai - 1, "A");
            if (compare(_s, s) < 0) {
                s = _s;
                continue;
            }  if (compare(_s, s) >= 0) {
                    let __ss = s.replaceAt(ai - 1, "A");
                    if (compare(__ss, s) < 0) {
                        s = __ss;
                        continue;
                    }
            }
    }
}

   return s;
}

function compare(s1, s2) {
    return s1.localeCompare(s2)
}

String.prototype.replaceAt = function(index, replacement) {
    return this.substring(0, index) + replacement + this.substring(index + replacement.length);
}

function main() {
    // const ws = fs.createWriteStream(process.env.OUTPUT_PATH);

    const test_cases = parseInt(readLine().trim(), 10);

    for (let gItr = 0; gItr < test_cases; gItr++) {
        // const n_m = readLine().replace(/\s+$/g, '').split(' ').map(arrTemp => parseInt(arrTemp, 10));
        // const n = n_m[0];
        // const m = n_m[1];

        // if ((n >= 1 && n <= 50) && (m >= 1 && m <= 50)) {
        // const val = readLine().replace(/\s+$/g, '').split(' ').map(arrTemp => parseInt(arrTemp, 10));
        const val = readLine().trim()
        if (val.toUpperCase() == "YES") console.log("YES")
        else console.log("NO")
        // let output = calc(val, m);
        // console.log(output)
        // }
        // ws.write(result + '\n');
    }

    // ws.end();
}

"use strict";
process.stdin.resume();
process.stdin.setEncoding("utf-8");

function print(x) {
  console.log(x);
}
let inputString = "";
let currentLine = 0;

process.stdin.on("data", (inputStdin) => {
  inputString += inputStdin;
});
process.stdin.on("end", () => {
  inputString = inputString.split("\n");
  main();
});
function readline() {
  return inputString[currentLine++];
}

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

function main() {
    var tests = parseInt(readline());
    for (let t = 0;t < tests; ++t) {
        var s = readline();
        let arr = Array.from(s);
        if ((arr[0] == 'Y' || arr[0] == 'y') &&
            (arr[1] == 'E' || arr[1] == 'e') &&
            (arr[2] == 'S' || arr[2] == 's')) {
              console.log(
                'YES'
              );
        } else {
          console.log('NO');
        }
    }
}

const readline = require('readline')

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

function solve(str) {
    return str.toUpperCase() === 'YES' ? 'YES' : 'NO'
}

// https://stackoverflow.com/questions/20086849/how-to-read-from-stdin-line-by-line-in-node
// // cat .\input.txt | node .\script.js
const state = { i: 0 }
const readline = require('readline');
const rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout,
    terminal: false
});
rl.on('line', function (line) {
    if (state.i > 0) {
        let sum = 0
        let data = line.split('')
        if (data[0] == 'y' || data[0] == 'Y') sum++
        if (data[1] == 'e' || data[1] == 'E') sum++
        if (data[2] == 's' || data[2] == 'S') sum++
        if (sum == 3) console.log("YES")
        if (sum != 3) console.log("NO")
    }
    state.i++
})

"use strict";
const fs = require("fs");
//let filename = "0.txt";
let filename = 0;
const input = fs.readFileSync(filename, "utf8").trim().split("\n");
let line = 0;
function readline() {
  return input[line++];
}
const solve = () => {
  let t = parseInt(readline());
  while (t--) {
    let arr = readline().trim();
    let a1 = false,
      a2 = false,
      a3 = false;
    if (arr[0] === "Y" || arr[0] === "y") a1 = true;
    if (arr[1] === "E" || arr[1] === "e") a2 = true;
    if (arr[2] === "S" || arr[2] === "s") a3 = true;
    if (a1 && a2 && a3) console.log("YES");
    else console.log("NO");
  }
};
solve();

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

function alph() {
  var f = 'abcdefghijklmnopqrstuvwxyz';
  return f;
}
function Alph() {
  var f = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
  return f;
}
function max(x,y) {
  return x >=y ? x : y;
}
function min(x,y) {
  return x <=y ? x : y;
}
function abs(x) {
  return x < 0 ? x*(-1) : x;
}
// console.log(input)
var T = readline();
// var inf = 1000000000000;
for(var tc=1;tc<=T;tc++) {
  // var nul = readline();
  var n = readline()//.split(' ').map((x) => parseInt(x));
  // var a = readline().split(' ').map((x) => parseInt(x));
  if(n.toUpperCase() == "YES") 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++];
}

function main() {
  let times = parseInt(readline());
  for (let i = 0; i < times; i++) {
    let word = readline().toUpperCase();
    console.log(word === 'YES' ? 'YES' : 'NO');
  }
}

//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 if(code == 'long'){
			ret[i] = nextLong();
		}else if(code == 'double'){
			ret[i] = nextDouble();
		}else{
			ret[i] = next();
		}
	}
	return ret;
}
function nextIntArray(size){return nextArray(size, 'int');} function nextStrArray(size){return nextArray(size, 'str');} function nextLongArray(size){return nextArray(size, 'long');} function nextDoubleArray(size){return nextArray(size, 'double');}
function nextCharArray(){return myconv(next(),6);}
function next(){return obj.next();} function hasNext(){return obj.hasNext();} function nextInt(){return myconv(next(),1);} function nextLong(){return BigInt(next());} function nextDouble(){return parseFloat(next());}
function getCountMap(list){
	var map = {};
	for(var i = 0; i < list.length; i++){
		if(map[list[i]] == null){
			map[list[i]] = 0;
		}
		map[list[i]]++;
	}
	return map;
}
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();
	while(hasNext()){
		var S = next().toUpperCase();
		if(S == 'YES'){
			myout("YES");
		}else{
			myout("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++];
}

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

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

    for (let test = 0; test < N; test++) {
        const str = readline();
        output(str.toLowerCase() === 'yes' ? 'YES' : 'NO');
    }
}

const length = Number(readline())
const input = ((length) => Array.from({ length: length }, () => readline()))(length)

const solution = (input) => {
  const result = input.map(str => {
    str.toUpperCase() === 'YES' ? 'YES' : 'NO'
  })

  return result.join('\n')
}

print(solution(input))

let testCount;

process.stdin.on("data", (data) => {
  if (!testCount) {
    testCount = +data.toString();
    return;
  }
  console.log(testCount, line.toLowerCase().trim() == "yes" ? "YES" : "NO");

  const input = data.toString().trim();
  const lines = input.split("\n");
  for (let line of lines) {
    console.log(line.toLowerCase().trim() == "yes" ? "YES" : "NO");
  }

  testCount--;
});

let testCount;

process.stdin.on("data", (data) => {
  if (!testCount) {
    testCount = +data.toString();
    return;
  }

  const input = data.toString().trim();
  const lines = input.split("\n");
  for (let line of lines) {
    console.log(line.toLowerCase().trim() == "yes" ? "YES" : "NO");
  }

  testCount--;
});

let firstRun = true;

process.stdin.on("data", (data) => {
  if (firstRun) {
    firstRun = false;
    return;
  }

  const input = data.toString().trim();
  const lines = input.split("\n");
  for (let line of lines) {
    console.log(line.toLowerCase().trim() == "yes" ? "YES" : "NO");
  }
});

let numTests = null;
let curTest = 0;

process.stdin.on("data", (data) => {
  if (numTests === null) {
    numTests = parseInt(data.toString());
    return;
  }
  const input = data.toString().trim();
  const lines = input.split("\n");
  for (let line of lines) {
    console.log(line.toLowerCase().trim() == "yes" ? "YES" : "NO");
  }

  curTest++;
  if (curTest >= numTests) {
    process.exit();
  }
});

process.stdin.on("data", (data) => {
  const input = data.toString().trim();
  const lines = input.split("\n");
  for (let line of lines) {
    console.log(line.toLowerCase().trim() == "yes" ? "YES" : "NO");
  }
});

process.stdin.on("data", (data) => {
  const input = data.toString().trim();
  const lines = input.split("\n");
  for (let line of lines) {
    console.log("line", line.toLowerCase().trim());

  }
});

process.stdin.on("data", (data) => {
  const input = data.toString().trim();
  const lines = input.split("\n");
  for (let line of lines) {
    console.log(line.toLowerCase() === "yes" ? "YES" : "NO");
  }
});

process.stdin.on("data", (data) => {
  const input = data.toString().trim();
  const lines = input.split("\n");
  for (let line of lines) {
    console.log("line: ", line);
  }
});

process.stdin.on("data", (data) => {
  const input = data.toString().trim();
  console.log("Input: ", input);
});

process.stdin.on("data", (data) => {
  console.log("Input: ", data);
});

let i = "";
let o = "";
process.stdin.on("data", (c) => (i += c));
process.stdin.on("end", () => {
  const lines = i.toString().trim();

  for (let line of lines) {
    if (line.toLowerCase().trim() === "yes") {
      o += "YES\n";
    } else {
      o += "NO\n";
    }
  }
  console.log(o);
});

const stdin = process.openStdin();

stdin.addListener("data", function (d) {
  const line = d.toString().trim();
  if (line.toLowerCase().trim() === "yes") {
    console.log("YES");
  } else {
    console.log("NO");
  }
});

process.stdin.resume();
process.stdin.setEncoding("ascii");

_input = "";
process.stdin.on("data", function (input) {
   _input += input;
});

process.stdin.on("end", function () {
    processData(_input);
});

function processData(input) {
    const lines = input.split("\n");
    for (let i = 1; i <= lines[0]; i++) {
        processTC(lines, i);
    }
}

function processTC(lines, startLine) {
    const str = lines[startLine];
    console.log((str.toLowerCase() === "yes") ? "YES" : "NO");
}

process.stdin.resume();
process.stdin.setEncoding("ascii");

_input = "";
process.stdin.on("data", function (input) {
   _input += input;
});

process.stdin.on("end", function () {
    processData(_input);
});

function processData(input) {
    const lines = input.split("\n");
    for (let i = 1; i <= lines[0]; i++) {
        processTC(lines, i);
    }
}

function processTC(lines, startLine) {
    const str = lines[startLine];
    return (str.toLowerCase() === "yes") ? "YES" : "NO";
}

process.stdin.resume();
process.stdin.setEncoding("ascii");

_input = "";
process.stdin.on("data", function (input) {
   _input += input;
});

process.stdin.on("end", function () {
    processData(_input);
});

function processData(input) {
    const lines = input.split("\n");
    for (let i = 1; i <= lines[0]; i++) {
        processTC(lines, i);
    }
}

function processTC(lines, startLine) {
    const str = lines[startLine];
    return (str.toLowerCase() === "yes");
}

const readline = require("readline");

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

rl.on("line", line => {
    if (!isNaN(Number(line))) {
        console.log(Number(line));
    };
    if (line.toLowerCase() === "yes") {
        console.log("YES");
    } else {
        console.log("NO");
    }
});

const readline = require("readline");

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

rl.on("line", line => {
    if (line.toLowerCase() === "yes") {
        console.log("YES");
    } else {
        console.log("NO");
    }
});


An African crossword is a rectangular table n × m in size. Each cell of the table contains exactly one letter. This table (it is also referred to as grid) contains some encrypted word that needs to be decoded.To solve the crossword you should cross out all repeated letters in rows and columns. In other words, a letter should only be crossed out if and only if the corresponding column or row contains at least one more letter that is exactly the same. Besides, all such letters are crossed out simultaneously.When all repeated letters have been crossed out, we should write the remaining letters in a string. The letters that occupy a higher position follow before the letters that occupy a lower position. If the letters are located in one row, then the letter to the left goes first. The resulting word is the answer to the problem.You are suggested to solve an African crossword and print the word encrypted there.

The first line contains two integers n and m (1 ≤ n, m ≤ 100). Next n lines contain m lowercase Latin letters each. That is the crossword grid.

Print the encrypted word on a single line. It is guaranteed that the answer consists of at least one letter.

var nm = readline().trim().split(' ').map((_x)=>parseInt(_x));
var n=nm[0],m=nm[1];
var s=[];
var crossed = [];
for(var i=0;i<n;i++){
 s.push(readline().trim().split(''))
 var bools= [];
 for(var j=0;j<m;j++){
     bools.push(false)
 }
 crossed.push(bools)
}
//print(s)

for(var i=0;i<n;i++){
    for(var j=0;j<m;j++){
        for(var k=i+1;k<n;k++){
            if(s[i][j]==s[k][j]){
                crossed[i][j]=true
                crossed[k][j]=true
            }
        }
        for(var k=j+1;k<m;k++){
            if(s[i][j]==s[i][k]){
                crossed[i][j]=true
                crossed[i][k]=true
            }
        }
    }
}
//print(crossed)

var ans = '';

for(var i=0;i<n;i++){
    for(var j=0;j<m;j++){
  //      print(crossed[i][j],s[i][j])
        if(!crossed[i][j])
            ans+=s[i][j];
    }
}

print(ans)


Let's call a number k-good if it contains all digits not exceeding k (0, ..., k). You've got a number k and an array a containing n numbers. Find out how many k-good numbers are in a (count each number every time it occurs in array a).

The first line contains integers n and k (1 ≤ n ≤ 100, 0 ≤ k ≤ 9). The i-th of the following n lines contains integer ai without leading zeroes (1 ≤ ai ≤ 109).

Print a single integer — the number of k-good numbers in a.

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

const readLine=()=> inputString[currentLine++];
/* ================================================
           Main Solution Starts Here
===================================================*/

const main=()=>{
	let [n,k]=readLine().split(" ").map(n=>+n)
	let ans=0
	while(n--){
		let counter=0
		let x=readLine()
		for(let i=0;i<=k;i++)
			if(x.search(i-'0')!=-1)
				counter++
		if(counter==(k+1))
			ans++
	}
	console.log(ans)
}

print(function(n, k) {
	var i, j, c, s, ans = 0;
	for (i = 0; i < n; i++) {
		s = 0;
		c = new Int8Array(10);

		readline().split('').forEach(function(v) {
			c[v] = 1;
		});

		for (j = 0; j <= k; j++) {
			s += c[j];
		}
		if (s === k + 1) {
			ans++;
		}
	}

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

var num = readline().split(' ').map(c => parseInt(c)),count = 0
var encap = [0,0,0,0,0,0,0,0,0,0], bag = new Set()
for (var j = 0; j < num[0]; j++){
	readline().split('').map(c => bag.add(parseInt(c)))
	bag.forEach(c => encap[c] += 1)
	var res = encap.reduce((sum,val,index) =>{
		if (index < num[1]+1) return sum + val
		else return sum
	},0)
	if (res >= num[1]+1){
		count += 1
	}
	encap.fill(0)
	bag.clear()
}
print(count)

;(function () {

        print((function (n, k) {
                var t = 0;
                while (n--) {

                        for (var i = 0, s = readline(), f = true; i <= k; i++)
                                if (s.indexOf(i) === -1) {
                                        f = false;
                                        break;
                                }

                        t += f;
                }

                return t;
        }).apply(null, readline().split(' ').map(Number)));

}).call(this);

(function(n, k) {
    var i, j, exist, s, ans = 0;
    for (i = 0; i < n; i++) {
        s = 0;
        exist = [];

        readline().split('').forEach(function(v) {
            exist[v] = 1;
        });

        for (j = 0; j <= k; j++) {
            s += exist[j];
        }
        if (s === k + 1) {
            ans++;
        }
    }

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

var values = readline().split(" ").map(Number);
var n = values[0];
var k = values[1];
count = 0;

while (n--) {
    var arr = Array.from(new Set(readline().split('').map(Number))).sort((a, b) => a - b);
    var needed = arr.slice(0, k + 1);
    if (needed[0] === 0 &&
        needed[needed.length - 1] === k &&
        needed.length === k + 1) {
          count++;
        }
}

print(count);

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

const readLine=()=> inputString[currentLine++];
/* ================================================
           Main Solution Starts Here
===================================================*/

const main=()=>{
	let [n,k]=readLine().split(" ").map(n=>+n)
	let count=0
	while(n--){
		let isGood=true
		let number = +readLine()
		while(number){
			let digit = number%10
			if(digit>k)
			{
				isGood=false
				break
			}
			number/=10
		}
		if(isGood)
			count++
	}
	console.log(count)
}

print(function(n, k) {
	var i, j, c, s, ans = 0;
	for (i = 0; i < n; i++) {
		s = 0;
		c = new Int8Array(10);

		readline().split('').forEach(function(v) {
			c[v] = 1;
		});

		for (j = 0; j < k; j++) {
			s += c[j];
		}
		if (s === k) {
			ans++;
		}
	}

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

var num = readline().split(' ').map(c => parseInt(c)),count = 0
var encap = [0,0,0,0,0,0,0,0,0,0]
for (var j = 0; j < num[0]; j++){
	var array = readline().split('').map(c => parseInt(c))
	array.sort((a,b) => {return a-b}).forEach(v => encap[v]+=1)
	var res = encap.reduce((sum,val,index) =>{
		if (index < num[1]+1) return sum + val
		else return sum
	},0)
	if (res >= num[1]+1){
		count += 1
	}
	encap.fill(0)
}
print(count)

var num = readline().split(' ').map(c => parseInt(c)),count = 0
var encap = [0,0,0,0,0,0,0,0,0,0]
for (var j = 0; j < num[0]; j++){
	var array = readline().split('').map(c => parseInt(c))
	array.forEach(v => encap[v]+=1)
	var res = encap.reduce((sum,val,index) =>{
		if (index < num[1]+1) return sum + val
		else return sum
	},0)
	if (res == num[1]+1){
		count += 1
	}
	encap.fill(0)
}
print(count)

var values = readline().split(" ").map(Number);
var n = values[0];
var k = values[1];
count = 0;

while (n--) {
    var arr = Array.from(new Set(readline().split('').map(Number))).sort((a, b) => a - b);
    if (arr[0] === 0 &&
        arr[arr.length - 1] === k &&
        arr.length === k + 1) {
          count++;
        }
}

print(count);

var values = readline().split(" ").map(Number);
var n = values[0];
var k = values[1];
count = 0;

while (n--) {
    var arr = Array.from(new Set(readline().split('').map(Number))).sort((a, b) => a - b);
    var needed = arr.slice(0, k + 1);
    if (arr[0] === 0 &&
        needed[needed.length - 1] === k) {
          count++;
        }
}

print(count);


You finally woke up after this crazy dream and decided to walk around to clear your head. Outside you saw your house's fence — so plain and boring, that you'd like to repaint it.  You have a fence consisting of $$$n$$$ planks, where the $$$i$$$-th plank has the color $$$a_i$$$. You want to repaint the fence in such a way that the $$$i$$$-th plank has the color $$$b_i$$$.You've invited $$$m$$$ painters for this purpose. The $$$j$$$-th painter will arrive at the moment $$$j$$$ and will recolor exactly one plank to color $$$c_j$$$. For each painter you can choose which plank to recolor, but you can't turn them down, i. e. each painter has to color exactly one plank.Can you get the coloring $$$b$$$ you want? If it's possible, print for each painter which plank he must paint.

The first line contains one integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The first line of each test case contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 10^5$$$) — the number of planks in the fence and the number of painters. The second line of each test case contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le n$$$) — the initial colors of the fence. The third line of each test case contains $$$n$$$ integers $$$b_1, b_2, \dots, b_n$$$ ($$$1 \le b_i \le n$$$) — the desired colors of the fence. The fourth line of each test case contains $$$m$$$ integers $$$c_1, c_2, \dots, c_m$$$ ($$$1 \le c_j \le n$$$) — the colors painters have. It's guaranteed that the sum of $$$n$$$ doesn't exceed $$$10^5$$$ and the sum of $$$m$$$ doesn't exceed $$$10^5$$$ over all test cases.

For each test case, output "NO" if it is impossible to achieve the coloring $$$b$$$. Otherwise, print "YES" and $$$m$$$ integers $$$x_1, x_2, \dots, x_m$$$, where $$$x_j$$$ is the index of plank the $$$j$$$-th painter should paint. You may print every letter in any case you want (so, for example, the strings "yEs", "yes", "Yes" and "YES" are all recognized as positive answer).

YES
1
YES
2 2
YES
1 1 1
YES
2 1 9 5 9
NO
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, m] = rna();
		const a = rna();
		const b = rna();
		const c = rna();

		const need = Array.from(Array(n+1), x => []);
		let done = n;
		for (let i = 0; i < n; i++) {
			if (a[i] != b[i]) {
				need[b[i]].push(i+1);
				done--;
			}
		}

		let splplk;
		if (need[c[m-1]].length) {
			splplk = need[c[m-1]][0];
		} else {
			for (let i = 0; i < n; i++) {
				if (b[i] == c[m-1]) {
					splplk = i+1;
					break;
				}
			}
			if (!splplk) {
				console.log('NO');
				continue;
			}
		}

		const ans = Array(m);
		for (let i = 0; i < m; i++) {
			if (need[c[i]].length) {
				ans[i] = need[c[i]].pop();
				done++;
			} else {
				ans[i] = splplk;
			}
		}

		console.log(done == n ? 'YES\n' + ans.join(' ') : 'NO');
	}
}

//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 M = nextInt();
		var alist = nextIntArray(N);
		var blist = nextIntArray(N);
		var clist = nextIntArray(M);
		var diff = {};
		var colorMap = {};
		for(var j = 0; j < N; j++){
			if(colorMap[alist[j]] == null){
				colorMap[alist[j]] = new Set();
			}
			colorMap[alist[j]].add(j);
			if(alist[j] != blist[j]){
				if(diff[blist[j]] == null){
					diff[blist[j]] = [];
				}
				diff[blist[j]].push(j);
			}
		}

		var keep = [];
		var output = [];
		for(var j = 0; j < M; j++){
			var c = clist[j];
			if(diff[c] == null || diff[c].length == 0){
				if(colorMap[c] != null && colorMap[c].size > 0){
					var te = Array.from(colorMap[c]);
					while(keep.length > 0){
						output.push(te[0] + 1);
						keep.pop();
					}
					output.push(te[0] + 1);
				}else{
					keep.push(c);
				}
			}else{
				var ok = diff[c].shift();
				while(keep.length > 0){
					output.push(ok + 1);
					keep.pop();
				}
				output.push(ok + 1);
				colorMap[alist[ok]].delete(ok);
				if(colorMap[c] == null){
					colorMap[c] = new Set();
				}
				colorMap[c].add(ok);
			}
		}
		//myerr(diff);
		var key = Object.keys(diff);
		var isOK = true;
		for(var j = 0; j < key.length; j++){
			if(diff[key[j]].length > 0){
				isOK = false;
				break;
			}
		}
		if(!isOK || output.length != M){
			myout("NO");
		}else{
			myout("YES");
			myout(myconv(output, 8));
		}
	}
}

'use strict';

function solve(n, m, a, b, c) {
  const colors = new Map(),
        change = new Map(),
        painters = new Map();
  for (let [i, color] of b.entries()) {
    colors.set(color, i);
    if (a[i] !== b[i]) {
      var _change$get;
      if (!change.has(color)) change.set(color, []);
      (_change$get = change.get(color)) === null || _change$get === void 0 ? void 0 : _change$get.push(i);
    }
  }
  for (let color of c) {
    var _painters$get;
    painters.set(color, ((_painters$get = painters.get(color)) !== null && _painters$get !== void 0 ? _painters$get : 0) + 1);
  }
  for (let [color, arr] of change) {
    var _painters$get2;
    if (arr.length > ((_painters$get2 = painters.get(color)) !== null && _painters$get2 !== void 0 ? _painters$get2 : 0)) return 'NO';
  }
  let res = [],
      last = -1;
  for (let i = m - 1; i >= 0; i--) {
    const color = c[i],
          idx = change.get(color);
    if (idx !== null && idx !== void 0 && idx.length) {
      res[i] = idx.pop();
    } else if (last !== -1) {
      res[i] = last;
    } else {
      if (colors.has(color)) {
        res[i] = colors.get(color);
      } else {
        return 'NO';
      }
    }
    if (last === -1) last = res[i];
  }
  return `YES\n${res.map(num => num + 1).join(' ')}`;
}

async function main(read) {
  try {
    let res = [];
    let t = Number(await read());
    while (t--) {
      const [n, m] = (await read()).split(' ').map(Number);
      const a = (await read()).split(' ').map(Number);
      const b = (await read()).split(' ').map(Number);
      const c = (await read()).split(' ').map(Number);
      res.push(solve(n, m, a, b, c));
    }
    console.log(res.join('\n'));
  } catch (error) {
    console.log(error);
  }
}

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

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, m] = rna();
		const a = rna();
		const b = rna();
		const c = rna();

		const need = Array(n+1).fill([]);
		let done = n;
		for (let i = 0; i < n; i++) {
			if (a[i] != b[i]) {
				need[b[i]].push(i+1);
				done--;
			}
		}

		let splplk;
		if (need[c[m-1]].length) {
			splplk = need[c[m-1]][0];
		} else {
			for (let i = 0; i < n; i++) {
				if (b[i] == c[m-1]) {
					splplk = i+1;
					break;
				}
			}
			if (!splplk) {
				console.log('NO');
				continue;
			}
		}

		const ans = Array(n+1);
		for (let i = 0; i < m; i++) {
			if (need[c[i]].length) {
				ans[i] = need[c[i]].pop();
				done++;
			} else {
				ans[i] = splplk;
			}
		}

		console.log(done == n ? 'YES\n' + ans.join(' ') : 'NO');
	}
}