Ford Prefect got a job as a web developer for a small company that makes towels. His current work task is to create a search engine for the website of the company. During the development process, he needs to write a subroutine for comparing strings S and T of equal length to be "similar". After a brief search on the Internet, he learned about the Hamming distance between two strings S and T of the same length, which is defined as the number of positions in which S and T have different characters. For example, the Hamming distance between words "permanent" and "pergament" is two, as these words differ in the fourth and sixth letters.Moreover, as he was searching for information, he also noticed that modern search engines have powerful mechanisms to correct errors in the request to improve the quality of search. Ford doesn't know much about human beings, so he assumed that the most common mistake in a request is swapping two arbitrary letters of the string (not necessarily adjacent). Now he wants to write a function that determines which two letters should be swapped in string S, so that the Hamming distance between a new string S and string T would be as small as possible, or otherwise, determine that such a replacement cannot reduce the distance between the strings.Help him do this!

The first line contains integer n (1 ≤ n ≤ 200 000) — the length of strings S and T. The second line contains string S. The third line contains string T. Each of the lines only contains lowercase Latin letters.

In the first line, print number x — the minimum possible Hamming distance between strings S and T if you swap at most one pair of letters in S. In the second line, either print the indexes i and j (1 ≤ i, j ≤ n, i ≠ j), if reaching the minimum possible distance is possible by swapping letters on positions i and j, or print "-1 -1", if it is not necessary to swap characters. If there are multiple possible answers, print any of them.

NoteIn the second test it is acceptable to print i = 2, j = 3.

var tok = null;
var index = 0;
function next() {
    while (tok == null || index == tok.length) {
        tok = readline().split(' ');
        index = 0;
    }
    var res = tok[index++];
    return res;
}

function nextInt() {
    return parseInt(next());
}

function main() {
    var n = nextInt();
    var s = next();
    var t = next();
    var dif = 0;

    var pair = {};
    var sKey = {};
    var tKey = {};

    for (var i = 0; i < n; i++) {
        var si = s.charAt(i);
        var ti = t.charAt(i);
        if (si != ti) {
            dif++;
            var p = si + "" + ti;
            if (typeof (pair[p]) != 'undefined') {
                pair[p]++;
            } else {
                pair[p] = 1;
            }
            if (typeof (sKey[si]) != 'undefined') {
                sKey[si]++;
            } else {
                sKey[si] = 1;
            }
            if (typeof (tKey[ti]) != 'undefined') {
                tKey[ti]++;
            } else {
                tKey[ti] = 1;
            }
        }
    }

    for (var i = 0; i < n; i++) {
        var si = s.charAt(i);
        var ti = t.charAt(i);
        if (si != ti) {
            var p = ti + "" + si;
            if (typeof (pair[p]) != 'undefined') {
                for (var k = 0; k < n; k++) {
                    if (t.charAt(k) == s.charAt(i) && s.charAt(k) == t.charAt(i)) {
                        print((dif - 2) + "\n" + (i + 1) + " " + (k + 1));
                        return;
                    }
                }
            }
        }
    }

    for (var i = 0; i < n; i++) {
        var si = s.charAt(i);
        var ti = t.charAt(i);
        if (si != ti) {
            if (typeof (sKey[ti]) != 'undefined') {
                for (var k = 0; k < n; k++) {
                    if (t.charAt(k) != s.charAt(k) &&
                        s.charAt(k) == t.charAt(i)) {
                        print((dif - 1) + "\n" + (i + 1) + " " + (k + 1));
                        return;
                    }
                }
            }
            if (typeof (tKey[si]) != 'undefined') {
                for (var k = 0; k < n; k++) {
                    if (t.charAt(k) == s.charAt(i) &&
                        s.charAt(k) != t.charAt(k)) {
                        print((dif - 1) + "\n" + (i + 1) + " " + (k + 1));
                        return;
                    }
                }
            }
        }
    }
    print(dif + "\n-1 -1");
}

main();

var tok = null;
var index = 0;
function next() {
    while (tok == null || index == tok.length) {
        tok = readline().split(' ');
        index = 0;
    }
    var res = tok[index++];
    return res;
}

function nextInt() {
    return parseInt(next());
}

function main() {
    var n = nextInt();
    var s = next();
    var t = next();
    var dif = 0;

    var pair = {};
    var sKey = {};
    var tKey = {};

    for (var i = 0; i < n; i++) {
        var si = s.charAt(i);
        var ti = t.charAt(i);
        if (si != ti) {
            dif++;
            var p = si + "" + ti;
            if (typeof (pair[p]) != 'undefined') {
                pair[p]++;
            } else {
                pair[p] = 1;
            }
            if (typeof (sKey[si]) != 'undefined') {
                sKey[si]++;
            } else {
                sKey[si] = 1;
            }
            if (typeof (tKey[ti]) != 'undefined') {
                tKey[ti]++;
            } else {
                tKey[ti] = 1;
            }
        }
    }
    for (var i = 0; i < n; i++) {
        var si = s.charAt(i);
        var ti = t.charAt(i);
        if (si != ti) {
            var p = si + "" + ti;
            if (typeof (pair[p]) != 'undefined') {
                for (var k = 0; k < n; k++) {
                    if (t.charAt(k) == s.charAt(i) &&
                        s.charAt(k) == t.charAt(i)) {
                        print((dif - 2) + "\n" + (i + 1) + " " + (k + 1));
                        return;
                    }
                }
            }
            if (typeof (sKey[si]) != 'undefined') {
                for (var k = 0; k < n; k++) {
                    if (t.charAt(k) == s.charAt(i) &&
                        s.charAt(k) != t.charAt(k)) {
                        print((dif - 1) + "\n" + (i + 1) + " " + (k + 1));
                        return;
                    }
                }
            }
            if (typeof (tKey[ti]) != 'undefined') {
                for (var k = 0; k < n; k++) {
                    if (t.charAt(k) != s.charAt(k) &&
                        s.charAt(k) == t.charAt(i)) {
                        print((dif - 1) + "\n" + (i + 1) + " " + (k + 1));
                        return;
                    }
                }
            }
        }
    }
    print(dif + "\n-1 -1");
}

main();

var tok = null;
var index = 0;
function next() {
    while (tok == null || index == tok.length) {
        tok = readline().split(' ');
        index = 0;
    }
    var res = tok[index++];
    return res;
}

function nextInt() {
    return parseInt(next());
}

function check1(s, t) {
    for (var i = 0; i < s.length - 1; i++) {
        if (s.charAt(i) != t.charAt(i)) {
            for (var k = s.length - 1 ; k > i; k--) {
                if (s.charAt(i) == t.charAt(k) && s.charAt(k) == t.charAt(i)) {
                    return (i + 1) + " " + (k + 1);
                }
            }
        }
    }
    return "";
}

function main() {
    var n = nextInt();
    var s = next();
    var t = next();
    var dif = 0;
    for (var i = 0; i < n; i++) {
        if (s.charAt(i) != t.charAt(i)) {
            dif++;
        }
    }
    var result = check1(s, t);
    if (s == t) {
        print(0 + "\n-1 -1");
        return;
    } else if (result != "") {
        print((dif - 2) + "\n" + result);
        return;
    } else {
        for (var i = 0; i < n - 1; i++) {
            if (s.charAt(i) != t.charAt(i)) {
                for (var k = n - 1; k > i; k--) {
                    if (s.charAt(i) == t.charAt(k) && s.charAt(k) != t.charAt(k)) {
                        print((dif - 1) + "\n" + (i + 1) + " " + (k + 1));
                        return;
                    }
                }
            }
        }
    }
    print(dif + "\n-1 -1");
}

main();

var tok = null;
var index = 0;
function next() {
    while (tok == null || index == tok.length) {
        tok = readline().split(' ');
        index = 0;
    }
    var res = tok[index++];
    return res;
}

function nextInt() {
    return parseInt(next());
}

function main() {
    var n = nextInt();
    var s = next();
    var t = next();
    var dif = 0;

    var pair = {};
    var sKey = {};
    var tKey = {};

    for (var i = 0; i < n; i++) {
        var si = s.charAt(i);
        var ti = t.charAt(i);
        if (si != ti) {
            dif++;
            var p = si + "" + ti;
            if (typeof (pair[p]) != 'undefined') {
                pair[p]++;
            } else {
                pair[p] = 1;
            }
            if (typeof (sKey[si]) != 'undefined') {
                sKey[si]++;
            } else {
                sKey[si] = 1;
            }
            if (typeof (tKey[ti]) != 'undefined') {
                tKey[ti]++;
            } else {
                tKey[ti] = 1;
            }
        }
    }
    for (var i = 0; i < n; i++) {
        var si = s.charAt(i);
        var ti = t.charAt(i);
        if (si != ti) {
            if (typeof (pair[p]) != 'undefined') {
                for (var k = 0; k < n; k++) {
                    if (t.charAt(k) == s.charAt(i) &&
                        s.charAt(k) == t.charAt(i)) {
                        print((dif - 2) + "\n" + (i+1) + " " + (k+1));
                        return;
                    }
                }
            }
            if (typeof (sKey[si]) != 'undefined') {
                for (var k = 0; k < n; k++) {
                    if (t.charAt(k) == s.charAt(i) &&
                        s.charAt(k) != t.charAt(k)) {
                        print((dif - 1) + "\n" + (i+1) + " " + (k+1));
                        return;
                    }
                }
            }
            if (typeof (tKey[ti]) != 'undefined') {
                for (var k = 0; k < n; k++) {
                    if (t.charAt(k) != s.charAt(k) &&
                        s.charAt(k) == t.charAt(i)) {
                        print((dif - 1) + "\n" + (i+1) + " " + (k+1));
                        return;
                    }
                }
            }
        }
    }
    print(dif + "\n-1 -1");
}

main();

var tok = null;
var index = 0;
function next() {
    while (tok == null || index == tok.length) {
        tok = readline().split(' ');
        index = 0;
    }
    var res = tok[index++];
    return res;
}

function nextInt() {
    return parseInt(next());
}

function main() {
    var n = nextInt();
    var s = next();
    var t = next();
    var dif = 0;

    var pair = {};
    var sKey = {};
    var tKey = {};

    print(s + "\n" + t);

    for (var i = 0; i < n; i++) {
        var si = s.charAt(i);
        var ti = t.charAt(i);
        if (si != ti) {
            dif++;
            var p = si + "" + ti;
            if (typeof (pair[p]) != 'undefined') {
                pair[p]++;
            } else {
                pair[p] = 1;
            }
            if (typeof (sKey[si]) != 'undefined') {
                sKey[si]++;
            } else {
                sKey[si] = 1;
            }
            if (typeof (tKey[ti]) != 'undefined') {
                tKey[ti]++;
            } else {
                tKey[ti] = 1;
            }
        }
    }
    for (var i = 0; i < n; i++) {
        var si = s.charAt(i);
        var ti = t.charAt(i);
        if (si != ti) {
            if (typeof (pair[p]) != 'undefined') {
                for (var k = 0; k < n; k++) {
                    if (t.charAt(k) == s.charAt(i) &&
                        s.charAt(k) == t.charAt(i)) {
                        print((dif - 2) + "\n" + (i+1) + " " + (k+1));
                        return;
                    }
                }
            }
            if (typeof (sKey[si]) != 'undefined') {
                for (var k = 0; k < n; k++) {
                    if (t.charAt(k) == s.charAt(i) &&
                        s.charAt(k) != t.charAt(k)) {
                        print((dif - 1) + "\n" + (i+1) + " " + (k+1));
                        return;
                    }
                }
            }
            if (typeof (tKey[ti]) != 'undefined') {
                for (var k = 0; k < n; k++) {
                    if (t.charAt(k) != s.charAt(k) &&
                        s.charAt(k) == t.charAt(i)) {
                        print((dif - 1) + "\n" + (i+1) + " " + (k+1));
                        return;
                    }
                }
            }
        }
    }
    print(dif + "\n-1 -1");
}

main();

var tok = null;
var index = 0;
function next() {
    while (tok == null || index == tok.length) {
        tok = readline().split(' ');
        index = 0;
    }
    var res = tok[index++];
    return res;
}

function nextInt() {
    return parseInt(next());
}

function main() {
    var n = nextInt();
    var s = next();
    var t = next();
    var dif = 0;

    var pair = {};
    var sKey = {};
    var tKey = {};

    for (var i = 0; i < n; i++) {
        var si = s.charAt(i);
        var ti = t.charAt(i);
        if (si != ti) {
            dif++;
            var p = si + "" + ti;
            if (typeof (pair[p]) != 'undefined') {
                pair[p]++;
            } else {
                pair[p] = 1;
            }
            if (typeof (sKey[si]) != 'undefined') {
                sKey[si]++;
            } else {
                sKey[si] = 1;
            }
            if (typeof (tKey[ti]) != 'undefined') {
                tKey[ti]++;
            } else {
                tKey[ti] = 1;
            }
        }
    }

    for (var i = 0; i < n; i++) {
        var si = s.charAt(i);
        var ti = t.charAt(i);
        if (si != ti) {
            var p = ti + "" + si;
            if (typeof (pair[p]) != 'undefined') {
                for (var k = 0; k < n; k++) {
                    if (t.charAt(k) == s.charAt(i) && s.charAt(k) == t.charAt(i)) {
                        print((dif - 2) + "\n" + (i + 1) + " " + (k + 1));
                        return;
                    }
                }
            }
        }
    }

    for (var i = 0; i < n; i++) {
        var si = s.charAt(i);
        var ti = t.charAt(i);
        if (si != ti) {
            if (typeof (sKey[ti]) != 'undefined') {
                for (var k = 0; k < n; k++) {
                    if (t.charAt(k) == s.charAt(i) &&
                        s.charAt(k) != t.charAt(k)) {
                        print((dif - 1) + "\n" + (i + 1) + " " + (k + 1));
                        return;
                    }
                }
            }
            if (typeof (tKey[si]) != 'undefined') {
                for (var k = 0; k < n; k++) {
                    if (t.charAt(k) != s.charAt(k) &&
                        s.charAt(k) == t.charAt(i)) {
                        print((dif - 1) + "\n" + (i + 1) + " " + (k + 1));
                        return;
                    }
                }
            }
        }
    }
    print(dif + "\n-1 -1");
}

main();

var tok = null;
var index = 0;
function next() {
    while (tok == null || index == tok.length) {
        tok = readline().split(' ');
        index = 0;
    }
    var res = tok[index++];
    return res;
}

function nextInt() {
    return parseInt(next());
}

function main() {
    var n = nextInt();
    var s = next();
    var t = next();
    var dif = 0;

    var pair = {};
    var sKey = {};
    var tKey = {};

    for (var i = 0; i < n; i++) {
        var si = s.charAt(i);
        var ti = t.charAt(i);
        if (si != ti) {
            dif++;
            var p = si + "" + ti;
            if (typeof (pair[p]) != 'undefined') {
                pair[p]++;
            } else {
                pair[p] = 1;
            }
            if (typeof (sKey[si]) != 'undefined') {
                sKey[si]++;
            } else {
                sKey[si] = 1;
            }
            if (typeof (tKey[ti]) != 'undefined') {
                tKey[ti]++;
            } else {
                tKey[ti] = 1;
            }
        }
    }
    for (var i = 0; i < n; i++) {
        var si = s.charAt(i);
        var ti = t.charAt(i);
        if (si != ti) {
            var p = ti + "" + si;
            if (typeof (pair[p]) != 'undefined') {
                for (var k = 0; k < n; k++) {
                    if (t.charAt(k) == s.charAt(i) &&
                        s.charAt(k) == t.charAt(i)) {
                        print((dif - 2) + "\n" + (i + 1) + " " + (k + 1));
                        return;
                    }
                }
            }
            if (typeof (sKey[si]) != 'undefined') {
                for (var k = 0; k < n; k++) {
                    if (t.charAt(k) == s.charAt(i) &&
                        s.charAt(k) != t.charAt(k)) {
                        print((dif - 1) + "\n" + (i + 1) + " " + (k + 1));
                        return;
                    }
                }
            }
            if (typeof (tKey[ti]) != 'undefined') {
                for (var k = 0; k < n; k++) {
                    if (t.charAt(k) != s.charAt(k) &&
                        s.charAt(k) == t.charAt(i)) {
                        print((dif - 1) + "\n" + (i + 1) + " " + (k + 1));
                        return;
                    }
                }
            }
        }
    }
    print(dif + "\n-1 -1");
}

main();


You are given four integers $$$a$$$, $$$b$$$, $$$x$$$ and $$$y$$$. Initially, $$$a \ge x$$$ and $$$b \ge y$$$. You can do the following operation no more than $$$n$$$ times:  Choose either $$$a$$$ or $$$b$$$ and decrease it by one. However, as a result of this operation, value of $$$a$$$ cannot become less than $$$x$$$, and value of $$$b$$$ cannot become less than $$$y$$$. Your task is to find the minimum possible product of $$$a$$$ and $$$b$$$ ($$$a \cdot b$$$) you can achieve by applying the given operation no more than $$$n$$$ times.You have to answer $$$t$$$ independent test cases.

The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The only line of the test case contains five integers $$$a$$$, $$$b$$$, $$$x$$$, $$$y$$$ and $$$n$$$ ($$$1 \le a, b, x, y, n \le 10^9$$$). Additional constraint on the input: $$$a \ge x$$$ and $$$b \ge y$$$ always holds.

For each test case, print one integer: the minimum possible product of $$$a$$$ and $$$b$$$ ($$$a \cdot b$$$) you can achieve by applying the given operation no more than $$$n$$$ times.

NoteIn the first test case of the example, you need to decrease $$$b$$$ three times and obtain $$$10 \cdot 7 = 70$$$.In the second test case of the example, you need to decrease $$$a$$$ one time, $$$b$$$ one time and obtain $$$11 \cdot 7 = 77$$$.In the sixth test case of the example, you need to decrease $$$a$$$ five times and obtain $$$5 \cdot 11 = 55$$$.In the seventh test case of the example, you need to decrease $$$b$$$ ten times and obtain $$$10 \cdot 1 = 10$$$.

process.stdin.resume();
process.stdin.setEncoding("utf-8");
let standardInputString = "";
let currentLine = 0;

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

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

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

  main();
});

function main() {
  const t = parseInt(readLine());
  for (let i = 0; i < t; i++) {
    let l = readLine()
      .split(" ")
      .map((el) => parseInt(el));
    let [a, b, x, y, n] = l;

    let [small, large] =
      Math.max(a - n, x) < Math.max(b - n, y)
        ? [
            [a, x],
            [b, y],
          ]
        : [
            [b, y],
            [a, x],
          ];
    let rest = Math.max(-(small[0] - small[1] - n), 0);
    small[0] -= n;
    let finalsmall = BigInt(Math.max(small[0], small[1]));
    large[0] -= rest;
    let finallarge = BigInt(Math.max(large[0], large[1]));

    let res = (finalsmall * finallarge).toString();
    console.log(res);
  }
}

let input = '';
let inputResolve;
let inputPromise = new Promise(resolve => inputResolve = resolve);
process.stdin.on('data', c => input += c);
process.stdin.on('end', () => inputResolve());

function For(a, b, cb) {
  let res;
  if (a < b) {
    for (let i = a; i < b; i++) {
      if ((res = cb(i)) !== undefined) return res;
    }
  } else {
    for (let i = b - 1; i >= a; i--) {
      if ((res = cb(i)) !== undefined) return res;
    }
  }
}

function gcd(a, b) {
  if (!b) return a;
  return gcd(b, a % b);
}
function mod(a, n, m) {
  if (n == 0n) return 1n;
  if (n % 2n == 0n) return mod(a * a % m, n / 2n, m);
  return a * mod(a, n - 1n, m) % m;
}
function extendedEuclid(a, b) {
  if (!b) return [1, 0];
  else {
    let [x, y] = extendedEuclid(b, a % b);
    return [y, x - (a / b | 0) * y];
  }
}

function max(a, b) {
  if (a > b) return a;
  return b;
}

(async () => {
  await inputPromise;
  let inp = input.split(/\D+/).map(v => +v); r = 0;
  let t = inp[r++];
  For(0, t, i => {
    let [a, b, x, y, n] = inp.slice(r, r = r + 5).map(v => BigInt(v));
    let min1, min2;
    if (n >= b - y) min1 = y * max(x, a - (n - (b - y)));
    else min1 = a * (b - n);
    if (n >= a - x) min2 = x * max(y, b - (n - (a - x)));
    else min2 = b * (a - n);
    console.log(min1 < min2 ? min1 + '' : min2 + '');
  })
})();

process.stdin.resume();
process.stdin.setEncoding("utf-8");
let standardInputString = "";
let currentLine = 0;

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

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

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

  main();
});

function main() {
  const t = parseInt(readLine());
  for (let i = 0; i < t; i++) {
    let l = readLine()
      .split(" ")
      .map((el) => parseInt(el));
    let [a, b, x, y, n] = l;

    let [small, large] =
      Math.max(a - n, x) < Math.max(b - n, y)
        ? [
            [a, x],
            [b, y],
          ]
        : [
            [b, y],
            [a, x],
          ];
    let rest = Math.max(-(small[0] - small[1] - n), 0);
    small[0] -= n;
    let finalsmall = Math.max(small[0], small[1]);
    large[0] -= rest;
    let finallarge = Math.max(large[0], large[1]);

    console.log(finalsmall * finallarge);
  }
}

process.stdin.resume();
process.stdin.setEncoding("utf-8");
let standardInputString = "";
let currentLine = 0;

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

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

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

  main();
});

function main() {
  const t = parseInt(readLine());
  for (let i = 0; i < t; i++) {
    let l = readLine()
      .split(" ")
      .map((el) => parseInt(el));
    let [a, b, x, y, n] = l;

    let [small, large] =
      a < b
        ? [
            [a, x],
            [b, y],
          ]
        : [
            [b, y],
            [a, x],
          ];
    let rest = Math.max(-(small[0] - small[1] - n), 0);
    small[0] -= n;
    small = Math.max(small[0], small[1]);
    large[0] -= rest;
    large = Math.max(large[0], large[1]);

    console.log(large * small);
  }
}

let input = '';
let inputResolve;
let inputPromise = new Promise(resolve => inputResolve = resolve);
process.stdin.on('data', c => input += c);
process.stdin.on('end', () => inputResolve());

function For(a, b, cb) {
  let res;
  if (a < b) {
    for (let i = a; i < b; i++) {
      if ((res = cb(i)) !== undefined) return res;
    }
  } else {
    for (let i = b - 1; i >= a; i--) {
      if ((res = cb(i)) !== undefined) return res;
    }
  }
}

function gcd(a, b) {
  if (!b) return a;
  return gcd(b, a % b);
}
function mod(a, n, m) {
  if (n == 0n) return 1n;
  if (n % 2n == 0n) return mod(a * a % m, n / 2n, m);
  return a * mod(a, n - 1n, m) % m;
}
function extendedEuclid(a, b) {
  if (!b) return [1, 0];
  else {
    let [x, y] = extendedEuclid(b, a % b);
    return [y, x - (a / b | 0) * y];
  }
}

(async () => {
  await inputPromise;
  let inp = input.split(/\D+/).map(v => +v); r = 0;
  let t = inp[r++];
  For(0, t, i => {
    let [a, b, x, y, n] = inp.slice(r, r = r + 5);
    let min1, min2;
    if (n >= b - y) min1 = y * Math.max(x, a - (n - (b - y)));
    else min1 = a * (b - n);
    if (n >= a - x) min2 = x * Math.max(y, b - (n - (a - x)));
    else min2 = b * (a - n);
    console.log(Math.min(min1, min2));
  })
})();


A wise man told Kerem "Different is good" once, so Kerem wants all things in his life to be different. Kerem recently got a string s consisting of lowercase English letters. Since Kerem likes it when things are different, he wants all substrings of his string s to be distinct. Substring is a string formed by some number of consecutive characters of the string. For example, string "aba" has substrings "" (empty substring), "a", "b", "a", "ab", "ba", "aba".If string s has at least two equal substrings then Kerem will change characters at some positions to some other lowercase English letters. Changing characters is a very tiring job, so Kerem want to perform as few changes as possible.Your task is to find the minimum number of changes needed to make all the substrings of the given string distinct, or determine that it is impossible.

The first line of the input contains an integer n (1 ≤ n ≤ 100 000) — the length of the string s. The second line contains the string s of length n consisting of only lowercase English letters.

If it's impossible to change the string s such that all its substring are distinct print -1. Otherwise print the minimum required number of changes.

NoteIn the first sample one of the possible solutions is to change the first character to 'b'.In the second sample, one may change the first character to 'a' and second character to 'b', so the string becomes "abko".

var n = +readline();
if (n > 26) {
    print(-1)
} else {
    print(n - new Set(readline()).size)
}

var n = +readline();
print(n > 26 ? -1: n - new Set(readline()).size);

var n = parseInt(readline());

var s = readline().trim();

var e = new Set(s.split(''));

var ans=s.length-Array.from(e).length;
print(s.length>26?-1:ans)

var n = Number(readline());
var string = readline().split('').map(String);

// create an object to keep track of how many times each letter is present in the original string
var count = {};

for (var i = 0; i < n; i++) {
	if (string[i] in count) {
		count[string[i]] += 1;
	} else {
		count[string[i]] = 1;
	}
}

var letters = Object.keys(count).length // how many distinct letters are int the original string

var changes = 0;

for (var key in count) {
	if (count[key] >= 2) {
		changes += count[key] - 1;
	}
}

// If I would have to change more letters than whatever letters are still available, then it's impossible
if (changes > 26 - letters) {
	changes = -1;
}

print(changes);

function main() {
    var n = Number(readline());
    var s = String(readline());

    if (s.length > 26) {
        print(-1);
        return;
    }

    var count = new Array(26);
    var i = 0;
    for (i = 0; i < 26; ++i) {
        count[i] = 0;
    }
    var a_code = "a".charCodeAt(0);
    for (i = 0; i < n; ++i) {
        var j = s.charCodeAt(i) - a_code;
        ++count[j];
    }

    var ans = 0;
    for (i = 0; i < 26; ++i) {
        if (count[i] > 1) {
            ans += count[i] - 1;
        }
    }

    print(ans);
}

main();

var n = +readline();
var s = readline();

const aCode = 'a'.charCodeAt(0);
const zCode = 'z'.charCodeAt(0);
const cardinality = zCode - aCode + 1;

if (s.length > cardinality) {
  write('-1');
  quit();
}

var u = [...new Set(s)].join('');

write(s.length - u.length)

var n = parseInt(readline());
var str = readline();

if (n > 26) {
	print("-1");
}
else {
	var s = {};
	for (var i = 0; i < n; i++) {
		s[str[i]] = true;
	}

	print(n - Object.keys(s).length);
}

"use strict";

function main() {
	var n = parseInt(readline());
	var str = readline();

	if (n > 26) {
		print("-1");
		return;
	}

	var s = {};
	for (let i = 0; i < n; i++) {
		s[str[i]] = true;
	}

	print(n - Object.keys(s).length);
}

main();

function main() {
	var n = parseInt(readline());
	var str = readline();

	if (n > 26) {
		print("-1");
		return;
	}

	var s = {};
	for (var i = 0; i < n; i++) {
		s[str[i]] = true;
	}

	print(n - Object.keys(s).length);
}

main();

var howManyToChange = function ( s ) {
  var letters,
    engLettersCount = 26;
  if ( s.length > engLettersCount ) {
    return;
  }

  letters = new Set( s );
  return s.length - letters.size;
};

readline();
var toChange = howManyToChange( readline() );
if ( typeof toChange === "undefined" ) {
  print( -1 );
} else {
  print( toChange );
}

function getInput() {
    var line = readline();
    var lines = [line];
    while (line = readline()) {
        lines.push(line);
    }
    return lines;
}

var alphabet = "abcdefghijklmnopqrstuvwxyz";
var lastIndex = 0;

function main() {
	var input = getInput();
	var str = input[1];

    if (str.length > alphabet.length) {
        print(-1);
        return;
    }
    var c = 0;
    str.split('').forEach((item, index, arr) => {
       var ind = arr.indexOf(item, index + 1);
       if (ind !== -1) {
           c++;
       }
    });
	print(c);
}

function _main() {
	var input = getInput();
	var str = input[1];
	var res = solve(str);

	if (res === undefined) {
	    print(-1);
	    return;
	}

	var c = 0;
	for(var i = 0, k = str.length; i < k; i++) {
	    if (res[i] !== str[i]) {
	        c++;
	    }
	}
	print(c);
}

function solve(str, a) {
	if (lastIndex > alphabet.length) {
	    return undefined;
	}

	var changed = false;
	var answ = str.split('').map((item, i, arr) => {
		var ind = arr.indexOf(item, i + 1);
		if (ind !== -1 && ind !== i) {
			changed = true;
			return alphabet[lastIndex++];
		}
		return item;
	}).join('');

	return changed ? solve(answ) : answ;
}

main();

function rda(){ return readline().split(" ").map(Number); }
function rdn(){ return +readline(); }

var n = rdn();
var s = readline().split("");

var ans;
if(n > 26){
    ans = -1;
}else{
    var u = [];
    for(var i = 0; i < n; i++){
        if(u.indexOf(s[i]) == -1) u.push(s[i]);
    }
    ans = n-u.length;
}

write(ans);

function main(n,str){

      var chars = {};
      var cnt = 0;

      if(n > 26){
        print(-1);
        return;
      }

      for(var i = 0 ; i < n ; i++){
        if(chars[str[i]] !== 1)chars[str[i]] = 1;
        else cnt++;
      }
    print(cnt);
}

var n = parseInt(readline());

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

var str = readline();

main(n,str);

var n = +readline();
if (n > 26) {
    print(-1)
} else {
    var s = readline();
    print(s.length - new Set(s).size)
}

var n = parseInt(readline());

var s = readline().trim();

var e = new Set(s.split(''));

var ans=s.length-Array.from(e).length;
print(ans>=26?-1:ans)

var n = parseInt(readline());

var s = readline().trim();

var e = new Set(s.split(''));

var ans=s.length-Array.from(e).length;
print(ans>=24?-1:ans)

var n = parseInt(readline());

var s = readline().trim();

var e = new Set(s.split(''));

var ans=s.length-Array.from(e).length;
print(ans>26?-1:ans)

var n = Number(readline());
var string = readline().split('').map(String);

var count = {};

for (var i = 0; i < n; i++) {
	if (string[i] in count) {
		count[string[i]] += 1;
	} else {
		count[string[i]] = 1;
	}
}

var changes = 0;

for (var key in count) {
	if (count[key] >= 2) {
		changes += count[key] - 1;
	}
}

print(changes);

var n = Number(readline());
var string = readline().split('').map(String);

var count = {};

for (var i = 0; i < n; i++) {
	if (string[i] in count) {
		count[string[i]] += 1;
	} else {
		count[string[i]] = 1;
	}
}

var changes = 0;

for (var key in count) {
	if (count[key] >= 2) {
		changes += count[key] - 1;
	}
}

print(JSON.stringify(count));
print(changes);

var n = +readline();
var s = readline();

const aCode = 'a'.charCodeAt(0);
const zCode = 'z'.charCodeAt(0);
const cardinality = zCode - aCode;

if (s.length > cardinality) {
  write('-1');
  quit();
}

var u = [...new Set(s)].join('');

write(s.length - u.length)

function getInput() {
    var line = readline();
    var lines = [line];
    while (line = readline()) {
        lines.push(line);
    }
    return lines;
}

var alphabet = "abcdefghijklmnopqrstuvwxyz";
var lastIndex = 0;

function main() {
	var input = getInput();
	var str = input[1];
	var res = solve(str);

	if (res === undefined) {
	    print(-1);
	    return;
	}

	var c = 0;
	for(var i = 0, k = str.length; i < k; i++) {
	    if (res[i] !== str[i]) {
	        c++;
	    }
	}
	print(c, res);
}

function solve(str, a) {
	if (lastIndex > alphabet.length) {
	    return undefined;
	}

	var changed = false;
	var answ = str.split('').map((item, i, arr) => {
		var ind = arr.indexOf(item, i + 1);
		if (ind !== -1 && ind !== i) {
			changed = true;
			return alphabet[lastIndex++];
		}
		return item;
	}).join('');

	return changed ? solve(answ) : answ;
}

main();

function getInput() {
    var line = readline();
    var lines = [line];
    while (line = readline()) {
        lines.push(line);
    }
    return lines;
}

var alphabet = "abcdefghijklmnopqrstuvwxyz";
var lastIndex = 0;

function main() {
	var input = getInput();
	var str = input[1];
	var res = solve(str);

	if (res === undefined) {
	    print(-1);
	    return;
	}

	var c = 0;
	for(var i = 0, k = str.length; i < k; i++) {
	    if (res[i] !== str[i]) {
	        c++;
	    }
	}
	print(c);
}

function solve(str, a) {
	if (lastIndex > alphabet.length) {
	    return undefined;
	}

	var changed = false;
	var answ = str.split('').map((item, i, arr) => {
		var ind = arr.indexOf(item, i + 1);
		if (ind !== -1 && ind !== i) {
			changed = true;
			return alphabet[lastIndex++];
		}
		return item;
	}).join('');

	return changed ? solve(answ) : answ;
}

main();

function getInput() {
    var line = readline();
    var lines = [line];
    while (line = readline()) {
        lines.push(line);
    }
    return lines;
}

var alphabet = "abcdefghijklmnopqrstuvwxyz";
var lastIndex = 0;

function main() {
	var input = getInput();
	var str = input[1];
	var res = solve(str);
	var c = 0;
	for(var i = 0, k = str.length; i < k; i++) {
	    if (res[i] !== str[i]) {
	        c++;
	    }
	}
	print(c);
}

function solve(str) {
	var changed = false;
	var answ = str.split('').map((item, i, arr) => {
		var ind = arr.indexOf(item, i + 1);
		if (ind !== -1 && ind !== i) {
			changed = true;
			return alphabet[lastIndex++];
		}
		return item;
	}).join('');

	return changed ? solve(answ) : answ;
}

main();


Valera is a collector. Once he wanted to expand his collection with exactly one antique item.Valera knows n sellers of antiques, the i-th of them auctioned ki items. Currently the auction price of the j-th object of the i-th seller is sij. Valera gets on well with each of the n sellers. He is perfectly sure that if he outbids the current price of one of the items in the auction (in other words, offers the seller the money that is strictly greater than the current price of the item at the auction), the seller of the object will immediately sign a contract with him.Unfortunately, Valera has only v units of money. Help him to determine which of the n sellers he can make a deal with.

The first line contains two space-separated integers n, v (1 ≤ n ≤ 50; 104 ≤ v ≤ 106) — the number of sellers and the units of money the Valera has. Then n lines follow. The i-th line first contains integer ki (1 ≤ ki ≤ 50) the number of items of the i-th seller. Then go ki space-separated integers si1, si2, ..., siki (104 ≤ sij ≤ 106) — the current prices of the items of the i-th seller.

In the first line, print integer p — the number of sellers with who Valera can make a deal. In the second line print p space-separated integers q1, q2, ..., qp (1 ≤ qi ≤ n) — the numbers of the sellers with who Valera can make a deal. Print the numbers of the sellers in the increasing order.

NoteIn the first sample Valera can bargain with each of the sellers. He can outbid the following items: a 40000 item from the first seller, a 20000 item from the second seller, and a 10000 item from the third seller.In the second sample Valera can not make a deal with any of the sellers, as the prices of all items in the auction too big for him.

var lines=readline().split(" ");//reads the first line of the input

var noOfSellers=lines[0];
var Amount=parseInt(lines[1]);

var sellersAmount;
var sellers=[];

for (var i=0;i<noOfSellers;i++) {
    sellersAmount=readline().split(" ");
    for(var j=1;j<sellersAmount.length;j++) {
        if (parseInt(sellersAmount[j])<Amount) {
            sellers.push(i+1);
            break;
        }
    }
}

print(sellers.length);
if (sellers.length>0) {
    print(sellers.join(" "));
}

const readline = require('readline');

let inputs = [];

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

// Read Inputs
rl.on('line', lineInput => {
    inputs.push(lineInput);
})

// Excute algorithm
rl.on('close', () => {
    let line1 = inputs[0].split(' ').map(num => +num);
    const n = line1[0];
    const v = line1[1];
    let canDealWith = [];

    for (let i = 1; i < n + 1; i++) {
        const canMakeDeal = inputs[i].split(' ').slice(1).some(price => v > price);
        if (canMakeDeal)
            canDealWith.push(i);
    }

    console.log(canDealWith.length)

    if (canDealWith.length)
        console.log(...canDealWith)

})

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

print(function(n, v) {

  var ans = [];

  for (var i = 0; i < n; i++) {
    var s = readline().split(' ').map(Number);
    for (var j = 1; j <= s.length; j++) {
      if (s[j] < v) {
        ans.push(i + 1);
        break;
      }
    }
  }
  return ans.length + '\n' + ans.sort(function(a, b) {
    return a - b;
  }).join(' ');

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

var input = readline().split(" "), n = +input[0], v = +input[1];
var ans = [], id, k;

for(var i = 0; i < n; i++){
	input = readline().split(" ").map(Number);
	id = i+1;
	k = input.shift();

	for(var j = 0; j < k; j++){
		if(v > input[j]){
			ans.push(id);
			break;
		}
	}
}

write(ans.length);
if(ans.length > 0){
	write("\n" + ans.join(" "));
}

var nextToken = new function() {
    var line = [];
    var lineIndex = 0;

    return function() {
        while (lineIndex >= line.length) {
            line = readline().split(/\s+/);
            lineIndex = 0;
        }

        return line[lineIndex++];
    }
}();

var nextInt = function() {
    return parseInt(nextToken(), 10);
};

var main = function () {
    var n = nextInt();
    var v = nextInt();
    var ans = [];
    var i, j, good, cnt, cur;

    for (i = 0; i < n; ++i) {
        cnt = nextInt();
        good = false;

        for (j = 0; j < cnt; ++j) {
            cur = nextInt();
            if (cur < v) {
                good = true;
            }
        }

        if (good) {
            ans.push(i + 1);
        }
    }

    print(ans.length);
    print(ans.join(" "));
};

main();

function main(n,v,arr){

    var ans = [];
    var index = 0;
    var ansstr = "";

    for(var i = 0 ; i < n ; i++ ){
      for(var j = 1; j < arr[i].length ; j++){
        if(v > parseInt(arr[i][j])){
          ans[index] = parseInt(i)+1;
          index++;
          break;
        }
      }
    }
    if(ans.length === 0){
    print("0")
    return;
    };
    print(ans.length);
    for(var i = 0 ; i<ans.length ; i++)ansstr = ansstr + ans[i] + " ";
    print(ansstr);
}

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

var arr = [];
for(var i = 0 ; i < nv[0] ; i++){
  arr[i] = readline().split(" ");
}

main(nv[0],nv[1],arr)

var info = readline().split(' ').map(Number);
var result = "";
var mSell = 0;
var sellers = [];
for (var k=0; k<info[0]; k++) {
    sellers[k] = readline().split(' ').map(Number);
}
for (var i=0; i<info[0]; i++) {
    for (var j=1; j<=sellers[i][0]; j++) {
        if (sellers[i][j] < info[1]) {
            mSell += 1;
            result += (i+1) +" ";
            break;
        }
    }
}
print(mSell);
print(result);

;(function () {

	var n = readline().split(' ').map(Number);
	var t = [];
	for (var i = 0; i < n[0]; i++) {
		var s = readline().split(' ').map(Number);
		for (var j = 1; j < s.length; j++)
			if (s[j] < n[1]) {
				t.push(i + 1);
				break;
			}
	}

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

}).call(this);

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 data = tokenizeIntegers(readline()),
		numSellers = data[0], cash = data[1],
		result = [];
	for (var i = 0; i < numSellers; ++i) {
		data = tokenizeIntegers(readline());
		for (var j = 1; j < data.length; ++j) {
			if (data[j] < cash) {
				result.push(i+1);
				break;
			}
		}
	}
	print(result.length);
	if (result.length > 0) {
		print(result.join(' '));
	}
}

main();

var N = readline().split(' ').map(Number),
    r = Array.apply(null, Array(N[0])).map(readline)
    .map(function(v, i) { return [i + 1, v.split(' ').map(Number).slice(1).sort(function(a,b){return a-b})[0]]; })
    .filter(function(_) { return _[1] < N[1] })
    .map(function(_) { return _[0] });

print(r.length + '\n' + r.join(' '));

var N = readline().split(' ').map(Number);

var r = [];
for(var i = 0; i < N[0]; ++i) {
  r.push([i + 1, readline().split(' ').map(Number).slice(1).sort(function(a,b){return a-b})[0]]);
}

r = r.filter(function(_) { return _[1] < N[1] });

print(r.length);
print(r.map(function(_) { return _[0] }).join(' '));

var tokenizer;
var index = 0;

function next(){
    while(tokenizer == null || index == tokenizer.length){
        tokenizer = readline().split(" ");
        index = 0;
    }
    var res = tokenizer[index++];
    return res;
}

function nextInt(){
    return parseInt(next());
}

function nextFloat(){
    return parseFloat(next());
}

function solve(){
    var n = nextInt();
    var v = nextInt();
    var res = 0;
    var s = "";
    for(var i = 0; i < n; ++i){
        var k = nextInt();
        var flag = false;
        for(var j = 0; j < k; ++j){
            var cur = nextInt();
            if(cur < v) flag = true;
        }
        if(flag){
            ++res;
            s += ((i+1) + " ");
        }

    }
    print(res);
    print(s);
}
solve();

var A = [];
var solution = [];
var line = readline();
var n = line.split(' ')[0];
var v = line.split(' ')[1];

for(var i =0; i < n; i++){
    A.push(readline().split(' '));
    for(var j = 1; j <= A[i][0]; j++){
        if(parseInt(A[i][j]) < parseInt(v)){
            solution.push(i+1);
            break;
        }
    }
}

print(solution.length);
print(solution.join(' '));

var n=readline().split(' ').map(Number);
var ss = ((xs)=>{for (var i=0;i<n[0];i++) {xs.push([readline().split(' ').map(Number).slice(1).sort((a,b)=>a-b).shift(),i+1]);} return xs;})([]);
var ps=ss.filter((x)=>n[1]>x[0]);
print(ps.length);
if (ps.length!==0) print(ps.map((xs)=>xs[1].toString()).join(' '));

var line = readline().split(' ').map(Number);
var sellers = [];
var res = "";
var sellersNum = 0;
for (var k = 0; k<line[0]; ++k) {
    sellers[k] = readline().split(' ').map(Number);
    }
for (var i = 0; i<line[0]; ++i) {
    for (var j = 1; j<=sellers[i][0]; ++j) {
            if (sellers[i][j] < line[1]) {
            ++sellersNum;
            res = res + (i + 1) + " ";
            break;
            }
    }
}
print(sellersNum);
print(res);

// 441A     Валера и антиквариат

//var n = parseInt(readline());
var input_line = readline().split(' ').map(Number);
var n = parseInt(input_line[0]);
var v = parseInt(input_line[1]);

var out = '';
var count = 0;

for (var i = 1; i <= n; i++) {
    input_line = readline().split(' ').map(Number);
    for (j = 1; j <= input_line[0]; j ++) {
        if (parseInt(input_line[j]) < v) {
            out += i + ' ';
            count ++;
            break;
        };
    }
};

print(count);
print(out);

var line;
line = readline().split(' ');
var n = parseInt(line[0]), v = parseInt(line[1]);
var ret = '', elems = 0;
for(var i = 0; i < n; i++) {
    line = readline().split(' ');
    var k = parseInt(line[0]);
    var minValue = 1 << 30;
    for(var j = 1; j < line.length; j++) {
        if(minValue > parseInt(line[j])) {
            minValue = parseInt(line[j]);
        }
    }
    if(minValue < v) {
        if(ret.length !== 0) ret += ' ';
        ret += (i + 1);
        ++elems;
    }
}
print(elems);
print(ret);

var lines=readline().split(" ");//reads the first line of the input

var noOfSellers=lines[0];
var Amount=lines[1];

var sellersAmount;
var sellers=[];

for (var i=0;i<noOfSellers;i++) {
    sellersAmount=readline().split(" ");
    for(var j=1;j<sellersAmount.length-1;j++) {
        if (sellersAmount[j]<=Amount) {
            sellers.push(sellersAmount[0]);
            break;
        }
    }
}

print(sellers.length);
if (sellers.length>0) {
    print(sellers);
}

var lines=readline().split(" ");//reads the first line of the input

var noOfSellers=lines[0];
var Amount=lines[1];

var sellersAmount;
var sellers=[];

for (var i=0;i<noOfSellers;i++) {
    sellersAmount=readline().split(" ");
    for(var j=1;j<sellersAmount;j++) {
        if (sellersAmount[j]<=Amount) {
            sellers.push(sellersAmount[0]);
            break;
        }
    }
}

print(sellersAmount.length);
if (sellersAmount.length>0) {
    print(sellers.join(" "));
}

var lines=readline().split(" ");//reads the first line of the input

var noOfSellers=lines[0];
var Amount=lines[1];

var sellersAmount;
var sellers=[];

for (var i=0;i<noOfSellers;i++) {
    sellersAmount=readline().split(" ");
    for(var j=1;j<sellersAmount;j++) {
        if (sellersAmount[j]<=Amount) {
            sellers.push(sellersAmount[0]);
        }
    }
}

print(sellersAmount.length);
if (sellersAmount.length>0) {
    print(sellers);
}

var lines=readline().split(" ");//reads the first line of the input

var noOfSellers=lines[0];
var Amount=lines[1];

var sellersAmount;
var sellers=[];

for (var i=0;i<noOfSellers;i++) {
    sellersAmount=readline().split(" ");
    for(var j=1;j<sellersAmount.length;j++) {
        if (sellersAmount[j]<=Amount) {
            sellers.push(sellersAmount[0]);
            break;
        }
    }
}

print(sellers.length);
if (sellers.length>0) {
    print(sellers);
}

var lines=readline().split(" ");

print(lines);

var lines=readline().split(" ");//reads the first line of the input

var noOfSellers=lines[0];
var Amount=lines[1];

var sellersAmount;
var sellers=[];

for (var i=0;i<noOfSellers;i++) {
    sellersAmount=readline().split(" ");
    for(var j=1;j<sellersAmount-1;j++) {
        if (sellersAmount[j]<=Amount) {
            sellers.push(sellersAmount[0]);
        }
    }
}

print(sellersAmount.length);
if (sellersAmount.length>0) {
    print(sellers);
}

var lines=readline().split(" ");//reads the first line of the input

var noOfSellers=lines[0];
var Amount=lines[1];

var sellersAmount;
var sellers=[];

for (var i=0;i<noOfSellers;i++) {
    sellersAmount=readline().split(" ");
    for(var j=1;j<sellersAmount.length;j++) {
        if (sellersAmount[j]<=Amount) {
            sellers.push(sellersAmount[0]);
            break;
        }
    }
}

print(sellers.length);
if (sellers.length>0) {
    print(sellers.join(" "));
}

var lines=readline().split(" ");//reads the first line of the input

var noOfSellers=lines[0];
var Amount=lines[1];

var sellersAmount;
var sellers=[];

for (var i=0;i<noOfSellers;i++) {
    sellersAmount=readline().split(" ");
    for(var j=1;j<sellersAmount.length-1;j++) {
        if (sellersAmount[j]<=Amount) {
            sellers.push(sellersAmount[0]);
            break;
        }
    }
}

print(sellers.length);
if (sellers.length>0) {
    print(sellers.join(" "));
}

var lines=readline().split(" ");//reads the first line of the input

var noOfSellers=lines[0];
var Amount=parseInt(lines[1]);

var sellersAmount;
var sellers=[];

for (var i=0;i<noOfSellers;i++) {
    sellersAmount=readline().split(" ");
    for(var j=1;j<sellersAmount.length;j++) {
        if (parseInt(sellersAmount[j])<Amount) {
            sellers.push(sellersAmount[0]);
            break;
        }
    }
}

print(sellers.length);
if (sellers.length>0) {
    print(sellers.join(" "));
}

function main(n,v,arr){

    var ans = [];
    var index = 0;
    var ansstr = "";

    for(var i = 0 ; i < n ; i++ ){
      for(var j = 1; j < arr[i].length ; j++){
        if(v > parseInt(arr[i][j])){
          ans[index] = parseInt(arr[i][0]);
          index++;
          break;
        }
      }
    }
    if(ans.length === 0){
    print("0")
    return;
    };
    print(ans.length);
    for(var i = 0 ; i<ans.length ; i++)ansstr = ansstr + ans[i] + " ";
    print(ansstr);
}

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

var arr = [];
for(var i = 0 ; i < nv[0] ; i++){
  arr[i] = readline().split(" ");
}

main(nv[0],nv[1],arr)

function main(n,v,arr){

    var ans = [];
    var index = 0;
    var ansstr = "";

    for(var i = 0 ; i < n ; i++ ){
      for(var j = 1; j < arr[i].length ; j++){
        if(v > parseInt(arr[i][j])){
          ans[index] = parseInt(arr[i][0]);
          index++;
          break;
        }
      }
    }
    if(ans.length === 0){
    print("0")
    return;
    };
    print(ans.length);
    ans.sort();
    for(var i = 0 ; i<ans.length ; i++)ansstr = ansstr + ans[i] + " ";
    print(ansstr);
}

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

var arr = [];
for(var i = 0 ; i < nv[0] ; i++){
  arr[i] = readline().split(" ");
}

main(nv[0],nv[1],arr)

;(function () {

	var n = readline().split(' ').map(Number);
	var t = [];
	for (var i = 0; i < n[0]; i++) {
		var s = readline().split(' ').map(Number);
		for (var j = 1; j < s.length; j++)
			if (s[j] < n[1]) {
				t.push(i + 1);
				break;
			}
	}

	print( t.length ? t.join(' ') : '0' );

}).call(this);

var A = [];
var solution = [];
var line = readline();
var n = line.split(' ')[0];
var v = line.split(' ')[1];

for(var i =0; i < n; i++){
    A.push(readline().split(' '));
    for(var j = 1; j <= A[i][0]; j++){
        if(parseInt(A[i][j]) < parseInt(v)){
            solution.push(i+1);
            break;
        }
    }
}

print(solution.length);
print(solution);

var line = readline().split(' ').map(Number);
var res = "";
var sellersNum = 0;
var sellers = [];
for (var k = 0; k<line[0]; ++k) {
    sellers[k] = readline().split(' ').map(Number);
    }
for (var i = 0; i<line[0]; ++i) {
    for (var j = 1; j<=sellers[i][0]; ++j) {
            if (sellers[i][j] < line[1]) {
            ++sellersNum,
            res = res + (i+1) + " ";
             }
    }
}
print(sellersNum);
print(res);

// 441A     Валера и антиквариат

//var n = parseInt(readline());
var input_line = readline().split(' ').map(Number);
var n = parseInt(input_line[0]);
var v = parseInt(input_line[1]);

var out = '';
var count = 0;

for (var i = 1; i <= n; i++) {
    input_line = readline().split(' ').map(Number);
    for (j = 1; j <= input_line[0]; j ++) {
        if (parseInt(input_line[j]) < v) {
            out += i + ' ';
            count ++;
        };
    }
};

print(count);
print(out);

// 441A     Валера и антиквариат

//var n = parseInt(readline());
var input_line = readline().split(' ').map(Number);
var n = parseInt(input_line[0]);
var v = parseInt(input_line[1]);

var out = '';
var count = 0;

for (var i = 1; i <= n; i++) {
    input_line = readline().split(' ').map(Number);
    for (j = 1; j <= input_line[0]; j ++) {
        if (parseInt(input_line[j]) <= v) {
            out += i + ' ';
            count ++;
        };
    }
};

print(count);
print(out);

var line;
line = readline().split(' ');
var n = parseInt(line[0]), v = parseInt(line[1]);
var ret = '';
for(var i = 0; i < n; i++) {
    line = readline().split(' ');
    var k = parseInt(line[0]);
    var minValue = 1 << 30;
    for(var j = 1; j < line.length; j++) {
        if(minValue > parseInt(line[j])) {
            minValue = parseInt(line[j]);
        }
    }
    if(minValue < v) {
        if(ret.length !== 0) ret += ' ';
        ret += (i + 1);
    }
}
print(ret.length);
print(ret);

var lines=readline().split(" ");//reads the first line of the input

var noOfSellers=lines[0];
var Amount=lines[1];

var sellersAmount;
var sellers=[];

for (var i=0;i<noOfSellers;i++) {
    sellersAmount=readline().split(" ");
    for(var j=1;j<sellersAmount.length-1;j++) {
        if (sellersAmount[j]<=Amount) {
            sellers.push(sellersAmount[0]);
            break;
        }
    }
}

print(sellersAmount.length);
if (sellersAmount.length>0) {
    print(sellers);
}


The sequence of $$$m$$$ integers is called the permutation if it contains all integers from $$$1$$$ to $$$m$$$ exactly once. The number $$$m$$$ is called the length of the permutation.Dreamoon has two permutations $$$p_1$$$ and $$$p_2$$$ of non-zero lengths $$$l_1$$$ and $$$l_2$$$.Now Dreamoon concatenates these two permutations into another sequence $$$a$$$ of length $$$l_1 + l_2$$$. First $$$l_1$$$ elements of $$$a$$$ is the permutation $$$p_1$$$ and next $$$l_2$$$ elements of $$$a$$$ is the permutation $$$p_2$$$. You are given the sequence $$$a$$$, and you need to find two permutations $$$p_1$$$ and $$$p_2$$$. If there are several possible ways to restore them, you should find all of them. (Note that it is also possible that there will be no ways.)

The first line contains an integer $$$t$$$ ($$$1 \le t \le 10\,000$$$) denoting the number of test cases in the input. Each test case contains two lines. The first line contains one integer $$$n$$$ ($$$2 \leq n \leq 200\,000$$$): the length of $$$a$$$. The second line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$1 \leq a_i \leq n-1$$$). The total sum of $$$n$$$ is less than $$$200\,000$$$.

For each test case, the first line of output should contain one integer $$$k$$$: the number of ways to divide $$$a$$$ into permutations $$$p_1$$$ and $$$p_2$$$. Each of the next $$$k$$$ lines should contain two integers $$$l_1$$$ and $$$l_2$$$ ($$$1 \leq l_1, l_2 \leq n, l_1 + l_2 = n$$$), denoting, that it is possible to divide $$$a$$$ into two permutations of length $$$l_1$$$ and $$$l_2$$$ ($$$p_1$$$ is the first $$$l_1$$$ elements of $$$a$$$, and $$$p_2$$$ is the last $$$l_2$$$ elements of $$$a$$$). You can print solutions in any order.

NoteIn the first example, two possible ways to divide $$$a$$$ into permutations are $$$\{1\} + \{4, 3, 2, 1\}$$$ and $$$\{1,4,3,2\} + \{1\}$$$.In the second example, the only way to divide $$$a$$$ into permutations is $$$\{2,4,1,3\} + \{2,1\}$$$.In the third example, there are no possible ways.

// var stdin = [ '1',
//   "12",
// "3 2 1 1 2"];
// main();

function main() {

    const c = parseInt(stdin.shift());

    for (let i = 0; i < c; i++) {
        let input1 = stdin.shift();
        const a = stdin.shift().split(" ").map(x => parseInt(x));
        let cases = [];

        check(a, cases, false)
        if (cases.length === 1 && cases[0][0] === cases[0][1]) {

        } else {
          check(a.reverse(), cases, true);
          if (cases.length === 2 && cases[0][0] === cases[1][0]) {
              cases.pop();
          }
        }

        console.log(cases.length);
        cases.map((x) => console.log(x.join(' ')));

    }
}

function check (a, cases, reverse) {
        let p1 = new Array(a.length + 1).fill(false);
        p1[0] = true;
        let p2 = new Array(a.length + 1).fill(false);
        p2[0] = true;

        let next = false;
        for (let i = 0; i < a.length; i++) {
            if (!next) {
                if (!p1[a[i]]) {
                    p1[a[i]] = true;
                } else {
                    next = true;
                }
            }

            if (next) {
                if (!p2[a[i]]) {
                    p2[a[i]] = true;
                } else {
                    break;
                }
            }
        }

        const lp1 = p1.indexOf(false) - 1;
        const lp2 = p2.indexOf(false) - 1;
        if (lp1 + lp2 === a.length) {
          if (reverse) {
            cases.push([lp2, lp1])
          } else {
            cases.push([lp1, lp2])
          }
        }
}
const readline = require('readline');
const rl = readline.createInterface({input: process.stdin});
var stdin = [];
rl.on('line', function (line) {stdin.push(line);});
rl.on('close', main);

// var stdin = [ '1',
//   '2',
//   '1 1'];
// main();

function main() {

    const c = parseInt(stdin.shift());

    for (let i = 0; i < c; i++) {
        let input1 = stdin.shift();
        const a = stdin.shift().split(" ").map(x => parseInt(x));

        let cases = [];

        check(a, cases);
        if (cases.length === 1 && cases[0][0] === cases[0][1]) {

        } else {
          check(a.reverse(), cases);
        }

        console.log(cases.length);
        cases.map((x) => console.log(x.join(' ')));

    }
}

function check (a, cases) {
        let p1 = new Array(a.length + 1).fill(false);
        p1[0] = true;
        let p2 = new Array(a.length + 1).fill(false);
        p2[0] = true;

        let next = false;
        for (let i = 0; i < a.length; i++) {
            if (!next) {
                if (!p1[a[i]]) {
                    p1[a[i]] = true;
                } else {
                    next = true;
                }
            }

            if (next) {
                if (!p2[a[i]]) {
                    p2[a[i]] = true;
                } else {
                    break;
                }
            }
        }

        const lp1 = p1.indexOf(false) - 1;
        const lp2 = p2.indexOf(false) - 1;
        if (lp1 + lp2 === a.length) {
          cases.push([lp2, lp1]);
        }
}
const readline = require('readline');
const rl = readline.createInterface({input: process.stdin});
var stdin = [];
rl.on('line', function (line) {stdin.push(line);});
rl.on('close', main);

function main() {

    const c = parseInt(stdin.shift());

    for (let i = 0; i < c; i++) {
        let input1 = stdin.shift();
        const a = stdin.shift().split(" ").map(x => parseInt(x));

        let cases = [];

        check(a, cases, false);
        check(a.reverse(), cases, true);
        console.log(cases.length);
        cases.map((x) => console.log(x.join(" ")));

    }
}

function check (a, cases, reverse) {
        let p1 = new Array(a.length + 1).fill(false);
        p1[0] = true;
        let p2 = new Array(a.length + 1).fill(false);
        p2[0] = true;

        let next = false;
        for (let i = 0; i < a.length; i++) {
            if (!next) {
                if (!p1[a[i]]) {
                    p1[a[i]] = true;
                } else {
                    next = true;
                }
            }

            if (next) {
                if (!p2[a[i]]) {
                    p2[a[i]] = true;
                } else {
                    break;
                }
            }
        }

        const lp1 = p1.indexOf(false) - 1;
        const lp2 = p2.indexOf(false) - 1;
        if (lp1 + lp2 === a.length) {
          if (reverse) {
            cases.push([lp2, lp1])
          } else {
            cases.push([lp1, lp2])
          }
        }
}

const readline = require('readline');
const rl = readline.createInterface({input: process.stdin});
var stdin = [];
rl.on('line', function (line) {stdin.push(line);});
rl.on('close', main);

// var stdin = [ '1',
//   '2',
//   '1 1'];
// main();

function main() {

    const c = parseInt(stdin.shift());

    for (let i = 0; i < c; i++) {
        let input1 = stdin.shift();
        const a = stdin.shift().split(" ").map(x => parseInt(x));

        let cases = [];

        check(a, cases, false);
        if (cases.length === 1 && cases[0][0] === cases[0][1]) {

        } else {
          check(a.reverse(), cases, true);
        }

        console.log(cases.length);
        cases.map((x) => console.log(x.join(' ')));

    }
}

function check (a, cases, reverse) {
        let p1 = new Array(a.length + 1).fill(false);
        p1[0] = true;
        let p2 = new Array(a.length + 1).fill(false);
        p2[0] = true;

        let next = false;
        for (let i = 0; i < a.length; i++) {
            if (!next) {
                if (!p1[a[i]]) {
                    p1[a[i]] = true;
                } else {
                    next = true;
                }
            }

            if (next) {
                if (!p2[a[i]]) {
                    p2[a[i]] = true;
                } else {
                    break;
                }
            }
        }

        const lp1 = p1.indexOf(false) - 1;
        const lp2 = p2.indexOf(false) - 1;
        if (lp1 + lp2 === a.length) {
          if (reverse) {
            cases.push([lp2, lp1])
          } else {
            cases.push([lp1, lp2])
          }
        }
}
const readline = require('readline');
const rl = readline.createInterface({input: process.stdin});
var stdin = [];
rl.on('line', function (line) {stdin.push(line);});
rl.on('close', main);

function main() {

    const c = parseInt(stdin.shift());

    for (let i = 0; i < c; i++) {
        let input1 = stdin.shift();
        const a = stdin.shift().split(" ").map(x => parseInt(x));

        let cases = [];

        check(a, cases, false);
        check(a.reverse(), cases, true);
        console.log(cases.length);
        cases.map((x) => console.log(x));

    }
}

function check (a, cases, reverse) {
        let p1 = new Array(a.length + 1).fill(false);
        p1[0] = true;
        let p2 = new Array(a.length + 1).fill(false);
        p2[0] = true;

        let next = false;
        for (let i = 0; i < a.length; i++) {
            if (!next) {
                if (!p1[a[i]]) {
                    p1[a[i]] = true;
                } else {
                    next = true;
                }
            }

            if (next) {
                if (!p2[a[i]]) {
                    p2[a[i]] = true;
                } else {
                    break;
                }
            }
        }

        const lp1 = p1.indexOf(false) - 1;
        const lp2 = p2.indexOf(false) - 1;
        if (lp1 + lp2 === a.length) {
          if (reverse) {
            cases.push([lp2, lp1])
          } else {
            cases.push([lp1, lp2])
          }
        }
}

const readline = require('readline');
const rl = readline.createInterface({input: process.stdin});
var stdin = [];
rl.on('line', function (line) {stdin.push(line);});
rl.on('close', main);