'use strict';

const parseProblem = (line, problem) => {
    if (!problem.T || problem.T === 0) {
        problem.T = parseInt(line);
        return problem;
    }

    const cases = problem.cases;

    if (cases.length === 0 || cases[cases.length - 1].arr) {
        cases.push({
            s: line
        });
    } else {
        cases[cases.length - 1].arr = line;
    }

    const isProcessing = cases.length < problem.T || !cases[cases.length - 1].arr;
    problem.isProcessing = isProcessing;

    return problem;
};

const solve = data => {
    const {s, arr} = data;
    const sizes = arr.split(' ').map(i => +i);
    let max = 0;
    const ans = [];

    for(let i = 0; i < s; i++) {
        max = Math.max(f(i, sizes, ans), max);
    }

    return max;
}

const f = (i, sizes, arr) => {
    if(!arr[i]) {
        let max = 0;

        for(let j = 2 * i + 1; j < sizes.length; j += i + 1) {
            if(sizes[j] > sizes[i]) {
                max = Math.max(f(j, sizes, arr), max);
            }
        }

        arr[i] = max + 1;
    }

    return arr[i];
}

const solveCases = cases => {
    for (let index = 0; index < cases.length; index++) {
        const result = solve(cases[index]);
        console.log(result);
    }
};

const main = () => {
    const readline = require('readline');

    let problem = {
        T: 0,
        cases: [],
        isProcessing: true
    };

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

    rl.on('line', line => {
        problem = parseProblem(line, problem);

        if (!problem.isProcessing) {
            rl.close();
        }
    }).on('close', () => {
        solveCases(problem.cases);
        process.exit(0);
    });
};

if (!module.parent) {
    main();
}

'use strict';

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

let inputString = '';
let currentLine = 0;

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

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

    main();
});

function readline() {
    return inputString[currentLine++];
}
/**
    4
    4
    5 3 4 6
    7
    1 4 2 3 6 4 9
    5
    5 4 3 2 1
    1
    9

**/

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

    for(let r=0;r<range;r++) {
        let n = parseInt(readline());
        let a = readline().split(" ").map((Number));
        a.unshift(0);

        const dp = new Array(n+1).fill(1);

        for(let i=1;i<=n;i++) {
            for(let j=i*2;j<=n;j+=i) {
                    if(a[i] < a[j]) {
                        dp[j] = Math.max(dp[j], dp[i] + 1);
                    }
            }
        }
        console.log(Math.max(...dp));
    }

}

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

    B();
});

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

function pi(a) {
    return parseInt(a);
}

function ti(a){
    for(let i = 0; i < a.length; i++)
        a[i] = pi(a[i]);

    return a;
}

function B(){
    let t = pi(readline());
    while(t > 0){
        t--;
        let n = pi(readline());
        let s = ti(readline().split(' '));

        let dp = new Array(n);
        dp.fill(1);
        for(let i = 0; i < n; i++){
            let x = 2;
            while((i+1)*x <= n){
                let index = (i+1)*x - 1;
                if(s[index] > s[i]){
                    dp[index] = Math.max(dp[index], dp[i]+1);
                }
                x++;
            }
        }

        let max = 0;
        for(let i = 0; i < n; i++)
            max = Math.max(max, dp[i]);

        //console.log(dp);
        console.log(max);
    }
}

'use strict';

const parseProblem = (line, problem) => {
    if (!problem.T || problem.T === 0) {
        problem.T = parseInt(line);
        return problem;
    }

    const cases = problem.cases;

    if (cases.length === 0 || cases[cases.length - 1].arr) {
        cases.push({
            s: line
        });
    } else {
        cases[cases.length - 1].arr = line;
    }

    const isProcessing = cases.length < problem.T || !cases[cases.length - 1].arr;
    problem.isProcessing = isProcessing;

    return problem;
};

const solve = data => {
    const {s, arr} = data;
    const sizes = arr.split(' ').map(i => +i);
    let res = [];

    for(let i = s - 1; i >= 0; i--) {
        let m = [sizes[i]];

        for(let j = i - 1; j >= 0; j--) {
            if((sizes[j] != m[m.length - 1]) && (m[m.length - 1] % sizes[j] == 0))
                m.push(sizes[j]);
        }

        res.push(m.length);
    }

    res.sort();

    return res[res.length - 1];
}

const solveCases = cases => {
    for (let index = 0; index < cases.length; index++) {
        const result = solve(cases[index]);
        console.log(result);
    }
};

const main = () => {
    const readline = require('readline');

    let problem = {
        T: 0,
        cases: [],
        isProcessing: true
    };

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

    rl.on('line', line => {
        problem = parseProblem(line, problem);

        if (!problem.isProcessing) {
            rl.close();
        }
    }).on('close', () => {
        solveCases(problem.cases);
        process.exit(0);
    });
};

if (!module.parent) {
    main();
}

'use strict';

const parseProblem = (line, problem) => {
    if (!problem.T || problem.T === 0) {
        problem.T = parseInt(line);
        return problem;
    }

    const cases = problem.cases;

    if (cases.length === 0 || cases[cases.length - 1].arr) {
        cases.push({
            s: line
        });
    } else {
        cases[cases.length - 1].arr = line;
    }

    const isProcessing = cases.length < problem.T || !cases[cases.length - 1].arr;
    problem.isProcessing = isProcessing;

    return problem;
};

const solve = data => {
    const {s, arr} = data;
    const sizes = arr.split(' ').map(i => +i);
    let res = [];

    for(let i = 0; i < s; i++) {
        let m = [sizes[i]];

        for(let j = i; j < s; j++) {
            if((sizes[i] != sizes[j - 1]) && (sizes[j] % sizes[j - 1] == 0))
                m.push(sizes[j]);
        }

        res.push(m.length);
    }

    res.sort();

    return res[res.length - 1];
}

const solveCases = cases => {
    for (let index = 0; index < cases.length; index++) {
        const result = solve(cases[index]);
        console.log(result);
    }
};

const main = () => {
    const readline = require('readline');

    let problem = {
        T: 0,
        cases: [],
        isProcessing: true
    };

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

    rl.on('line', line => {
        problem = parseProblem(line, problem);

        if (!problem.isProcessing) {
            rl.close();
        }
    }).on('close', () => {
        solveCases(problem.cases);
        process.exit(0);
    });
};

if (!module.parent) {
    main();
}

'use strict';

const parseProblem = (line, problem) => {
    if (!problem.T || problem.T === 0) {
        problem.T = parseInt(line);
        return problem;
    }

    const cases = problem.cases;

    if (cases.length === 0 || cases[cases.length - 1].arr) {
        cases.push({
            s: line
        });
    } else {
        cases[cases.length - 1].arr = line;
    }

    const isProcessing = cases.length < problem.T || !cases[cases.length - 1].arr;
    problem.isProcessing = isProcessing;

    return problem;
};

const solve = data => {
    const {s, arr} = data;
    const sizes = arr.split(' ').map(i => +i);
    let res = [];

    for(let i = s - 1; i >= 0; i--) {
        let m = [sizes[i]];
        let indexes = [i + 1];

        for(let j = i + 1; j >= 0; j--) {
            if((indexes[indexes.length - 1] % (j + 1) == 0)
                && (m[m.length - 1] > sizes[j])
            ) {
                m.push(sizes[j]);
                indexes.push(j + 1);
            }
        }

        res.push(m.length);
    }

    res.sort();

    return res[res.length - 1];
}

const solveCases = cases => {
    for (let index = 0; index < cases.length; index++) {
        const result = solve(cases[index]);
        console.log(result);
    }
};

const main = () => {
    const readline = require('readline');

    let problem = {
        T: 0,
        cases: [],
        isProcessing: true
    };

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

    rl.on('line', line => {
        problem = parseProblem(line, problem);

        if (!problem.isProcessing) {
            rl.close();
        }
    }).on('close', () => {
        solveCases(problem.cases);
        process.exit(0);
    });
};

if (!module.parent) {
    main();
}

'use strict';

const parseProblem = (line, problem) => {
    if (!problem.T || problem.T === 0) {
        problem.T = parseInt(line);
        return problem;
    }

    const cases = problem.cases;

    if (cases.length === 0 || cases[cases.length - 1].arr) {
        cases.push({
            s: line
        });
    } else {
        cases[cases.length - 1].arr = line;
    }

    const isProcessing = cases.length < problem.T || !cases[cases.length - 1].arr;
    problem.isProcessing = isProcessing;

    return problem;
};

const solve = data => {
    const {s, arr} = data;
    const sizes = arr.split(' ').map(i => +i);
    let res = 1;

    for(let i = s - 1; i >= 0; i--) {
        let indexes = [i + 1];

        for(let j = i + 1; j >= 0; j--) {
            if((indexes[indexes.length - 1] % (j + 1) == 0)
                && (sizes[indexes[indexes.length - 1] - 1] > sizes[j])
            ) {
                indexes.push(j + 1);
            }
        }

        if(indexes.length > res) res = indexes.length;
    }

    return res;
}

const solveCases = cases => {
    for (let index = 0; index < cases.length; index++) {
        const result = solve(cases[index]);
        console.log(result);
    }
};

const main = () => {
    const readline = require('readline');

    let problem = {
        T: 0,
        cases: [],
        isProcessing: true
    };

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

    rl.on('line', line => {
        problem = parseProblem(line, problem);

        if (!problem.isProcessing) {
            rl.close();
        }
    }).on('close', () => {
        solveCases(problem.cases);
        process.exit(0);
    });
};

if (!module.parent) {
    main();
}

'use strict';

const parseProblem = (line, problem) => {
    if (!problem.T || problem.T === 0) {
        problem.T = parseInt(line);
        return problem;
    }

    const cases = problem.cases;

    if (cases.length === 0 || cases[cases.length - 1].arr) {
        cases.push({
            s: line
        });
    } else {
        cases[cases.length - 1].arr = line;
    }

    const isProcessing = cases.length < problem.T || !cases[cases.length - 1].arr;
    problem.isProcessing = isProcessing;

    return problem;
};

const solve = data => {
    const {s, arr} = data;
    const sizes = arr.split(' ').map(i => +i);
    let res = [];

    for(let i = s - 1; i >= 0; i--) {
        let m = [sizes[i]];
        let indexes = [i + 1];

        for(let j = i - 1; j >= 0; j--) {
            if((indexes[indexes.length - 1] % (j + 1) == 0)
                && (m[m.length - 1] > sizes[j])
            ) {
                m.push(sizes[j]);
                indexes.push(j + 1);
            }
        }

        res.push(m.length);
    }

    res.sort();

    return res[res.length - 1];
}

const solveCases = cases => {
    for (let index = 0; index < cases.length; index++) {
        const result = solve(cases[index]);
        console.log(result);
    }
};

const main = () => {
    const readline = require('readline');

    let problem = {
        T: 0,
        cases: [],
        isProcessing: true
    };

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

    rl.on('line', line => {
        problem = parseProblem(line, problem);

        if (!problem.isProcessing) {
            rl.close();
        }
    }).on('close', () => {
        solveCases(problem.cases);
        process.exit(0);
    });
};

if (!module.parent) {
    main();
}

'use strict';

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

let inputString = '';
let currentLine = 0;

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

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

    main();
});

function readline() {
    return inputString[currentLine++];
}
/**
    4
    4
    5 3 4 6
    7
    1 4 2 3 6 4 9
    5
    5 4 3 2 1
    1
    9

**/

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

    for(let r=0;r<range;r++) {
        let n = parseInt(readline());
        let a = readline().split(" ").map((Number));
        a.unshift(0);

        const dp = new Array(n+1).fill(1);

        for(let i=1;i<=n;i++) {
            for(let j=i*2;j<=n;j++) {
                    if(a[i] < a[j]) {
                        dp[j] = Math.max(dp[j], dp[i] + 1);
                    }
            }
        }
        console.log(Math.max(...dp));
    }

}

'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++];
}
/**
    4
    4
    5 3 4 6
    7
    1 4 2 3 6 4 9
    5
    5 4 3 2 1
    1
    9

**/

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

    for(let r=0;r<range;r++) {
        let n = parseInt(readline());
        let a = readline().split(" ").map(Number);
        const dp = new Array(n).fill(1);

        for(let i=1;i<n;i++) {
            for(let j=0;j<i;j++) {
                if( (i+1) % (j+1) === 0) {
                    if(a[i] > a[j]) {
                        let index = ((i+1)/(j+1)) - 1;
                        dp[i-1] = Math.max(dp[i-1], dp[index] + 1)
                    }
                }
            }
        }

        console.log(Math.max(...dp));
    }

}

'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++];
}
/**
    4
    4
    5 3 4 6
    7
    1 4 2 3 6 4 9
    5
    5 4 3 2 1
    1
    9

**/

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

    for(let r=0;r<range;r++) {
        let n = parseInt(readline());
        let a = readline().split(" ").map(Number);
        a.unshift(1);
        const dp = new Array(n+1).fill(1);

        for(let i=1;i<=n;i++) {
            for(let j=i-1;j>=1;j--) {
                if(i % j=== 0) {
                    let index = i / j;
                    if(a[j] < a[i]) {
                        dp[i] = Math.max(dp[i], dp[index] + 1);
                        break;
                    }
                }
            }
        }
        console.log(Math.max(...dp));
    }

}

'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++];
}
/**
    4
    4
    5 3 4 6
    7
    1 4 2 3 6 4 9
    5
    5 4 3 2 1
    1
    9

**/

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

    for(let r=0;r<range;r++) {
        let n = parseInt(readline());
        let a = readline().split(" ").map(Number);
        a.unshift(1);
        const dp = new Array(n+1).fill(1);

        for(let i=1;i<=n;i++) {
            for(let j=i;j<=n;j++) {
                if(j % i=== 0) {
                    if(a[i] < a[j]) {
                        let index = j / i;
                        dp[j] = Math.max(dp[j], dp[index] + 1)
                    }
                }
            }
        }
        console.log(Math.max(...dp));
    }

}

'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++];
}
/**
    4
    4
    5 3 4 6
    7
    1 4 2 3 6 4 9
    5
    5 4 3 2 1
    1
    9

**/

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

    for(let r=0;r<range;r++) {
        let n = parseInt(readline());
        let a = readline().split(" ").map(Number);
        a.unshift(1);
        const dp = new Array(n+1).fill(1);

        for(let i=1;i<=n;i++) {
            for(let j=i;j<=n;j++) {
                if(j % i=== 0 && j > i) {
                    if(a[i] < a[j]) {
                        let index = j / i;
                        dp[j] = Math.max(dp[j], dp[index] + 1)
                    }
                }
            }
        }
        console.log(Math.max(...dp));
    }

}

'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++];
}
/**
  3
5 1
8 2
3 4

**/

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

    for(let r=0;r<range;r++) {
        let len = parseInt(readline());
        let values = readline().split(" ").map(Number);

        let divisble = [];
        let found = 0;

        for(let i=0;i<len - 1;i++) {
            for(let j=i+1;j<len;j++) {
                if(values[j] > values[i] && (values[j] % values[i] === 0)) {
                    divisble.push(values[i], values[j]);
                    i++;
                    j++;
                }
            }
        }

        if(divisble.length === 0) {
            console.log(1);
            continue;
        }

        let max = Math.max(...divisble);
        let newValue = [];

        for(let i=0;i<max;i++) {
            if(max % divisble[i] === 0) {
                newValue.push(divisble[i]);
            }
        }

        console.log(newValue.length);
    }

}


(function() {
var INPUT = ``;
var OUTPUT = ``;

var main = function() {"use strict";
    // TODO
    var t = rdN();
    loop:while (t --> 0) {
        //pr(t)
        var input = rdArN();
        var n = input[0];
        var m = input[1];
        var k = input[2];
        var H = [null].concat(rdArN());

        for (var i = 1; i < n; ++i) {
            var curH = H[i];
            var nxtH = H[i+1];

            var curH_ = Math.max(nxtH - k, 0);
            if (curH < curH_) {
                m -= curH_ - curH;
                if (m < 0) {
                    pr('NO');
                    continue loop;
                }
            } else {
                m += curH - curH_;
            }
        }

        pr('YES');
    }
};

if(INPUT){INPUT=INPUT.split('\n').reverse();
readline=()=>INPUT.pop();
write=(...s)=>{OUTPUT+=[...s].join(' ')};
print=(...s)=>{write(...s);OUTPUT+='\n'};}
const
rdS=readline,
rdN=()=>+rdS(),
rdArS=()=>rdS().split(' '),
rdArN=()=>rdArS().map(v=>+v),
wr=write,
pr=print,
prAr=(a)=>pr(...a),
prOb=(o)=>pr(JSON.stringify(o,null,4)),
crAr=function(length,...fillArgs){return new Array(length).fill(...fillArgs);},
getPrimes=function(n){var sieve=crAr(n+1,true),primes=[],i,j;for(i=2,j=4;j<sieve.length;j=Math.pow(++i,2)){if(sieve[j]){for(;j<sieve.length;j+=i){sieve[j]=false;}}}for(i=2;i<sieve.length;++i){if(sieve[i]){primes.push(i);}}return primes;},
getPrimeFactors=function(n){var primes=getPrimes(Math.floor(Math.sqrt(n))),last=primes.push(n)-1,factors=[],i,p;for(i=0,p=primes[0];primes[last]>1;){if(primes[last]%p===0){primes[last]/=p;factors.push(p);}else{p=primes[++i];}}return factors;},
defineProperty=(o,pN,v)=>Object.defineProperty(o,pN,{value:v,writable:true,enumerable:false,configurable:true});
defineProperty(Array.prototype,'sortLt',function(){return this.sort((a,b)=>a-b);});
defineProperty(Array.prototype,'sortGt',function(){return this.sort((a,b)=>b-a);});

main();
return OUTPUT;
})();

const processData = (lines) => {
  const [countTests, ...tests] = lines

  const checkTest = (countRows, cubs, countToNext, rows) => {
    for (let i = 0; i < countRows - 1; i++) {
      cubs += Math.min(rows[i] - rows[i + 1] + countToNext, rows[i])
      if (cubs < 0) return 'NO'
    }
    return 'YES'
  }

  for (let j = 0; j < Number(countTests); j++) {
    const [countRows, cubs, countToNext] = tests[2 * j].split(' ').map(n => Number(n))
    const rows = tests[2 * j + 1].split(' ').map(n => Number(n))
    console.log(checkTest(countRows, cubs, countToNext, rows))
  }
}

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

const processData = (lines) => {
  const [countTests, ...tests] = lines

  const checkTest = (countRows, cubs, countToNext, rows) => {
    for (let i = 0; i < countRows - 1; i++) {
      cubs += rows[i] - rows[i + 1] + countToNext
      if (cubs < 0) return 'NO'
    }
    return 'YES'
  }

  for (let j = 0; j < Number(countTests); j++) {
    const [countRows, cubs, countToNext] = tests[2 * j].split(' ').map(n => Number(n))
    const rows = tests[2 * j + 1].split(' ').map(n => Number(n))
    console.log(checkTest(countRows, cubs, countToNext, rows))
  }
}

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


//↓見なくていいよ！ここから--------------------------------------------------
var read = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});
var obj;
var inLine = [];
read.on('line', function(input){inLine.push(input);});
read.on('close', function(){
  obj = init(inLine);
  myerr("-----start-----");
  var start = new Date();
  Main();
  var end = new Date() - start;
  myerr("----- end -----");
  myerr("time : " + (end) + "ms");
  myerr("memory : " + Math.round(process.memoryUsage().heapTotal / 1024) + "KB");
});
function nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}
function nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}
function next(){return obj.next();} function hasNext(){return obj.hasNext();}
function init(input){
  var returnObj = {
    list : input, index : 0, max : input.length,
    hasNext : function(){return (this.index < this.max);},
    next : function(){if(!this.hasNext()){throw "ArrayIndexOutOfBoundsException これ以上ないよ";}else{var returnInput = this.list[this.index];this.index++;return returnInput;}}
  };
  return returnObj;
}
function myout(s){console.log(s);}
function myerr(s){console.error("debug:" + require("util").inspect(s,false,null));}
//[no]要素の扱い。数値型
//不明値、異常時:引数そのまま返す 1:数値へ変換
//2:半角SPで分割 4:半角SPで分割し、数値配列へ
//6:1文字で分割  7:1文字で分割し、数値配列へ
//8:半角SPで結合 9:改行で結合 0:文字なしで結合
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map(Number);case 6:return i.split("");case 7:return i.split("").map(Number);case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}catch(e){return i;}}

//↑見なくていいよ！ここまで--------------------------------------------------
function Main(){
	var N = nextInt();
	var alist = nextIntArray();
	var blist = nextIntArray();
	var aIndexes = {};
	for(var i = 0; i < N; i++){
		aIndexes[alist[i]] = i;
	}
	var moveCountRight = {};//右に向かうと一致するのに必要な移動数
	var moveCountLeft = {};//左に向かうと〃
	for(var i = 0; i < N; i++){
		if(aIndexes[blist[i]] > i){
			moveCountRight[blist[i]] = aIndexes[blist[i]] - i;
			moveCountLeft[blist[i]] = i + (N - aIndexes[blist[i]]);
		}else if(aIndexes[blist[i]] < i){
			moveCountRight[blist[i]] = (N - i) + aIndexes[blist[i]];
			moveCountLeft[blist[i]] = i - aIndexes[blist[i]];;
		}else{
			moveCountRight[blist[i]] = 0;
			moveCountLeft[blist[i]] = 0;
		}
	}

	var max = 0;
	var count = {};
	var keys = Object.keys(moveCountRight);
	for(var i = 0; i < keys.length; i++){
		if(count[moveCountRight[keys[i]]] == null){
			count[moveCountRight[keys[i]]] = 1;
		}else{
			count[moveCountRight[keys[i]]]++;
		}
		max = Math.max(max, count[moveCountRight[keys[i]]]);
	}
	myout(max);
}

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

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

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

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

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

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

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

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

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

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

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

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

function main() {
  const n = rc.readInt()
  const a = rc.readInts()
  const b = rc.readInts()

  const x = new Array(n + 1)

  for(let i = 0; i < n; i++) {
    let a1 = a[i]
    let b1 = b[i]
    if(!x[a1]) x[a1] = new Array(4)
    if(!x[b1]) x[b1] = new Array(4)
    x[a1][0] = i
    x[b1][1] = i
  }

  // wr(x)

  for(let i = 0; i < n; i++) {
    let a1 = a[i]
    let diff1 = (x[a1][0] - (x[a1][1] + n)) % n

    x[a1][2] = diff1
  }

  // wr(x)
  let map1 = {}
  for(let i = 1; i <= n; i++) {
    let x1 = x[i][2]
    if(!map1[x1]) map1[x1] = 0
    map1[x1]++
  }
  let m1 = Object.entries(map1).map(a => a[1])
  wr(Math.max(...m1))
}

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

    C();
});

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

function pi(a) {
    return parseInt(a);
}

function ti(a){
    for(let i = 0; i < a.length; i++)
        a[i] = pi(a[i]);

    return a;
}

function C(){
    let n = pi(readline());
    let a = ti(readline().split(' '));
    let b = ti(readline().split(' '));

    let map = new Array(300000);
    for(let i = 0; i < a.length; i++){
        map[a[i]] = i;
    }

    let max = 0;
    let countMap = new Array(300000);

    for(let j = 0; j < b.length; j++){
        let i = map[b[j]];
        if(i-j < 0){
            countMap[n-j+i] = countMap[n-j+i] ? countMap[n-j+i]+1 : 1;
            max = Math.max(max, countMap[n-j+i]);
        }else{
            countMap[i-j] = countMap[i-j] ? countMap[i-j]+1 : 1;
            max = Math.max(max, countMap[i-j]);
        }
    }

    console.log(max);
}

'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++];
}
/**
5
4
10 20 20 30
0 1 0 1
3
3 1 2
0 1 1
4
2 2 4 8
1 1 1 1
3
5 15 4
0 0 0
4
20 10 100 50
1 0 0 1

**/

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

    return gcd(b, a % b);
};

function main() {
    let n = parseInt(readline());
    let a = readline().split(" ").map(Number);
    let b = readline().split(" ").map(Number);

    let offset = [];
    let map = {};

    for(let i=0;i<n;i++) {
        offset[a[i]] = i;
    }

    for(let i=0;i<n;i++) {
        let cur = offset[b[i]] - i;
        if(cur < 0) {
            cur += n;
        }

        if(map[cur]) {
            map[cur]++;
        } else {
            map[cur] = 1;
        }
    }

    let ans = 0;
    Object.keys(map).forEach((x) => {
        ans = Math.max(ans, map[x]);
    });

    console.log(ans);
}

// var lineIdx = 0;
// var readline = () => {
//   var input = ["4", "4 2 3 1", "4 2 3 1"]
//   return input[lineIdx++];
// };
// var print = (str) => {
//   console.log(str);
// };

var n = readline().split(" ").map(function(x) { return parseInt(x); })[0];
var sub = new Array(n);
var res = new Array(n);
for(var i = 0; i < n; i++){
  res[i] = 0;
}

var first = readline().split(" ").map(function(x) { return parseInt(x); }).forEach((x, i) => sub[x - 1] = i);
var second = readline().split(" ").map(function(x) { return parseInt(x); }).forEach((x, i) => {
   sub[x - 1] = sub[x - 1] - i >= 0 ? sub[x - 1] - i : n + sub[x - 1] - i;
   res[sub[x - 1]] = res[sub[x - 1]] + 1;
});

print(res.reduce((p, c) => Math.max(p, c), 0));

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

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

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

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

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

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

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

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

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

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

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

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

function main() {
  const n = rc.readInt()
  const a = rc.readInts()
  const b = rc.readInts()

  const x = new Array(n + 1)

  for(let i = 0; i < n; i++) {
    let a1 = a[i]
    let b1 = b[i]
    if(!x[a1]) x[a1] = new Array(4)
    if(!x[b1]) x[b1] = new Array(4)
    x[a1][0] = i
    x[b1][1] = i
  }

  // wr(x)

  for(let i = 0; i < n; i++) {
    let a1 = a[i]
    let diff1 = x[a1][0] - x[a1][1]
    let diff2 = diff1
    if(x[a1][0] === 0 && x[a1][1] !== 0) {
      diff2 = diff1 + n
    }

    x[a1][2] = diff1
    x[a1][3] = diff2
  }

  // wr(x)
  let map1 = {}
  let map2 = {}
  for(let i = 1; i <= n; i++) {
    let x1 = x[i][2]
    let x2 = x[i][3]
    if(!map1[x1]) map1[x1] = 0
    if(!map2[x2]) map2[x2] = 0
    map1[x1]++
    map2[x2]++
  }
  let m1 = Object.entries(map1).map(a => a[1])
  let m2 = Object.entries(map2).map(a => a[1])
  wr(Math.max(...m1, ...m2))
}

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

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

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

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

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

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

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

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

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

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

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

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

function main() {
  const n = rc.readInt()
  const a = rc.readInts()
  const b = rc.readInts()

  const x = new Array(n + 1)

  for(let i = 0; i < n; i++) {
    let a1 = a[i]
    let b1 = b[i]
    if(!x[a1]) x[a1] = new Array(4)
    if(!x[b1]) x[b1] = new Array(4)
    x[a1][0] = i
    x[b1][1] = i
  }

  // wr(x)

  for(let i = 0; i < n; i++) {
    let a1 = a[i]
    let diff1 = x[a1][0] - x[a1][1]
    let diff2 = diff1
    if(x[a1][0] === 0 && x[a1][1] !== 0) {
      diff2 = diff1 + n
    }
    if(x[a1][0] === n - 1 && x[a1][1] !== n - 1) {
      diff1 = -1 - x[a1][1]
    }

    x[a1][2] = diff1
    x[a1][3] = diff2
  }

  // wr(x)
  let map1 = {}
  let map2 = {}
  for(let i = 1; i <= n; i++) {
    let x1 = x[i][2]
    let x2 = x[i][3]
    if(!map1[x1]) map1[x1] = 0
    if(!map2[x2]) map2[x2] = 0
    map1[x1]++
    map2[x2]++
  }
  let m1 = Object.entries(map1).map(a => a[1])
  let m2 = Object.entries(map2).map(a => a[1])
  wr(Math.max(...m1, ...m2))
}

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

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

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

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

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

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

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

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

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

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

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

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

function main() {
  const n = rc.readInt()
  const a = rc.readInts()
  const b = rc.readInts()

  const x = new Array(n + 1)

  for(let i = 0; i < n; i++) {
    let a1 = a[i]
    let b1 = b[i]
    if(!x[a1]) x[a1] = new Array(4)
    if(!x[b1]) x[b1] = new Array(4)
    x[a1][0] = i
    x[b1][1] = i
  }

  // wr(x)

  for(let i = 0; i < n; i++) {
    let a1 = a[i]
    let diff1 = x[a1][0] - x[a1][1]
    let diff2 = diff1
    if(x[a1][0] === 0 && x[a1][1] !== 0) {
      diff2 = diff1 + n
    }
    if(x[a1][0] === n - 1 && x[a1][1] !== n - 1) {
      diff1 = -1 - x[a1][1]
    }

    x[a1][2] = diff1
    x[a1][3] = diff2
  }

  wr(x)
  let map1 = {}
  let map2 = {}
  for(let i = 1; i <= n; i++) {
    let x1 = x[i][2]
    let x2 = x[i][3]
    if(!map1[x1]) map1[x1] = 0
    if(!map2[x2]) map2[x2] = 0
    map1[x1]++
    map2[x2]++
  }
  let m1 = Object.entries(map1).map(a => a[1])
  let m2 = Object.entries(map2).map(a => a[1])
  wr(Math.max(...m1, ...m2))
}

'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++];
}
/**
5
5 1 2 3 4
1 2 3 4 5

**/

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

    return gcd(b, a % b);
};

function main() {
    //let range = parseInt(readline());

    //for(let r=0;r<range;r++) {
        let n = parseInt(readline());
        let a = readline().split(" ").map(Number);
        let b = readline().split(" ").map(Number);
        let combination = 0;
        for(let i=0;i<n-1;i++) {
            if(a[i] + 1 === b[i]) {
                combination++;
            }
        }

        if(a[0] === b[n-1]) {
            combination++;
        }

        let combinationX = 0;
        if(a[0] === b[n-1]) {
            combinationX++;
        }

        for(let i=1;i<n;i++) {
            if(a[i] === b[i] - 1) {
                combinationX++;
            }
        }

        console.log(Math.max(combination, combinationX));
    //}
}

'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++];
}
/**
5
5 1 2 3 4
1 2 3 4 5

**/

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

    return gcd(b, a % b);
};

function main() {
    //let range = parseInt(readline());

    //for(let r=0;r<range;r++) {
        let n = parseInt(readline());
        let a = readline().split(" ").map(Number);
        let b = readline().split(" ").map(Number);

        b.unshift(b[n-1]);
        let combination = 0;
        for(let i=0;i<b.length;i++) {
            if(a[i] === b[i]) {
                combination++;
            }
        }

        b.shift();

        b.push(b[0]);
        let combinationX = 0;

        for(let i=0;i<b.length;i++) {
            if(a[i] === b[i]) {
                combinationX++;
            }
        }

        console.log(Math.max(combination, combinationX));
    //}
}

'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++];
}
/**
5
5 1 2 3 4
1 2 3 4 5

**/

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

    return gcd(b, a % b);
};

function main() {
    //let range = parseInt(readline());

    //for(let r=0;r<range;r++) {
        let n = parseInt(readline());
        let a = readline().split(" ").map(Number);
        let b = readline().split(" ").map(Number);
        let combination = 0;
        for(let i=0;i<n-1;i++) {
            if(a[i] + 1 === b[i]) {
                combination++;
            }
        }

        if(a[n-1] === n && b[n-1] === 1) {
            combination++;
        }

        let combinationY = 0;
        for(let i=0;i<n-1;i++) {
            if(a[i]  === b[i] + 1) {
                combinationY++;
            }
        }

        if(a[n-1] === 1 && b[n-1] === n) {
            combinationY++;
        }

        combination = Math.max(combination, combinationY);

        let combinationX = 0;
        if(a[0] === n && b[0] === 1) {
            combinationX++;
        }

        for(let i=1;i<n;i++) {
            if(a[i] === b[i] - 1) {
                combinationX++;
            }
        }

        combinationY = 0;
        if(b[0] === n && a[0] === 1) {
            combinationY++;
        }

        for(let i=1;i<n;i++) {
            if(a[i] - 1 === b[i]) {
                combinationY++;
            }
        }

        console.log(Math.max(combination, combinationX, combinationY));
    //}
}

// var lineIdx = 0;
// var readline = () => {
//   var input = ["4", "4 2 3 1", "4 2 3 1"]
//   return input[lineIdx++];
// };
// var print = (str) => {
//   console.log(str);
// };

var n = readline().split(" ").map(function(x) { return parseInt(x); })[0];
var sub = new Array(n);
var res = new Array(n);
for(var i = 0; i < n; i++){
  res[i] = 0;
}

var first = readline().split(" ").map(function(x) { return parseInt(x); }).forEach((x, i) => sub[x - 1] = i);
var second = readline().split(" ").map(function(x) { return parseInt(x); }).forEach((x, i) => {
   sub[x - 1] = sub[x - 1] - i >= 0 ? sub[x - 1] - i : n + sub[x - 1] - i;
   res[sub[x - 1]] = res[sub[x - 1]] + 1;
});

print(res.reduce((p, c) => Math.max(p, c), 0) % n);


var ABn = readline().split(' ');
var A = Number(ABn[0]),
	B = Number(ABn[1]),
	n = Number(ABn[2]);

for (var i = 0; i < n; i++) {
	var line = readline().split(' ');
	var l = Number(line[0]),
		t = Number(line[1]),
		m = Number(line[2]);
	var heightAtL = A + (l - 1) * B;

	//1
	if (heightAtL > t) {
		print(-1);
		continue;
	}

	//binary search, check heightAtR and
	var MAX = 100000000;
	var low = l, high = MAX, mid, r = -1;

	while (low <= high) {
		mid = (low + high) >> 1;
		var heightAtR = A + (mid - 1) * B;
		if (heightAtR > t) {
			high = mid - 1;
			continue;
		}
		var sum = (mid - l + 1) * heightAtL + (mid - l)* (mid - l + 1) / 2 * B;
		if (sum > t * m) {
			high = mid - 1;
			continue;
		}
		low = mid + 1;
		r = mid;
	}
	print (r);

}

/* jslint node: true */
function Sum(a1, d, n) {
  return ((a1+a1+(n-1)*d)*n)/2;
}

var input = readline().split(" ").map(Number);
var a1, d, n;
var first = true;
var
  a1 = input[0];
  d = input[1];
  n = input[2];
while( n-- ) {
  input = readline().split(" ").map(Number);
  var
    l = input[0],
    t = input[1],
    m = input[2],
    suml = Sum(a1, d, l-1),
    tm = t*m,
    st = l,
    ed = ( ~~((t-a1)/d) ) + 1,
    md, ans;
  if( st>ed || a1+(l-1)*d>tm ) {
    ans = -1;
  } else {
    while( st<=ed ) {
      md = (st+ed)>>1;
      if( Sum(a1, d, md)-suml<=tm ) {
        ans = md;
        st = md+1;
      } else {
        ed = md-1;
      }
    }
  }
  print(ans);
}

/* jslint node: true */
"use strict";
function Sum(a1, d, n) {
  return ((a1+a1+(n-1)*d)*n) >> 1;
}

var input = readline().split(' ').map(Number);
var a1, d, n;
var first = true;
var
  a1 = input[0];
  d = input[1];
  n = input[2];
while( n-- ) {
  input = readline().split(' ').map(Number);
  var
    l = input[0],
    t = input[1],
    m = input[2],
    suml = Sum(a1, d, l-1),
    tm = t*m,
    st = l,
    ed = ( ((t-a1)/d) | 0 ) + 1,
    md, ans;
  if( st>ed || a1+(l-1)*d>tm ) {
    ans = -1;
  } else {
    while( st<=ed ) {
      md = (st+ed)>>1;
      if( Sum(a1, d, md)-suml<=tm ) {
        ans = md;
        st = md+1;
      } else {
        ed = md-1;
      }
    }
  }
  print(ans);
}

/* jslint node: true */
function Sum(a1, d, n) {
  return ((a1+a1+(n-1)*d)*n)/2;
}

var input = readline().split(" ").map(Number);
var a1, d, n;
var first = true;
var
  a1 = input[0];
  d = input[1];
  n = input[2];
while( n-- ) {
  input = readline().split(" ").map(Number);
  var
    l = input[0],
    t = input[1],
    m = input[2],
    suml = Sum(a1, d, l-1),
    tm = t*m,
    st = l,
    ed = ( ~~((t-a1)/d) ) + 1,
    md, ans;
  print(l, t, m, suml, tm, st, ed);
  if( st>ed || a1+(l-1)*d>tm ) {
    ans = -1;
  } else {
    while( st<=ed ) {
      md = (st+ed)>>1;
      if( Sum(a1, d, md)-suml<=tm ) {
        ans = md;
        st = md+1;
      } else {
        ed = md-1;
      }
    }
  }
  print(ans);
}


if (process.env.ANT)
{
    global.print = this.print || function(){console.log([...arguments].join(' '))} || require('lol-io').print
    global.write = this.write || require('lol-io').write
    global.readline = this.readline || require('lol-io').readline
    global.debug = function(){console.log('debug:', [...arguments].join(' '))}
    main();
}
else
{
    const rl = require('readline').createInterface({ input: process.stdin, output: process.stdout })
    global.print = console.log
    global.write = (...args) => {
        process.stdout.write(args.join(' '));
    }
    const lines = []
    rl.on('line', line =>{
        lines.push(line);
    });
    rl.on('close', main)
    let rli = 0;
    global.readline = ()=>lines[rli++];
    global.debug = ()=>{};
}

///////////// CODE

function t(n, arr){
    let ans = 0;
    let min = arr[n-1];
    for (let i = n-2; i>=0; i--)
    {
        if (arr[i]>min)
            ans++;
        else
            min = arr[i];
    }
    return ans;
}

function main(){

var q = +readline();
while (q--)
    print(t(+readline(), readline().split(' ').map(n=>+n)));

}

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

while(t--) {
    var n = parseInt(readline(), 10);
    var a = readline().split(' ');
    var min = parseInt(a[n-1], 10), count = 0;

    for(var i=n-1; i>=0; i--) {
        a[i] = parseInt(a[i], 10);

        if(a[i] > min) count++;
        else if(a[i] < min) min = a[i];
    }

    print(count);
}

(function() {
var INPUT = ``;
var OUTPUT = ``;

var main = function() {"use strict";
    // TODO
    var t = rdN();
    while (t --> 0) {
        var res = 0;

        var n = rdN();
        var A = rdArN();
        var min = A[n-1];
        for (var i = n-2; i >= 0; --i) {
            if (A[i] > min) {
                ++res;
            }
            min = Math.min(min, A[i]);
        }

        pr(res);
    }
};

if(INPUT){INPUT=INPUT.split('\n').reverse();
readline=()=>INPUT.pop();
write=(...s)=>{OUTPUT+=[...s].join(' ')};
print=(...s)=>{write(...s);OUTPUT+='\n'};}
const
rdS=readline,
rdN=()=>+rdS(),
rdArS=()=>rdS().split(' '),
rdArN=()=>rdArS().map(v=>+v),
wr=write,
pr=print,
prAr=(a)=>pr(...a),
prOb=(o)=>pr(JSON.stringify(o,null,4)),
crAr=function(length,...fillArgs){return new Array(length).fill(...fillArgs);},
getPrimes=function(n){var sieve=crAr(n+1,true),primes=[],i,j;for(i=2,j=4;j<sieve.length;j=Math.pow(++i,2)){if(sieve[j]){for(;j<sieve.length;j+=i){sieve[j]=false;}}}for(i=2;i<sieve.length;++i){if(sieve[i]){primes.push(i);}}return primes;},
getPrimeFactors=function(n){var primes=getPrimes(Math.floor(Math.sqrt(n))),last=primes.push(n)-1,factors=[],i,p;for(i=0,p=primes[0];primes[last]>1;){if(primes[last]%p===0){primes[last]/=p;factors.push(p);}else{p=primes[++i];}}return factors;},
defineProperty=(o,pN,v)=>Object.defineProperty(o,pN,{value:v,writable:true,enumerable:false,configurable:true});
defineProperty(Array.prototype,'sortLt',function(){return this.sort((a,b)=>a-b);});
defineProperty(Array.prototype,'sortGt',function(){return this.sort((a,b)=>b-a);});

main();
return OUTPUT;
})();

let lines = ''

process.stdin.resume()
process.stdin.setEncoding('utf-8')
process.stdin.on('data', input => lines += input)
process.stdin.on('end', () => {
  const { EOL } = require('os')
  lines = lines.split(EOL)

  main()
})

function main() {
  const t = Number(lines[0])

  for(let i = 0; i < t; i++) {
    const a = lines[2 * i + 2].split(' ')
    const prev = []
    let r = 0

    a.forEach((b, j) => {
      const c = Number(b)

      if(j === 0) prev.push(c)
      else {
        r = check(prev, c, r)
      }
    })

    console.log(r)
  }
}

function check(arr, v, count) {
  const last = _last(arr)

  if(last <= v || !arr.length) {
    arr.push(v)
    return count
  }
  else {
    arr.pop()
    return check(arr, v, count + 1)
  }
}

function _last(arr) {
  return arr[arr.length - 1]
}

let i = '';
process.stdin.on('data', (c) => {
  i += c;
});
process.stdin.on('end', () => {
  const { EOL } = require('os');
  const lines = i.split(EOL);
  let start = 2;
  while (start < lines.length) {
    let prices = lines[start].split(' ');
    prices = prices.map(price => parseInt(price, 10));
    badPrices(prices);
    start += 2;
  }
});

function badPrices(prices) {
  if (prices.length === 1) {
    console.log('0');
    return;
  }
  let min = prices[prices.length - 1];
  let badDays = 0;
  for (let i = prices.length - 2; i >= 0; i--) {
    if (prices[i] > min) badDays++;
    else min = prices[i];
  }
  console.log(badDays);
}

'use strict'

const fn = (n, a) => {
    let m = a[n-1];
    let r = 0;
    for(let i = n-2; i > -1; i--) {
        if (a[i] > m) r++;
        else m = a[i];
    }
    return r;
}

let t = parseInt(readline());
while(t--) write(fn(parseInt(readline()), readline().split(' ').map(Number)) + '\n');


/**
 * https://codeforces.com/problemset/problem/723/D
 */

'use strict';
const readline = require('readline');
const fs = require('fs');

const rl = readline.createInterface({
    input: process.stdin,
    // input: fs.createReadStream('src/LECTURE 06: DFS/0.input1.json'),
    output: process.stdout,
    terminal: false,
});

const lines = [];
let currentLine = 0;

const direction = [
    { x: 1, y: 0 },
    { x: -1, y: 0 },
    { x: 0, y: 1 },
    { x: 0, y: -1 },
];
/**
 * Time complexity:
 * Space complexity:
 */
rl.on('line', function (line) {
    lines.push(line.trim());
}).on('close', () => {
    const read = () => lines[currentLine++];
    let [rows, columns, k] = read().split(' ').map(Number);

    const isInRange = ({ x, y }) => x >= 0 && y >= 0 && x <= rows - 1 && y <= columns - 1;
    const isOnBorder = ({ x, y }) => [0, rows - 1].indexOf(x) > -1 || [0, columns - 1].indexOf(y) > -1;

    let visited = {};
    let matrix = [];
    let lakes = [];
    for (let row = 0; row < rows; row++) {
        matrix.push(read().split(''));
    }
    for (let row = 1; row < rows - 1; row++) {
        for (let col = 1; col < columns - 1; col++) {
            let key = `${row}-${col}`;
            if (matrix[row][col] !== '.' || visited[key]) {
                continue;
            }

            let stack = [{ x: row, y: col }],
                isLake = true,
                lake = [{ x: row, y: col }];

            visited[key] = true;

            while (stack.length > 0) {
                let node = stack.pop();

                for (let d of direction) {
                    let [x, y] = [node.x + d.x, node.y + d.y];
                    let dKey = `${x}-${y}`;
                    if (!visited[dKey] && isInRange({ x, y }) && matrix[x][y] === '.') {
                        visited[dKey] = true;
                        stack.push({ x, y });
                        lake.push({ x, y });

                        if (isOnBorder({ x, y })) {
                            isLake = false;
                        }
                    }
                }
            }
            if (isLake) {
                lakes.push(lake);
            }
        }
    }

    lakes.sort((a, b) => a.length - b.length);
    let count = 0;
    for (let i = lakes.length; i > k; i--) {
        let lake = lakes.shift();
        count += lake.length;
        lake.forEach(({ x, y }) => (matrix[x][y] = '*'));
    }
    console.log(count);
    console.log(matrix.map((row) => row.join('')).join('\n'));
});

var arr = readline().split(' ');
var M = Number(arr[0]);
var N = Number(arr[1]);
var K = Number(arr[2]);
var rs = 0;

var rect = [];
for (var i = 0;i < M;i ++) {
	var _str = readline().split(' ')[0];
	rect[i] = _str.split('');
}

var obj_arr = [];

for (var i = 0;i < M;i ++) {
	var _str = rect[i];
	for (var j = 0;j < N;j ++) {
		if (_str[j] == '.') {
			var area = helper(i, j);
			if (area > 0) {
				obj_arr.push({
					start_x: i,
					start_y: j,
					area: area
				});
			}
		}
	}
}

if (obj_arr.length > K) {
	for (var i = 0;i < obj_arr.length;i ++) {
		for (var j = i + 1;j < obj_arr.length;j ++) {
			if (obj_arr[i].area > obj_arr[j].area) {
				var tmp = obj_arr[i];
				obj_arr[i] = obj_arr[j];
				obj_arr[j] = tmp;
			}
		}
	}
	var index = 0;
	var tmp = obj_arr.length - K;
	while (tmp) {
		var obj = obj_arr[index];
		fill(obj.start_x, obj.start_y);
		index ++;
		tmp--;
	}
}

for (var i = 0;i < M;i ++) {
	for (var j = 0;j < N;j ++) {
		if (rect[i][j] == '&') {
			rect[i][j] = '.';
		}
	}
}

print(rs);

for (var i = 0;i < M;i ++) {
	var _str = "";
	for (var j = 0;j < N;j++) {
		_str += rect[i][j];
	}
	print(_str);
}

function helper(_x, _y) {
	if (_x < 0 || _y < 0 || _x >= M  || _y >= N) {
		return -1;
	}
	if (rect[_x][_y] != '.') {
		return 0;
	}
	rect[_x][_y] = '&';
	var area1 = helper(_x - 1, _y);
	var area2 = helper(_x + 1, _y);
	var area3 = helper(_x, _y - 1);
	var area4 = helper(_x, _y + 1);
	if (area1 < 0 || area2 < 0 || area3 < 0 || area4 < 0) {
		return -1;
	}
	return  area1 + area2 + area3 + area4 + 1;
}

function fill (_x, _y) {
	if (_x < 0 || _y < 0 || _x >= M  || _y >= N) {
		return;
	}
	if (rect[_x][_y] == '&') {
		rs ++;
		rect[_x][_y] = '*';
		fill(_x - 1, _y);
		fill(_x + 1, _y);
		fill(_x, _y - 1);
		fill(_x, _y + 1);
	}
}

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

const direction = [
  [0, 1],
  [0, -1],
  [1, 0],
  [-1, 0],
];

// Make a Snippet for the code above this and then write your logic in main()
function main() {
  const [n, m, k] = readline().split(' ').map(Number);
  const isOcean = (row, col) =>
    row === 0 || row === n - 1 || col === 0 || col === m - 1;
  const isInRange = (row, col) =>
    row >= 0 && row <= n - 1 && col >= 0 && col <= m - 1;
  let matrix = new Array(n);
  for (let i = 0; i < n; i++) {
    matrix[i] = readline().split('');
  }

  let visited = {};
  let lakes = [];

  for (let i = 0; i < n; i++) {
    for (let j = 0; j < m; j++) {
      if (matrix[i][j] === '.' && !visited[`${i}-${j}`]) {
        let stack = [[i, j]];
        visited[`${i}-${j}`] = true;
        let lake = [];
        let isLake = true;
        while (stack.length) {
          const [row, col] = stack.pop();

          lake.push([row, col]);
          if (isOcean(row, col)) isLake = false;
          for (let k = 0; k < direction.length; k++) {
            const x = row + direction[k][0];
            const y = col + direction[k][1];
            if (
              isInRange(x, y) &&
              matrix[x][y] === '.' &&
              !visited[`${x}-${y}`]
            ) {
              stack.push([x, y]);
              visited[`${x}-${y}`] = true;
            }
          }
        }

        if (isLake) {
          lakes.push(lake);
        }
      }
    }
  }
  lakes.sort((l1, l2) => l2.length - l1.length);
  let cnt = 0;

  lakes.forEach((lake, i) => {
    if (i >= k) {
      // transform
      lake.forEach(([i, j]) => {
        matrix[i][j] = '*';
        cnt++;
      });
    }
  });
  console.log(cnt);
  for (let i = 0; i < n; i++) {
    console.log(matrix[i].join(''));
  }
}

'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 [n, m, k] = readline().split(' ').map(Number);
  const isOcean = (row, col) =>
    row === 0 || row === n - 1 || col === 0 || col === m - 1;
  let matrix = new Array(n);
  for (let i = 0; i < n; i++) {
    matrix[i] = readline().split('');
  }

  let visited = {};
  let lakes = [];

  for (let i = 0; i < n; i++) {
    for (let j = 0; j < m; j++) {
      if (matrix[i][j] === '.' && !visited[`${i}-${j}`]) {
        let stack = [[i, j]];
        visited[`${i}-${j}`] = true;
        let lake = [];
        let isLake = true;
        while (stack.length) {
          const [row, col] = stack.pop();

          lake.push([row, col]);
          if (isOcean(row, col)) isLake = false;
          if (
            row > 0 &&
            matrix[row - 1][col] === '.' &&
            !visited[`${row - 1}-${col}`]
          ) {
            stack.push([row - 1, col]);
            visited[`${row - 1}-${col}`] = true;
          }
          if (
            row < n - 1 &&
            matrix[row + 1][col] === '.' &&
            !visited[`${row + 1}-${col}`]
          ) {
            stack.push([row + 1, col]);
            visited[`${row + 1}-${col}`] = true;
          }
          if (
            col > 0 &&
            matrix[row][col - 1] === '.' &&
            !visited[`${row}-${col - 1}`]
          ) {
            stack.push([row, col - 1]);
            visited[`${row}-${col - 1}`] = true;
          }
          if (
            col < m - 1 &&
            matrix[row][col + 1] === '.' &&
            !visited[`${row}-${col + 1}`]
          ) {
            stack.push([row, col + 1]);
            visited[`${row}-${col + 1}`] = true;
          }
        }

        if (isLake) {
          lakes.push(lake);
        }
      }
    }
  }
  lakes.sort((l1, l2) => l2.length - l1.length);
  let cnt = 0;

  lakes.forEach((lake, i) => {
    if (i >= k) {
      // transform
      lake.forEach(([i, j]) => {
        matrix[i][j] = '*';
        cnt++;
      });
    }
  });
  console.log(cnt);
  for (let i = 0; i < n; i++) {
    console.log(matrix[i].join(''));
  }
}

var arr = readline().split(' ');
var M = Number(arr[0]);
var N = Number(arr[1]);
var K = Number(arr[2]);
var rs = 0;

var rect = [];
for (var i = 0;i < M;i ++) {
	var _str = readline().split(' ')[0];
	rect[i] = _str.split('');
}

var obj_arr = [];

for (var i = 0;i < M;i ++) {
	var _str = rect[i];
	for (var j = 0;j < N;j ++) {
		if (_str[j] == '.') {
			var area = helper(i, j);
			if (area > 0) {
				obj_arr.push({
					start_x: i,
					start_y: j,
					area: area
				});
			}
		}
	}
}

if (obj_arr.length > K) {
	for (var i = 0;i < obj_arr.length;i ++) {
		for (var j = i + 1;j < obj_arr.length;j ++) {
			if (obj_arr[i].area > obj_arr[j].area) {
				var tmp = obj_arr[i];
				obj_arr[i] = obj_arr[j];
				obj_arr[j] = tmp;
			}
		}
	}
	var index = 0;
	var tmp = obj_arr.length - K;
	while (tmp) {
		var obj = obj_arr[index];
		fill(obj.start_x, obj.start_y);
		index ++;
		tmp--;
	}
}

for (var i = 0;i < M;i ++) {
	for (var j = 0;j < N;j ++) {
		if (rect[i][j] == '&') {
			rect[i][j] = '.';
		}
	}
}

print(rs);

for (var i = 0;i < M;i ++) {
	var _str = "";
	for (var j = 0;j < N;j++) {
		_str += rect[i][j];
	}
	print(_str);
}

function helper(_x, _y) {
	if (_x < 0 || _y < 0 || _x >= M  || _y >= N) {
		return -1;
	}
	if (rect[_x][_y] != '.') {
		return 0;
	}
	rect[_x][_y] = '&';
	var area1 = helper(_x - 1, _y);
	var area2 = helper(_x + 1, _y);
	var area3 = helper(_x, _y - 1);
	var area4 = helper(_x, _y + 1);
	if (area1 < 0 || area2 < 0 || area3 < 0 || area4 < 0) {
		return -1;
	}
	return  area1 + area2 + area3 + area4 + 1;
}

function fill (_x, _y) {
	if (_x < 0 || _y < 0 || _x >= M  || _y >= N) {
		return;
	}
	if (rect[_x][_y] == '&') {
		rect[_x][_y] = '*';
		fill(_x - 1, _y);
		fill(_x + 1, _y);
		fill(_x, _y - 1);
		fill(_x, _y + 1);
	}
}

/**
 * https://codeforces.com/problemset/problem/723/D
 */

'use strict';
const readline = require('readline');
const fs = require('fs');

const rl = readline.createInterface({
    input: process.stdin,
    // input: fs.createReadStream('src/LECTURE 06: DFS/0.input1.json'),
    output: process.stdout,
    terminal: false,
});

const lines = [];
let currentLine = 0;

const direction = [
    { x: 1, y: 0 },
    { x: -1, y: 0 },
    { x: 0, y: 1 },
    { x: 0, y: -1 },
];
/**
 * Time complexity:
 * Space complexity:
 */
rl.on('line', function (line) {
    lines.push(line.trim());
}).on('close', () => {
    const read = () => lines[currentLine++];
    let [m, n, k] = read().split(' ').map(Number);

    const isInRange = ({ x, y }) => x >= 0 && y >= 0 && x <= m - 1 && y <= n - 1;

    let parentVisited = {};
    let matrix = [];
    let lakes = [];
    for (let row = 0; row < m; row++) {
        matrix.push(read().split(''));
    }
    for (let row = 1; row < m - 1; row++) {
        for (let col = 1; col < n - 1; col++) {
            let rect = matrix[row][col];
            let key = `${row}-${col}`;
            if (rect !== '.' || parentVisited[key]) {
                continue;
            }
            let visited = { [key]: true },
                stack = [{ x: row, y: col }];

            let isLake = true;
            let lake = [{ x: row, y: col }];
            while (stack.length > 0) {
                let node = stack.pop();

                for (let d of direction) {
                    let x = node.x + d.x,
                        y = node.y + d.y;
                    let dKey = `${x}-${y}`;
                    if (!visited[dKey] && isInRange({ x, y }) && matrix[x][y] === '.') {
                        visited[dKey] = true;
                        parentVisited[dKey] = true;
                        stack.push({ x, y });
                        lake.push({ x, y });

                        if ([0, m - 1].indexOf(x) > -1 || [0, n - 1].indexOf(y) > -1) {
                            isLake = false;
                        }
                    }
                }
            }
            if (isLake) {
                lakes.push(lake);
            }
        }
    }

    lakes.sort((a, b) => a.length - b.length);
    let count = 0;
    for (let i = lakes.length; i > k; i--) {
        let lake = lakes.shift();
        count++;
        lake.forEach(({ x, y }) => (matrix[x][y] = '*'));
    }
    console.log(count);
    console.log(matrix.map((row) => row.join('')).join('\n'));
});

/**
 * https://codeforces.com/problemset/problem/723/D
 */

'use strict';
const readline = require('readline');
const fs = require('fs');

const rl = readline.createInterface({
    input: process.stdin,
    // input: fs.createReadStream('src/LECTURE 06: DFS/0.input1.json'),
    output: process.stdout,
    terminal: false,
});

const lines = [];
let currentLine = 0;

const direction = [
    { x: 1, y: 0 },
    { x: -1, y: 0 },
    { x: 0, y: 1 },
    { x: 0, y: -1 },
];
/**
 * Time complexity:
 * Space complexity:
 */
rl.on('line', function (line) {
    lines.push(line.trim());
}).on('close', () => {
    const read = () => lines[currentLine++];
    let [rows, columns, k] = read().split(' ').map(Number);

    const isInRange = ({ x, y }) => x >= 0 && y >= 0 && x <= rows - 1 && y <= columns - 1;
    const isOnBorder = ({ x, y }) =>
        [0, rows - 1].indexOf(x) > -1 || [0, columns - 1].indexOf(y) > -1;

    let visited = {};
    let matrix = [];
    let lakes = [];
    for (let row = 0; row < rows; row++) {
        matrix.push(read().split(''));
    }
    for (let row = 1; row < rows - 1; row++) {
        for (let col = 1; col < columns - 1; col++) {
            let key = `${row}-${col}`;
            if (matrix[row][col] !== '.' || visited[key]) {
                continue;
            }

            let stack = [{ x: row, y: col }],
                isLake = true,
                lake = [];

            visited = { [key]: true };

            while (stack.length > 0) {
                let node = stack.pop();
                lake.push(node);

                if (isOnBorder(node)) {
                    isLake = false;
                }

                for (let d of direction) {
                    let [x, y] = [node.x + d.x, node.y + d.y];
                    let dKey = `${x}-${y}`;
                    if (!visited[dKey] && isInRange({ x, y }) && matrix[x][y] === '.') {
                        visited[dKey] = true;
                        stack.push({ x, y });
                    }
                }
            }
            if (isLake) {
                lakes.push(lake);
            }
        }
    }

    lakes.sort((a, b) => a.length - b.length);
    let count = 0;
    for (let i = 0; i < lakes.length - k; i++) {
        let lake = lakes[i];
        count += lake.length;
        lake.forEach(({ x, y }) => (matrix[x][y] = '*'));
    }
    console.log(count);
    console.log(matrix.map((row) => row.join('')).join('\n'));
});

/**
 * https://codeforces.com/problemset/problem/723/D
 */

'use strict';
const readline = require('readline');
const fs = require('fs');

const rl = readline.createInterface({
    input: process.stdin,
    // input: fs.createReadStream('src/LECTURE 06: DFS/0.input1.json'),
    output: process.stdout,
    terminal: false,
});

const lines = [];
let currentLine = 0;

const direction = [
    { x: 1, y: 0 },
    { x: -1, y: 0 },
    { x: 0, y: 1 },
    { x: 0, y: -1 },
];
/**
 * Time complexity:
 * Space complexity:
 */
rl.on('line', function (line) {
    lines.push(line.trim());
}).on('close', () => {
    const read = () => lines[currentLine++];
    let [rows, columns, k] = read().split(' ').map(Number);

    const isInRange = ({ x, y }) => x >= 0 && y >= 0 && x <= rows - 1 && y <= columns - 1;
    const isOnBorder = ({ x, y }) =>
        [0, rows - 1].indexOf(x) > -1 || [0, columns - 1].indexOf(y) > -1;

    let visited = {};
    let matrix = [];
    let lakes = [];
    for (let row = 0; row < rows; row++) {
        matrix.push(read().split(''));
    }
    for (let row = 1; row < rows - 1; row++) {
        for (let col = 1; col < columns - 1; col++) {
            let key = `${row}-${col}`;
            if (matrix[row][col] !== '.' || visited[key]) {
                continue;
            }

            let stack = [{ x: row, y: col }],
                isLake = true,
                lake = [{ x: row, y: col }];

            visited = { [key]: true };

            while (stack.length > 0) {
                let node = stack.pop();

                for (let d of direction) {
                    let [x, y] = [node.x + d.x, node.y + d.y];
                    let dKey = `${x}-${y}`;
                    if (!visited[dKey] && isInRange({ x, y }) && matrix[x][y] === '.') {
                        visited[dKey] = true;
                        stack.push({ x, y });
                        lake.push({ x, y });

                        if (isOnBorder({ x, y })) {
                            isLake = false;
                        }
                    }
                }
            }
            if (isLake) {
                lakes.push(lake);
            }
        }
    }

    lakes.sort((a, b) => a.length - b.length);
    let count = 0;
    for (let i = lakes.length; i > k; i--) {
        let lake = lakes.shift();
        count += lake.length;
        lake.forEach(({ x, y }) => (matrix[x][y] = '*'));
    }
    console.log(count);
    console.log(matrix.map((row) => row.join('')).join('\n'));
});

/**
 * https://codeforces.com/problemset/problem/723/D
 */

'use strict';
const readline = require('readline');
const fs = require('fs');

const rl = readline.createInterface({
    input: process.stdin,
    // input: fs.createReadStream('src/LECTURE 06: DFS/0.input1.json'),
    output: process.stdout,
    terminal: false,
});

const lines = [];
let currentLine = 0;

const direction = [
    { x: 1, y: 0 },
    { x: -1, y: 0 },
    { x: 0, y: 1 },
    { x: 0, y: -1 },
];
/**
 * Time complexity:
 * Space complexity:
 */
rl.on('line', function (line) {
    lines.push(line.trim());
}).on('close', () => {
    const read = () => lines[currentLine++];
    let [m, n, k] = read().split(' ').map(Number);

    const isInRange = ({ x, y }) => x >= 0 && y >= 0 && x <= m - 1 && y <= n - 1;
    const isOnBorder = ({ x, y }) => [0, m - 1].indexOf(x) > -1 || [0, n - 1].indexOf(y) > -1;

    let visited = {};
    let matrix = [];
    let lakes = [];
    for (let row = 0; row < m; row++) {
        matrix.push(read().split(''));
    }
    for (let row = 1; row < m - 1; row++) {
        for (let col = 1; col < n - 1; col++) {
            let rect = matrix[row][col],
                key = `${row}-${col}`;
            if (rect !== '.' || visited[key]) {
                continue;
            }

            let stack = [{ x: row, y: col }],
                isLake = true,
                lake = [{ x: row, y: col }];

            visited = { [key]: true };

            while (stack.length > 0) {
                let node = stack.pop();

                for (let d of direction) {
                    let [x, y] = [node.x + d.x, node.y + d.y];
                    let dKey = `${x}-${y}`;
                    if (!visited[dKey] && isInRange({ x, y }) && matrix[x][y] === '.') {
                        visited[dKey] = true;
                        stack.push({ x, y });
                        lake.push({ x, y });

                        if (isOnBorder({ x, y })) {
                            isLake = false;
                        }
                    }
                }
            }
            if (isLake) {
                lakes.push(lake);
            }
        }
    }

    lakes.sort((a, b) => a.length - b.length);
    let count = 0;
    for (let i = lakes.length; i > k; i--) {
        let lake = lakes.shift();
        count += lake.length;
        lake.forEach(({ x, y }) => (matrix[x][y] = '*'));
    }
    console.log(count);
    console.log(matrix.map((row) => row.join('')).join('\n'));
});

/**
 * https://codeforces.com/problemset/problem/723/D
 */

'use strict';
const readline = require('readline');
const fs = require('fs');

const rl = readline.createInterface({
    input: process.stdin,
    // input: fs.createReadStream('src/LECTURE 06: DFS/0.input1.json'),
    output: process.stdout,
    terminal: false,
});

const lines = [];
let currentLine = 0;

const direction = [
    { x: 1, y: 0 },
    { x: -1, y: 0 },
    { x: 0, y: 1 },
    { x: 0, y: -1 },
];
/**
 * Time complexity:
 * Space complexity:
 */
rl.on('line', function (line) {
    lines.push(line.trim());
}).on('close', () => {
    const read = () => lines[currentLine++];
    let [m, n, k] = read().split(' ').map(Number);

    const isInRange = ({ x, y }) => x >= 0 && y >= 0 && x <= m - 1 && y <= n - 1;
    const isOnBorder = ({ x, y }) => [0, m - 1].indexOf(x) > -1 || [0, n - 1].indexOf(y) > -1;

    let visited = {};
    let matrix = [];
    let lakes = [];
    for (let row = 0; row < m; row++) {
        matrix.push(read().split(''));
    }
    for (let row = 1; row < m - 1; row++) {
        for (let col = 1; col < n - 1; col++) {
            let rect = matrix[row][col],
                key = `${row}-${col}`;
            if (rect !== '.' || visited[key]) {
                continue;
            }

            let stack = [{ x: row, y: col }],
                isLake = true,
                lake = [{ x: row, y: col }];

            visited = { [key]: true };

            while (stack.length > 0) {
                let node = stack.pop();

                for (let d of direction) {
                    let [x, y] = [node.x + d.x, node.y + d.y];
                    let dKey = `${x}-${y}`;
                    if (!visited[dKey] && isInRange({ x, y }) && matrix[x][y] === '.') {
                        visited[dKey] = true;
                        stack.push({ x, y });
                        lake.push({ x, y });

                        if (isOnBorder({ x, y })) {
                            isLake = false;
                        }
                    }
                }
            }
            if (isLake) {
                lakes.push(lake);
            }
        }
    }

    lakes.sort((a, b) => a.length - b.length);
    console.log(lakes.length);
    let count = 0;
    for (let i = lakes.length; i > k; i--) {
        let lake = lakes.shift();
        count += lake.length;
        lake.forEach(({ x, y }) => (matrix[x][y] = '*'));
    }
    console.log(count);
    console.log(matrix.map((row) => row.join('')).join('\n'));
});

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

const direction = [
  [0, 1],
  [0, -1],
  [1, 0],
  [-1, 0],
];

// Make a Snippet for the code above this and then write your logic in main()
function main() {
  const [n, m, k] = readline().split(' ').map(Number);
  const isOcean = (row, col) =>
    row === 0 || row === n - 1 || col === 0 || col === m - 1;
  const isInRange = (row, col) =>
    row >= 0 && row <= n - 1 && col >= 0 && col <= m - 1;
  let matrix = new Array(n);
  for (let i = 0; i < n; i++) {
    matrix[i] = readline().split('');
  }

  let visited = {};
  let lakes = [];

  for (let i = 0; i < n; i++) {
    for (let j = 0; j < m; j++) {
      if (matrix[i][j] === '.' && !visited[`${i}-${j}`]) {
        let stack = [[i, j]];
        visited[`${i}-${j}`] = true;
        let lake = [];
        let isLake = true;
        while (stack.length) {
          const [row, col] = stack.pop();

          lake.push([row, col]);
          if (isOcean(row, col)) isLake = false;
          for (let k = 0; k < direction.length; k++) {
            const x = row + direction[k][0];
            const y = col + direction[k][1];
            if (
              isInRange(x, y) &&
              matrix[x][y] === '.' &&
              !visited[`${x}-${y}`]
            ) {
              stack.push([x, y]);
              visited[`${x}-${y}`] = true;
            }
          }
        }

        if (isLake) {
          lakes.push(lake);
        }
      }
    }
  }
  console.log(lakes);
  lakes.sort((l1, l2) => l2.length - l1.length);
  let cnt = 0;

  lakes.forEach((lake, i) => {
    if (i >= k) {
      // transform
      lake.forEach(([i, j]) => {
        matrix[i][j] = '*';
        cnt++;
      });
    }
  });
  console.log(cnt);
  for (let i = 0; i < n; i++) {
    console.log(matrix[i].join(''));
  }
}

'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 [n, m, k] = readline().split(' ').map(Number);
  const isOcean = (x, y) => x === 0 || x === n - 1 || y === 0 || y === m - 1;
  let matrix = new Array(n);
  for (let i = 0; i < n; i++) {
    matrix[i] = readline().split('');
  }

  let visited = {};
  let lakes = [];

  for (let i = 0; i < n; i++) {
    for (let j = 0; j < m; j++) {
      if (matrix[i][j] === '.' && !visited[`${i}-${j}`]) {
        let stack = [[i, j]];
        let lake = [];
        let isLake = true;
        while (stack.length) {
          const [row, col] = stack.pop();
          visited[`${row}-${col}`] = true;
          lake.push([row, col]);
          if (isOcean(row, col)) isLake = false;
          if (
            row > 0 &&
            matrix[row - 1][col] === '.' &&
            !visited[`${row - 1}-${col}`]
          )
            stack.push([row - 1, col]);
          if (
            row < n - 1 &&
            matrix[row + 1][col] === '.' &&
            !visited[`${row + 1}-${col}`]
          )
            stack.push([row + 1, col]);
          if (
            col > 0 &&
            matrix[row][col - 1] === '.' &&
            !visited[`${row}-${col - 1}`]
          )
            stack.push([row, col - 1]);
          if (
            col < m - 1 &&
            matrix[row][col + 1] === '.' &&
            !visited[`${row}-${col + 1}`]
          )
            stack.push([row, col + 1]);
        }

        if (isLake) {
          lakes.push(lake);
        }
      }
    }
  }

  lakes.sort((l1, l2) => l2.length - l1.length);
  let cnt = 0;

  lakes.forEach((lake, i) => {
    if (i >= k) {
      // transform
      lake.forEach(([i, j]) => {
        matrix[i][j] = '*';
        cnt++;
      });
    }
  });
  console.log(cnt);
  for (let i = 0; i < n; i++) {
    console.log(matrix[i].join(''));
  }
}

'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 [n, m, k] = readline().split(' ').map(Number);
  const isOcean = (x, y) => x === 0 || x === n - 1 || y === 0 || y === m - 1;
  let matrix = new Array(n);
  for (let i = 0; i < n; i++) {
    matrix[i] = readline().split('');
  }

  let visited = {};
  let lakes = [];

  for (let i = 0; i < n; i++) {
    for (let j = 0; j < m; j++) {
      if (matrix[i][j] === '.' && !visited[`${i}-${j}`]) {
        let stack = [[i, j]];
        let lake = [];
        let isLake = true;
        while (stack.length) {
          const [row, col] = stack.pop();
          visited[`${row}-${col}`] = true;
          lake.push([row, col]);
          if (isOcean(row, col)) isLake = false;
          if (
            row > 0 &&
            matrix[row - 1][col] === '.' &&
            !visited[`${row - 1}-${col}`]
          )
            stack.push([row - 1, col]);
          if (
            row < n - 1 &&
            matrix[row + 1][col] === '.' &&
            !visited[`${row + 1}-${col}`]
          )
            stack.push([row + 1, col]);
          if (
            col > 0 &&
            matrix[row][col - 1] === '.' &&
            !visited[`${row}-${col - 1}`]
          )
            stack.push([row, col - 1]);
          if (
            col < m - 1 &&
            matrix[row][col + 1] === '.' &&
            !visited[`${row}-${col + 1}`]
          )
            stack.push([row, col + 1]);
        }

        if (isLake) {
          lakes.push(lake);
        }
      }
    }
  }

  lakes.sort((l1, l2) => l2.length - l1.length);
  let cnt = 0;

  lakes.forEach((lake, i) => {
    if (i >= k) {
      // transform
      cnt++;
      lake.forEach(([i, j]) => {
        matrix[i][j] = '*';
      });
    }
  });
  console.log(cnt);
  for (let i = 0; i < n; i++) {
    console.log(matrix[i].join(''));
  }
}


;(function () {

	var s = readline().replace(/^0*/, '');
	var ns = s.replace(/0/, '');
	print( ns.length != s.length ? ns : s.replace(/1/, '') );

}).call(this);

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 main() {
  const str = readLine();
  let found = false;
  let res = "";

  for (let i = 0; i < str.length; i++) {
    const char = str[i];
    if (char === "0" && !found) {
      found = true;
      continue;
    }
    res += char;
  }

  if (!found) console.log(res.slice(0, -1));
  else console.log(res);
}

function main(){

var num = readline();
var length = num.length;

var zloc=-1;

for(i=0;i<length;i++){
    if(num[i]==='0'){
	zloc=i;
	break;
    }
}

if(zloc===-1){
    print(num.slice(1,length));
    return;
}

print(num.slice(0,zloc)+num.slice(zloc+1,length));

}

main();

if (!this.readline) print = console.log, readline = require('./readline');

function readNums() {
	return readline().split(' ').map(Number);
}

var a = readline().split('');
var ans = [];
var f = false;
for (var i = 0; i < a.length; i++) {
	if (!f && a[i] === '0') {
		f = true;
	} else {
		ans.push(a[i]);
	}
}
if (!f) {
	ans.pop();
}
print(ans.join(''));

;(function () {

	print( readline().replace(/^0*/, '').replace(/0/, '') );

}).call(this);


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];
    var n = 0;
    for(i = 1; i <= t * 2; i++){
        if(i % 2 == 1){
            n = lines[i];
        }else{
            var a = lines[i].split(' ').map(Number);
            var m = new Map();
            var h = [];
            for(j = 0; j < n; j++){
                if(m.get(a[j]) === 0){
                    m.set(a[j], 1);
                }else{
                    var temp = m.get(a[j]);
                    temp++;
                    m.set(a[j], temp);
                }
            }
            for(j = 1; j <= n; j++){
                if(j <= m.size){
                    h.push(m.size);
                }else{
                    var x = h[h.length - 1];
                    h.push(x + 1);
                }
            }
            var ans = '';
            for(j = 0; j < h.length; j++){
                ans += h[j] + ' ';
            }
            console.log(ans);
        }
    }
});

'use strict';

function solve(n, a) {
  const size = new Set(a).size;
  const res = new Array(n);
  for (let i = 0; i < size; i++) {
    res[i] = size;
  }
  for (let i = size; i < n; i++) {
    var _res;
    res[i] = ((_res = res[i - 1]) !== null && _res !== void 0 ? _res : 0) + 1;
  }
  return res.join(' ');
}

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

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

'use strict';
const { throws } = require('assert');

 /*jslint node:true, browser:true, es6:true*/
const print = console.log
const E = {};
const lines = []
if (!process.env.JEST_WORKER_ID){
  const rl = require('readline').createInterface({ input: process.stdin, output: process.stdout })
  rl.on('line', line => {
      lines.push(line);
  });
  rl.on('close', main)
}
let rli = 0;
function readline() {
    return lines[rli++];
}
const l = process.env.DEBUG ? console.log : ()=>{};

module.exports = E;

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

const MOD = 1e9+7;

const calc = (n, arr)=>{
  let ans = [];
  arr.sort((a,b)=>a-b);
  let cnt = new Map();
  for (let i=0; i<n; i++){
    cnt.set(arr[i], (cnt.get(arr[i])||0)+1);
  }
  let ded = 0;
  for (let [k, v] of cnt){
    ded += v-1;
  }
  //l(arr, ded, cnt)
  let nn = n;
  for (let i=0; i<n; i++){
    ans.push(nn);
    if (--ded>=0)
      nn--;
  }
  l('ans')
  return ans.reverse();
};

function main() {
    let T = +readline()
    while (T--){
      let n = +readline()
      let arr = ra();
      print(calc(n, arr).join(' '));
    }
}

E.calc = calc;

var t = readline();

for (var i = 0; i < t; i++) {
  var n = readline();
  var k = readline().split(' ').map(Number);
  var len = Array.from(new Set(k)).length;
  var res = k.map((el, i) => Math.max(i + 1, len)).join(' ');
  print(res);
}

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

let inputString = '';

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

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

    main(inputString);
});

function log(message){
    if(process.env.NODE_ENV === "debug"){
        console.log(message);
    }
}

function main(fileContents) {//input lines as an array
    // console.log(fileContents);
    fileContents.splice(0,1);

    for(let i = 0; i < fileContents.length; i+=2){
        const setDiff = new Set()
        const powerUps = fileContents[i+1]
        // console.log("powerUps",powerUps)
        const splitPow = powerUps.split(" ")

        splitPow.forEach(type => {
            if(!setDiff.has(type)) {
                setDiff.add(type)
            }
        })

        let output = []

        for(let k = 1; k <= splitPow.length; k++){
            const add = k <= setDiff.size ? setDiff.size : k
            output.push(add)

        }

        console.log(output.join(" "))
    }

}

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

let inputString = '';

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

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

    main(inputString);
});

function log(message){
    if(process.env.NODE_ENV === "debug"){
        console.log(message);
    }
}

function main(fileContents) {//input lines as an array
    // console.log(fileContents);
    fileContents.splice(0,1);

    for(let i = 0; i < fileContents.length; i+=2){
        const setDiff = new Set()
        const powerUps = fileContents[i+1]
        console.log("powerUps",powerUps)
        powerUps.split(" ").forEach(type => {
            setDiff.add(type)
        })

        let output = ""

        for(let k = 1; k <= powerUps.split(" ").length; k++){
            const add = k <= setDiff.size ? setDiff.size : k
            output+=add
            if(powerUps.length != k){
                output+=" "
            }

        }

        console.log(output)
    }

}


const readline = require('readline')

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

function solve(n, arr, qs) {
    const gs = Array(1001).fill(0).map(() => [])
    arr.forEach(([h, w]) => {
        gs[h].push(w)
    })
    for (let i = 0; i < gs.length; i++) {
        gs[i].sort((a, b) => a - b)
        const sum = []
        if (gs[i].length) {
            sum[0] = gs[i][0]
            for (let j = 1; j < gs[i].length; j++) {
                sum[j] = sum[j - 1] + gs[i][j]
            }
        }
        gs[i].sum = sum
    }
    // console.log(gs[999])
    const query = []
    qs.forEach(([hs, ws, hb, wb], i) => {
        query.push([hs, -1, i])
        query.push([hb - 1, 1, i])
    })
    // console.log(query)
    const ans = Array(qs.length).fill(0)
    const F = Array(1e3 + 5).fill(0) // a little larger in case
    let hnow = 0
    query.sort((a, b) => a[0] - b[0])
        .forEach(([h, d, i]) => {
        while (hnow < h) {
            hnow++
            gs[hnow].forEach(w => {
                inc(F, w, w * hnow)
            })
        }
        // console.log(hnow)
        const [hs, ws, hb, wb] = qs[i]
        if (wb - 1 > ws) {
            ans[i] += d * (sum(F, wb - 1) - sum(F, ws))
        }
        // console.log(ans[i], F.slice(0, 6), sum(F, wb - 1), sum(F, ws))
    })
    return ans.join('\n')
}
function inc(F, idx, val) {
    for (; idx < F.length; idx |= idx + 1) {
        F[idx] += val
    }
}
function sum(F, idx) {
    let s = 0
    for (; idx >= 0; idx = (idx & (idx + 1)) - 1) {
        s += F[idx]
    }
    return s
}

var t = parseInt(readline());

for (var test = 0; test < t; test++) {
    var inp = readline().split(' ');
    var n = inp[0];
    var q = inp [1];

    var matr = [];
    for (var i = 0; i < 1001; i++) {
        matr.push(new Array(1001).fill(0));
    }

    for (var i = 0; i < n; i++) {
        var rect = readline().split(' ');
        matr[rect[0]][rect[1]] += rect[0] * rect[1];
    }

    var s = matr;
    for (var i = 1; i < 1001; i++) {
        for (var j = 1; j < 1001; j++) {
            s[i][j] = s[i-1][j] + s[i][j-1] - s[i-1][j-1] + s[i][j];
        }
    }

    for (var i = 0; i < q; i++) {
        var query = readline().split(' ');
        var hs = query[0] - (-1);
        var ws = query[1] - (-1);
        var hb = query[2] - 1;
        var wb = query[3] - 1;

        if (hs > hb || ws > wb) {
            print(0);
        } else {
            var ans = s[hb][wb] - s[hs-1][wb] - s[hb][ws-1] + s[hs-1][ws-1];

            print(ans);
        }
    }
}

const readline = require('readline')

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

function solve(n, arr, qs) {
    const gs = Array(1001).fill(0).map(() => [])
    arr.forEach(([h, w]) => {
        gs[h].push(w)
    })
    for (let i = 0; i < gs.length; i++) {
        gs[i].sort((a, b) => a - b)
        const sum = []
        if (gs[i].length) {
            sum[0] = gs[i][0]
            for (let j = 1; j < gs[i].length; j++) {
                sum[j] = sum[j - 1] + gs[i][j]
            }
        }
        gs[i].sum = sum
    }
    // console.log(gs[999])
    return qs.map(([hs, ws, hb, wb]) => {
        let r = 0
        for (let h = hs + 1; h < hb; h++) {
            if (!gs[h].length) continue
            const i = binarySearch(0, gs[h].length - 1, x => {
                return !(ws < gs[h][x])
            }) + 1
            const j = binarySearch(0, gs[h].length - 1, x => {
                return gs[h][x] < wb
            })
            // r += j - i + 1
            // console.log(i, j, gs[h])
            r += h * range(gs[h].sum, i, j)
        }
        return r
    }).join('\n')
    //
    function range(sum, i, j) {
        return sum[j] - (sum[i - 1] || 0)
    }
}
function binarySearch(l, r, fn) {
    while (l <= r) {
        const m = Math.floor((l + r) / 2)
        if (fn(m)) {
            l = m + 1
        } else {
            r = m - 1
        }
    }
    return r
}


s=readline().split(' ')
n=+s[0]
x=+s[1]
sum=0
a=readline().split(' ').map(function(q){sum+=+q;})
if (sum+n==x+1)
{
    print("YES")
}
else
{
    print("NO")
}

var n_x =readline().split(' ');
var sum=0;
readline().split(' ').map(q=>sum+=Number(q));
print(sum+Number(n_x[0])-1==Number(n_x[1])?"Yes":"No");

var n_x =readline().split(' ');
var sum=0;
readline().split(' ').map(q=>sum+=(q));
print(sum+(n_x[0])-1==(n_x[1])?"Yes":"No");


function trim(s) {
	return s.replace(/^\s+|\s+$/gm, '');
}

function tokenize(s) {
	return trim(s).split(/\s+/);
}

function tokenizeIntegers(s) {
	var tokens = tokenize(s);
	for (var i = 0; i < tokens.length; i += 1) {
		tokens[i] = parseInt(tokens[i]);
	};
	return tokens;
}

function main() {
	var pointNum = parseInt(readline());
	var xLine = [], yLine = [];
	for (var i = 0; i < 101; ++i) {
		xLine.push(0);
		yLine.push(0);
	}

	for (var i = 0; i < pointNum; ++i) {
		var point = tokenizeIntegers(readline());
		var x = point[0], y = point[1];
		xLine[x] = 1;
		yLine[y] = 1;
	}

	var xSum = 0, ySum = 0;
	for (var i = 0; i < 101; ++i) {
		xSum += xLine[i];
		ySum += yLine[i];
	}
	print(Math.min(xSum, ySum));
}

main();

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

let count = 0;
let linesCount = 0;
const lines = [];
rl.on('line', (line) => {
    if (count != linesCount - 1) {
        if (linesCount == 0) {
            linesCount = parseInt(line);
        } else {
            lines.push(line.split(' '));
            count++;
        }
    } else {
        lines.push(line.split(' '));
        const linesData = {
            x: [],
            y: []
        }
        for (let i = 0; i < lines.length; i++) {
            if (linesData.x.indexOf(lines[i][0]) == -1) linesData.x.push(lines[i][0])
            if (linesData.y.indexOf(lines[i][1]) == -1) linesData.y.push(lines[i][1])
        }
        console.log(linesData.x.length >= linesData.y.length ? linesData.y.length : linesData.x.length);
    }
})

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

let count = 0;
let linesCount = 0;
const lines = [];
rl.on('line', (line) => {
    if (count != linesCount - 1) {
        if (linesCount == 0) {
            linesCount = parseInt(line);
        } else {
            lines.push(line.split(' '));
            count++;
        }
    } else {
        lines.push(line.split(' '));
        const xes = [];
        const ys = [];
        for (let i = 0; i < lines.length; i++) {
            if (xes.indexOf(lines[i][0]) == -1) xes.push(lines[i][0])
            if (ys.indexOf(lines[i][1]) == -1) ys.push(lines[i][1])
        }
        console.log(xes.length >= ys.length ? ys.length : xes.length);
    }
})