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*/
    let cases = parseInt(lines[0])
    //const splitLines = lines.map(x => x.split(" ").map(x => parseInt(x)))
    for (let i = 1; i <= cases; i ++)
    {
        let a = lines[i].split(" ").map(x => parseInt(x))
        let n = a[0];
        let k = a[1];
        switch (k % 4)
        {
            case 0:
                console.log("NO");
                break;
            case 1:
            case 3:
                console.log("YES")
                for (let i = 1; i <= n; i +=2)
                {
                    console.log(i + " " + (i + 1))
                }
                break;
            case 2:
                console.log("YES")
                for (let i = 1; i <= n; i += 2)
                {
                    if (i % 4 == 1)
                    {
                        console.log((i + 1) + " " + i)
                    }
                    else{
                        console.log(i + " " + (i + 1))
                    }
                }
        }
    }
})

const fs = require("fs");

const input = fs.readFileSync(0, "utf8").trim().split("\n");

const testCases = [];
let T;

function parseInput() {
  T = parseInt(input[0]);
  let index = 0;

  for (let i = 0; i < T; i++) {
    index++;
    const [n, k] = input[index].split(" ").map((item) => parseInt(item));
    const testCase = {
      n,
      k,
    };

    testCases.push(testCase);
  }
}

function solution(testCase) {
  const { n, k } = testCase;
  // console.log(n, k);

  if (k % 4 == 0) console.log("NO");
  else {
    console.log("YES");
    const a2 = (4 - (k % 4)) % 4;
    const b1 = 4;
    const s = new Set([1, 2, 3]);
    s.delete(a2);
    const a1 = Array.from(s)[0];
    const b2 = Array.from(s)[1];

    // console.error(a1, b1, a2, b2);

    for (let i = 0; i < Math.floor(n / 4); i++) {
      console.log(
        i * 4 + a1,
        i * 4 + b1
        // ((i * 4 + a1 + k) * (i * 4 + b1)) % 4
      );
      console.log(
        i * 4 + a2,
        i * 4 + b2
        // ((i * 4 + a2 + k) * (i * 4 + b2)) % 4
      );
    }
    if (n % 4 == 2) {
      if (k % 4 == 2)
        console.log(
          n,
          n - 1
          // ((n + k) * (n - 1)) % 4
        );
      else
        console.log(
          n - 1,
          n
          // ((n - 1 + k) * n) % 4
        );
    }
  }
}

parseInput();

testCases.forEach(solution);

'use strict';

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

let inputString = '';
let currentLine = 0;

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

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

    main();
});

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

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

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

    for (let test = 0; test < N; test++) {
        const [n, k] = readline().split(' ').map(Number);

        if (k % 2 === 1) {
            output('YES');
            for (let i = 0; i < (n / 2); i++) {
                let first = i * 2 + 1;
                let second = first + 1;
                output(first + ' ' + second);
            }
            continue;
        } else if (k % 4 === 0) {
            output('NO');
        } else if (k % 4 === 2) {
            let start = 4;
            output('YES');
            let temp = n;
            while (start <= n) {
                output((start - 1) + ' ' + start);
                output((start - 2) + ' ' + (start - 3));
                start += 4;
                temp -= 4;
            }
            if (temp === 2) {
                output((start - 2) + ' ' + (start  - 3));
            }
        }
    }
}

const readline = require('readline')

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

function solve(n, k) {
    // (a + k) * b = 4x
    const h = n / 2
    const ans = []
    if (k & 1) {
        // (odd + k) * even
        for (let i = 1; i < n; i += 2) {
            ans.push([i, i + 1])
        }
    } else {
        const r = k % 4
        if (!r) return 'NO'
        // 4n, 4n - k, with odd
        const ps = [[], [], [], [], []]
        let i = 1
        while (i <= n) {
            for (let j = 1; j <= 4; j++) {
                ps[j].push(i++)
                if (i > n) break
            }
        }
        ps[0] = ps[4] // hack
        let p0 = 0
        let p1 = 0, ps1 = ps[4 - r]
        for (let i = 1; i < n; i += 2) {
            if (p0 < ps[0].length) {
                ans.push([i, ps[0][p0++]])
            } else {
                ans.push([ps1[p1++], i])
            }
        }
    // console.log(ps, ans)
    //     const other = ps[r]
    //     for (let i = 0; i < other.length; i += 2) {
    //         ans.push([other[i], other[i + 1]])
    //     }
    }
    return 'YES\n' + ans.map(x => x.join(' ')).join('\n')
}

'use strict';

function solve(a) {
  const [n, m] = a;
  if (m & 1) {
    const res = ['YES'];
    for (let i = 1; i <= n; i += 2) {
      res.push(`${i} ${i + 1}`);
    }
    return res.join('\n');
  } else if (m % 4 === 2) {
    let res = ['YES'];
    for (let i = 1; i <= n; i += 2) {
      if ((i + 1) / 2 & 1) {
        res.push(`${i + 1} ${i}`);
      } else {
        res.push(`${i} ${i + 1}`);
      }
    }
    return res.join('\n');
  }
  return 'NO';
}

async function main(r) {
  const rns = async () => {
    return (await r()).split(' ').filter(s => s !== '').map(Number);
  };
  try {
    let t = Number(await r());
    let res = new Array(t);
    for (let i = 0; i < t; i++) {
      const a = await rns();
      res[i] = solve(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);
});

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

/***
Codeforces Round #814 (Div. 2)
2022-08-16

A. Chip Game
***/

function main() {
  const t = parseInt(readline());

  for (let i = 0; i < t; i++) {
    const testCase = readline().split(" ");
    const n = parseInt(testCase[0]);
    const k = parseInt(testCase[1]);

    // k is odd -> pair 1-2, 3-4
    // k is 2 (mod 4) -> pair 2-1, 3-4
    switch (k % 4) {
      case 1:
      case 3:
        console.log("YES");
        for (let startNum = 1; startNum < n; startNum += 2) {
          console.log(startNum + " " + (startNum + 1));
        }
        break;
      case 2:
        console.log("YES");
        for (let startNumB = 3; startNumB < n; startNumB += 4) {
          console.log(startNumB + " " + (startNumB + 1));
        }
        for (let startNumA = 2; startNumA <= n; startNumA += 4) {
          console.log(startNumA + " " + (startNumA - 1));
        }
        break;
      case 0:
        console.log("NO");
        break;
      default:
        console.log(
          "Something went wrong: " +
            k +
            " is in none of the mod 4 residue classes"
        );
        break;
    }
  }
}

var n, k;
    var tests = parseInt(readline());
    for (var t=0; t<tests;t++) {
        var nk = readline().split(' ').map(x=>parseInt(x));
        n = nk[0];
        k = nk[1];
        if (k % 4 == 0) {
            print('NO');
            continue;
        }
        print('YES');
        if (k & 1) {
            for (var i = 1; i <= n; i+=2) {
                print(i + ' ' + (i+1));
            }
        } else {
            for (var i = 2; i <= n; i+=2) {
                if (i % 4 == 0) {
                    print((i-1) + ' ' + i);
                } else {
                    print(i + ' ' + (i-1));
                }
            }
        }
    }

const fs = require("fs");

const input = fs.readFileSync(0, "utf8").trim().split("\n");

const testCases = [];
let T;

function parseInput() {
  T = parseInt(input[0]);
  let index = 0;

  for (let i = 0; i < T; i++) {
    index++;
    const [n, k] = input[index].split(" ").map((item) => parseInt(item));
    const testCase = {
      n,
      k,
    };

    testCases.push(testCase);
  }
}

function solution(testCase) {
  const { n, k } = testCase;
  // console.log(n, k);

  if (k % 4 == 0 || (k % 4 == 2 && n % 4 == 2)) console.log("NO");
  else {
    console.log("YES");
    const a2 = (4 - (k % 4)) % 4;
    const b1 = 4;
    const s = new Set([1, 2, 3]);
    s.delete(a2);
    const a1 = Array.from(s)[0];
    const b2 = Array.from(s)[1];

    // console.error(a1, b1, a2, b2);

    for (let i = 0; i < Math.floor(n / 4); i++) {
      console.log(
        i * 4 + a1,
        i * 4 + b1
        // ((i * 4 + a1 + k) * (i * 4 + b1)) % 4
      );
      console.log(
        i * 4 + a2,
        i * 4 + b2
        // ((i * 4 + a2 + k) * (i * 4 + b2)) % 4
      );
    }
    if (n % 4 == 2) console.log(n - 1, n);
  }
}

parseInput();

testCases.forEach(solution);

'use strict';

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

let inputString = '';
let currentLine = 0;

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

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

    main();
});

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

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

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

    for (let test = 0; test < N; test++) {
        const [n, k] = readline().split(' ').map(Number);

        if (k % 2 === 1) {
            output('YES');
            for (let i = 0; i < (n / 2); i++) {
                let first = i * 2 + 1;
                let second = first + 1;
                output(first + ' ' + second);
            }
            continue;
        } else if (k % 4 === 0) {
            output('NO');
        } else if (k % 4 === 2) {
            let start = 4;
            output('YES');
            let temp = n;
            while (start <= n) {
                output((start - 1) + ' ' + start);
                output((start - 2) + ' ' + (start - 3));
                start += 4;
                temp -= 4;
            }
            if (temp === 2) {
                output((start + 2) + ' ' + (start + 1));
            }
        }
    }
}


function solve() {
   var n = Number(read());
   var a = readArray(Number);
   var cream = [];
   var low = -1;
   var high = -1;
   for (var i = 0; i < n; i++) {
      cream[i] = 0;
      if (a[i] === 0) {
         continue;
      }
      var bottom = i - a[i] + 1;
      if (bottom < 0) {
         bottom = 0;
      }
      if (bottom > high) {
         low = bottom;
         high = i;
         for (var j = low; j <= high; j++) {
            cream[j] = 1;
         }
         continue;
      }
      if (bottom < low) {
         for (var j = bottom; j < low; j++) {
            cream[j] = 1;
         }
         low = bottom;
      }
      for (var j = high + 1; j <= i; j++) {
         cream[j] = 1;
      }
      high = i;
   }
   write(cream.join(' '));
}

function sortF(a, b) {
   if (a < b) {
      return -1;
   }
   if (a > b) {
      return 1;
   }
   return 0;
}

function init() {
   try {
      var T;
      T = 1;
      T = Number(read());
      for (var t = 0; t < T; t++) {
         solve();
      }
   } catch (e) {
      write(e);
   }
}

function readArray(mapF) {
   var res = read().split(' ');
   if (mapF) {
      res = res.map(mapF);
   }
   return res;
}

var isNode = typeof console !== 'undefined';
var MEMORY = [];
var MEMORY_INDEX = 0;
if (isNode) {
   var fs = require('fs');
   var path = require('path');

   var inTextName;
   var outTextName;
   if (process.argv.length === 5) {
      inTextName = process.argv[3];
      outTextName = process.argv[4];
   }
   MEMORY = fs.readFileSync(inTextName ? path.join(__dirname, inTextName) : 0, 'utf8').split('\r\n');
   init();
} else {
   init();
}

function write(value) {
   isNode ? console.log('' + value) : print('' + value);
}
function read() {
   return isNode ? MEMORY[MEMORY_INDEX++] : readline();
}
function readAll() {
   if (isNode) {
      return MEMORY;
   }
   var res = [];
   var x;
   while (x = read()) {
      res.push(x);
   }
   return res;
}

var input = parseInt(readline());

for (var z = 0; z < input; z++) {
    var pies = parseInt(readline());
    var cr = readline()
    .split(" ")
    .map((x) => parseInt(x));
    var dt = pies, ndt;
    for(var i =pies-1;i>=0;i--)
    {
        if(cr[i])
        {
            if(cr[i] > i+1)
            {
                cr[i] = i+1;
            }
            if(dt > (i - cr[i]+1))
            {
                dt = i - cr[i] + 1;
            }
        }

        if(i>=dt)
        {
            cr[i]=1;
        }
        else
        {
            cr[i]=0
        }
    //   print(dt)
    }
    var str="";
     for(var i =0;i<pies;i++)
     {
         str += cr[i]+" "
     }
     print(str)
    }

var input = parseInt(readline());

for (var z = 0; z < input; z++) {
    var pies = parseInt(readline());
    var cr = readline()
    .split(" ")
    .map((x) => parseInt(x));
    var dt = pies, ndt;
    for(var i =pies-1;i>=0;i--)
    {
        if(cr[i])
        {
            if(cr[i] > i+1)
            {
                cr[i] = i+1;
            }
            if(dt > (i - cr[i]+1))
            {
                dt = i - cr[i] + 1;
            }
        }

        if(i>=dt)
        {
            cr[i]=1;
        }
        else
        {
            cr[i]=0
        }
    //   print(dt)
    }
    var str="";
     for(var i =0;i<pies;i++)
     {
         str += cr[i]+" "
     }
     print(str)
//   var n = params[0];
//   var m = params[1];
//   var k = params[2];
//   var graph = [];
//   var vertLen = [];

//   print(vertLen);
//   for (var i = 0; i < m; i++) {
//     var verts = readline()
//       .split(" ")
//       .map((x) => parseInt(x));
//     var a = verts[0];
//     var b = verts[1];
//     if (!graph[a]) {
//       graph[a] = [];
//       graph[a].fill(0);
//       vertLen[a] = 0;
//     }
//     if (!graph[b]) {
//       graph[b] = [];
//       graph[b].fill(0);
//       vertLen[b] = 0;
//     }
//     graph[a][b] = 1;
//     graph[b][a] = 1;
//     vertLen[a] += 1;
//     vertLen[b] += 1;
//   }

//   var vertToDel = [];

// //   print(vertLen);

//   var r = 0;
//   while (
//     vertLen.map((x, index) => {
//       if (x < k - 1 && x != -1) vertToDel.push(index);
//     }) &&
//     vertToDel.length > 0
//   ) {
//     r++;
//     // print("entered", vertToDel, "-", vertLen);
//     for (var i = 0; i < vertToDel.length; i++) {
//       var vert = vertToDel[i];
//       graph.map((x, index) => {
//         if (x.length > 0) {
//           if (graph[index][vert] === 1) {
//             graph[index][vert] = 0;
//             vertLen[index] = vertLen[index] - 1;
//           }
//         }
//       });
//       graph[vert] = [];
//       vertLen[vert] = -1;
//     }
//     vertToDel = [];
//   }

//   var ind = 0;
//   graph.map((x, index) => {
//     if (x.length > 0) {
//       ind = index;
//     }
//   });

//     if(ind===0)
//     {
//         print('-1');
//         continue;
//     }
//   var subset = [];
//   var level1 = [ind];
//   var level2 = [];
//   subset = subset.concat(level1);

//   while (level1.length > 0) {
//       print(subset);
//     level1.forEach((x, index) => {
//       if (graph[x].length > 0) {
//       graph[x].map((x,index)=>{
//           if(x===1 && !subset.includes(index) && !level2.includes(index))
//           {
//               level2.push(index);
//           }
//       })
//       }
//     });
//     subset = subset.concat(level2);
//     level1= [].concat(level2);
//     level2 = [];
//   }
//   print(subset);
}

function solve() {
   var n = Number(read());
   var a = readArray(Number);
   var cream = [];
   var low = -1;
   var high = -1;
   for (var i = 0; i < n; i++) {
      cream[i] = 0;
      if (a[i] === 0) {
         continue;
      }
      var bottom = i - a[i] + 1;
      if (bottom < 0) {
         bottom = 0;
      }
      if (bottom > high) {
         low = bottom;
         high = i;
         for (var j = low; j <= high; j++) {
            cream[j] = 1;
         }
         continue;
      }
      if (bottom < low) {
         for (var j = bottom; j < low; j++) {
            cream[j] = 1;
         }
         low = bottom;
      }
      for (var j = high + 1; j <= i; j++) {
         cream[j] = 1;
      }
      high = i;
   }
   write(cream.join(' '));
}

function sortF(a, b) {
   if (a < b) {
      return -1;
   }
   if (a > b) {
      return 1;
   }
   return 0;
}

function init() {
   try {
      var T;
      T = 1;
      T = Number(read());
      for (var t = 0; t < T; t++) {
         solve();
      }
   } catch (e) {
      write(e);
   }
}

function readArray(mapF) {
   var res = read().split(' ');
   if (mapF) {
      res = res.map(mapF);
   }
   return res;
}

var isNode = typeof console !== 'undefined';
var MEMORY = [];
var MEMORY_INDEX = 0;
if (isNode) {
   var fs = require('fs');
   var path = require('path');

   var inTextName;
   var outTextName;
   if (process.argv.length === 5) {
      inTextName = process.argv[3];
      outTextName = process.argv[4];
   }

   if (inTextName) {
      fs.readFile(path.join(__dirname, inTextName), 'utf8', function(err, data) {
         MEMORY = data.split('\r\n');
         init();
      });
   } else {
      var readable = process.stdin;
      readable.once('readable', function() {
         MEMORY = ('' + readable.read()).split('\r\n');
         init();
      });
   }
} else {
   init();
}

function write(value) {
   isNode ? console.log(value) : print(value);
}
function read() {
   return isNode ? MEMORY[MEMORY_INDEX++] : readline();
}
function readAll() {
   if (isNode) {
      return MEMORY;
   }
   var res = [];
   var x;
   while (x = read()) {
      res.push(x);
   }
   return res;
}

function getInt(num){
        return parseInt(num, 10);
    }
var t = parseInt(readline(), 10);
for(var it = 0; it<t; it++){
    var n = parseInt(readline(), 10);

    var line = readline().split(' ').map(getInt);
    var counter = 0;
    var result = [];
    for(var i = n - 1; i >=0; i--){
        counter = Math.max(line[i], counter);
        var res = counter > 0? 1 : 0;
        counter --;

        result.push(res);

    }

    print(result.reverse().join(' '))

}

function solve() {
   var n = Number(read());
   var a = readArray(Number);
   var cream = [];
   var low = -1;
   var high = -1;
   for (var i = 0; i < n; i++) {
      cream[i] = 0;
      if (a[i] === 0) {
         continue;
      }
      var bottom = i - a[i] + 1;
      if (bottom < 0) {
         bottom = 0;
      }
      if (bottom > high) {
         low = bottom;
         high = i;
         for (var j = low; j <= high; j++) {
            cream[j] = 1;
         }
         continue;
      }
      if (bottom < low) {
         for (var j = bottom; j < low; j++) {
            cream[j] = 1;
         }
         low = bottom;
      }
      for (var j = high + 1; j <= i; j++) {
         cream[j] = 1;
      }
      high = i;
   }
   write(cream.join(' '));
}

function sortF(a, b) {
   if (a < b) {
      return -1;
   }
   if (a > b) {
      return 1;
   }
   return 0;
}

function init() {
   try {
      var T;
      T = 1;
      T = Number(read());
      for (var t = 0; t < T; t++) {
         solve();
      }
   } catch (e) {
      write(e);
   }
}

function readArray(mapF) {
   var res = read().split(' ');
   if (mapF) {
      res = res.map(mapF);
   }
   return res;
}

var isNode = typeof console !== 'undefined';
var MEMORY = [];
var MEMORY_INDEX = 0;
if (isNode) {
   var fs = require('fs');

   var inTextName;
   var outTextName;
   if (process.argv.length === 5) {
      inTextName = process.argv[3];
      outTextName = process.argv[4];
   }
   MEMORY = fs.readFileSync(inTextName ? require('path').join(__dirname, inTextName) : 0, 'utf8').split('\r\n');
   init();
} else {
   init();
}

function write(value) {
   isNode ? console.log('' + value) : print('' + value);
}
function read() {
   return isNode ? MEMORY[MEMORY_INDEX++] : readline();
}
function readAll() {
   if (isNode) {
      return MEMORY;
   }
   var res = [];
   var x;
   while (x = read()) {
      res.push(x);
   }
   return res;
}

function solve() {
   var n = Number(read());
   var a = readArray(Number);
   var cream = [];
   var low = -1;
   var high = -1;
   for (var i = 0; i < n; i++) {
      cream[i] = 0;
      if (a[i] === 0) {
         continue;
      }
      var bottom = i - a[i] + 1;
      if (bottom < 0) {
         bottom = 0;
      }
      if (bottom > high) {
         low = bottom;
         high = i;
         for (var j = low; j <= high; j++) {
            cream[j] = 1;
         }
         continue;
      }
      if (bottom < low) {
         for (var j = bottom; j < low; j++) {
            cream[j] = 1;
         }
         low = bottom;
      }
      for (var j = high + 1; j <= i; j++) {
         cream[j] = 1;
      }
      high = i;
   }
   write(cream.join(' '));
}

function sortF(a, b) {
   if (a < b) {
      return -1;
   }
   if (a > b) {
      return 1;
   }
   return 0;
}

function init() {
   try {
      var T;
      T = 1;
      T = Number(read());
      for (var t = 0; t < T; t++) {
         solve();
      }
   } catch (e) {
      write(e);
   }
}

function readArray(mapF) {
   var res = read().split(' ');
   if (mapF) {
      res = res.map(mapF);
   }
   return res;
}

var isNode = typeof console !== 'undefined';
var MEMORY = [];
var MEMORY_INDEX = 0;
if (isNode) {
   var fs = require('fs');
   var path = require('path');

   var inTextName;
   var outTextName;
   if (process.argv.length === 5) {
      inTextName = process.argv[3];
      outTextName = process.argv[4];
   }
   fs.readFile(inTextName ? path.join(__dirname, inTextName) : 0, 'utf8', function(err, data) {
      MEMORY = data.split('\r\n');
      init();
   });
} else {
   init();
}

function write(value) {
   isNode ? console.log('' + value) : print('' + value);
}
function read() {
   return isNode ? MEMORY[MEMORY_INDEX++] : readline();
}
function readAll() {
   if (isNode) {
      return MEMORY;
   }
   var res = [];
   var x;
   while (x = read()) {
      res.push(x);
   }
   return res;
}

process.stdin.setEncoding('utf-8')
const readline = require('readline')

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

let count = -1
let inputArr = []

rl.on('line', data => {
    if (count === -1) {
        count = +data * 2
    } else if (count !== 0) {
        inputArr.push(data.trim())
        count--
    }
    // max number 2^(53) - 1 ~~ 10^(15)
    if (count === 0) {
        inputArr = inputArr.map(i => i.split(' ').map(j => +j))
        main()
        process.exit(0)
    }
})

function solve(n, arr) {
    const res = Array(n).fill(0)
    for (let i = n - 1; i >= 0; i--) {
        if (arr[i] !== 0) {
            res[i] = 1
            if (arr[i - 1] < arr[i]) arr[i - 1] = arr[i] - 1
        }
    }
    console.log(res.join(' '))
}

function main() {
    for (let i = 0; i < inputArr.length; i += 2) solve(inputArr[i][0], inputArr[i + 1])
}

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

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

const INF = 2e5+1;

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

		const ans = [];
		for (let i = n - 1, mn = INF; i >= 0; i--) {
			mn = Math.min(mn, i - a[i] + 1);
			ans[i] = i >= mn ? 1 : 0;
		}

		console.log(ans.join(' '));
	}
}

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

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

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

		const st = [];
		for (let i = 0; i < n; i++) {
			if (a[i] == 0) {
				st.push(i);
			} else {
				while (st.length && i - a[i] < st[st.length-1]) {
					st.pop();
				}
			}
		}

		const ans = Array(n).fill(1);
		while (st.length) {
			ans[st.pop()] = 0;
		}

		console.log(ans.join(' '));
	}
}

const { EOL } = require('os');

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

function getAnswer(c) {
  const creams = c.reverse();
  let size = 0;
  for (let i = 0; i < creams.length; i++) {
    if (creams[i] > size) size = creams[i];
    creams[i] = size > 0 ? 1 : 0;
    size--;
  }
  return c.reverse().join(' ');
}

function main(param) {
  const input = param.split(EOL);
  const t = Number(input[0]);
  let index = 1;
  for (let i = 0; i < t; i++) {
    index++;
    const creams = input[index++].split(/\s+/).map(Number);
    console.log(getAnswer(creams));
  }
}

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 temp = a[n - 1];
            var b = new Array(n);
            for(j = 0; j < n; j++){
                b[j] = 0;
            }
            for(j = n - 1; j >= 0; j--){
                if(temp !== 0 || a[j] !== 0){
                    b[j] = 1;
                    temp = Math.max(temp, a[j]);
                    temp--;
                }else{
                    temp = a[j];
                }
            }
            var ans = '';
            for(j = 0; j < n; j++){
                ans += b[j] + ' ';
            }
            console.log(ans);
        }
    }
});

'use strict';

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

let inputString = '';
let currentLine = 0;

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

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

  main();
});

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

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

function main() {
  const x = readline();

  Array(parseInt(x)).fill(1).map((t, iii) => {
    var n = parseInt(readline())

    var a = readline().split(' ').map((x, iii) => {
      return parseInt(x)
    })

    var max = 0
    var ans = new Array(n).fill(0)
    for (let i = n; i >= 0; i--) {
      if (a[i] > 0 && a[i] > max-1) {
        max = a[i]
        ans[i] = 1
        max--
        continue
      }
      if (max > 0) {
        ans[i] = 1
        max--
      }

    }

    // if(n>=1) ans-=a[n-1]

    console.log(ans.join(' '))
    // console.log(a)

  })
}

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

  return gcd(b, a % b);
}

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

//Don't have to see. end------------------------------------------
function Main(){
	var t = nextInt();
	for(var i = 0; i < t; i++){
		var N = nextInt();
		var list = nextIntArray(N);
		var queue = [];
		for(var j = 0; j < N; j++){
			queue.push(0);
			if(list[j] != 0){
				if(queue.length > list[j]){
					queue[j - list[j] + 1] = list[j];
				}else{
					queue[0] = queue.length;
				}
			}
		}

		var last = -1;
		for(var j = 0; j < N; j++){
			if(queue[j] != 0){
				last = Math.max(last, queue[j]);
			}
			if(last > 0){
				queue[j] = 1;
				last--;
			}
		}
		myout(myconv(queue, 8));
	}
}

function solve() {
  var numPan = readline("");
  var array = readline("").split(" ");

  array.reverse();
var ans = [];
var curNum = 0;
  for (var elm in array) {
    curNum = Math.max(array[elm], curNum);
    if (curNum) {
      ans.push(1);
      curNum--;
    } else {
      ans.push(0);
    }
  }

  for (var ab=ans.length-1;ab>=0;ab--) {
    print(ans[ab]);
  }
  return "hi";
}

var testCases = readline("");
for (var i=0;i<testCases;i++) {
  solve();
}

function solve() {
   var n = Number(read());
   var a = readArray(Number);
   var cream = [];
   var low = -1;
   var high = -1;
   for (var i = 0; i < n; i++) {
      cream[i] = 0;
      if (a[i] === 0) {
         continue;
      }
      var bottom = i - a[i] + 1;
      if (bottom < 0) {
         bottom = 0;
      }
      if (bottom > high) {
         low = bottom;
         high = i;
         for (var j = low; j <= high; j++) {
            cream[j] = 1;
         }
         continue;
      }
      if (bottom < low) {
         for (var j = bottom; j < low; j++) {
            cream[j] = 1;
         }
         low = bottom;
      }
      for (var j = high + 1; j <= i; j++) {
         cream[j] = 1;
      }
      high = i;
   }
   write(cream.join(' '));
}

function sortF(a, b) {
   if (a < b) {
      return -1;
   }
   if (a > b) {
      return 1;
   }
   return 0;
}

function init() {
   try {
      var T;
      T = 1;
      T = Number(read());
      for (var t = 0; t < T; t++) {
         solve();
      }
   } catch (e) {
      write(e);
   }
}

function readArray(mapF) {
   var res = read().split(' ');
   if (mapF) {
      res = res.map(mapF);
   }
   return res;
}

var isNode = typeof console !== 'undefined';
var MEMORY = [];
var MEMORY_INDEX = 0;
if (isNode) {
   var fs = require('fs');
   var path = require('path');

   var inTextName;
   var outTextName;
   if (process.argv.length === 5) {
      inTextName = process.argv[3];
      outTextName = process.argv[4];
   }

   if (inTextName) {
      fs.readFile(path.join(__dirname, inTextName), 'utf8', (err, data) => {
         MEMORY = data.split('\r\n');
         init();
      });
   } else {
      var readable = process.stdin;
      readable.once('readable', function() {
         MEMORY = ('' + readable.read()).split('\r\n');
         init();
      });
   }
} else {
   init();
}

function write(value) {
   isNode ? console.log(value) : print(value);
}
function read() {
   return isNode ? MEMORY[MEMORY_INDEX++] : readline();
}
function readAll() {
   if (isNode) {
      return MEMORY;
   }
   var res = [];
   var x;
   while (x = read()) {
      res.push(x);
   }
   return res;
}

function solve() {
   var n = Number(read());
   var a = readArray(Number);
   var cream = [];
   var low = -1;
   var high = -1;
   for (var i = 0; i < n; i++) {
      if (!a[i]) {
         cream[i] = 0;
         continue;
      }
      var bottom = Math.max(0, i - a[i] + 1);
      if (bottom > high) {
         low = bottom;
         high = i;
         for (var j = low; j <= high; j++) {
            cream[j] = 1;
         }
         continue;
      }
      if (bottom < low) {
         for (var j = bottom; j < low; j++) {
            cream[j] = 1;
         }
         low = bottom;
      }
      for (var j = high + 1; j <= i; j++) {
         cream[j] = 1;
      }
      high = i;
   }
   write(cream.join(' '));
}

function sortF(a, b) {
   if (a < b) {
      return -1;
   }
   if (a > b) {
      return 1;
   }
   return 0;
}

function init() {
   try {
      var T;
      T = 1;
      T = Number(read());
      for (var t = 0; t < T; t++) {
         solve();
      }
   } catch (e) {
      write(e);
   }
}

function readArray(mapF) {
   var res = read().split(' ');
   if (mapF) {
      res = res.map(mapF);
   }
   return res;
}

var isNode = typeof console !== 'undefined';
var MEMORY = [];
var MEMORY_INDEX = 0;
if (isNode) {
   var fs = require('fs');
   var path = require('path');

   var inTextName;
   var outTextName;
   if (process.argv.length === 5) {
      inTextName = process.argv[3];
      outTextName = process.argv[4];
   }

   if (inTextName) {
      fs.readFile(path.join(__dirname, inTextName), 'utf8', (err, data) => {
         MEMORY = data.split('\r\n');
         init();
      });
   } else {
      var readable = process.stdin;
      readable.once('readable', function() {
         MEMORY = ('' + readable.read()).split('\r\n');
         init();
      });
   }
} else {
   init();
}

function write(value) {
   isNode ? console.log(value) : print(value);
}
function read() {
   return isNode ? MEMORY[MEMORY_INDEX++] : readline();
}
function readAll() {
   if (isNode) {
      return MEMORY;
   }
   var res = [];
   var x;
   while (x = read()) {
      res.push(x);
   }
   return res;
}

function solve() {
   var n = Number(read());
   var a = readArray(Number);
   var cream = a.map(x => 0);
   var low = -1;
   var high = -1;
   for (var i = 0; i < n; i++) {
      if (!a[i]) {
         continue;
      }
      var bottom = Math.max(0, i - a[i] + 1);
      if (bottom > high) {
         low = bottom;
         high = i;
         for (var j = low; j <= high; j++) {
            cream[j] = 1;
         }
         continue;
      }
      if (bottom < low) {
         for (var j = bottom; j < low; j++) {
            cream[j] = 1;
         }
         low = bottom;
      }
      for (var j = high + 1; j <= i; j++) {
         cream[j] = 1;
      }
      high = i;
   }
   write(cream.join(' '));
}

function sortF(a, b) {
   if (a < b) {
      return -1;
   }
   if (a > b) {
      return 1;
   }
   return 0;
}

function init() {
   try {
      var T;
      T = 1;
      T = Number(read());
      for (var t = 0; t < T; t++) {
         solve();
      }
   } catch (e) {
      write(e);
   }
}

function readArray(mapF) {
   var res = read().split(' ');
   if (mapF) {
      res = res.map(mapF);
   }
   return res;
}

var isNode = typeof console !== 'undefined';
var MEMORY = [];
var MEMORY_INDEX = 0;
if (isNode) {
   var fs = require('fs');
   var path = require('path');

   var inTextName;
   var outTextName;
   if (process.argv.length === 5) {
      inTextName = process.argv[3];
      outTextName = process.argv[4];
   }

   if (inTextName) {
      fs.readFile(path.join(__dirname, inTextName), 'utf8', (err, data) => {
         MEMORY = data.split('\r\n');
         init();
      });
   } else {
      var readable = process.stdin;
      readable.once('readable', function() {
         MEMORY = ('' + readable.read()).split('\r\n');
         init();
      });
   }
} else {
   init();
}

function write(value) {
   isNode ? console.log(value) : print(value);
}
function read() {
   return isNode ? MEMORY[MEMORY_INDEX++] : readline();
}
function readAll() {
   if (isNode) {
      return MEMORY;
   }
   var res = [];
   var x;
   while (x = read()) {
      res.push(x);
   }
   return res;
}

process.stdin.setEncoding('utf-8')
const readline = require('readline')

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

let count = -1
let inputArr = []

rl.on('line', data => {
    if (count === -1) {
        count = +data * 2
    } else if (count !== 0) {
        inputArr.push(data.trim())
        count--
    }
    // max number 2^(53) - 1 ~~ 10^(15)
    if (count === 0) {
        inputArr = inputArr.map(i => i.split(' ').map(j => +j))
        main()
        process.exit(0)
    }
})

function solve(n, arr) {
    for (let i = n-1; i >= 0; i--) {
        let count = arr[i]
        if(count === 0) continue
        for (let j = 0; j < count; j++) {
            if ((i - j) < 0) break
            arr[i - j] = 1
        }
        i -= (count-1)
    }
    console.log(arr.join(' '))
}

function main() {
    for (let i = 0; i < inputArr.length; i += 2) {
        solve(inputArr[i][0], inputArr[i + 1])
    }
}

process.stdin.setEncoding('utf-8')
const readline = require('readline')

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

let count = -1
let inputArr = []

rl.on('line', data => {
    if (count === -1) {
        count = +data * 2
    } else if (count !== 0) {
        inputArr.push(data.trim())
        count--
    }
    // max number 2^(53) - 1 ~~ 10^(15)
    if (count === 0) {
        inputArr = inputArr.map(i => i.split(' ').map(j => +j))
        main()
        process.exit(0)
    }
})

function solve(n, arr) {
    for (let i = n-1; i >= 0; i--) {
        let count = arr[i]
        for (let j = 0; j < count; j++) {
            if ((i - j) < 0) break
            arr[i - j] = 1
        }
        i -= count
    }
    console.log(arr.join(' '))
}

function main() {
    for (let i = 0; i < inputArr.length; i += 2) {
        solve(inputArr[i][0], inputArr[i + 1])
    }
}

process.stdin.setEncoding('utf-8')
const readline = require('readline')

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

let count = -1
let inputArr = []

rl.on('line', data => {
    if (count === -1) {
        count = +data * 2
    } else if (count !== 0) {
        inputArr.push(data.trim())
        count--
    }
    // max number 2^(53) - 1 ~~ 10^(15)
    if (count === 0) {
        inputArr = inputArr.map(i => i.split(' ').map(j => +j))
        main()
        process.exit(0)
    }
})

function solve(n, arr) {
    const res = Array(n).fill(0)
    for (let i = n; i !== 0; i--) {
        for (let j = 0; j < arr[i]; j++) {
            res[i - j] = 1
        }
    }
    console.log(res.join(' '))
}

function main() {
    for (let i = 0; i < inputArr.length; i += 2) {
        solve(inputArr[i][0], inputArr[i + 1])
    }
}

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

const readLine = () => dataitr.next().value.trim();
function rl () {
	let ans = readLine().split(' ');
	if (!isNaN(Number(ans[0]))) ans = ans.map(x => Number(x));
	return ans.length == 1 ? ans[0] : ans;
}

function main () {

	let t = rl();
	while (t--) {
		let n = rl();
		let a = rl();

		let ans = Array(n).fill(0);
		for (let i = n - 1, k = 0; i >= 0; i--) {
			k = Math.max(k, a[i]);
			if (k) { ans[i] = 1; k--; }
		}

		console.log(ans.join(' '));
	}

}

function solve() {
  var numPan = readline("");
  var array = readline("").split(" ");

  array.reverse();
var ans = [];
var curNum = 0;
  for (var elm in array) {
    curNum = Math.max(array[elm], curNum);
    if (curNum) {
      ans.push(1);
      curNum--;
    } else {
      ans.push(0);
    }
  }

  for (var ab=ans.length;ab>=0;ab--) {
    print(ans[ab]);
  }
  return "hi";
}

function test() {
var testCases = readline("");
for (var i=0;i<testCases;i++) {
  solve();
}
return "hello";
}
test();

function solve() {
  var numPan = readline("");
  var array = readline("").split(" ");

  array.reverse();
var ans = [];
var curNum = 0;
  for (var elm in array) {
    curNum = Math.max(array[elm], curNum);
    if (curNum) {
      ans.push(1);
      curNum--;
    } else {
      ans.push(0);
    }
  }

  for (var ab=ans.length;ab>=0;ab--) {
    print(ans[ab]);
  }
  return "hi";
}

var testCases = readline("");
for (var i=0;i<testCases;i++) {
  solve();
}

function solve() {
  var numPan = readline("");
  var array = readline("").split(" ");

  array.reverse();
var ans = [];
var curNum = 0;
  for (var elm in array) {
    curNum = Math.max(array[elm], curNum);
    if (curNum) {
      ans.push(1);
      curNum--;
    } else {
      ans.push(0);
    }
  }

  for (var ab=ans.length;ab>=0;ab--) {
    print(ans[ab]);
  }
  return;
}

var testCases = readline("");
for (var i=0;i<testCases;i++) {
  solve();
}

function solve() {
  var numPan = readline("");
  var array = readline("").split(" ");

  array.reverse();
var ans = [];
var curNum = 0;
  for (var elm in array) {
    curNum = Math.max(array[elm], curNum);
    if (curNum) {
      ans.push(1);
      curNum--;
    } else {
      ans.push(0);
    }
  }

  for (var ab=ans.length;ab>=0;ab--) {
    print(ans[ab]);
  }
}

var testCases = readline("");
for (var i=0;i<testCases;i++) {
  solve();
}

function solve() {
  var numPan = readline("");
  var array = [];
  for (var i=0;i<numPan;i++) {
    var e = readline("");
    array.push(e);
  }
  array.reverse();
var ans = [];
var curNum = 0;
  for (var elm in array) {
    curNum = Math.max(array[elm], curNum);
    if (curNum) {
      ans.push(1);
      curNum--;
    } else {
      ans.push(0);
    }
  }

  for (var ab=ans.length;ab>=0;ab--) {
    print(ans[ab]);
  }
}

var testCases = readline("");
for (var i=0;i<testCases;i++) {
  solve();
}

var input = parseInt(readline());

for (var z = 0; z < input; z++) {
    var pies = parseInt(readline());
    var cr = readline()
    .split(" ")
    .map((x) => parseInt(x));
    var dt = pies, ndt;
    for(var i =pies-1;i>=0;i--)
    {
        if(cr[i])
        {
            if(cr[i] > i+1)
            {
                cr[i] = i+1;
            }
            if(dt > (i - cr[i]+1))
            {
                dt = i - cr[i] + 1;
            }
        }

        if(i>=dt)
        {
            cr[i]=1;
        }
        else
        {
            cr[i]=0
        }
    //   print(dt)
    }
    print(cr);
//   var n = params[0];
//   var m = params[1];
//   var k = params[2];
//   var graph = [];
//   var vertLen = [];

//   print(vertLen);
//   for (var i = 0; i < m; i++) {
//     var verts = readline()
//       .split(" ")
//       .map((x) => parseInt(x));
//     var a = verts[0];
//     var b = verts[1];
//     if (!graph[a]) {
//       graph[a] = [];
//       graph[a].fill(0);
//       vertLen[a] = 0;
//     }
//     if (!graph[b]) {
//       graph[b] = [];
//       graph[b].fill(0);
//       vertLen[b] = 0;
//     }
//     graph[a][b] = 1;
//     graph[b][a] = 1;
//     vertLen[a] += 1;
//     vertLen[b] += 1;
//   }

//   var vertToDel = [];

// //   print(vertLen);

//   var r = 0;
//   while (
//     vertLen.map((x, index) => {
//       if (x < k - 1 && x != -1) vertToDel.push(index);
//     }) &&
//     vertToDel.length > 0
//   ) {
//     r++;
//     // print("entered", vertToDel, "-", vertLen);
//     for (var i = 0; i < vertToDel.length; i++) {
//       var vert = vertToDel[i];
//       graph.map((x, index) => {
//         if (x.length > 0) {
//           if (graph[index][vert] === 1) {
//             graph[index][vert] = 0;
//             vertLen[index] = vertLen[index] - 1;
//           }
//         }
//       });
//       graph[vert] = [];
//       vertLen[vert] = -1;
//     }
//     vertToDel = [];
//   }

//   var ind = 0;
//   graph.map((x, index) => {
//     if (x.length > 0) {
//       ind = index;
//     }
//   });

//     if(ind===0)
//     {
//         print('-1');
//         continue;
//     }
//   var subset = [];
//   var level1 = [ind];
//   var level2 = [];
//   subset = subset.concat(level1);

//   while (level1.length > 0) {
//       print(subset);
//     level1.forEach((x, index) => {
//       if (graph[x].length > 0) {
//       graph[x].map((x,index)=>{
//           if(x===1 && !subset.includes(index) && !level2.includes(index))
//           {
//               level2.push(index);
//           }
//       })
//       }
//     });
//     subset = subset.concat(level2);
//     level1= [].concat(level2);
//     level2 = [];
//   }
//   print(subset);
}


function main() {
  const is = new Scanner();
  const [n, m] = is.nextArray(Number);
  const s = is.nextLine();
  const t = is.nextLine();

  const index = s.indexOf('*');
  if (index === -1 || n > m + 1) {
    console.log(s === t ? 'YES' : 'NO');
  } else {
    const left = s.substr(0, index);
    const right = s.substr(index + 1, s.length);
    let tReverse = t.slice();
    tReverse = tReverse.split('').reverse().slice(0, right.length).reverse().join('');
    if (left === t.substr(0, left.length) && right === tReverse) {
      console.log('YES');
    } else {
      console.log('NO');
    }
  }

}

/*
 *  Api Scanner
 */
class Scanner {
  constructor() {
    this.index = -1;
    this.lines = stdinInput.trim().split('\n'); // eslint-disable-line
  }

  nextLine() {
    this.index += 1;
    return this.lines[this.index].trim();
  }

  nextInt() {
    return parseInt(this.nextLine(), 10);
  }

  nextDouble() {
    return parseFloat(this.nextLine());
  }

  nextArray(fn) {
    const array = this.nextLine().split(' ');
    return fn === String ? array : array.map(fn);
  }

  hasNext() {
    return this.index < this.lines.length;
  }
}

let stdinInput = '';
process.stdin.resume();
process.stdin.setEncoding('utf-8');
process.stdin.on('data', (input) => { stdinInput += input; });
process.stdin.on('end', () => { main(); });

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

var str0 = ""
var str1 = ""

var c = 0;
rl.on('line', function (line) {
    c += 1;
    if (c == 2) {
        str0 = line;
    }
    else if (c == 3) {
        str1 = line;
        rl.close();
        console.log(isOk() ? "YES" : "NO");
    }
});

function isOk() {
    if (str0.indexOf("*") == -1) {
        if (str0!=str1) {return false}
    }
    var tCs = str0.split("");
    var fCs = str1.split("");
    var index = 0;
    var sBefore = ""; iStart = 0; iPos = 0;
    while (index < str0.length) {
        if (tCs[index]!="*") {
            sBefore += tCs[index];
        }
        else {
            if (str1.indexOf(sBefore, iPos)!=iStart) {
                return false;
            }
            iPos = sBefore.length;
            sBefore = "";
            jIndex = index + 1;
            while (tCs[jIndex]!="*" && jIndex < str0.length) {
                sBefore += tCs[jIndex];
                jIndex += 1;
            }
            iStart = str1.indexOf(sBefore, iPos);
            if (iStart==-1) {
                return false
            }
            index = jIndex - 1;
            if (index==str0.length-1) {
               if (!(str0[index]=="*" || str0[index]==fCs[str1.length-1])) {
                   return false
                }
            }
        }
        index += 1;
    }
    return true;
}

readline();
var str = readline();
var a = str.split('*');
var b = readline();
if (b.substring(0,a[0].length) === a[0] && ((a.length == 2)?(b.substring(b.length-a[1].length,b.length) === a[1]) && str.length-1<=b.length:str.length === b.length)){
    print('YES')
}else{
    print('NO')
}

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

var templateString = ""
var testString = ""

var c = 0;
rl.on('line', function (line) {
    c += 1;
    if (c == 2) {
        templateString = line;
    }
    else if (c == 3) {
        testString = line;
        rl.close();
        console.log(isOk() ? "yes" : "no");
    }
});

function isOk() {
    if (templateString.indexOf("*") == -1) {
        if (templateString!=testString) {return false}
    }
    var tCs = templateString.split("");
    var fCs = testString.split("");
    var index = 0;
    var sBefore = ""; iStart = 0; iPos = 0;
    while (index < templateString.length) {
        if (tCs[index]!="*") {
            sBefore += tCs[index];
        }
        else {
            if (testString.indexOf(sBefore, iPos)!=iStart) {
                return false;
            }
            iPos = sBefore.length;
            sBefore = "";
            jIndex = index + 1;
            while (tCs[jIndex]!="*" && jIndex < templateString.length) {
                sBefore += tCs[jIndex];
                jIndex += 1;
            }
            iStart = testString.indexOf(sBefore, iPos);
            if (iStart==-1) {
                return false
            }
            index = jIndex - 1;
            if (index==templateString.length-1) {
               if (!(templateString[index]=="*" || templateString[index]==fCs[testString.length-1])) {
                   return false
                }
            }
        }
        index += 1;
    }
    return true;
}

var lengths = readline();

var length1 = parseInt(lengths.split(" ")[0])
var length2 = parseInt(lengths.split(" ")[1])

var string = readline();
var string1 = readline();
var p = false;

print(check());

function check() {
    if (length1 >= length2 + 2) {
        return "NO";
    }

    for (var i = 0; i < length1; i++) {
        if (string[i] === "*") {
            p = true;
            break;
        }
        if (string1[i] !== string[i]) {
            return "NO";
        }
    }

    for (var i = 0; i < length1; i++) {
        if (string[length1-i] === "*") {
            p = true;
            break;
        }
        if (string1[length2-i] !== string[length1-i]) {
            return "NO";
        }
    }

    if (!p && length1 !== length2) {
        return "NO";
    }

    return "YES";
}

readline();
var str = readline();
var a = str.split('*');
var b = readline();
if (b.indexOf(a[0]) === 0 && ((a.length == 2)?(b.lastIndexOf(a[1])+a[1].length === b.length)&&str.length-1<=b.length:true)){
    print('YES')
}else{
    print('NO')
}

var lengths = readline();

var length1 = parseInt(lengths.split(" ")[0])
var length2 = parseInt(lengths.split(" ")[1])

var string = readline();
var string1 = readline();

print(check());

function check() {
    if (length1 > length2 + 2) {
        return "NO";
    }

    for (var i = 0; i < length1; i++) {
        if (string[i] === "*") {
            break;
        }
        if (string1[i] !== string[i]) {
            return "NO";
        }
    }

    for (var i = 0; i < length1; i++) {
        if (string[length1-i] === "*") {
            break;
        }
        if (string1[length2-i] !== string[length1-i]) {
            return "NO";
        }
    }

    return "YES";
}

var lengths = readline();

var length1 = parseInt(lengths.split(" ")[0])
var length2 = parseInt(lengths.split(" ")[1])

var string = readline();
var string1 = readline();

print(check());

function check() {
    if (length1 >= length2 + 2) {
        return "NO";
    }

    for (var i = 0; i < length1; i++) {
        if (string[i] === "*") {
            break;
        }
        if (string1[i] !== string[i]) {
            return "NO";
        }
    }

    for (var i = 0; i < length1; i++) {
        if (string[length1-i] === "*") {
            break;
        }
        if (string1[length2-i] !== string[length1-i]) {
            return "NO";
        }
    }

    return "YES";
}

var lengths = readline();

var length1 = parseInt(lengths.split(" ")[0])
var length2 = parseInt(lengths.split(" ")[1])

var string = readline();
var string1 = readline();

print(check());

function check() {
    if (length1 > length2 + 2) {
        return "NO";
    }

    for (var i = 0; i < length1; i++) {
        if (string[i] === "*") {
            break;
        }
        if (string1[i] !== string[i]) {
            print(string1[i] + ' 2  ' + string[i])
            return "NO";
        }
    }

    for (var i = 0; i < length1; i++) {
        if (string[length1-i] === "*") {
            break;
        }
        if (string1[length2-i] !== string[length1-i]) {
            print(string1[length2-i] + ' 4  ' + string[length1-i])
            return "NO";
        }
    }

    return "YES";
}

var lengths = readline();

var length1 = parseInt(lengths.split(" ")[0])
var length2 = parseInt(lengths.split(" ")[1])

var string = readline();
var string1 = readline();

print(check());

function check() {
    if (length1 > length2 + 2) {
        return "NO";
    }

    for (var i = 0; i < length1; i++) {
        if (string[i] === "*") {
            break;
        }
        if (string1[i] !== string[i]) {
            print(string1[i] + ' 2  ' + string[i])
            return "NO";
        }
    }

    for (var i = 0; i < length1; i++) {
        if (string[length1-i] === "*") {
            break;
        }
        if (string1[length2-i] !== string[length1-i]) {
            return "NO";
        }
    }

    return "YES";
}

function main() {
  const is = new Scanner();
  const [n, m] = is.nextArray(Number);
  const s = is.nextLine();
  const t = is.nextLine();

  const index = s.indexOf('*');
  if (index === -1) {
    console.log(s === t ? 'YES' : 'NO');
  } else {
    const left = s.substr(0, index);
    const right = s.substr(index + 1, s.length);
    let tReverse = t.slice();
    tReverse = tReverse.split('').reverse().slice(0, right.length).reverse().join('');
    if (left === t.substr(0, left.length) && right === tReverse) {
      console.log('YES');
    } else {
      console.log('NO');
    }
  }

}

/*
 *  Api Scanner
 */
class Scanner {
  constructor() {
    this.index = -1;
    this.lines = stdinInput.trim().split('\n'); // eslint-disable-line
  }

  nextLine() {
    this.index += 1;
    return this.lines[this.index].trim();
  }

  nextInt() {
    return parseInt(this.nextLine(), 10);
  }

  nextDouble() {
    return parseFloat(this.nextLine());
  }

  nextArray(fn) {
    const array = this.nextLine().split(' ');
    return fn === String ? array : array.map(fn);
  }

  hasNext() {
    return this.index < this.lines.length;
  }
}

let stdinInput = '';
process.stdin.resume();
process.stdin.setEncoding('utf-8');
process.stdin.on('data', (input) => { stdinInput += input; });
process.stdin.on('end', () => { main(); });

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

var str0 = ""
var str1 = ""

var c = 0;
rl.on('line', function (line) {
    c += 1;
    if (c == 2) {
        str0 = line;
    }
    else if (c == 3) {
        str1 = line;
        rl.close();
        console.log(isOk() ? "YES" : "NO");
    }
});

function isOk() {
    if (str0.indexOf("*") == -1) {
        if (str0!=str1) {return false}
    }
    var tCs = str0.split("");
    var fCs = str1.split("");
    var index = 0;
    var sBefore = ""; iStart = 0; iPos = 0;
    while (index < str0.length) {
        if (tCs[index]!="*") {
            sBefore += tCs[index];
        }
        else {
            if (str1.indexOf(sBefore, iPos)!=iStart) {
                return false;
            }
            iPos = sBefore.length;
            sBefore = "";
            jIndex = index + 1;
            while (tCs[jIndex]!="*" && jIndex < str0.length) {
                sBefore += tCs[jIndex];
                jIndex += 1;
            }
            iStart = str1.indexOf(sBefore, iPos);
            if (iStart==-1) {
                return false
            }
            index = jIndex - 1;
            if (index==str0.length-1) {
               if (!(str0[index]=="*" || str0[index]==fCs[str1.length-1])) {
                   return false
                }
            }
        }
        index += 1;
    }
    console.log(sBefore);

    return true;
}


/*
 * File Created: Monday, 30th November 2020 3:31:00 pm
 * Author: Lukas Rimkus
 */

'use-strict'

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

let data = '';
let currentLine = 0;

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

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

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

    while(testCases--) {

        const n = data.shift();

        const res = a(n);

        console.log(res)
    }
});

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

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

function a(num)
{
    return num.length ;
}

module.exports = a;

function task(input){
	let ia = input.trim().split('\n');
	let t = +ia.shift();
	for (let i = 0; i < t; i++) {
		let n = ia.shift().trim()
		let x = n.length
		console.log(x)
	}
}

process.stdin.resume();
process.stdin.setEncoding('utf-8');
let inputString = '';
process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});
process.stdin.on('end', _ => {
    task(inputString);
});

const solve = (n) => {
    console.log(n.length);
};

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

main()

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() {
  let t = +readLine();
  while (t--) {
    const n = readLine();
    console.log(n.length);
  }
}

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

//Don't have to see. end------------------------------------------
function Main(){
	var t = nextInt();
	for(var i = 0; i < t; i++){
		var N = next();
		var count = N.length;
		/*if(N[N.length - 1] == "0"){
			count++;
		}*/
		myout(count);
	}
}

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

  let i = 1;
  let t = 0;
  readline.on('line', line => {
    if (i == 1) {
        // number of test case
        t = parseInt(line)
        i++;
    } else if (i <= t) {
        solve(line)
        i++;
    } else {
        solve(line)
        readline.close()
    }
  });

  function solve(input) {
      console.log(input.length)
  }

function run(sol) {
  let i = ''
  process.stdin.on('data', c => i += c)
  process.stdin.on('end', () => {
      const {EOL} = require('os')
      const inputs = i.split(EOL)
      sol(inputs)
  })
}

function solution(inputs) {
  const t = Number(inputs[0])
  for (let i = 1; i <= t; ++i) {
    console.log(inputs[i].length)
  }

}

run(solution)

(()=>{"use strict";var t={675:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),Array.numbersMatrix=(t,e,r)=>{let n=[];null==t&&(e=t),null==r&&(r=0);for(let i=0;i<t;++i){let t=[];for(let n=0;n<e;++n)t.push(r);n.push(t)}return n},Array.prototype.sortAsc=function(){return this.sort(((t,e)=>t-e))},Array.prototype.sortDesc=function(){return this.sort(((t,e)=>e-t))},Array.prototype.max=function(){if(0==this.length)return 0;let t=this[0];for(let e=1;e<this.length;++e)t=Math.max(t,this[e]);return t},Array.prototype.min=function(){if(0==this.length)return 0;let t=this[0];for(let e=1;e<this.length;++e)t=Math.min(t,this[e]);return t},Array.prototype.sum=function(){let t=0;for(let e=0;e<this.length;++e)t+=this[e];return t},Array.prototype.modSum=function(t){let e=0;for(let r=0;r<this.length;++r)e+=this[r],e%=t;return e},Array.prototype.avg=function(){return this.sum()/this.length},Array.prototype.groupBy=function(t){let e=new Map;for(let r=0;r<this.length;++r){const n=t(this[r]);e.has(n)?e.get(n).push(this[r]):e.set(n,[this[r]])}return e},Array.prototype.deepCopy=function(){let t=[];if(0==this.length)return t;let e=!1;Array.isArray(this[0])&&(e=!0);for(let r=0;r<this.length;++r)e?t.push(this[r].deepCopy()):t.push(this[r]);return t},Array.prototype.transpose=function(){let t=[];if(0==this.length)return[[]];for(let e=0;e<this[0].length;++e){let r=[];for(let t=0;t<this.length;++t)r.push(this[t][e]);t.push(r)}return t},Array.prototype.toString=function(){if(0==this.length)return"";if(!Array.isArray(this[0]))return this.join(" ");let t="";for(let e=0;e<this.length;++e)t+=this[e].join(" "),e!=this.length-1&&(t+="\n");return t}},312:function(t,e,r){var n=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const i=n(r(747));let o="",s=[],u=0,l="";const p="local"===process.argv[2],h=t=>{if(p){if(s=i.default.readFileSync("input.txt").toString().trim().split("\n").map((t=>t.trim())),t(),i.default.writeFileSync("output.txt",l),console.log(l),i.default.readFileSync("expected.txt").toString().trim()==l.trim()){const{exec:t}=r(129);t("osascript -e 'display notification \"✅ AC!!\"'")}}else process.stdin.resume(),process.stdin.setEncoding("utf-8"),process.stdin.on("data",(t=>{o+=t})),process.stdin.on("end",(e=>{s=o.trim().split("\n").map((t=>t.trim())),t(),console.log(l)}))};function a(){return s[u++]}function f(){return a().split(" ").map((t=>parseFloat(t)))}function c(){return a().split("")}e.default={runMain:h,runEachTest:t=>{h((()=>{let[e]=f();for(;e>0;)t(),e--}))},readline:a,nextNumbers:f,nextBigNumbers:function(){return a().split(" ").map((t=>BigInt(t)))},nextNumbersMatrix:function(t){let e=[];for(let r=0;r<t;++r)e.push(f());return e},nextCharacters:c,nextCharacterMatrix:function(t){let e=[];for(let r=0;r<t;++r)e.push(c());return e},nextIntervalArray:function(t){let e=[];for(let r=0;r<t;++r){const[t,r]=f();e.push({a:t,b:r})}return e},put:function(t){l+=t},puts:function(t){l+=t+"\n"},debug:function(t){p&&console.log(t)}}},965:function(t,e,r){var n=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),r(675);const i=n(r(312));i.default.runEachTest((function(){let t=i.default.readline();i.default.puts(t.length)}))},129:t=>{t.exports=require("child_process")},747:t=>{t.exports=require("fs")}},e={};!function r(n){if(e[n])return e[n].exports;var i=e[n]={exports:{}};return t[n].call(i.exports,i,i.exports,r),i.exports}(965)})();

// Solution written in typescript and compiled via webpack. Original source code below
// Happy Hacking 😜

// import './array'
//
// import io from './io'
//
// function main() {
//   let s = io.readline()
//
//   io.puts(s.length)
// }
//
// io.runEachTest(main)
// // io.runMain(main)

'use strict';

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

let inputString = '';
let currentLine = 0;

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

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

  main();
});

function readline() {
  return inputString[currentLine++];
}
// Make a Snippet for the code above this and then write your logic in main();

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

  Array(Number(x)).fill(1).map((t, i)=>{
    var line = readline();
    console.log(line.length)
  })

}

'use strict'

let t = readline();

while(t--)
{
    let n = readline();
    print(n.length);
}

var t = +readline();

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

  print(l.length);
}

var tc = parseInt(readline());
for (; tc--;){
    var s = readline();
    print(s.length);
}

function task(input){
	let ia = input.trim().split('\n');
	let t = +ia.shift();
	for (let i = 0; i < t; i++) {
		let n = ia.shift()
		console.log(n.length)
	}
}

process.stdin.resume();
process.stdin.setEncoding('utf-8');
let inputString = '';
process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});
process.stdin.on('end', _ => {
    task(inputString);
});

function task(input){
	let ia = input.trim().split('\n');
	let t = +ia.shift();
	for (let i = 0; i < t; i++) {
		let n = ia.shift()
		let x = n.length
		console.log(x)
	}
}

process.stdin.resume();
process.stdin.setEncoding('utf-8');
let inputString = '';
process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});
process.stdin.on('end', _ => {
    task(inputString);
});

function task(input){
	let ia = input.trim().split('\n');
	let t = +ia.shift();
	for (let i = 0; i < t; i++) {
		let n = ia.shift()
		console.log([...n].length)
	}
}

process.stdin.resume();
process.stdin.setEncoding('utf-8');
let inputString = '';
process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});
process.stdin.on('end', _ => {
    task(inputString);
});

const solve = (n) => {
    console.log(n.length);
};

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

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

function main() {
  const inputs=+readline();

  for(let j = 0; j < inputs; j++) {
    const number_of_heroes = +readline();
    const heroes = readline().split(" ");

    let number_of_values = [];
    heroes.forEach((item, i) => {
      if(+item !== Math.min(...heroes)) number_of_values.push(+item);
    });
    foo(number_of_values.length)
  }

}

const foo = (x) => console.log(x);

//required remainder
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*/
    var a = lines[0];
    var lowest = 0;
    var answer = 0;
    for(var j = 1; j < (Number(a) + 1) * 2; j++){
        lowest = 0;
        answer = 0;
        if(j % 2 === 0){
            var n = lines[j].split(' ').map(Number).sort(function(a, b){return a - b});
            lowest = n[0];
            for(var k = 1; k < n.length; k++){
                if(lowest < n[k]){
                    answer++;
                }
            }
            console.log(answer);
        }
    }
});

function solve(input) {
    // YOUR BUGS HERE...
    res = [];
    input.forEach(e => {
        let a = e[1].split(' ').map(o => parseInt(o));
        let min_a = Math.min(...a);
        let res = a.filter(data => (data - min_a) > 0)
        console.log(res.length);
    });
    // console.log(res.join('\n'));
}

/** =========== DEFAULT FORMAT ==============
 *
 *  */
function set_n_line() {
    // set return 0 if the problem needs dynamic n line inputs
    // set return n > 0 if the problem needs fixed n  line inputs
    return 2
}
const readline = require('readline').createInterface({ input: process.stdin });
let inputs = []; let sub_input = []; let t = 0; let n_line_subinput = set_n_line();
function fillInput(line) {
    // dynamic n_line
    if (n_line_subinput === 0) n_line_subinput = parseInt(line)
    else if (sub_input.length < n_line_subinput) {
        sub_input.push(line)
        if (sub_input.length == n_line_subinput) {
            inputs.push(sub_input); sub_input = [];
            n_line_subinput = set_n_line();
        }
    }
}

readline.on('line', line => {
    if (t === 0) t = parseInt(line)
    else if (inputs.length < t) {
        fillInput(line)
        if (inputs.length == t) { solve(inputs);readline.close() }
    }
});
/* =========== DEFAULT FORMAT END ============== */

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

//Don't have to see. end------------------------------------------
function Main(){
	var t = nextInt();
	for(var i = 0; i < t; i++){
		var N = nextInt();
		var list = nextIntArray(N);
		list.sort(function(a,b){
			return a - b;
		});
		var output = 0;
		for(var j = 0; j < N - 1; j++){
			if(list[j] < list[j + 1]){
				output = N - (j + 1);
				break;
			}
		}
		myout(output);
	}
}

/*
 * File Created: Tuesday, 16th February 2021 2:01:47 pm
 * Author: Lukas Rimkus
 */

 'use-strict'

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

 let data = '';
 let currentLine = 0;

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

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

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

     while(testCases--) {

         const l = parseInt(readLine());

         const an = readLine().split(' ').map(Number);

         const res = a(l, an);

         console.log(res)
     }
 });

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

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

 function a(n,a){
     a.sort((a,b) => a - b);
     let count = 0;
     for(let i = 0 ; i < n; i++){
         if(i === n - 1) break;
         if(a[i] !== a[i+1]){
             return n - i - 1;
         }
     }
     return 0;
 }

module.exports = a;

'use strict';

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

let inputString = '';
let currentLine = 0;

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

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

    main();
});

function readline() {
    return inputString[currentLine++];
}
/**
2
3 7
24 25 27
10 7
51 52 53 54 55 56 57 58 59 60
**/

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

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

function lcm(a, b) {
    return (a / gcd(a, b) * b);
}

function main() {
    let n = Number(readline());

    for(let r=0;r<n;r++) {
        solve();
    }

}

function solve() {
    let n = readline();
    let a = readline().split(" ").map(Number);

    let min = Math.min(...a);

    let count = 0;

    for(let i=0;i<a.length;i++) {
        if(a[i] > min) {
            //console.log(a[i], max);
            count++;
        }
    }

    console.log(count);

}

'use strict';

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

let inputString = '';
let currentLine = 0;

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

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

    main();
});

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

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

function main() {
    var x = Number(readline())
    Array(Number(x)).fill(1).map((t, i) => {
        var n = parseInt(readline())

        var a = readline().split(' ').map((x, i) => {
            return parseInt(x)
        })
        var min = a[0]
        for (var i = 0; i < n; i++) {
            if (a[i] < min) {
                min = a[i]
            }
        }
        var res = n
        for (var i = 0; i < n; i++) {
            if(a[i] === min) res--
        }
        console.log(res)
    })

}

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

    return gcd(b, a % b);
}

var t = readline();
    for(var i = 0 ; i < t ; i++){
        var n = readline(),
            a = readline().split(' ').sort((a,b) => a-b),
            winners = a.filter((hero)=>{
                return hero!= a[0];
            });
            print(winners.length);
    }

var t = readline();
    for(var i = 0 ; i < t ; i++){
        var n = readline(),
            a = readline().split(' ').sort((a,b) => a-b),
            winnrers = a.filter((hero)=>{
                return hero!= a[0];
            });
            print(winnrers.length);
    }

var tests = +readline();
while(tests>0){
    var arrLen = +readline();
    var arr = readline().split(" ").map(x=> parseInt(x));
    arr.sort((a,b)=>a-b);

    var i=0;
    var res = 0;

    while(i<arrLen-1) {
        if(arr[i]<arr[i+1]) {
            res = arrLen-i-1;
            break;
        }
        i++;
    }
    tests--;
    print(res);
}

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

let standardInputString = "";
let currentLine = 0;

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

process.stdin.on("data", rawData => {
    standardInputString += rawData;
});

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

function main() {
    let t = parseInt(readline());
    while (t--) {
        readline();
        let arrLevel = readline().split(" ").map(string => { return parseInt(string) });
        console.log(getWinners(arrLevel));
    }
}
function getWinners(arrLevels) {
    let min = arrLevels[0];
    let minCount = 1;

    for (let i = 1; i < arrLevels.length; i++) {
        if (arrLevels[i] < min) {
            min = arrLevels[i];
            minCount = 1;
        }
        else if (arrLevels[i] == min) {
            minCount++;
        }
    }
    return arrLevels.length - minCount;
}

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

let standardInputString = "";
let currentLine = 0;

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

process.stdin.on("data", rawData => {
    standardInputString += rawData;
});

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

function main() {
    let t = parseInt(readline());
    while (t--) {
        readline();
        let arrLevel = readline().split(" ").map(string => { return parseInt(string) });
        console.log(getWinners(arrLevel));
    }
}
function getWinners(arrLevels) {
    let min = arrLevels[0];
    let minCount = 0;

    for (let i = 1; i < arrLevels.length; i++) {
        if (arrLevels[i] < min) {
            min = arrLevels[i];
            minCount = 1;
        }
        else if (arrLevels[i] == min) {
            minCount++;
        }
    }
    return arrLevels.length - minCount;
}

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

let standardInputString = "";
let currentLine = 0;

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

process.stdin.on("data", rawData => {
    standardInputString += rawData;
});

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

function main() {
    let t = parseInt(readline());
    while (t--) {
        readline();
        let arrLevel = readline().split(" ").map(string => { return parseInt(string) });
        console.log(getWinners(arrLevel));
    }
}
function getWinners(arrLevels) {
    let min = arrLevels[0];
    let minCount = 1;

    for (let i = 1; i < arrLevels.length; i++) {
        if (arrLevels[i] < min) {
            min = arrLevels[i];
            minCount = 1;
        }
        else if (arrLevels == min) {
            minCount++;
        }
    }
    return arrLevels.length - minCount;
}

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

let standardInputString = "";
let currentLine = 0;

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

process.stdin.on("data", rawData => {
    standardInputString += rawData;
});

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

function main() {
    let t = parseInt(readline());
    while (t--) {
        readline();
        let arrLevel = readline().split(" ").map(string => { return parseInt(string) });
        console.log(getWinners(arrLevel));
    }
}
function getWinners(arrLevels) {
    let min = arrLevels[0];
    let minCount = 0;

    for (let i = 1; i < arrLevels.length; i++) {
        if (arrLevels[i] < min) {
            min = arrLevels[i];
            minCount = 1;
        }
        else if (arrLevels == min) {
            minCount++;
        }
    }
    return arrLevels.length - minCount;
}

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

let standardInputString = "";
let currentLine = 0;

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

process.stdin.on("data", rawData => {
    standardInputString += rawData;
});

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

function main() {
    let t = parseInt(readline());
    while (t--) {
        readline();
        let arrLevel = readline().split(" ").map(string => { return parseInt(string) });
        console.log(getWinners(arrLevel));
    }
}
function getWinners(arrLevels) {
    let min = arrLevels[0];
    let minCount = 0;

    for (let i = 1; i < arrLevels.length; i++) {
        if (arrLevels[i] < min) {
            min = arrLevels[i];
            minCount = 1;
        }
        else if (arrLevels) {
            minCount++;
        }
    }
    return arrLevels.length - minCount;
}

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

let standardInputString = "";
let currentLine = 0;

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

process.stdin.on("data", rawData => {
    standardInputString += rawData;
});

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

function main() {
    let t = parseInt(readline());
    while (t--) {
        readline();
        let arrLevel = readline().split(" ").map(string => { return parseInt(string) });
        console.log(getWinners(arrLevel));
    }
}
function getWinners(arrLevels) {
    let min = arrLevels[0];
    let minCount = 0;
    let max = arrLevels[0];

    for (let i = 1; i < arrLevels.length; i++) {
        if (arrLevels[i] < min) {
            min = arrLevels[i];
            minCount = 1;
        }
        else if (arrLevels) {
            minCount++;
        }
        if (arrLevels[i] > max) {
            max = arrLevels[i];
        }
    }
    return (max === min) ? 0 : arrLevels.length - minCount;
}

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

let standardInputString = "";
let currentLine = 0;

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

process.stdin.on("data", rawData => {
    standardInputString += rawData;
});

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

function main() {
    let t = parseInt(readline());
    while (t--) {
        let n = readline();
        let arrLevel = readline().split(" ").map(string => { return parseInt(string) });
        console.log(getWinners(arrLevel));
    }
}
function getWinners(arrLevels) {
    let min = arrLevels[0];
    let max = arrLevels[0];

    for (let i = 1; i < arrLevels.length; i++) {
        if (arrLevels[i] < min) {
            min = arrLevels[i];
        }
        if (arrLevels[i] > max) {
            max = arrLevels[i];
        }
    }
    return (max === min) ? 0 : arrLevels.length - 1;
}

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

let standardInputString = "";
let currentLine = 0;

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

process.stdin.on("data", rawData => {
    standardInputString += rawData;
});

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

function main() {
    let t = parseInt(readline());
    while (t--) {
        readline();
        let arrLevel = readline().split().map(string => { return parseInt(string) });
        console.log(getWinners(arrLevel));
    }
}
function getWinners(arrLevels) {
    console.log(arrLevels);
    let min = arrLevels[0];
    let max = arrLevels[0];

    for (let i = 1; i < arrLevels.length; i++) {
        if (arrLevels[i] < min) {
            min = arrLevels[i];
        }
        if (arrLevels[i] > max) {
            max = arrLevels[i];
        }
    }
    return (max === min) ? 0 : arrLevels.length - 1;
}

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

let standardInputString = "";
let currentLine = 0;

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

process.stdin.on("data", rawData => {
    standardInputString += rawData;
});

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

function main() {
    let t = parseInt(readline());
    while (t--) {
        readline();
        let arrLevel = readline().split().map(string => { return parseInt(string) });
        console.log(getWinners(arrLevel));
    }
}
function getWinners(arrLevels) {
    let min = arrLevels[0];
    let max = arrLevels[0];

    for (let i = 1; i < arrLevels.length; i++) {
        if (arrLevels[i] < min) {
            min = arrLevels[i];
        }
        if (arrLevels[i] > max) {
            max = arrLevels[i];
        }
    }
    return (max === min) ? 0 : arrLevels.length - 1;
}

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

let standardInputString = "";
let currentLine = 0;

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

process.stdin.on("data", rawData => {
    standardInputString += rawData;
});

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

function main() {
    let t = parseInt(readline());
    while (t--) {
        let arrLevel = readline().split().map(string => { return parseInt(string) });
        console.log(getWinners(arrLevel));
    }
}
function getWinners(arrLevels) {
    let min = arrLevels[0];
    let max = arrLevels[0];

    for (let i = 1; i < arrLevels.length; i++) {
        if (arrLevels[i] < min) {
            min = arrLevels[i];
        }
        if (arrLevels[i] > max) {
            max = arrLevels[i];
        }
    }
    return (max === min) ? 0 : arrLevels.length - 1;
}

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

let standardInputString = "";
let currentLine = 0;

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

process.stdin.on("data", rawData => {
    standardInputString += rawData;
});

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

function main() {
    let arrLevels = [];
    let testCases = +(readline());
    for (let i = 0; i < testCases.length; i++) {
        readline();
        arrLevels.push(readline().split(" ").map(string => { return parseInt(string) }));
    }
    for (let i = 0; i < arrLevels.length; i++) {
        console.log(getWinners(arrLevels[i]));
    }
}
function getWinners(arrLevels) {
    let min = arrLevels[0];
    let max = arrLevels[0];

    for (let i = 1; i < arrLevels.length; i++) {
        if (arrLevels[i] < min) {
            min = arrLevels[i];
        }
        if (arrLevels[i] > max) {
            max = arrLevels[i];
        }
    }
    return (max === min) ? 0 : arrLevels.length - 1;
}

//required remainder
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*/
    var a = lines[0];
    var lowest = 0;
    var answer = 0;
    for(var j = 1; j < (Number(a) + 1) * 2; j++){
        lowest = 0;
        answer = 0;
        if(j % 2 === 0){
            var n = lines[j].split(' ').sort(function(a, b){return a - b});
            lowest = n[0];
            for(var k = 1; k < n.length; k++){
                if(lowest < n[k]){
                    answer++;
                }
            }
            console.log(answer);
        }
    }
});

//required remainder
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*/
    var a = lines[0];
    var lowest = 0;
    var answer = 0;
    for(var j = 1; j < (Number(a) + 1) * 2; j++){
        lowest = 0;
        answer = 0;
        if(j % 2 === 0){
            var n = lines[j].split(' ').sort(function(a, b){return a - b});
            lowest = n[0];
            for(var k = 1; k < n.length + 1; k++){
                if(lowest < n[k]){
                    answer++;
                }else{
                    continue;
                }
            }
            console.log(answer);
        }
    }
});

//required remainder
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*/
    var a = lines[0];
    var lowest = 0;
    var answer = 0;
    for(var j = 1; j < (Number(a) + 1) * 2; j++){
        lowest = 0;
        answer = 0;
        if(j % 2 === 0){
            var n = lines[j].split(' ').sort(function(a, b){return a - b});
            lowest = n[0];
            for(var k = 1; k < n.length + 1; k++){
                if(lowest < n[k]){
                    answer++;
                }
            }
            console.log(answer);
        }
    }
});

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*/
    var k = lines[0];
    var answer = '';
    var a = 0;
    var b = 0;
    for(var j = 1; j < Number(k) + 1; j++){
        var n = lines[j];
        a = 0;
        b = 0;
        answer = '';
        if(n % 4 !== 0){
            console.log('NO');
        }else{
            console.log('YES');
            for(i = 2; i <= n; i += 2){
                answer += i + ' ';
                a += i;
            }
            for(i = 1; i < n - 2; i += 2){
                answer += i + ' ';
                b += i;
            }
            console.log(answer + (a-b));
        }
    }
});

function solve(input) {
    // YOUR BUGS HERE...
    res = [];
    input.forEach(e => {
        let a = e[1].split(' ').map(o => parseInt(o));
        a.sort();
        let res = a.filter(data => (data - a[0]) > 0)
        console.log(res.length);
    });
}

/** =========== DEFAULT FORMAT ==============
 *
 *  */
function set_n_line() {
    return 2
}
const readline = require('readline').createInterface({ input: process.stdin });
let inputs = []; let sub_input = []; let t = 0; let n_line_subinput = set_n_line();
function fillInput(line) {
    // dynamic n_line
    if (n_line_subinput == 0) n_line_subinput = parseInt(line)
    else if (sub_input.length < n_line_subinput) {
        sub_input.push(line)
        if (sub_input.length == n_line_subinput) {
            inputs.push(sub_input); sub_input = [];
            n_line_subinput = set_n_line();
        }
    }
}

readline.on('line', line => {
    if (t == 0) t = parseInt(line)
    else if (inputs.length < t) {
        fillInput(line)
        if (inputs.length == t) { solve(inputs);readline.close() }
    }
});
/* =========== DEFAULT FORMAT END ============== */


const getInversionsCount = (nums) => {
  var count = 0;

  for (var i = 1; i < nums.length; i++) {
    for (var j = 0; j < i; j++) {
      if (nums[i] < nums[j]) {
        count++;
      }
    }
  }

  return count;
};

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

  const nums = readline()
    .split(" ")
    .map((i) => Number(i));

  var operationsCount = getInversionsCount(nums);

  const inputCount = Number(readline());

  for (var i = 0; i < inputCount; i++) {
    var input = readline()
      .split(" ")
      .map((i) => Number(i));

    operationsCount += Math.floor((input[1] - input[0] + 1) / 2);

    if (operationsCount % 2 === 0) {
      print("even");
    } else {
      print("odd");
    }
  }
};

main();

// https://en.wikipedia.org/wiki/Parity_of_a_permutation
var line = readline ();
line = line.trim ().split ( ' ' );
var n = line;
var aa = [ ];
line = readline ();
aa = line.trim ().split ( ' ' );
var i, j, cnt = 0;
var a = aa;
a.map ( function ( a ) { return (+ a); } ); // convert array elements to numbers
function merge ( a, b ) {
    var i = 0, j = 0;
    var result = [ ];
    while ( i < a.length && j < b.length ) {
        if ( (+ a [ i ]) < (+ b [ j ]) ) {
            result.push ( a [ i ++ ] );
        } else {
            result.push ( b [ j ++ ] );
            cnt += a.length - i;
        }
    }
    while ( i < a.length ) {
        result.push ( a [ i ++ ] );
    }
    while ( j < b.length ) {
        result.push ( b [ j ++ ] );
        cnt += a.length - i;
    }
    return result;
}
function mergesort ( arr ) {
    var suba = [ ], subb = [ ];
    if ( arr.length > 1 ) {
        suba = mergesort ( arr.slice ( 0, Math.floor ( arr.length / 2 ) ) );
        subb = mergesort ( arr.slice ( Math.floor ( arr.length / 2 ), arr.length ) );
        return merge ( suba, subb );
    }
    return arr;
}
mergesort ( a );
var parity = cnt % 2;
var m = (+ readline ());
var l, r;
for ( var g = 0; g < m; g ++ ) {
    line = readline ();
    line = line.trim ().split ( ' ' );
    l = line [ 0 ];
    r = line [ 1 ];
    if ( Math.ceil ( (r - l) / 2) % 2 == 1 ) parity ^= 1;
    print ( parity ? 'odd' : 'even' );
}

// https://en.wikipedia.org/wiki/Parity_of_a_permutation
var line = readline ();
line = line.trim ().split ( ' ' );
var n = line;
var aa = [ ];
line = readline ();
aa = line.trim ().split ( ' ' );
var i, j, cnt = 0;
for ( i = 0; i < n - 1; i ++ )
    for ( j = i + 1; j < n; j ++ )
        if ( aa [ i ] > aa [ j ] ) cnt ++;
var parity = cnt % 2;
var m = (+ readline ());
var l, r;
for ( var g = 0; g < m; g ++ ) {
    line = readline ();
    line = line.trim ().split ( ' ' );
    l = line [ 0 ];
    r = line [ 1 ];
    if ( Math.ceil ( (r - l) / 2) % 2 == 1 ) parity ^= 1;
    print ( parity ? 'odd' : 'even' );
}