You are given two strings $$$s$$$ and $$$t$$$, both consisting of lowercase English letters. You are going to type the string $$$s$$$ character by character, from the first character to the last one.When typing a character, instead of pressing the button corresponding to it, you can press the "Backspace" button. It deletes the last character you have typed among those that aren't deleted yet (or does nothing if there are no characters in the current string). For example, if $$$s$$$ is "abcbd" and you press Backspace instead of typing the first and the fourth characters, you will get the string "bd" (the first press of Backspace deletes no character, and the second press deletes the character 'c'). Another example, if $$$s$$$ is "abcaa" and you press Backspace instead of the last two letters, then the resulting text is "a".Your task is to determine whether you can obtain the string $$$t$$$, if you type the string $$$s$$$ and press "Backspace" instead of typing several (maybe zero) characters of $$$s$$$.

The first line contains a single integer $$$q$$$ ($$$1 \le q \le 10^5$$$) — the number of test cases. The first line of each test case contains the string $$$s$$$ ($$$1 \le |s| \le 10^5$$$). Each character of $$$s$$$ is a lowercase English letter. The second line of each test case contains the string $$$t$$$ ($$$1 \le |t| \le 10^5$$$). Each character of $$$t$$$ is a lowercase English letter. It is guaranteed that the total number of characters in the strings over all test cases does not exceed $$$2 \cdot 10^5$$$.

For each test case, print "YES" if you can obtain the string $$$t$$$ by typing the string $$$s$$$ and replacing some characters with presses of "Backspace" button, or "NO" if you cannot. You may print each letter in any case (YES, yes, Yes will all be recognized as positive answer, NO, no and nO will all be recognized as negative answer).

4
ababa
ba
ababa
bb
aaa
aaaa
aababa
ababa

NoteConsider the example test from the statement.In order to obtain "ba" from "ababa", you may press Backspace instead of typing the first and the fourth characters.There's no way to obtain "bb" while typing "ababa".There's no way to obtain "aaaa" while typing "aaa".In order to obtain "ababa" while typing "aababa", you have to press Backspace instead of typing the first character, then type all the remaining characters.

function test(s, t) {
  var sLength = s.length;
  var tLength = t.length;
  if (tLength > sLength) return 'NO';
  var lengthDiff = sLength - tLength;
  var parityMatch = lengthDiff % 2;
  var subS = parityMatch === 1 ? s.substring(1) : s;
  var subT = t;

  var foundNextStep = false;
  var newLengthDiff = lengthDiff - parityMatch;

  // for (var i = parityMatch; i <= newLengthDiff; i += 2) {
  //   if (s.substring(i, t.length) === t) {
  //     return 'Yes';
  //   }
  // }

  while (subT.length) {
    for (var i = 0; i <= newLengthDiff; i += 2) {
      if (subS[i] === subT[0]) {
        subS = subS.substring(i + 1);
        subT = subT.substring(1);
        newLengthDiff = subS.length - subT.length;
        foundNextStep = true;
        break;
      }
    }
    if (!foundNextStep) {
      return 'NO';
    }
    if (newLengthDiff === 0) {
      return subS === subT ? 'YES' : 'NO';
    }
    if (subT.length === 0) {
      if (subS.length % 2) {
        console.log(subS);
      }
      return 'YES';
    }
    foundNextStep = false;
  }
}

var amount = parseInt(readline());
for (var i = 0; i < amount; i++) {
  print(test(readline(), readline()));
}

for(t=readline();t--;){
    x=readline(),y=readline()
    for(i=x.length-1, p=y.length-1; ~p && i>-1; i--) {
        ~p && x[i] == y[p] ? p-- : i--;
    }
    print(~p?'NO':'YES')
}

for(t=readline();t--;){
    x=readline(),y=readline()
    for(i=x.length-1, p=y.length-1; i>-1; i--) {
        ~p && x[i] == y[p] ? p-- : i--;
    }
    print(~p?'NO':'YES')
}

for (var n = Number (readline ()); n > 0; n--)
    {
    var s = readline ();
    var t = readline ();
    var i = s.length - 1;
    var j = t.length - 1;

    while (i >= j && j >= 0)
        {
        if (s[i] === t[j]) { i--; j--; }
        else { i -= 2; }
        }

    print (j < 0 ? "Yes" : "No");
    }

for(t=readline();t--;){
    x=readline(),y=readline()
    for(i=x.length-1,p=y.length-1;i>-1;i--)~p&&x[i]==y[p]?p--:i--;
    print(~p?'NO':'YES')
}

'use strict';

function solve(a, b) {
  const n = a.length,
        m = b.length;
  if (m > n) return 'NO';
  const check = (i, j = 1) => {
    let flag = i & 1 ^ 1;
    for (; i < n && j < m; i++) {
      if (a[i] === b[j] && (i & 1) !== flag) {
        j++;
        flag ^= 1;
      }
    }
    return j === m && !(n - i & 1);
  };
  for (let i = 0; i < n; i += 2) {
    if (a[i] === b[0]) {
      if (check(i + 1)) return 'YES';
      break;
    }
  }
  for (let i = 1; i < n; i += 2) {
    if (a[i] === b[0]) {
      if (check(i + 1)) return 'YES';
      break;
    }
  }
  return 'NO';
}

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

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

'use strict';

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 tests_count = parseInt(readline());
  for (var test = 0; test < tests_count; test++) {
    const text = readline();
    const pattern = readline();
    console.log(verifyPattern(text, pattern, 0) || verifyPattern(text, pattern, 1) ? "YES" : "NO")
  }
}

function verifyPattern(text, pattern, parity) {
  let text_idx = parity - 1;
  for (let pattern_idx = 0; pattern_idx < pattern.length; pattern_idx++) {
    text_idx = findNextWithParity(text, text_idx + 1, pattern[pattern_idx]);
    if (text_idx >= text.length)
      return false;
  }
  return (text.length - text_idx) % 2 == 1;
}
function findNextWithParity(src, idx, c) {
  while (idx < src.length && c !== src[idx]) idx += 2;
  return idx;
}

'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 tests_count = parseInt(readline());
  for (var test = 0; test < tests_count; test++) {
    const text = readline();
    const pattern = readline();
    console.log(verifyPattern(text, pattern, 0) || verifyPattern(text, pattern, 1) ? "YES" : "NO")
  }
}

function verifyPattern(text, pattern, parity) {
  let pattern_idx = 0;
  let text_idx = parity-1;
  while (pattern_idx < pattern.length) {
    text_idx = findNextWithParity(text, text_idx + 1, pattern[pattern_idx]);
    if (text_idx >= text.length)
      return false;
    pattern_idx++
  }
  return (text.length - text_idx) % 2 == 1;
}
function findNextWithParity(src, idx, c) {
  while (idx < src.length && c !== src[idx]) idx += 2;
  return idx;
}

'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 tests_count = parseInt(readline());
  for (var test = 0; test < tests_count; test++) {
    const src = readline();
    const pat = readline();
    console.log(verify(src, pat, 0) || verify(src, pat, 1) ? "YES" : "NO")
  }
}

function verify(src, pat, parity) {
  let src_idx = findNextWithParity(src, 0, pat[0], parity);
  if (src_idx >= src.length)
    return false;

  let pat_idx = 1;
  while (pat_idx < pat.length) {
    parity = 1 - src_idx % 2
    // El índice debe tener una paridad diferente al elemento actual (para que la diferencia sea divisible por 2)
    src_idx = findNextWithParity(src, src_idx + 1, pat[pat_idx], parity);
    if (src_idx >= src.length)
      return false;

    pat_idx++
  }
  return (src.length - src_idx)%2==1;
}
function findNextWithParity(src, idx, c, parity) {
  idx = findNext(src, idx, c);
  while (idx < src.length && (idx % 2 !== parity))
    idx = findNext(src, idx + 1, c);
  return idx;
}
function findNext(src, idx, c) {
  while (idx < src.length && c !== src[idx]) idx++;
  return idx;
}

function solution(s, t) {
  const m = s.length, n = t.length
  if (m < n) return false
  let i = m - 1, j = n - 1
  const delFirstOfS = (m - n) & 1
  const smallestIdxOfS = delFirstOfS ? 1 : 0
  while(i >= smallestIdxOfS && j >= 0) {
    if(s[i] === t[j]) {
      i--
      j--
    } else {
      i -= 2
    }
    if (j < 0) return true
  }
  return false
}

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

rl.on("line", (line) => {
  input.push(line);
  if (input.length === 3) {
    const t = input.pop()
    const s = input.pop()
    const res = solution(s, t)
    resArr.push(res ? 'YES' : 'NO')
  }
});
rl.on("close", () => {
  resArr.forEach(e => console.log(e))
});

let _inputLines;
let _lineNumber = 0;
let inputReader = _inputReader();

function _main() {
  _inputLines = _inputData
    .trim()
    .split("\n")
    .map((string) => {
      return string.trim();
    });

  //------------------------------ <Solution> -------------------------------//

  let t = inputReader.readNumber();
  function solve() {
    let s = inputReader.readLine().split("");
    let t = inputReader.readLine().split("");
    if (s.length < t.length) {
      console.log("NO");
      return;
    }
    let i = s.length - 1,
      j = t.length - 1;
    while (i >= 0 && j >= 0) {
      if (s[i] == t[j]) {
        i--;
        j--;
      } else {
        i -= 2;
      }
    }
    //console.log([i, j]);
    if (j >= 0) {
      console.log("NO");
    } else console.log("YES");
  }

  while (t--) {
    solve();
  }

  //------------------------------ </Solution> -------------------------------//
}

var _inputData = "";
function cacheInput(data) {
  _inputData += data;
}

process.stdin.resume();
process.stdin.setEncoding("utf8");
process.stdin.on("data", cacheInput).on("end", _main);

function _inputReader() {
  function readNumber() {
    return Number(_inputLines[_lineNumber++]);
  }

  function readLine() {
    return _inputLines[_lineNumber++];
  }

  return {
    readNumber,
    readLine,
  };
}

/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    Node.js template for
    the coding contests.

            ~~*/
        'use strict';
            /*~~

    Tip:
    Don't raise your voice,
    improve your argument.

            ~~~~

   cat /dev/ass > /dev/head
           Ctrl+C
  cat /knowledge > /dev/head

               © Yakov Gellert
                       frvr.ru

~~~~Don't~touch~that~part:~~*/

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

let inputString = '',
    currentLine = 0,
    outputString = '';

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

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

    /*
     * Running a solution function
     * with whole input as an array
     * and a string for a buffered output
     */
    solution(inputString, outputString);

    /*
     * Return a buffered output
     */
    write(outputString);
});

/* Read a line from stdin */
function readline() {
    if (currentLine < inputString.length) {
        return inputString[currentLine++];
    }

    return '';
}

/* Read array from stdin */
function readarr() {
    return readline().split(' ');
}

/* Read numbers from stdin */
function readnums() {
    return readarr().map(num => parseInt(num));
}

/* Write a string to stdout */
function write(data) {
    data = data.toString();
    process.stdout.write(data);

    return data;
}

/* Write a string with \n to stdout */
function writeline(data) {
    write(data.toString() + '\n');
}

/* Append a string to a buffer */
function fwrite(data) {
    outputString += data.toString() + ' ';
}

/* Append a string with \n to a buffer */
function fwriteline(data) {
    fwrite(data);
    outputString += '\n';
}

/* Throw an error */
function error(name) {
    throw new Error(name.toString());
}

/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   Write your solution here
~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/

function solution(input, output) {

    for (let cases = readnums()[0]; cases > 0; cases -= 1) {
        let sample = readline().split('').reverse().join(''),
            target = readline().split('').reverse().join(''),
            sampleI = 0,
            targetI = 0;

        if (target.length > sample.length) {
            fwriteline("NO");
            continue;
        }

        while (targetI < target.length && sampleI < sample.length) {
            if (target[targetI] === sample[sampleI]) {
                sampleI += 1;
                targetI += 1;
                continue;
            }

            sampleI += 2;
        }

        fwriteline(targetI === target.length ? "YES" : "NO");
    }
}

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

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

function main () {
	let T = rn();
	while (T--) {
		let s = rl();
		let t = rl();

		let i = s.length - 1, j = t.length - 1;
		while (i >= 0 && j >= 0) {
			if (s[i] == t[j]) {
				i--; j--;
			} else {
				i -= 2;
			}
		}

		const ans = j < 0;

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

function test(s, t) {
  var sLength = s.length;
  var tLength = t.length;
  if (tLength > sLength) return 'NO';
  var dbg = s.startsWith('fwnzzvuqoqfxzgicxplljpoitnkkjvrsdpighivrvnawrc');
  var lengthDiff = sLength - tLength;
  var parityMatch = lengthDiff % 2;
  var subS = parityMatch === 1 ? s.substring(1) : s;
  var subT = t;

  var foundNextStep = false;
  var newLengthDiff = lengthDiff - parityMatch;

  // for (var i = parityMatch; i <= newLengthDiff; i += 2) {
  //   if (s.substring(i, t.length) === t) {
  //     return 'Yes';
  //   }
  // }
  if (dbg) {
    print('sLe: ' + sLength + ' - tLe: ' + tLength);
  }
  while (subT.length) {
    for (var i = 0; i <= newLengthDiff; i += 2) {
      if (subS[i] === subT[0]) {
        subS = subS.substring(i + 1);
        subT = subT.substring(1);
        newLengthDiff = subS.length - subT.length;
        foundNextStep = true;
        break;
      }
    }
    if (!foundNextStep) {
      return 'NO';
    }
    if (newLengthDiff === 0) {
      return subS === subT ? 'YES' : 'NO';
    }
    if (subT.length === 0) {
      if (subS.length % 2) {
        console.log(subS);
      }
      return 'YES';
    }
    foundNextStep = false;
  }
}

var amount = parseInt(readline());
for (var i = 0; i < amount; i++) {
  print(test(readline(), readline()));
}

function test(s, t) {
  var sLength = s.length;
  var tLength = t.length;
  if (tLength > sLength) return 'NO';
  var dbg = tLength > 40000 && sLength > 40000 && sLength !== 49912;
  var lengthDiff = sLength - tLength;
  var parityMatch = lengthDiff % 2;
  var subS = parityMatch === 1 ? s.substring(1) : s;
  var subT = t;

  var branches = [];
  var foundNextStep = false;
  var newLengthDiff = lengthDiff - parityMatch;

  // for (var i = parityMatch; i <= newLengthDiff; i += 2) {
  //   if (s.substring(i, t.length) === t) {
  //     return 'Yes';
  //   }
  // }

  while (subT.length) {
    for (var i = 0; i <= newLengthDiff; i++) {
      if (i % 2 === 0 && subS[i] === subT[0]) {
        var lengthLeft = newLengthDiff - i;
        if (newLengthDiff - i - 2 >= 0 && subS.length > i + 2) {
          branches.push({ subT, subS: subS.substring(i + 2) });
        }
        var groupLen;
        var prevTryLen = 1;
        var tryLen = lengthLeft;
        var nextTryLen = lengthLeft;
        subS = subS.substring(i);
        while (!groupLen) {
          var lengthMatches = subS.startsWith(subT.substring(0, tryLen));
          if (lengthMatches && lengthLeft === tryLen) {
            groupLen = tryLen;
          }
          // var lengthMin1Matches = subS.startsWith(subT.substring(0, tryLen - 1));
          if (!lengthMatches) {
            nextTryLen = Math.floor(tryLen - Math.abs(tryLen - prevTryLen) / 2);
          } else if (subS.startsWith(subT.substring(0, tryLen + 1))) {
            nextTryLen = Math.floor(tryLen + Math.abs(tryLen - prevTryLen) / 2);
          } else {
            groupLen = tryLen;
          }
          prevTryLen = tryLen;
          tryLen = nextTryLen;
          if (prevTryLen === nextTryLen) {
            groupLen = Math.max(tryLen - 1, 1);
          }
        }
        if (dbg) {
          print('groupLen: ' + groupLen + ' - sLe: ' + sLength + ' - tLe: ' + tLength);
        }
        subS = subS.substring(groupLen);
        subT = subT.substring(groupLen);
        newLengthDiff = subS.length - subT.length;
        foundNextStep = true;
        break;
      }
    }

    if (!foundNextStep || newLengthDiff === 0 || (subT.length === 0 && subS.length % 2 === 0)) {
      if (subS === subT || (subS.length % 2 === 0 && subT.length === 0)) {
        return 'YES';
      }
      var roadNotTaken = branches.pop();
      // console.log('roadNotTaken', roadNotTaken)
      if (!roadNotTaken) {
        return 'NO';
      }
      // print(roadNotTaken);
      subS = roadNotTaken.subS;
      subT = roadNotTaken.subT;
    }
    foundNextStep = false;
  }
}

var amount = parseInt(readline());
for (var i = 0; i < amount; i++) {
  print(test(readline(), readline()));
}

function test(s, t) {
  var sLength = s.length;
  var tLength = t.length;
  if (tLength > sLength) return 'NO';
  var dbg = tLength > 40000 && sLength > 40000;
  var lengthDiff = sLength - tLength;
  var parityMatch = lengthDiff % 2;
  var subS = parityMatch === 1 ? s.substring(1) : s;
  var subT = t;

  var branches = [];
  var foundNextStep = false;
  var newLengthDiff = lengthDiff - parityMatch;

  // for (var i = parityMatch; i <= newLengthDiff; i += 2) {
  //   if (s.substring(i, t.length) === t) {
  //     return 'Yes';
  //   }
  // }

  while (subT.length) {
    for (var i = 0; i <= newLengthDiff; i++) {
      if (i % 2 === 0 && subS[i] === subT[0]) {
        var lengthLeft = newLengthDiff - i;
        if (newLengthDiff - i - 2 >= 0 && subS.length > i + 2) {
          branches.push({ subT, subS: subS.substring(i + 2) });
        }
        var groupLen;
        var prevTryLen = 1;
        var tryLen = lengthLeft;
        var nextTryLen = lengthLeft;
        subS = subS.substring(i);
        while (!groupLen) {
          var lengthMatches = subS.startsWith(subT.substring(0, tryLen));
          if (lengthMatches && lengthLeft === tryLen) {
            groupLen = tryLen;
          }
          // var lengthMin1Matches = subS.startsWith(subT.substring(0, tryLen - 1));
          if (!lengthMatches) {
            nextTryLen = Math.floor(tryLen - Math.abs(tryLen - prevTryLen) / 2);
          } else if (subS.startsWith(subT.substring(0, tryLen + 1))) {
            nextTryLen = Math.floor(tryLen + Math.abs(tryLen - prevTryLen) / 2);
          } else {
            groupLen = tryLen;
          }
          prevTryLen = tryLen;
          tryLen = nextTryLen;
          if (prevTryLen === nextTryLen) {
            groupLen = Math.max(tryLen - 1, 1);
          }
        }
        if (dbg) {
          print('groupLen: ' + groupLen + ' - sLe: ' + sLength + ' - tLe: ' + tLength);
        }
        subS = subS.substring(groupLen);
        subT = subT.substring(groupLen);
        newLengthDiff = subS.length - subT.length;
        foundNextStep = true;
        break;
      }
    }

    if (!foundNextStep || newLengthDiff === 0 || (subT.length === 0 && subS.length % 2 === 0)) {
      if (subS === subT || (subS.length % 2 === 0 && subT.length === 0)) {
        return 'YES';
      }
      var roadNotTaken = branches.pop();
      // console.log('roadNotTaken', roadNotTaken)
      if (!roadNotTaken) {
        return 'NO';
      }
      // print(roadNotTaken);
      subS = roadNotTaken.subS;
      subT = roadNotTaken.subT;
    }
    foundNextStep = false;
  }
}

var amount = parseInt(readline());
for (var i = 0; i < amount; i++) {
  print(test(readline(), readline()));
}

function test(s, t) {
  var sLength = s.length;
  var tLength = t.length;
  if (tLength > sLength) return 'NO';
  var lengthDiff = sLength - tLength;
  var parityMatch = lengthDiff % 2;
  var subS = parityMatch === 1 ? s.substring(1) : s;
  var subT = t;

  var branches = [];
  var foundNextStep = false;
  var newLengthDiff = lengthDiff - parityMatch;

  // for (var i = parityMatch; i <= newLengthDiff; i += 2) {
  //   if (s.substring(i, t.length) === t) {
  //     return 'Yes';
  //   }
  // }

  while (subT.length) {
    for (var i = 0; i <= newLengthDiff; i++) {
      if (i % 2 === 0 && subS[i] === subT[0]) {
        var lengthLeft = newLengthDiff - i;
        if (newLengthDiff - i - 2 >= 0 && subS.length > i + 2) {
          branches.push({ subT, subS: subS.substring(i + 2) });
        }
        var groupLen = 1;
        var prevTryLen = 1;
        var tryLen = lengthLeft;
        var nextTryLen = lengthLeft;
        subS = subS.substring(i);
        // while (!groupLen) {
        //   var lengthMatches = subS.startsWith(subT.substring(0, tryLen));
        //   if (lengthMatches && lengthLeft === tryLen) {
        //     groupLen = tryLen;
        //   }
        //   // var lengthMin1Matches = subS.startsWith(subT.substring(0, tryLen - 1));
        //   if (!lengthMatches) {
        //     nextTryLen = Math.floor((prevTryLen + tryLen) / 2);
        //   } else if (subS.startsWith(subT.substring(0, tryLen + 1))) {
        //     nextTryLen = Math.floor(tryLen + Math.abs(tryLen - prevTryLen) / 2);
        //   } else {
        //     groupLen = tryLen;
        //   }
        //   prevTryLen = tryLen;
        //   tryLen = nextTryLen;
        //   if (prevTryLen === nextTryLen) {
        //     groupLen = Math.max(tryLen - 1, 1);
        //   }
        // }
        subS = subS.substring(i + groupLen);
        subT = subT.substring(groupLen);
        newLengthDiff = subS.length - subT.length;
        foundNextStep = true;
        break;
      }
    }

    if (!foundNextStep || newLengthDiff === 0 || (subT.length === 0 && subS.length % 2 === 0)) {
      if (subS === subT || (subS.length % 2 === 0 && subT.length === 0) || subS.startsWith(subT)) {
        return 'YES';
      }
      var roadNotTaken = branches.pop();
      if (!roadNotTaken) {
        return 'NO';
      }
      // print(roadNotTaken);
      subS = roadNotTaken.subS;
      subT = roadNotTaken.subT;
    }
    foundNextStep = false;
  }
}

var amount = parseInt(readline());
for (var i = 0; i < amount; i++) {
  print(test(readline(), readline()));
}

function test(s, t) {
  var sLength = s.length;
  var tLength = t.length;
  if (tLength > sLength) return 'NO';
  var lengthDiff = sLength - tLength;
  var parityMatch = lengthDiff % 2;
  var subS = parityMatch === 1 ? s.substring(1) : s;
  var subT = t;

  var branches = [];
  var foundNextStep = false;
  var newLengthDiff = lengthDiff - parityMatch;

  // for (var i = parityMatch; i <= newLengthDiff; i += 2) {
  //   if (s.substring(i, t.length) === t) {
  //     return 'Yes';
  //   }
  // }

  while (subT.length) {
    for (var i = 0; i <= newLengthDiff; i++) {
      if (i % 2 === 0 && subS[i] === subT[0]) {
        var lengthLeft = newLengthDiff - i;
        if (newLengthDiff - i - 2 >= 0 && subS.length > i + 2) {
          branches.push({ subT, subS: subS.substring(i + 2) });
        }
        var groupLen;
        var prevTryLen = 1;
        var tryLen = lengthLeft;
        var nextTryLen = lengthLeft;
        subS = subS.substring(i);
        while (!groupLen) {
          var lengthMatches = subS.startsWith(subT.substring(0, tryLen));
          if (lengthMatches && lengthLeft === tryLen) {
            groupLen = tryLen;
          }
          // var lengthMin1Matches = subS.startsWith(subT.substring(0, tryLen - 1));
          if (!lengthMatches) {
            nextTryLen = Math.floor((prevTryLen + tryLen) / 2);
          } else if (subS.startsWith(subT.substring(0, tryLen + 1))) {
            nextTryLen = Math.floor(tryLen + Math.abs(tryLen - prevTryLen) / 2);
          } else {
            groupLen = tryLen;
          }
          prevTryLen = tryLen;
          tryLen = nextTryLen;
          if (prevTryLen === nextTryLen) {
            groupLen = Math.max(tryLen - 1, 1);
          }
        }
        subS = subS.substring(i + groupLen);
        subT = subT.substring(groupLen);
        newLengthDiff = subS.length - subT.length;
        foundNextStep = true;
        break;
      }
    }

    if (!foundNextStep || newLengthDiff === 0 || (subT.length === 0 && subS.length % 2 === 0)) {
      if (subS === subT || (subS.length % 2 === 0 && subT.length === 0) || subS.startsWith(subT)) {
        return 'YES';
      }
      var roadNotTaken = branches.pop();
      if (!roadNotTaken) {
        return 'NO';
      }
      // print(roadNotTaken);
      subS = roadNotTaken.subS;
      subT = roadNotTaken.subT;
    }
    foundNextStep = false;
  }
}

var amount = parseInt(readline());
for (var i = 0; i < amount; i++) {
  print(test(readline(), readline()));
}

function test(s, t) {
  var sLength = s.length;
  var tLength = t.length;
  if (tLength > sLength) return 'NO';
  var freqS = {};
  var freqT = {};
  var lengthDiff = sLength - tLength;
  var parityMatch = lengthDiff % 2;
  var subS = parityMatch === 1 ? s.substring(1) : s;
  var subT = t;

  Array.from(subS).forEach(function (sC) {
    freqS[sC] = (freqS[sC] || 0) + 1;
  });
  Array.from(subT).forEach(function (tC) {
    freqT[tC] = (freqT[tC] || 0) + 1;
  });
  var issueLetter = Object.keys(freqT).find(function (k) {
    return freqT[k] > (freqS[k] || 0);
  });
  if (issueLetter) {
    return 'NO';
  }

  var branches = [];
  var foundNextStep = false;
  var newLengthDiff = lengthDiff - parityMatch;
  while (subT.length) {
    for (var i = 0; i <= newLengthDiff; i++) {
      var sC = subS[i];
      freqS[sC]--;

      if (i % 2 === 0 && subS[i] === subT[0]) {
        if (newLengthDiff - i - 2 >= 0 && subS.length > i + 2) {
          var sCP1 = subS[i + 1];
          var savedFreqS = Object.assign({}, freqS);
          var savedFreqT = Object.assign({}, freqT);
          savedFreqS[sCP1]--;
          if (!freqT[sCP1] || freqT[sCP1] <= savedFreqS[sCP1]) {
            branches.push({
              subT, subS: subS.substring(i + 2), savedFreqS, savedFreqT,
            });
          }
        }
        freqT[subT[0]] -= 1;
        subS = subS.substring(i + 1);
        subT = subT.substring(1);
        newLengthDiff = subS.length - subT.length;
        foundNextStep = true;
        break;
      }
      if (freqT[sC] > freqS[sC]) {
        // console.log('SUB_S: ', subS);
        // console.log('SUB_T: ', subT);
        // console.log('I: ', i);
        // console.log(sC, freqT[sC], freqS[sC]);
        break;
      }
    }

    if (!foundNextStep || newLengthDiff === 0 || subT.length === 0) {
      if (subS === subT) {
        return 'YES';
      }
      var roadNotTaken = branches.pop();
      if (!roadNotTaken) {
        return 'NO';
      }
      // print(roadNotTaken);
      subS = roadNotTaken.subS;
      subT = roadNotTaken.subT;
      freqS = roadNotTaken.savedFreqS;
      freqT = roadNotTaken.savedFreqT;
    }
    foundNextStep = false;
  }
}

function test(s, t) {
  var sLength = s.length;
  var tLength = t.length;
  if (tLength > sLength) return 'NO';
  var freqS = {};
  var freqT = {};
  var lengthDiff = sLength - tLength;
  var parityMatch = lengthDiff % 2;
  var subS = parityMatch === 1 ? s.substring(1) : s;
  var subT = t;

  Array.from(subS).forEach(function (sC) {
    freqS[sC] = (freqS[sC] || 0) + 1;
  });
  Array.from(subT).forEach(function (tC) {
    freqT[tC] = (freqT[tC] || 0) + 1;
  });
  var issueLetter = Object.keys(freqT).find(function (k) {
    return freqT[k] > (freqS[k] || 0);
  });
  if (issueLetter) {
    return 'NO';
  }

  var branches = [];
  var foundNextStep = false;
  var newLengthDiff = lengthDiff - parityMatch;
  while (subT.length) {
    for (var i = 0; i <= newLengthDiff; i++) {
      var sC = subS[i];
      freqS[sC]--;
      if (freqT[sC] > freqS[sC]) {
        break;
      }

      if (i % 2 === 0 && subS[i] === subT[0]) {
        if (newLengthDiff - i - 2 >= 0 && subS.length > i + 2 && subS.substring(i + 2).includes(subT[0])) {
          var sCP1 = subS[i + 1];
          var savedFreqS = Object.assign({}, freqS);
          var savedFreqT = Object.assign({}, freqT);
          savedFreqS[sCP1]--;
          if (!freqT[sCP1] || freqT[sCP1] <= savedFreqS[sCP1]) {
            branches.push({
              subT, subS: subS.substring(i + 2), savedFreqS, savedFreqT,
            });
          }
        }
        freqT[subT[0]] -= 1;
        subS = subS.substring(i + 1);
        subT = subT.substring(1);
        newLengthDiff = subS.length - subT.length;
        foundNextStep = true;
        break;
      }
    }

    if (!foundNextStep || newLengthDiff === 0 || (subT.length === 0 && subS.length !== 0)) {
      if (subS === subT) {
        return 'YES';
      }
      var roadNotTaken = branches.pop();
      if (!roadNotTaken) {
        return 'NO';
      }
      // print(roadNotTaken);
      subS = roadNotTaken.subS;
      subT = roadNotTaken.subT;
      freqS = roadNotTaken.savedFreqS;
      freqT = roadNotTaken.savedFreqT;
    }
    foundNextStep = false;
  }
}

var amount = parseInt(readline());
for (var i = 0; i < amount; i++) {
  print(test(readline(), readline()));
}

function test(s, t) {
  var sLength = s.length;
  var tLength = t.length;
  if (tLength > sLength) return 'NO';
  var lengthDiff = sLength - tLength;
  var parityMatch = lengthDiff % 2;
  var subS = parityMatch === 1 ? s.substring(1) : s;
  var subT = t;
  var branches = [];
  var foundNextStep = false;
  var newLengthDiff = lengthDiff - parityMatch;
  var loopNr = 0;
  while (subT.length) {
    if (loopNr === 100000) {
      print(`B:${branches.length}, S:${s.length}, L:${t.length}`);
    }
    for (var i = 0; i <= newLengthDiff; i += 2) {
      if (subS[i] === subT[0]) {
        foundNextStep = true;
        if (newLengthDiff - i - 2 >= 0 && subS.length > i + 2) {
          branches.push({ subT, subS: subS.substring(i + 2) });
        }
        subS = subS.substring(i + 1);
        subT = subT.substring(1);
        newLengthDiff = subS.length - subT.length;
        break;
      }
    }
    if (!foundNextStep || newLengthDiff === 0 || (subT.length === 0 && subS.length !== 0)) {
      if (subS === subT) {
        return 'YES';
      }
      var roadNotTaken = branches.pop();
      if (!roadNotTaken) {
        return 'NO';
      }
      // print(roadNotTaken);
      subS = roadNotTaken.subS;
      subT = roadNotTaken.subT;
    }
    foundNextStep = false;
  }
}

'use strict';

function solve(a, b) {
  const n = a.length,
        m = b.length;
  if (m > n) return 'NO';
  const check = (i, j = 1) => {
    let flag = i & 1;
    for (let k = i + 1; k < n && j < m; k++) {
      if (a[k] === b[j] && (k & 1) !== flag) {
        j++;
        flag ^= 1;
      }
    }
    return j === m;
  };
  for (let i = 0; i < n; i += 2) {
    if (a[i] === b[0]) {
      if (check(i)) return 'YES';
      break;
    }
  }
  for (let i = 1; i < n; i += 2) {
    if (a[i] === b[0]) {
      if (check(i)) return 'YES';
      break;
    }
  }
  return 'NO';
}

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

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

'use strict';

function solve(a, b) {
  const n = a.length,
        m = b.length;
  if (m > n) return 'NO';
  const check = (i, j) => {
    let pre = i & 1;
    j++;
    for (let k = i + 1; k < n; k++) {
      if (a[k] === b[j] && (k & 1) !== pre) {
        j++;
        pre ^= 1;
      }
      if (j === m) return true;
    }
    return j === m;
  };
  for (let i = 0; i < n; i += 2) {
    if (a[i] === b[0]) {
      if (check(i, 0)) return 'YES';
      break;
    }
  }
  for (let i = 1; i < n; i += 2) {
    if (a[i] === b[0]) {
      if (check(i, 0)) return 'YES';
      break;
    }
  }
  return 'NO';
}

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

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

'use strict';

function solve(a, b) {
  const n = a.length,
        m = b.length;
  const check = (i, j) => {
    let pre = i & 1;
    j++;
    for (let k = i + 1; k < n; k++) {
      if (a[k] === b[j] && (k & 1) !== pre) {
        j++;
        pre ^= 1;
      }
      if (j === m) return true;
    }
    return j === m;
  };
  for (let i = 0; i < n; i += 2) {
    if (a[i] === b[0]) {
      if (check(i, 0)) return 'YES';
      break;
    }
  }
  for (let i = 1; i < n; i += 2) {
    if (a[i] === b[0]) {
      if (check(i, 0)) return 'YES';
      break;
    }
  }
  return 'NO';
}

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

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

'use strict';

function solve(a, b) {
  const n = a.length,
        m = b.length;
  const check = (i, j) => {
    let pre = i;
    j++;
    for (let k = i + 1; k < n; k++) {
      if (a[k] === b[j] && (k - pre - 1) % 2 === 0) {
        j++;
        pre = k;
      }
      if (j === m) return true;
    }
    return j === m;
  };
  for (let i = 0; i < n; i += 2) {
    if (a[i] === b[0]) {
      if (check(i, 0)) return 'YES';
      break;
    }
  }
  for (let i = 1; i < n; i += 2) {
    if (a[i] === b[0]) {
      if (check(i, 0)) return 'YES';
      break;
    }
  }
  return 'NO';
}

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

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

'use strict';

function solve(a, b) {
  const n = a.length,
        m = b.length;
  const check = (i, j) => {
    let pre = i;
    j++;
    for (let k = i + 1; k < n; k++) {
      if (a[k] === b[j] && (k - pre - 1) % 2 === 0) {
        j++;
        pre = k;
      }
      if (j === m) return true;
    }
    return false;
  };
  for (let i = 0; i < n; i += 2) {
    if (a[i] === b[0]) {
      if (check(i, 0)) return 'YES';
      break;
    }
  }
  for (let i = 1; i < n; i += 2) {
    if (a[i] === b[0]) {
      if (check(i, 0)) return 'YES';
      break;
    }
  }
  return 'NO';
}

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

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

'use strict';

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 tests_count = parseInt(readline());
  for (var test = 0; test < tests_count; test++) {
    const src = readline() || "";
    const pat = readline() || "";
    console.log(verify(src, pat, 0) || verify(src, pat, 1) ? "YES" : "NO")
  }
}

function verify(src, pat, parity) {
  if (pat.length === 0)
    return true;

  let src_idx = findNextWithParity(src, 0, pat[0], parity);
  if (src_idx >= src.length)
    return false;

  let pat_idx = 1;
  while (pat_idx < pat.length) {
    parity = 1 - src_idx % 2
    // El índice debe tener una paridad diferente al elemento actual (para que la diferencia sea divisible por 2)
    src_idx = findNextWithParity(src, src_idx + 1, pat[pat_idx], parity);
    if (src_idx >= src.length)
      return false;

    pat_idx++
  }
  return true;
}
function findNextWithParity(src, idx, c, parity) {
  idx = findNext(src, idx, c);
  while (idx < src.length && (idx % 2 !== parity))
    idx = findNext(src, idx + 1, c);
  return idx;
}
function findNext(src, idx, c) {
  while (idx < src.length && c !== src[idx]) idx++;
  return idx;
}

function solution(s, t) {
  const m = s.length, n = t.length
  if (m < n) return false
  let i = m - 1, j = n - 1
  const delFirstOfS = (m - n) & 1
  const smallestIdxOfS = delFirstOfS ? 1 : 0
  while(i >= smallestIdxOfS && j >= 0) {
    if(s[i] === t[j]) {
      i--
      j--
    } else {
      i -= 2
    }
    if (j < 0) return true
  }
  return false
}

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

rl.on("line", (line) => {
  input.push(line);
  if (input.length === 3) {
    const t = input.pop()
    const s = input.pop()
    const res = solution(s, t)
    console.log(res ? 'YES' : 'NO')
  }
});
rl.on("close", () => {
});

function solution(s, t) {
  const m = s.length, n = t.length
  if (m < n) return false
  let i = m - 1, j = n - 1
  const delFirstOfS = (m - n) & 1
  const smallestIdxOfS = delFirstOfS ? 1 : 0
  while(i >= smallestIdxOfS && j >= 0) {
    if(s[i] === t[j]) {
      i--
      j--
    } else {
      i -= 2
    }
  }
  return j === -1
}
const readline = require("readline");
const rl = readline.createInterface({
  input: process.stdin,
  output: process.stdout,
});
const input = [];

rl.on("line", (line) => {
  input.push(line);
  if (input.length === 3) {
    const t = input.pop()
    const s = input.pop()
    const res = solution(s, t)
    console.log(res ? 'YES' : 'NO')
  }
});
rl.on("close", () => {
});

function solution(s, t) {
  const m = s.length, n = t.length
  if (m < n) return false
  let i = m - 1, j = n - 1

  while(i >= 0 && j >= 0) {
    if(s[i] === t[j]) {
      i--
      j--
    } else {
      i -= 2
    }
  }
  return j === -1
}

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

rl.on("line", (line) => {
  input.push(line);
  if (input.length === 3) {
    const t = input.pop()
    const s = input.pop()
    const res = solution(s, t)
    console.log(res ? 'YES' : 'NO')
  }
});
rl.on("close", () => {
});

let _inputLines;
let _lineNumber = 0;
let inputReader = _inputReader();

function _main() {
  _inputLines = _inputData
    .trim()
    .split("\n")
    .map((string) => {
      return string.trim();
    });

  //------------------------------ <Solution> -------------------------------//

  let t = inputReader.readNumber();
  function solve() {
    let s = inputReader.readLine().split("");
    let t = inputReader.readLine().split("");
    if (s.length < t.length) {
      console.log("NO");
      return;
    }
    let i = s.length - 1,
      j = t.length - 1;
    while (i >= 0 && j >= 0) {
      if (s[i] == t[j]) {
        i--;
        j--;
      } else {
        i -= 2;
      }
    }
    //console.log([i, j]);
    if (j > 0) {
      console.log("NO");
    } else console.log("YES");
  }

  while (t--) {
    solve();
  }

  //------------------------------ </Solution> -------------------------------//
}

var _inputData = "";
function cacheInput(data) {
  _inputData += data;
}

process.stdin.resume();
process.stdin.setEncoding("utf8");
process.stdin.on("data", cacheInput).on("end", _main);

function _inputReader() {
  function readNumber() {
    return Number(_inputLines[_lineNumber++]);
  }

  function readLine() {
    return _inputLines[_lineNumber++];
  }

  return {
    readNumber,
    readLine,
  };
}

let _inputLines;
let _lineNumber = 0;
let inputReader = _inputReader();

function _main() {
  _inputLines = _inputData
    .trim()
    .split("\n")
    .map((string) => {
      return string.trim();
    });

  //------------------------------ <Solution> -------------------------------//

  let t = inputReader.readNumber();
  function solve() {
    let s = inputReader.readLine().split("");
    let t = inputReader.readLine().split("");
    if (s.length < t.length) {
      console.log("NO");
      return;
    }
    let i = s.length - 1,
      j = t.length - 1;
    while (i >= 0 && j >= 0) {
      if (s[i] == t[j]) {
        i--;
        j--;
      } else {
        i -= 2;
      }
    }
    //console.log([i, j]);
    if (j > 0 && i < 0) {
      console.log("NO");
    } else console.log("YES");
  }

  while (t--) {
    solve();
  }

  //------------------------------ </Solution> -------------------------------//
}

var _inputData = "";
function cacheInput(data) {
  _inputData += data;
}

process.stdin.resume();
process.stdin.setEncoding("utf8");
process.stdin.on("data", cacheInput).on("end", _main);

function _inputReader() {
  function readNumber() {
    return Number(_inputLines[_lineNumber++]);
  }

  function readLine() {
    return _inputLines[_lineNumber++];
  }

  return {
    readNumber,
    readLine,
  };
}

/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    Node.js template for
    the coding contests.

            ~~*/
        'use strict';
            /*~~

    Tip:
    Don't raise your voice,
    improve your argument.

            ~~~~

   cat /dev/ass > /dev/head
           Ctrl+C
  cat /knowledge > /dev/head

               © Yakov Gellert
                       frvr.ru

~~~~Don't~touch~that~part:~~*/

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

let inputString = '',
    currentLine = 0,
    outputString = '';

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

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

    /*
     * Running a solution function
     * with whole input as an array
     * and a string for a buffered output
     */
    solution(inputString, outputString);

    /*
     * Return a buffered output
     */
    write(outputString);
});

/* Read a line from stdin */
function readline() {
    if (currentLine < inputString.length) {
        return inputString[currentLine++];
    }

    return '';
}

/* Read array from stdin */
function readarr() {
    return readline().split(' ');
}

/* Read numbers from stdin */
function readnums() {
    return readarr().map(num => parseInt(num));
}

/* Write a string to stdout */
function write(data) {
    data = data.toString();
    process.stdout.write(data);

    return data;
}

/* Write a string with \n to stdout */
function writeline(data) {
    write(data.toString() + '\n');
}

/* Append a string to a buffer */
function fwrite(data) {
    outputString += data.toString() + ' ';
}

/* Append a string with \n to a buffer */
function fwriteline(data) {
    fwrite(data);
    outputString += '\n';
}

/* Throw an error */
function error(name) {
    throw new Error(name.toString());
}

/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   Write your solution here
~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/

function solution(input, output) {

    for (let cases = readnums()[0]; cases > 0; cases -= 1) {
        let sample = readline();
        let target = readline();

        let checkEqualityAndWrite = (
            (s, t) => fwriteline(s === t ? "YES" : "NO"));

        /*
         * t is larger than s, can't reach it
         */
        if (target.length > sample.length) {
            fwriteline("NO");
            continue;
        }

        if (target.length === sample.length) {
            checkEqualityAndWrite(target, sample);
            continue;
        }

        /*
         * Trying to find first symbol of the target in the sample
         */
        let sampleI = 0,
            targetI = 0;

        for (; sampleI < sample.length; sampleI += 1) {
            if (sample[sampleI] === target[targetI]) {
                sampleI += 1;
                targetI += 1;

                break;
            }
        }

        /*
         * Found none — failure!
         */
        if (targetI === 0) {
            fwriteline("NO");
            continue;
        }

        /*
         * Now, my main algo:
         * 1. find target's letter position in a sample (if none — failure)
         * 2. check if it's distance from the start of the current search is an even/odd number
         * 2.1. if even — great, start over with first step for the next letter in target
         * 2.2. if odd — retry first (1.) step, but for the same letter in target
         */
        let failure = 0;
        let currentI = sampleI;

        while (sampleI < sample.length && targetI < target.length) {
            let found = 0;

            while (sampleI < sample.length) {
                if (sample[sampleI] === target[targetI]) {
                    found = 1;
                    break;
                }

                sampleI += 1;
            }

            if (found === 0) {
                failure = 1;
                break;
            }

            if ((sampleI - currentI) % 2 === 0) {
                targetI += 1;
                currentI = sampleI + 1;
            }

            sampleI += 1;
        }

        if (failure === 1) {
            fwriteline("NO");
            continue;
        }

        /*
         * If we walked through all symbols of the target, but not the sample,
         * we just need to check the distance from last checked symbol in sample until the end of it.
         * If it's even — great, we can trim all of them.
         * If it's odd — failure, because we couldn't trim them without removing last checked symbol or adding extra one
         * to the sample sequence thus mismatching the target one.
         */
        if (sampleI < sample.length) {
            /*
             * +1, because of 0-notation
             * -1, to revert the last +1 at the end of a while cycle above
             */
            checkEqualityAndWrite((sample.length - sampleI) % 2, 0);
        }

        /*
         * Got to the end — great!
         */
        fwriteline("YES");
    }
}


The King of Berland Polycarp LXXXIV has $$$n$$$ daughters. To establish his power to the neighbouring kingdoms he wants to marry his daughters to the princes of these kingdoms. As a lucky coincidence there are $$$n$$$ other kingdoms as well.So Polycarp LXXXIV has enumerated his daughters from $$$1$$$ to $$$n$$$ and the kingdoms from $$$1$$$ to $$$n$$$. For each daughter he has compiled a list of kingdoms princes of which she wanted to marry.Polycarp LXXXIV is very busy, so he finds a couple for his daughters greedily one after another.For the first daughter he takes the kingdom with the lowest number from her list and marries the daughter to their prince. For the second daughter he takes the kingdom with the lowest number from her list, prince of which hasn't been taken already. If there are no free princes in the list then the daughter marries nobody and Polycarp LXXXIV proceeds to the next daughter. The process ends after the $$$n$$$-th daughter.For example, let there be $$$4$$$ daughters and kingdoms, the lists daughters have are $$$[2, 3]$$$, $$$[1, 2]$$$, $$$[3, 4]$$$, $$$[3]$$$, respectively.  In that case daughter $$$1$$$ marries the prince of kingdom $$$2$$$, daughter $$$2$$$ marries the prince of kingdom $$$1$$$, daughter $$$3$$$ marries the prince of kingdom $$$3$$$, leaving daughter $$$4$$$ nobody to marry to.Actually, before starting the marriage process Polycarp LXXXIV has the time to convince one of his daughters that some prince is also worth marrying to. Effectively, that means that he can add exactly one kingdom to exactly one of his daughter's list. Note that this kingdom should not be present in the daughter's list.Polycarp LXXXIV wants to increase the number of married couples.Unfortunately, what he doesn't have the time for is determining what entry to add. If there is no way to increase the total number of married couples then output that the marriages are already optimal. Otherwise, find such an entry that the total number of married couples increases if Polycarp LXXXIV adds it.If there are multiple ways to add an entry so that the total number of married couples increases then print any of them.For your and our convenience you are asked to answer $$$t$$$ independent test cases.

The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^5$$$) — the number of test cases. Then $$$t$$$ test cases follow. The first line of each test case contains a single integer $$$n$$$ ($$$1 \le n \le 10^5$$$) — the number of daughters and the number of kingdoms. Each of the next $$$n$$$ lines contains the description of each daughter's list. The first integer $$$k$$$ ($$$0 \le k \le n$$$) is the number of entries in the $$$i$$$-th daughter's list. After that $$$k$$$ distinct integers follow $$$g_i[1], g_i[2], \dots, g_i[k]$$$ ($$$1 \le g_i[j] \le n$$$) — the indices of the kingdoms in the list in the increasing order ($$$g_i[1] < g_i[2] < \dots < g_i[k]$$$). It's guaranteed that the total number of daughters over all test cases does not exceed $$$10^5$$$. It's also guaranteed that the total number of kingdoms in lists over all test cases does not exceed $$$10^5$$$.

For each test case print the answer to it. Print "IMPROVE" in the first line if Polycarp LXXXIV can add some kingdom to some of his daughter's list so that the total number of married couples increases. The second line then should contain two integers — the index of the daughter and the index of the kingdom Polycarp LXXXIV should add to that daughter's list. If there are multiple ways to add an entry so that the total number of married couples increases then print any of them. Otherwise the only line should contain one word "OPTIMAL".

IMPROVE
4 4
IMPROVE
1 1
OPTIMAL
OPTIMAL
OPTIMAL

NoteThe first test case is depicted in the statement. Adding the fourth kingdom to the list of the fourth daughter makes her marry the prince of the fourth kingdom.In the second test case any new entry will increase the number of marriages from $$$0$$$ to $$$1$$$.In the third and the fourth test cases there is no way to add an entry.In the fifth test case there is no way to change the marriages by adding any entry.

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

let input = ''
let ptr = 0
process.stdin.on('data', (i) => {
  input += i
})

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

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

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

function readInt() {
  return parseInt(input[ptr++])
}

function readString() {
  return input[ptr++]
}

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

function readInts() {
  return input[ptr++].split(' ').map(a => parseInt(a))
}

function main() {
  let t = readInt()
  while(t--) {
    const n = readInt()
    let ks = new Array(n)
    let d = {}
    let book = {}
    for(let i = 0; i < n; i++) {
      ks[i] = readInts()
    }
    for(let i = 0; i < n; i++) {
      let kD = ks[i]
      // wr(i + 1, kD)
      let s = 1
      let b = kD[0]
      for(let j = 1; j <= kD[0]; j++) {
        if(!book[kD[j]]) {
          // wr('b', b)
          // wr(book)
          book[kD[j]] = i + 1
          d[i + 1] = kD[j]
          break
        }
      }
    }
    // wr(d)
    // wr(book)
    let nD = -1
    let nK = -1
    for(let i = 1; i <= n; i++) {
      if(!d[i]) {
        nD = i
        break
      }
    }
    for(let i = 1; i <= n; i++) {
      if(!book[i]) {
        nK = i
        break
      }
    }
    if(nD !== -1) {
      wr('IMPROVE')
      wr(nD, nK)
    }
    else wr('OPTIMAL')
  }
}

const processData = (lines) => {
  const num = +lines[0]
  const restLines = lines.slice(1)
  let mark = 1
  for (let i =0; i<num; i++){
    const n = +lines[mark]
    const cur = mark + 1
    mark = mark + n + 1
    let restPrincess = null
    let princeList = Array(n).fill(false)
    for (let j = 0; j<n; j++) {
      const pList = lines[cur+j].split(' ').slice(1).map(x => x-1)
      let choose = false
      for (const chosenPrince of pList) {
        if (!princeList[chosenPrince]) {
          princeList[chosenPrince] = true
          choose = true
          break
        }
      }
      if (!choose)
        restPrincess = j+1
    }
    const restPrince = princeList.findIndex(x => !x)
    if (restPrince>=0) {
      console.log('IMPROVE')
      console.log((restPrincess) + ' ' + (restPrince+1))
    } else {
      console.log('OPTIMAL')
    }
  }
}

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

var len = readline()

for (var i = 0;i < len;i ++) {
  var dnum = readline();
  var nomarry = 0
  var obj = {}
  for(var j = 0;j < dnum; j ++) {
    var arr = readline().split(' ')
    var nomarryflag = true
    for (var p = 1;p <= arr[0];p ++) {
      if (!obj[arr[p]]) {
        nomarryflag = false
        obj[arr[p]] = 1
        break
      }

    }
    if (nomarryflag == true) {
      nomarry = j + 1
    }
  }
  for (var q = 1;q <= dnum; q ++) {
    if (!obj[q] && nomarry != 0) {
      print('IMPROVE')
      print(nomarry + ' ' + q)
      break
    }
    if (q == dnum) {
      print('OPTIMAL')
    }
  }
}

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

let input = ''
let ptr = 0
process.stdin.on('data', (i) => {
  input += i
})

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

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

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

function readInt() {
  return parseInt(input[ptr++])
}

function readString() {
  return input[ptr++]
}

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

function readInts() {
  return input[ptr++].split(' ').map(a => parseInt(a))
}

function main() {
  let t = readInt()
  while(t--) {
    const n = readInt()
    let ks = new Array(n)
    let d = {}
    let book = {}
    for(let i = 0; i < n; i++) {
      ks[i] = readInts()
    }
    for(let i = 0; i < n; i++) {
      let kD = ks[i]
      let s = 1
      let b = kD[0]
      while(s < b) {
        let m = Math.floor((s + b) / 2)
        if(!book[kD[m]]) {
          b = m
        }
        else {
          s = m + 1
        }
      }
      if(b !== 0 && !book[kD[b]]) {
        book[kD[b]] = true
        d[i + 1] = true
      }
    }
    // wr(d)
    // wr(book)
    let nD = -1
    let nK = -1
    for(let i = 1; i <= n; i++) {
      if(!d[i]) {
        nD = i
        break
      }
    }
    for(let i = 1; i <= n; i++) {
      if(!book[i]) {
        nK = i
        break
      }
    }
    if(nD !== -1) {
      wr('IMPROVE')
      wr(nD, nK)
    }
    else wr('OPTIMAL')
  }
}

const processData = (lines) => {
  const num = +lines[0]
  const restLines = lines.slice(1)
  let mark = 1
  for (let i =0; i<num; i++){
    const n = +lines[mark]
    const cur = mark + 1
    mark = mark + n + 1
    let restPrincess = null
    let princeList = Array(n).fill(false)
    let rest = n
    while(rest) {
      const pList = lines[cur+n-rest].split(' ').slice(1).map(x => x-1)
      for (const chosenPrince of pList) {
        if (!princeList[chosenPrince]) {
          princeList[chosenPrince] = true
          break
        }
        restPrincess = n-rest + 1
      }
      rest--
    }
    const restPrince = princeList.findIndex(x => !x)
    if (restPrince>=0) {
      console.log('IMPROVE')
      console.log((restPrincess || '1') + ' ' + (restPrince+1))
    } else {
      console.log('OPTIMAL')
    }
  }
}

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

var len = readline()

for (var i = 0;i < len;i ++) {
  var dnum = readline();
  var nomarry = 0
  var obj = {}
  for(var j = 0;j < dnum; j ++) {
    var arr = readline().split(' ')
    var nomarryflag = true
    for (var p = 1;p <= arr[0];p ++) {
      if (obj[arr[p]] == 0) {
        nomarryflag = false
        obj[arr[p]] = 1
        break
      }

    }
    if (nomarryflag == true) {
      nomarry = j + 1
    }
  }
  for (var q = 1;q <= dnum; q ++) {
    if (!obj[q] && nomarry != 0) {
      print('IMPROVE')
      print(nomarry + ' ' + q)
      break
    }
    if (q == dnum) {
      print('OPTIMAL')
    }
  }
}

var len = readline()
var obj = {}
for (var i = 0;i < len;i ++) {
  var dnum = readline();
  var nomarry = 0

  for(var j = 0;j < dnum; j ++) {
    var arr = readline().split(' ')
    var nomarryflag = true
    for (var p = 1;p < arr[0];p ++) {
      if (obj[arr[p]] == 0) {
        nomarryflag = false
      }
      obj[arr[p]] = 1
    }
    if (nomarryflag == true) {
      nomarry = j + 1
    }
  }
  for (var q = 0;q < dnum; q ++) {
    if (!obj[q] && nomarry != 0) {
      print('IMPROVE')
      print(nomarry + ' ' + q)
      break
    }
    if (q == dnum - 1) {
      print('OPTIMAL')
    }
  }
}

var len = readline()

for (var i = 0;i < len;i ++) {
  var dnum = readline();
  var nomarry = 0
  var obj = {}
  for(var j = 0;j < dnum; j ++) {
    var arr = readline().split(' ')
    var nomarryflag = true
    for (var p = 1;p < arr[0];p ++) {
      if (obj[arr[p]] == 0) {
        nomarryflag = false
      }
      obj[arr[p]] = 1
    }
    if (nomarryflag == true) {
      nomarry = j + 1
    }
  }
  for (var q = 0;q < dnum; q ++) {
    if (!obj[q] && nomarry != 0) {
      print('IMPROVE')
      print(nomarry + ' ' + q)
      break
    }
    if (q == dnum - 1) {
      print('OPTIMAL')
    }
  }
}

var len = readline()

for (var i = 0;i < len;i ++) {
  var dnum = readline();
  var nomarry = 0
  var obj = {}
  for(var j = 0;j < dnum; j ++) {
    var arr = readline().split(' ')
    var nomarryflag = true
    for (var p = 1;p < arr[0];p ++) {
      if (obj[arr[p]] == 0) {
        nomarryflag = false
        obj[arr[p]] = 1
        break
      }

    }
    if (nomarryflag == true) {
      nomarry = j + 1
    }
  }
  for (var q = 1;q <= dnum; q ++) {
    if (!obj[q] && nomarry != 0) {
      print('IMPROVE')
      print(nomarry + ' ' + q)
      break
    }
    if (q == dnum) {
      print('OPTIMAL')
    }
  }
}

var len = readline()

for (var i = 0;i < len;i ++) {
  var dnum = readline();
  var nomarry = 0
  var obj = {}
  for(var j = 0;j < dnum; j ++) {
    var arr = readline().split(' ')
    var nomarryflag = true
    for (var p = 1;p < arr[0];p ++) {
      if (obj[arr[p]] == 0) {
        nomarryflag = false
        obj[arr[p]] = 1
        break
      }

    }
    if (nomarryflag == true) {
      nomarry = j + 1
    }
  }
  for (var q = 0;q < dnum; q ++) {
    if (!obj[q] && nomarry != 0) {
      print('IMPROVE')
      print(nomarry + ' ' + q)
      break
    }
    if (q == dnum - 1) {
      print('OPTIMAL')
    }
  }
}


You and your friend Ilya are participating in an individual programming contest consisting of multiple stages. A contestant can get between $$$0$$$ and $$$100$$$ points, inclusive, for each stage, independently of other contestants.Points received by contestants in different stages are used for forming overall contest results. Suppose that $$$k$$$ stages of the contest are completed. For each contestant, $$$k - \lfloor \frac{k}{4} \rfloor$$$ stages with the highest scores are selected, and these scores are added up. This sum is the overall result of the contestant. (Here $$$\lfloor t \rfloor$$$ denotes rounding $$$t$$$ down.)For example, suppose $$$9$$$ stages are completed, and your scores are $$$50, 30, 50, 50, 100, 10, 30, 100, 50$$$. First, $$$7$$$ stages with the highest scores are chosen — for example, all stages except for the $$$2$$$-nd and the $$$6$$$-th can be chosen. Then your overall result is equal to $$$50 + 50 + 50 + 100 + 30 + 100 + 50 = 430$$$.As of now, $$$n$$$ stages are completed, and you know the points you and Ilya got for these stages. However, it is unknown how many more stages will be held. You wonder what the smallest number of additional stages is, after which your result might become greater than or equal to Ilya's result, at least in theory. Find this number!

Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 1000$$$). Description of the test cases follows. The first line of each test case contains a single integer $$$n$$$ ($$$1 \le n \le 10^5$$$) — the number of completed stages. The second line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$0 \le a_i \le 100$$$) — your points for the completed stages. The third line contains $$$n$$$ integers $$$b_1, b_2, \ldots, b_n$$$ ($$$0 \le b_i \le 100$$$) — Ilya's points for the completed stages. It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$10^5$$$.

For each test case print a single integer — the smallest number of additional stages required for your result to be able to become greater than or equal to Ilya's result. If your result is already not less than Ilya's result, print $$$0$$$.

NoteIn the first test case, you have scored $$$100$$$ points for the first stage, while Ilya has scored $$$0$$$. Thus, your overall result ($$$100$$$) is already not less than Ilya's result ($$$0$$$).In the second test case, you have scored $$$0$$$ points for the first stage, while Ilya has scored $$$100$$$. A single stage with an opposite result is enough for both your and Ilya's overall scores to become equal to $$$100$$$.In the third test case, your overall result is $$$30 + 40 + 50 = 120$$$, while Ilya's result is $$$100 + 100 + 100 = 300$$$. After three additional stages your result might become equal to $$$420$$$, while Ilya's result might become equal to $$$400$$$.In the fourth test case, your overall result after four additional stages might become equal to $$$470$$$, while Ilya's result might become equal to $$$400$$$. Three stages are not enough.

let input = '';
process.stdin.on('data', chunk => input += chunk);
process.stdin.on('end', () => {
  const {EOL} = require('os');
  const lines = input.split(EOL);
  const count = parseInt(lines.shift());
  for (let i = 1; i <= count; ++i) {
    const n = parseInt(lines.shift());
    const my = lines.shift().split(/\s+/).filter(x => x.match(/^\d+$/)).map(x => parseInt(x));
    const his = lines.shift().split(/\s+/).filter(x => x.match(/^\d+$/)).map(x => parseInt(x));
    console.log(solve(n, my, his));
  }
});

function solve(n, my, his) {
  my.sort((a, b) => b - a);
  his.sort((a, b) => b - a);
  let count = n - Math.floor(n / 4);
  let myScore = my.slice(0, count).reduce((acc, val) => acc + val);
  let hisScore = his.slice(0, count).reduce((acc, val) => acc + val);
  let idx = count - 1;
  for (let added = 0; ; ++added) {
    if (myScore >= hisScore) {
      return added;
    }
    let newSize = n + added + 1;
    let newCount = newSize - Math.floor(newSize / 4);
    myScore += 100;
    if (newCount === count) {
      if (idx >= 0) {
        myScore -= my[idx];
        --idx;
      } else {
        myScore -= 100;
      }
    } else { // newCount === count + 1
      if (count < n) {
        hisScore += his[count];
      }
    }
    count = newCount;
  }
}

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--) {
		let n = rn();
		let a = rna();
		let b = rna();

		a.sort((x, y) => x - y);
		b.sort((x, y) => x - y);

		k = Math.floor(n / 4) - 1;

		let asum = 0, bsum = 0;
		for (let i = k + 1; i < n; i++) {
			asum += a[i];
			bsum += b[i];
		}

		let stage = n;
		let i = j = k;
		while (asum < bsum) {
			stage++;
			if (stage % 4 == 0) {
				asum += 100 - a[++i];
			} else {
				asum += 100;
				if (j >= 0) bsum += b[j];
				--j;
			}
			//console.log('asm', asum, 'bsum', bsum, stage);
		}

		ans = stage - n;

		console.log(ans);
	}
}


"The zombies are lurking outside. Waiting. Moaning. And when they come...""When they come?""I hope the Wall is high enough."Zombie attacks have hit the Wall, our line of defense in the North. Its protection is failing, and cracks are showing. In places, gaps have appeared, splitting the wall into multiple segments. We call on you for help. Go forth and explore the wall! Report how many disconnected segments there are.The wall is a two-dimensional structure made of bricks. Each brick is one unit wide and one unit high. Bricks are stacked on top of each other to form columns that are up to R bricks high. Each brick is placed either on the ground or directly on top of another brick. Consecutive non-empty columns form a wall segment. The entire wall, all the segments and empty columns in-between, is C columns wide.

The first line of the input consists of two space-separated integers R and C, 1 ≤ R, C ≤ 100. The next R lines provide a description of the columns as follows:    each of the R lines contains a string of length C,  the c-th character of line r is B if there is a brick in column c and row R - r + 1, and . otherwise.  B

The number of wall segments in the input configuration.

NoteIn the first sample case, the 2nd and 3rd columns define the first wall segment, and the 5th column defines the second.

"use strict";

let input = readline().split(' ').map(e => +e);
let R = input[0] - 1, C = input[1];

while ( R-- > 0 )
	readline(); //ignore

let walls = readline().split('.').filter(e => e != '').length;
write(walls);

var array = readline().split(' ').map(Number);
var r = array[0];
var c = array[1];
var quantity = 0;
for (var i = 0; i < r -1; i++){
    readline();
}
var string = readline();

var flag = false;
for (var i = 0; i < string.length; i++){
    if (string[i] === 'B' && flag === false){
        flag = true;
        quantity++;
    } else if (string[i] === '.' && flag === true) {
        flag = false;
    }
}

print(quantity);


You've got table a, consisting of n rows, numbered from 1 to n. The i-th line of table a contains ci cells, at that for all i (1 < i ≤ n) holds ci ≤ ci - 1. Let's denote s as the total number of cells of table a, that is, . We know that each cell of the table contains a single integer from 1 to s, at that all written integers are distinct. Let's assume that the cells of the i-th row of table a are numbered from 1 to ci, then let's denote the number written in the j-th cell of the i-th row as ai, j. Your task is to perform several swap operations to rearrange the numbers in the table so as to fulfill the following conditions:  for all i, j (1 < i ≤ n; 1 ≤ j ≤ ci) holds ai, j > ai - 1, j;  for all i, j (1 ≤ i ≤ n; 1 < j ≤ ci) holds ai, j > ai, j - 1. In one swap operation you are allowed to choose two different cells of the table and swap the recorded there numbers, that is the number that was recorded in the first of the selected cells before the swap, is written in the second cell after it. Similarly, the number that was recorded in the second of the selected cells, is written in the first cell after the swap.Rearrange the numbers in the required manner. Note that you are allowed to perform any number of operations, but not more than s. You do not have to minimize the number of operations.

The first line contains a single integer n (1 ≤ n ≤ 50) that shows the number of rows in the table. The second line contains n space-separated integers ci (1 ≤ ci ≤ 50; ci ≤ ci - 1) — the numbers of cells on the corresponding rows. Next n lines contain table а. The i-th of them contains ci space-separated integers: the j-th integer in this line represents ai, j. It is guaranteed that all the given numbers ai, j are positive and do not exceed s. It is guaranteed that all ai, j are distinct.

In the first line print a single integer m (0 ≤ m ≤ s), representing the number of performed swaps. In the next m lines print the description of these swap operations. In the i-th line print four space-separated integers xi, yi, pi, qi (1 ≤ xi, pi ≤ n; 1 ≤ yi ≤ cxi; 1 ≤ qi ≤ cpi). The printed numbers denote swapping the contents of cells axi, yi and api, qi. Note that a swap operation can change the contents of distinct table cells. Print the swaps in the order, in which they should be executed.

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

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

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

function main() {
	var rowNum = parseInt(readline()),
		rowLens = tokenizeIntegers(readline()),
		value2info = {}, pos2info = [];
	for (var r = 0; r < rowNum; ++r) {
		var row = tokenizeIntegers(readline()),
			rowLen = rowLens[r];
		for (var c = 0; c < rowLen; ++c) {
			var value = row[c]-1,
				pos = pos2info.length,
				info = { value: value, pos: pos, r: r, c: c };
			value2info[value] = info;
			pos2info.push(info);
		}
	}
	var swaps = [];
	for (var pos = pos2info.length-1; pos > 0; --pos) {
		var curr = pos2info[pos];
		if (curr.value != pos) {
			var heir = value2info[pos],
				r = curr.r, c = curr.c;
			swaps.push([r+1, c+1, heir.r+1, heir.c+1].join(' '));
			curr.r = heir.r;
			curr.c = heir.c;
			heir.r = r;
			heir.c = c;
			curr.pos = heir.pos;
			heir.pos = pos;
			pos2info[pos] = value2info[pos] = heir;
			pos2info[curr.pos] = value2info[curr.value] = curr;
		}
	}
	print(swaps.length);
	if (swaps.length != 0) {
		print(swaps.join('\n'));
	}
}

main();


Masha works in an advertising agency. In order to promote the new brand, she wants to conclude contracts with some bloggers. In total, Masha has connections of $$$n$$$ different bloggers. Blogger numbered $$$i$$$ has $$$a_i$$$ followers.Since Masha has a limited budget, she can only sign a contract with $$$k$$$ different bloggers. Of course, Masha wants her ad to be seen by as many people as possible. Therefore, she must hire bloggers with the maximum total number of followers.Help her, find the number of ways to select $$$k$$$ bloggers so that the total number of their followers is maximum possible. Two ways are considered different if there is at least one blogger in the first way, which is not in the second way. Masha believes that all bloggers have different followers (that is, there is no follower who would follow two different bloggers).For example, if $$$n=4$$$, $$$k=3$$$, $$$a=[1, 3, 1, 2]$$$, then Masha has two ways to select $$$3$$$ bloggers with the maximum total number of followers:   conclude contracts with bloggers with numbers $$$1$$$, $$$2$$$ and $$$4$$$. In this case, the number of followers will be equal to $$$a_1 + a_2 + a_4 = 6$$$.  conclude contracts with bloggers with numbers $$$2$$$, $$$3$$$ and $$$4$$$. In this case, the number of followers will be equal to $$$a_2 + a_3 + a_4 = 6$$$. Since the answer can be quite large, output it modulo $$$10^9+7$$$.

The first line contains one integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. Then $$$t$$$ test cases follow. The first line of each test case contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le k \le n \le 1000$$$) — the number of bloggers and how many of them you can sign a contract with. The second line of each test case contains $$$n$$$ integers $$$a_1, a_2, \ldots a_n$$$ ($$$1 \le a_i \le n$$$) — the number of followers of each blogger. It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$1000$$$.

For each test case, on a separate line output one integer — the number of ways to select $$$k$$$ bloggers so that the total number of their followers is maximum possible.

NoteThe test case is explained in the statements.In the second test case, the following ways are valid:   conclude contracts with bloggers with numbers $$$1$$$ and $$$2$$$. In this case, the number of followers will be equal to $$$a_1 + a_2 = 2$$$;  conclude contracts with bloggers with numbers $$$1$$$ and $$$3$$$. In this case, the number of followers will be equal to $$$a_1 + a_3 = 2$$$;  conclude contracts with bloggers with numbers $$$1$$$ and $$$4$$$. In this case, the number of followers will be equal to $$$a_1 + a_4 = 2$$$;  conclude contracts with bloggers with numbers $$$2$$$ and $$$3$$$. In this case, the number of followers will be equal to $$$a_2 + a_3 = 2$$$;  conclude contracts with bloggers with numbers $$$2$$$ and $$$4$$$. In this case, the number of followers will be equal to $$$a_2 + a_4 = 2$$$;  conclude contracts with bloggers with numbers $$$3$$$ and $$$4$$$. In this case, the number of followers will be equal to $$$a_3 + a_4 = 2$$$. In the third test case, the following ways are valid:   concludes a contract with a blogger with the number $$$2$$$. In this case, the number of followers will be equal to $$$a_2 = 2$$$.

'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

var binom = new Array(maxN)
binom[0] = new Array(maxN).fill(1n)
binom[1] = new Array(maxN).fill(1n)

for (var i = 2; i < maxN; i++){
    binom[i] = new Array(maxN).fill(1n)

    for (var j = 1; j < i; j++){
        binom[i][j] = (binom[i - 1][j - 1] + binom[i - 1][j]) % mod;
    }
}
// console.log(binom)
function main() {
    const x = readline();

    // 1 1 7
    // 6 9, 15, 18
    Array(Number(x)).fill(1).map((t, iii) => {
        // var n = parseInt(readline())
        // var x = new Array(n)
        var [n, k] = readline().split(' ').map((x, iii) => {
            return x
        })
        var a = readline().split(' ').map((x, iii) => {
            return parseInt(x)
        })
        a = a.sort((a, b) => b - a)

        var add = a[k - 1]
        var ii = k - 1
        var count = 0
        for (let i = 0; i < n; i++) {
            if (a[i] === a[k - 1]) count++
        }
        while (a[k - 1] === a[ii]) ii++

        // var number =
        //     console.log(ii - k, count)

        // console.log(binom[3][2].toString())
        console.log(binom[count][ii - k].toString())
        // var res = []
    })
}

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

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

const MOD = 1000000007n;

function fast_pow(a, p)
{
	let res = 1n;
	while (p) {
		if (p % 2n == 0) {
			a = a * a % MOD;
			p /= 2n;
		} else {
			res = res * a % MOD;
			p--;
		}
	}
	return res;
}

function mmi (n) {
	return fast_pow(n, MOD - 2n);
}

function fact (n) {
	let res = 1n;
	for (let i = 1n; i <= n; i++)
		res = res * i % MOD;
	return res;
}

function c(n, r) {
	return fact(n) * mmi(fact(n-r)) % MOD * mmi(fact(r)) % MOD;
}

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

		a.sort((x, y) => y - x);

		let cntl = 0, cntr = 0;
		for (let i = 0; i < k; i++)
			cntl += a[i] == a[k-1];
		for (let i = k; i < n; i++)
			cntr += a[i] == a[k-1];

		const ans = c(cntl + cntr, cntl);

		console.log(ans.toString());
	}
}

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 MOD = 1e9 + 7;

function fast_pow(a, p)
{
	let res = 1;
	while (p) {
		if (p % 2 == 0) {
			a = Number(BigInt(a) * BigInt(a) % BigInt(MOD));
			p /= 2;
		} else {
			res = Number(BigInt(res) * BigInt(a)  % BigInt(MOD));
			p--;
		}
	}
	return res;
}

function mmi (n) {
	return fast_pow(n, MOD-2);
}

function fact (n) {
	let res = 1;
	for (let i = 1; i <= n; i++)
		res = Number(BigInt(res)*BigInt(i) % BigInt(MOD));
	return res;
}

function c(n, r) {
	return Number(BigInt(fact(n))
		* BigInt(mmi(fact(n-r))) % BigInt(MOD)
		* BigInt(mmi(fact(r))) % BigInt(MOD));
}

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

		a.sort((x, y) => y - x);

		let cntl = 0, cntr = 0;
		for (let i = 0; i < k; i++)
			cntl += a[i] == a[k-1];
		for (let i = k; i < n; i++)
			cntr += a[i] == a[k-1];

		const ans = c(cntl + cntr, cntl);

		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 = 10n

var iv = new Array(maxN + 1n).fill(0n)
iv[1] = 1n
for (let i = 2n; i <= maxN; i++) {
    iv[i] = (iv[i - 1n] * i) % mod
}
function main() {
    const x = readline();

    // 1 1 7
    // 6 9, 15, 18
    Array(Number(x)).fill(1).map((t, iii) => {
        // var n = parseInt(readline())
        // var x = new Array(n)
        var [n, k] = readline().split(' ').map((x, iii) => {
            return x
        })
        var a = readline().split(' ').map((x, iii) => {
            return parseInt(x)
        })
        a = a.sort((a, b) => b - a)

        var add = a[k - 1]
        var ii = k - 1
        while (a[k - 1] === a[ii]) ii++

        var number =
            // console.log(ii - k)
        console.log(iv[ii - k + 1].toString())
        // var res = []
    })
}

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

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

function fact (n) {
	if (n <= 1) return 1;
	return n * fact(n-1);
}

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

		a.sort((x, y) => y - x);

		let cntl = 0, cntr = 0;
		for (let i = 0; i < k; i++)
			cntl += a[i] == a[k-1];
		for (let i = k; i < n; i++)
			cntr += a[i] == a[k-1];

		const ans = fact(cntl+cntr) / (fact(cntl) * fact(cntr));

		console.log(ans);
	}
}


You are given an array $$$a$$$ with $$$n$$$ non-negative integers. You can apply the following operation on it.   Choose two indices $$$l$$$ and $$$r$$$ ($$$1 \le l < r \le n$$$).  If $$$a_l + a_r$$$ is odd, do $$$a_r := a_l$$$. If $$$a_l + a_r$$$ is even, do $$$a_l := a_r$$$. Find any sequence of at most $$$n$$$ operations that makes $$$a$$$ non-decreasing. It can be proven that it is always possible. Note that you do not have to minimize the number of operations.An array $$$a_1, a_2, \ldots, a_n$$$ is non-decreasing if and only if $$$a_1 \le a_2 \le \ldots \le a_n$$$.

The first line contains one integer $$$t$$$ ($$$1 \le t \le 10^5$$$) — the number of test cases. Each test case consists of two lines. The first line of each test case contains one integer $$$n$$$ ($$$1 \le n \le 10^5$$$) — the length of the array. The second line of each test case contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$0 \le a_i \le 10^9$$$)  — the array itself. It is guaranteed that the sum of $$$n$$$ over all test cases doesn't exceed $$$10^5$$$.

For each test case, print one integer $$$m$$$ ($$$0 \le m \le n$$$), the number of operations, in the first line. Then print $$$m$$$ lines. Each line must contain two integers $$$l_i, r_i$$$, which are the indices you chose in the $$$i$$$-th operation ($$$1 \le l_i < r_i \le n$$$). If there are multiple solutions, print any of them.

NoteIn the second test case, $$$a$$$ changes like this:  Select indices $$$3$$$ and $$$4$$$. $$$a_3 + a_4 = 3$$$ is odd, so do $$$a_4 := a_3$$$. $$$a = [1, 1000000000, 3, 3, 5]$$$ now.  Select indices $$$1$$$ and $$$2$$$. $$$a_1 + a_2 = 1000000001$$$ is odd, so do $$$a_2 := a_1$$$. $$$a = [1, 1, 3, 3, 5]$$$ now, and it is non-decreasing. In the first and third test cases, $$$a$$$ is already non-decreasing.

const readNum = () => +readline();
const readStr = () => readline();
const readNumArr = () => readline().split(' ').map(item => +item);
const createEmptyArr = (number) => new Array(number).fill(0);

const n = readNum();

for(var i = 0; i < n; i++) {
  var k = readNum();
  var arr = readNumArr();
  for(var j = 1; j < k && arr[j - 1] < arr[j]; j++) {}
  var temp = [];
  var count = 0;
  if(j !== k) {
    if((arr[0]+arr[k-1])%2===0) arr[0] = arr[k-1];
               else arr[k-1] = arr[0];
               count++;
               temp.push([1,k]);
               for(var j=1;j<k-1;j++){
                    if((arr[0]+arr[j])%2===1) temp.push([1,j+1]);
                    else temp.push([j+1,k]);
                    count++;
               }
  }
  print(count);
  for(var j = 0; j < temp.length; j++) {
    print(temp[j][0], temp[j][1]);
  }
}

'use strict';

var fs = require('fs');

function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }

var fs__default = /*#__PURE__*/_interopDefaultLegacy(fs);

const N = 100010;
const a = new Array(N);
      new Array(N);
function solve(read) {
  const rn = () => Number(read());
  const n = rn();
  let flag = true;
  for (let i = 0; i < n; i++) {
    a[i] = rn();
    if (i && a[i] < a[i - 1]) flag = false;
  }
  if (flag) return 0;
  let res = [];
  if (a[0] & 1) {
    const odd = [],
          even = [];
    let last = 0;
    for (let i = 0; i < n; i++) {
      if (a[i] & 1) {
        odd.push(i);
        last = i;
      } else even.push(i);
    }
    for (let i of odd) {
      if (i !== last) res.push([i, last]);
    }
    for (let i of even) {
      res.push([0, i]);
    }
  } else {
    const odd = [],
          even = [];
    let last = 0;
    for (let i = 0; i < n; i++) {
      if (a[i] & 1) {
        odd.push(i);
      } else {
        even.push(i);
        last = i;
      }
    }
    for (let i of even) {
      if (i !== last) res.push([i, last]);
    }
    for (let i of odd) {
      res.push([0, i]);
    }
  }
  return `${res.length}\n${res.map(([x, y]) => `${x + 1} ${y + 1}`).join('\n')}`;
}

function main(r) {
  try {
    let t = Number(r());
    let res = new Array(t);
    for (let i = 0; i < t; i++) {
      var _solve;
      const s = (_solve = solve(r)) !== null && _solve !== void 0 ? _solve : '';
      res[i] = s;
    }
    return res.join('\n');
    if (t >= 100) {
      return res.join('\n');
    } else {
      return '';
    }
  } catch (error) {
    console.log(error);
  }
}

const inputs = fs__default["default"].readFileSync(0, 'utf-8').split(/\s+/);
void function () {
  const read = ((i = 0) => () => inputs[i++])();
  const output = main(read);
  process.stdout.write(output);
}();

"use strict";
const fs = require("fs");
//let filename = "0.txt";
let filename = 0;
const input = fs.readFileSync(filename, "utf8").trim().split("\n");
let line = 0;
function readline() {
  return input[line++];
}
const solve = () => {
     let t = parseInt(readline());
     while(t--){
          let n = parseInt(readline());
          let arr = readline().trim().split(" ").map(cur=>parseInt(cur));
          let count = 0,res = [];
          if(n===1){
               console.log(0);
               continue;
          }
          else{
               if((arr[0]+arr[n-1])%2==0) arr[0] = arr[n-1];
               else arr[n-1] = arr[0];
               count++;
               res.push([1,n]);
               for(let i=1;i<n-1;i++){
                    if((arr[0]+arr[i])%2===1) res.push([1,i+1]);
                    else res.push([i+1,n]);
                    count++;
               }
               console.log(count);
               for(let i=0;i<res.length;i++) console.log(res[i].join(" "));
          }
     }
};
solve();

const readNum = () => +readline();
const readStr = () => readline();
const readNumArr = () => readline().split(' ').map(item => +item);
const createEmptyArr = (number) => new Array(number).fill(0);

const n = readNum();

for(var i = 0; i < n; i++) {
  var k = readNum();
  var arr = readNumArr();
  for(var j = 1; j < k && arr[j - 1] < arr[j]; j++) {}
  var temp = [];
  var count = 0;
  if(j !== k) {
    if((arr[0]+arr[n-1])%2==0) arr[0] = arr[n-1];
               else arr[n-1] = arr[0];
               count++;
               temp.push([1,k]);
    for(var j = 1; j < k - 1; j++) {
        if((arr[0] + arr[j]) % 2 > 0) {
          temp.push([1, j + 1]);
        } else {
          temp.push([j + 1, k]);
        }
        count++;
      }
  }
  print(count);
  for(var j = 0; j < temp.length; j++) {
    print(temp[j][0], temp[j][1]);
  }
}

const readNum = () => +readline();
const readStr = () => readline();
const readNumArr = () => readline().split(' ').map(item => +item);
const createEmptyArr = (number) => new Array(number).fill(0);

const n = readNum();

for(var i = 0; i < n; i++) {
  var k = readNum();
  var arr = readNumArr();
  for(var j = 1; j < k && arr[j - 1] < arr[j]; j++) {}
  var temp = [];
  var count = 0;
  if(j !== k) {
    for(var j = 1; j < k - 1; j++) {
        if((arr[0] + arr[j]) % 2 > 0) {
          temp.push([1, j + 1]);
        } else {
          temp.push([j + 1, k]);
        }
        count++;
      }
  }
  print(count);
  for(var j = 0; j < temp.length; j++) {
    print(temp[j][0], temp[j][1]);
  }
}

const readNum = () => +readline();
const readStr = () => readline();
const readNumArr = () => readline().split(' ').map(item => +item);
const createEmptyArr = (number) => new Array(number).fill(0);

const n = readNum();

for(var i = 0; i < n; i++) {
  var k = readNum();
  var arr = readNumArr();
  for(var j = 1; j < k && arr[j - 1] < arr[j]; j++) {}
  var temp = [];
  var count = 0;
  if(j !== k) {
    for(var j = 0; j < k - 1; j++) {
        if((arr[j] + arr[j + 1]) % 2 > 0) {
          arr[j + 1] = arr[j];
          count++;
          temp.push([j, j + 1]);
        }
      }
  }
  print(count);
  for(var j = 0; j < temp.length; j++) {
    print(temp[j][0] + 1, temp[j][1] + 1);
  }
}

const readNum = () => +readline();
const readStr = () => readline();
const readNumArr = () => readline().split(' ').map(item => +item);
const createEmptyArr = (number) => new Array(number).fill(0);

const n = readNum();

for(var i = 0; i < n; i++) {
  var k = readNum();
  var arr = readNumArr();
  for(var j = 1; j < k && arr[j - 1] < arr[j]; j++) {}
  var temp = [];
  var count = 0;
  if(j !== k) {
    for(var j = 0; j < k - 1; j++) {
        if((arr[j] + arr[j + 1]) % 2 > 0) {
          arr[j + 1] = arr[j];
          count++;
          temp.push([j, j + 1]);
        }
      }
      print(arr);
  }
  print(count);
  for(var j = 0; j < temp.length; j++) {
    print(temp[j][0] + 1, temp[j][1] + 1);
  }
}

const readNum = () => +readline();
const readNumArr = () => readline().split(' ').map(item => +item);

const n = readNum();

for(var i = 0; i < n; i++) {
  var k = readNum();
  var arr = readNumArr();
  for(var j = 1; j < k && arr[j - 1] < arr[j]; j++) {}
  var temp = [];
  var count = 0;
  if(j !== k) {
    for(var j = 0; j < k - 1; j++) {
      for(var jj = j + 1; jj < k; jj++) {
        if(arr[jj - 1] > arr[jj]) {
          break;
        }
        if((arr[j] + arr[jj]) % 2 > 0) {
          arr[jj] = arr[j];
          count++;
          temp.push([j, jj]);
        }
      }
    }
  }
  print(count);
  for(var j = 0; j < temp.length; j++) {
    print(temp[j][0], temp[j][1]);
  }
}

const readNum = () => +readline();
const readStr = () => readline();
const readNumArr = () => readline().split(' ').map(item => +item);
const createEmptyArr = (number) => new Array(number).fill(0);

const n = readNum();

for(var i = 0; i < n; i++) {
  var k = readNum();
  var arr = readNumArr();
  var temp = [];
  var count = 0;
  for(var j = 0; j < k - 1; j++) {
    for(var jj = j + 1; jj < k; jj++) {
      if(arr[jj - 1] > arr[jj]) {
        break;
      }
      if((arr[j] + arr[jj]) % 2 > 0) {
        arr[jj] = arr[j];
        count++;
        temp.push([j, jj]);
      }
    }
  }
  print(count);
  for(var j = 0; j < temp.length; j++) {
    print(temp[j][0], temp[j][1]);
  }
}

'use strict';

var fs = require('fs');

function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }

var fs__default = /*#__PURE__*/_interopDefaultLegacy(fs);

const N = 100010;
const a = new Array(N),
      even = new Array(N),
      odd = new Array(N);
function solve(read) {
  const rn = () => Number(read());
  const n = rn();
  let flag = true;
  for (let i = 0; i < n; i++) {
    a[i] = rn();
    if (i && a[i] < a[i - 1]) flag = false;
  }
  if (flag) return 0;
  let res = [];
  if (a[0] & 1) {
    let last = 0,
        ido = 0,
        ide = 0;
    for (let i = 0; i < n; i++) {
      if (a[i] & 1) {
        odd[ido++] = i;
        last = i;
      } else even[ide++] = i;
    }
    for (let i = 0; i < ido; i++) {
      const j = odd[i];
      if (j !== last && a[j] !== a[last]) res.push(`${j + 1} ${last + 1}`);
    }
    for (let i = 0; i < ide; i++) {
      const j = even[i];
      res.push(`${1} ${j + 1}`);
    }
  } else {
    let p = 0;
    for (let i = 1; i < n; i++) {
      even[i] = p;
      if (a[i] % 2 === 0) p = i;
    }
    for (let i = n - 1; i > 0; i--) {
      if (a[i] & 1) {
        res.push(`${even[i] + 1} ${i + 1}`);
      } else {
        if (a[even[i]] > a[i]) res.push(`${even[i] + 1} ${i + 1}`);
      }
    }
  }
  return `${res.length}\n${res.join('\n')}`;
}

function main(r) {
  try {
    let t = Number(r());
    let res = new Array(t);
    for (let i = 0; i < t; i++) {
      var _solve;
      const s = (_solve = solve(r)) !== null && _solve !== void 0 ? _solve : '';
      res[i] = s;
    }
    return res.join('\n');
    if (t >= 100) {
      return res.join('\n');
    } else {
      return '';
    }
  } catch (error) {
    console.log(error);
  }
}

const inputs = fs__default["default"].readFileSync(0, 'utf-8').split(/\s+/);
void function () {
  const read = ((i = 0) => () => inputs[i++])();
  const output = main(read);
  process.stdout.write(output);
}();

"use strict";
const fs = require("fs");
//let filename = "0.txt";
let filename = 0;
const input = fs.readFileSync(filename, "utf8").trim().split("\n");
let line = 0;
function readline() {
  return input[line++];
}
const solve = () => {
     let t = parseInt(readline());
     while(t--){
          let n = parseInt(readline());
          let arr = readline().trim().split(" ").map(cur=>parseInt(cur));
          let count = 0,res = [];
          if(n===1){
               console.log(0);
               continue;
          }
          else{
               if((arr[0]+arr[n-1])%2==0) arr[0] = arr[n-1];
               else arr[n-1] = arr[0];
               count++;
               res.push([1,n]);
               for(let i=1;i<n-1;i++){
                    if((arr[0]+arr[i])%2===1) res.push([1,i+1]);
                    else res.push([i+1,n-1]);
                    count++;
               }
               console.log(count);
               for(let i=0;i<res.length;i++) console.log(res[i].join(" "));
          }
     }
};
solve();

"use strict";
const fs = require("fs");
//let filename = "0.txt";
let filename = 0;
const input = fs.readFileSync(filename, "utf8").trim().split("\n");
let line = 0;
function readline() {
  return input[line++];
}
const solve = () => {
     let t = parseInt(readline());
     while(t--){
          let n = parseInt(readline());
          let arr = readline().trim().split(" ").map(cur=>parseInt(cur));
          let count = 0,res = [];
          if(n===1){
               console.log(0);
               continue;
          }
          while(true){
               for(let i=0;i<n-1;i++){
                    if(arr[i]>arr[i+1]){
                         if((arr[i]+arr[i+1])%2===0) arr[i] = arr[i+1]
                         else arr[i+1] = arr[i];
                         count++;
                         res.push([i+1,i+2]);
                    }
               }
               let flag = 0;
               for(let i=0;i<n-1;i++){
                    if(arr[i]>arr[i+1]){
                         flag = 1;
                         break;
                    }
               }
               if(flag===0){
                    console.log(count);
                    if(count!==0){
                         for(let i=0;i<res.length;i++) console.log(res[i].join(" "));
                    }
                    break;
               }
               for(let i=n-1;i>=1;i--){
                    if(arr[i-1]>arr[i]){
                         if((arr[i-1]+arr[i])%2==0) arr[i-1] = arr[i];
                         else arr[i] = arr[i-1];
                         count++;
                         res.push([i,i+1]);
                    }
               }
          }
     }
};
solve();