You are given a binary string $$$s$$$ (recall that a string is binary if each character is either $$$0$$$ or $$$1$$$).Let $$$f(t)$$$ be the decimal representation of integer $$$t$$$ written in binary form (possibly with leading zeroes). For example $$$f(011) = 3, f(00101) = 5, f(00001) = 1, f(10) = 2, f(000) = 0$$$ and $$$f(000100) = 4$$$.The substring $$$s_{l}, s_{l+1}, \dots , s_{r}$$$ is good if $$$r - l + 1 = f(s_l \dots s_r)$$$.For example string $$$s = 1011$$$ has $$$5$$$ good substrings: $$$s_1 \dots s_1 = 1$$$, $$$s_3 \dots s_3 = 1$$$, $$$s_4 \dots s_4 = 1$$$, $$$s_1 \dots s_2 = 10$$$ and $$$s_2 \dots s_4 = 011$$$. Your task is to calculate the number of good substrings of string $$$s$$$.You have to answer $$$t$$$ independent queries.

The first line contains one integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of queries. The only line of each query contains string $$$s$$$ ($$$1 \le |s| \le 2 \cdot 10^5$$$), consisting of only digits $$$0$$$ and $$$1$$$. It is guaranteed that $$$\sum\limits_{i=1}^{t} |s_i| \le 2 \cdot 10^5$$$.

For each query print one integer — the number of good substrings of string $$$s$$$.

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

const input = [];
readline.on('line', line => input.push(line));

readline.on('close', () => {
    const n = parseInt(input[0]);
    for (let i = 0; i < n; i++) {
        const str = input[i + 1];
        let nnn = 0;
        for (let j = 0, z = 0; j < str.length; j++) {
            if (str[j] === '1') {
                for (let k = j; k < j + (2 * 100000) && k < str.length; k++) {
                    let x = str.substring(j, k + 1);
                    if (parseInt(x, 2) > 2 && z < parseInt(x, 2) - x.length) {
                        break;
                    } else {
                        nnn++;
                    }
                }
                z = 0;
            } else {
                z++;
            }
        }
        console.log(nnn);
    }
});

let inputTextName;
let outTextName;
if (process.argv.length === 5) {
   inputTextName = process.argv[3];
   outTextName = process.argv[4];
}
let MEMORY = [];
let MEMORY_INDEX = 0;

if (inputTextName) {
   const fs = require('fs');
   const path = require('path');
   fs.readFile(path.join(__dirname, inputTextName), 'utf8', (err, data) => {
      MEMORY = data.split('\r\n');
      solve();
   });
} else {
   const RL = require('readline').createInterface({
      input : process.stdin,
      output : process.stdout
   });

   RL.on('line', (line) => {
      MEMORY.push(line);
   });

   RL.on('close', solve);
}

function print() {
   console.log.apply(null, arguments);
}
function readline() {
   return MEMORY[MEMORY_INDEX++];
}

function solve() {
   const T = Number.parseInt(readline(), 10);

   for (let I = 0; I < T; ++I) {
      let bin = readline();
      let oneIndexArr = [-1];
      let answer = 0;
      for (let i = 0; i < bin.length; ++i) {
         if (bin[i] === '1') {
            oneIndexArr.push(i);
         }
      }
      for(let i = 1; i < oneIndexArr.length; ++i) {
         let num = 0;
         let zeroCount = oneIndexArr[i] - oneIndexArr[i - 1] - 1;
         for (let j = oneIndexArr[i]; j < bin.length; ++j) {
            num = (num << 1) + (bin[j] === '1' ? 1 : 0);
            if (num > zeroCount + j - oneIndexArr[i] + 1) {
               break;
            }
            answer++;
         }
      }
      print(answer);
   }
}

const MEMORY = [];
let MEMORY_INDEX = 0;
function print() {
   console.log.apply(null, arguments);
}
function readline() {
   return MEMORY[MEMORY_INDEX++];
}

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

RL.on('line', (line) => {
   MEMORY.push(line);
});

RL.on('close', solve);

function solve() {
   const T = Number.parseInt(readline(), 10);

   for (let I = 0; I < T; ++I) {
      let bin = readline();
      let oneIndexArr = [-1];
      let answer = 0;
      for (let i = 0; i < bin.length; ++i) {
         if (bin[i] === '1') {
            oneIndexArr.push(i);
         }
      }
      for(let i = 1; i < oneIndexArr.length; ++i) {
         let num = 0;
         let zeroCount = oneIndexArr[i] - oneIndexArr[i - 1] - 1;
         for (let j = oneIndexArr[i]; j < bin.length; ++j) {
            num = (num << 1) + (bin[j] === '1' ? 1 : 0);
            if (num > zeroCount + j - oneIndexArr[i] + 1) {
               break;
            }
            answer++;
         }
      }
      print(answer);
   }
}

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

const base = [];
for(i = 1; i < 3192; i++) {
    let str = i.toString(2);
    base.push('0'.repeat(i - str.length) + str);
}

let count = (str, f) => {
    let j = 0;
    for (let i = 0; i < str.length; i++) {
        let x = str.indexOf(f, i);
        if (x == -1) {
            break;
        } else {
            j++;
            i = x;
        }
    }

    return j;
}

const input = [];
readline.on('line', line => input.push(line));

readline.on('close', () => {
    const n = parseInt(input[0]);
    for (let i = 0; i < n; i++) {
        const str = input[i + 1];
        let x = 0;

        for (let j = 0; j < str.length && j < base.length; j++) {
            x += count(str, base[j]);
        }

        console.log(x);
    }
});

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

const base = [];
for(i = 1; i < 1024; i++) {
    let str = i.toString(2);
    base.push('0'.repeat(i - str.length) + str);
}

let count = (str, f) => {
    let j = 0;
    for (let i = 0; i < str.length; i++) {
        let x = str.indexOf(f, i);
        if (x == -1) {
            break;
        } else {
            j++;
            i = x;
        }
    }

    return j;
}

const input = [];
readline.on('line', line => input.push(line));

readline.on('close', () => {
    const n = parseInt(input[0]);
    for (let i = 0; i < n; i++) {
        const str = input[i + 1];
        let x = 0;

        for (let j = 0; j < str.length && j < base.length; j++) {
            x += count(str, base[j]);
        }

        console.log(x);
    }
});

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

const base = [];
for(i = 1; i < 4200; i++) {
    let str = i.toString(2);
    base.push('0'.repeat(i - str.length) + str);
}

let count = (str, f) => {
    let j = 0;
    for (let i = 0; i < str.length; i++) {
        let x = str.indexOf(f, i);
        if (x == -1) {
            break;
        } else {
            j++;
            i = x;
        }
    }

    return j;
}

const input = [];
readline.on('line', line => input.push(line));

readline.on('close', () => {
    const n = parseInt(input[0]);
    for (let i = 0; i < n; i++) {
        const str = input[i + 1];
        let x = 0;

        for (let j = 0; j < str.length && j < base.length; j++) {
            x += count(str, base[j]);
        }

        console.log(x);
    }
});

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

const base = [];
for(i = 1; i < 512; i++) {
    let str = i.toString(2);
    base.push('0'.repeat(i - str.length) + str);
}

let count = (str, f) => {
    let j = 0;
    for (let i = 0; i < str.length; i++) {
        let x = str.indexOf(f, i);
        if (x == -1) {
            break;
        } else {
            j++;
            i = x;
        }
    }

    return j;
}

const input = [];
readline.on('line', line => input.push(line));

readline.on('close', () => {
    const n = parseInt(input[0]);
    for (let i = 0; i < n; i++) {
        const str = input[i + 1];
        let x = 0;

        for (let j = 0; j < str.length; j++) {
            x += count(str, base[j]);
        }

        console.log(x);
    }
});

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

const base = [];
for(i = 1; i < 256; i++) {
    let str = i.toString(2);
    base.push('0'.repeat(i - str.length) + str);
}

const input = [];
readline.on('line', line => input.push(line));

readline.on('close', () => {
    const n = parseInt(input[0]);
    for (let i = 0; i < n; i++) {
        const str = input[i + 1];
        let x = 0;

        for (let j = 0; j < str.length + 1; j++) {
            x += str.split(base[j]).length - 1;
        }

        console.log(x);
    }
});

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

const base = [];
for(i = 1; i < 2048; i++) {
    let str = i.toString(2);
    base.push('0'.repeat(i - str.length) + str);
}

const input = [];
readline.on('line', line => input.push(line));

readline.on('close', () => {
    const n = parseInt(input[0]);
    for (let i = 0; i < n; i++) {
        const str = input[i + 1];
        let x = 0;

        for (let j = 0; j < str.length + 1; j++) {
            x += str.split(base[j]).length - 1;
        }

        console.log(x);
    }
});

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

const input = [];
readline.on('line', line => input.push(line));

readline.on('close', () => {
    const n = parseInt(input[0]);
    for (let i = 0; i < n; i++) {
        const str = input[i + 1];
        nx = 0;
        for (let j = 1; j < str.length + 1; j++) {
            let jstr = j.toString(2);
            jstr = '0'.repeat(j - jstr.length) + jstr;
            nx += str.split(jstr).length - 1;
        }
        console.log(nx);
    }
});

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

const base = [];
for(i = 1; i < 512; i++) {
    let str = i.toString(2);
    base.push('0'.repeat(i - str.length) + str);
}

let count = (str, f) => {
    let j = 0;
    for (let i = 0; i < str.length; i++) {
        let x = str.indexOf(f, i);
        if (x == -1) {
            break;
        } else {
            j++;
            i = x;
        }
    }

    return j;
}

const input = [];
readline.on('line', line => input.push(line));

readline.on('close', () => {
    const n = parseInt(input[0]);
    for (let i = 0; i < n; i++) {
        const str = input[i + 1];
        let x = 0;

        for (let j = 0; j < str.length + 1; j++) {
            x += count(str, base[j]);
        }

        console.log(x);
    }
});

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

const base = [];
for(i = 1; i < 256; i++) {
    let str = i.toString(2);
    base.push('0'.repeat(i - str.length) + str);
}

let count = (str, f) => {
    let j = 0;
    for (let i = 0; i < str.length; i++) {
        let x = str.indexOf(f, i);
        if (x == -1) {
            break;
        } else {
            j++;
            i = x;
        }
    }

    return j;
}

const input = [];
readline.on('line', line => input.push(line));

readline.on('close', () => {
    const n = parseInt(input[0]);
    for (let i = 0; i < n; i++) {
        const str = input[i + 1];
        let x = 0;

        for (let j = 0; j < str.length + 1; j++) {
            x += count(str, base[j]);
        }

        console.log(x);
    }
});

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

const base = [];
for(i = 1; i < 3600; i++) {
    let str = i.toString(2);
    base.push('0'.repeat(i - str.length) + str);
}

let count = (str, f) => {
    let j = 0;
    for (let i = 0; i < str.length; i++) {
        let x = str.indexOf(f, i);
        if (x == -1) {
            break;
        } else {
            j++;
            i = x;
        }
    }

    return j;
}

const input = [];
readline.on('line', line => input.push(line));

readline.on('close', () => {
    const n = parseInt(input[0]);
    for (let i = 0; i < n; i++) {
        const str = input[i + 1];
        let x = 0;

        for (let j = 0; j < str.length && j < base.length; j++) {
            x += count(str, base[j]);
        }

        console.log(x);
    }
});

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

const base = [];
for(i = 1; i < 65535; i++) {
    let str = i.toString(2);
    base.push('0'.repeat(i - str.length) + str);
}

const input = [];
readline.on('line', line => input.push(line));

readline.on('close', () => {
    const n = parseInt(input[0]);
    for (let i = 0; i < n; i++) {
        const str = input[i + 1];
        let x = 0;

        for (let j = 0; j < str.length + 1; j++) {
            x += str.split(base[j]).length - 1;
        }

        console.log(x);
    }
});

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

const base = [];
for(i = 1; i < 3720; i++) {
    let str = i.toString(2);
    base.push('0'.repeat(i - str.length) + str);
}

let count = (str, f) => {
    let j = 0;
    for (let i = 0; i < str.length; i++) {
        let x = str.indexOf(f, i);
        if (x == -1) {
            break;
        } else {
            j++;
            i = x;
        }
    }

    return j;
}

const input = [];
readline.on('line', line => input.push(line));

readline.on('close', () => {
    const n = parseInt(input[0]);
    for (let i = 0; i < n; i++) {
        const str = input[i + 1];
        let x = 0;

        for (let j = 0; j < str.length && j < base.length; j++) {
            x += count(str, base[j]);
        }

        console.log(x);
    }
});

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

const base = [];
for(i = 1; i < 64; i++) {
    let str = i.toString(2);
    base.push('0'.repeat(i - str.length) + str);
}

const input = [];
readline.on('line', line => input.push(line));

readline.on('close', () => {
    const n = parseInt(input[0]);
    for (let i = 0; i < n; i++) {
        const str = input[i + 1];
        let x = 0;

        for (let j = 0; j < str.length; j++) {
            x += str.split(base[j]).length - 1;
        }

        console.log(x);
    }
});

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

const base = [];
for(i = 1; i < 256; i++) {
    let str = i.toString(2);
    base.push('0'.repeat(i - str.length) + str);
}

let count = (str, f) => {
    let j = 0;
    for (let i = 0; i < str.length; i++) {
        let x = str.indexOf(f, i);
        if (x == -1) {
            break;
        } else {
            j++;
            i = x;
        }
    }

    return j;
}

const input = [];
readline.on('line', line => input.push(line));

readline.on('close', () => {
    const n = parseInt(input[0]);
    for (let i = 0; i < n; i++) {
        const str = input[i + 1];
        let x = 0;

        for (let j = 0; j < str.length && j < base.length; j++) {
            x += count(str, base[j]);
        }

        console.log(x);
    }
});

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

const base = [];
for(i = 1; i < 256; i++) {
    let str = i.toString(2);
    base.push('0'.repeat(i - str.length) + str);
}

let count = (str, f) => {
    let j = 0;
    for (let i = 0; i < str.length; i++) {
        let x = str.indexOf(f, i);
        if (x == -1) {
            break;
        } else {
            j++;
            i = x + 1;
        }
    }

    return j;
}

const input = [];
readline.on('line', line => input.push(line));

readline.on('close', () => {
    const n = parseInt(input[0]);
    for (let i = 0; i < n; i++) {
        const str = input[i + 1];
        let x = 0;

        for (let j = 0; j < str.length + 1; j++) {
            x += count(str, base[j]);
        }

        console.log(x);
    }
});

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

const base = [];
for(i = 1; i < 2048; i++) {
    let str = i.toString(2);
    base.push('0'.repeat(i - str.length) + str);
}

let count = (str, f) => {
    let j = 0;
    for (let i = 0; i < str.length; i++) {
        let x = str.indexOf(f, i);
        if (x == -1) {
            break;
        } else {
            j++;
            i = x;
        }
    }

    return j;
}

const input = [];
readline.on('line', line => input.push(line));

readline.on('close', () => {
    const n = parseInt(input[0]);
    for (let i = 0; i < n; i++) {
        const str = input[i + 1];
        let x = 0;

        for (let j = 0; j < str.length && j < base.length; j++) {
            x += count(str, base[j]);
        }

        console.log(x);
    }
});


Mike has a sequence A = [a1, a2, ..., an] of length n. He considers the sequence B = [b1, b2, ..., bn] beautiful if the gcd of all its elements is bigger than 1, i.e. . Mike wants to change his sequence in order to make it beautiful. In one move he can choose an index i (1 ≤ i < n), delete numbers ai, ai + 1 and put numbers ai - ai + 1, ai + ai + 1 in their place instead, in this order. He wants perform as few operations as possible. Find the minimal number of operations to make sequence A beautiful if it's possible, or tell him that it is impossible to do so. is the biggest non-negative number d such that d divides bi for every i (1 ≤ i ≤ n).

The first line contains a single integer n (2 ≤ n ≤ 100 000) — length of sequence A. The second line contains n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 109) — elements of sequence A.

Output on the first line "YES" (without quotes) if it is possible to make sequence A beautiful by performing operations described above, and "NO" (without quotes) otherwise. If the answer was "YES", output the minimal number of moves needed to make sequence A beautiful.

NoteIn the first example you can simply make one move to obtain sequence [0, 2] with .In the second example the gcd of the sequence is already greater than 1.

  var n = parseInt(readline());
  var a = readline().split(' ').map(x => parseInt(x));
  var gcd = function(a, b) {
    if (!b) {
      return a;
    }
    return gcd(b, a % b);
  };
  var gcdn = a[0];
  for(var i = 1; i < n; i += 1) {
    gcdn = gcd(gcdn, a[i]);
  }
  if(gcdn !== 1) {
    print('YES');
    print(0);
  } else {
    var res = 0;
    for(var i = 0; i < n - 1; i += 1) {
      if(a[i] % 2 === 1 && a[i + 1] % 2 === 1) {
        res += 1;
        i += 2;
      }
    }
    if(a[n - 1] % 2 === 1 && a[n - 2] % 2 === 0) {
      res += 2;
    }
    print('YES');
    print(res);
  }

  // var tmp = readline().split(' ').map(x => parseInt(x));
  // var n = parseInt(readline());

  var n = parseInt(readline());
  var a = readline().split(' ').map(x => parseInt(x));
  var gcd = function(a, b) {
    if (!b) {
      return a;
    }
    return gcd(b, a % b);
  };
  var gcdn = a[0];
  for(var i = 1; i < n; i += 1) {
    gcdn = gcd(gcdn, a[i]);
  }
  if(gcdn !== 1) {
    print('YES');
    print(0);
  } else {
    var res = 0;
    for(var i = 0; i < n - 1; i += 1) {
      if(a[i] % 2 === 1 && a[i + 1] % 2 === 1) {
        res += 1;
        i += 1;
      }
      if(a[i] % 2 === 1 && a[i + 1] % 2 === 0) {
        res += 2;
        i += 1;
      }
    }
    if(a[n - 1] % 2 === 1 && a[n - 2] % 2 === 0) {
      res += 2;
    }
    print('YES');
    print(res);
  }


A palindrome is a string $$$t$$$ which reads the same backward as forward (formally, $$$t[i] = t[|t| + 1 - i]$$$ for all $$$i \in [1, |t|]$$$). Here $$$|t|$$$ denotes the length of a string $$$t$$$. For example, the strings 010, 1001 and 0 are palindromes.You have $$$n$$$ binary strings $$$s_1, s_2, \dots, s_n$$$ (each $$$s_i$$$ consists of zeroes and/or ones). You can swap any pair of characters any number of times (possibly, zero). Characters can be either from the same string or from different strings — there are no restrictions.Formally, in one move you:  choose four integer numbers $$$x, a, y, b$$$ such that $$$1 \le x, y \le n$$$ and $$$1 \le a \le |s_x|$$$ and $$$1 \le b \le |s_y|$$$ (where $$$x$$$ and $$$y$$$ are string indices and $$$a$$$ and $$$b$$$ are positions in strings $$$s_x$$$ and $$$s_y$$$ respectively),  swap (exchange) the characters $$$s_x[a]$$$ and $$$s_y[b]$$$. What is the maximum number of strings you can make palindromic simultaneously?

The first line contains single integer $$$Q$$$ ($$$1 \le Q \le 50$$$) — the number of test cases. The first line on each test case contains single integer $$$n$$$ ($$$1 \le n \le 50$$$) — the number of binary strings you have. Next $$$n$$$ lines contains binary strings $$$s_1, s_2, \dots, s_n$$$ — one per line. It's guaranteed that $$$1 \le |s_i| \le 50$$$ and all strings constist of zeroes and/or ones.

Print $$$Q$$$ integers — one per test case. The $$$i$$$-th integer should be the maximum number of palindromic strings you can achieve simultaneously performing zero or more swaps on strings from the $$$i$$$-th test case.

NoteIn the first test case, $$$s_1$$$ is palindrome, so the answer is $$$1$$$.In the second test case you can't make all three strings palindromic at the same time, but you can make any pair of strings palindromic. For example, let's make $$$s_1 = \text{0110}$$$, $$$s_2 = \text{111111}$$$ and $$$s_3 = \text{010000}$$$.In the third test case we can make both strings palindromic. For example, $$$s_1 = \text{11011}$$$ and $$$s_2 = \text{100001}$$$.In the last test case $$$s_2$$$ is palindrome and you can make $$$s_1$$$ palindrome, for example, by swapping $$$s_1[2]$$$ and $$$s_1[3]$$$.

function answer (input) {
    var l = [];
    var chars = [];
    input.forEach(elem => {
        chars.push(...elem.split(''));
        l.push(elem.length);
    });
    var sum = l.reduce((a, b) => a + b, 0);
    var evens = l.filter(elem => elem % 2 === 0);
    evens.sort().reverse();
    var evenSum = evens.reduce((a, b) => a + b, 0);
    var ones = chars.filter(elem => elem === '1').length;
    var zeros = chars.length - ones;
    if (ones % 2 !== 0) ones--;
    if (zeros % 2 !== 0) zeros--;
    if (zeros + ones >= evenSum) return input.length;
    var i = 0;
    while (zeros + ones < evenSum) {
        evenSum -= evens.pop();
        i++;
    }
    return input.length - i;
}

var Q = parseInt(readline());
var result = '';
for (var i = 0; i < Q; i++) {
    var n = parseInt(readline());
    var s = [];
    for (var j = 0; j < n; j++) {
        s.push(readline());
    }
    result += answer(s) + '\n';
}
write(result);


An accordion is a string (yes, in the real world accordions are musical instruments, but let's forget about it for a while) which can be represented as a concatenation of: an opening bracket (ASCII code $$$091$$$), a colon (ASCII code $$$058$$$), some (possibly zero) vertical line characters (ASCII code $$$124$$$), another colon, and a closing bracket (ASCII code $$$093$$$). The length of the accordion is the number of characters in it.For example, [::], [:||:] and [:|||:] are accordions having length $$$4$$$, $$$6$$$ and $$$7$$$. (:|:), {:||:}, [:], ]:||:[ are not accordions. You are given a string $$$s$$$. You want to transform it into an accordion by removing some (possibly zero) characters from it. Note that you may not insert new characters or reorder existing ones. Is it possible to obtain an accordion by removing characters from $$$s$$$, and if so, what is the maximum possible length of the result?

The only line contains one string $$$s$$$ ($$$1 \le |s| \le 500000$$$). It consists of lowercase Latin letters and characters [, ], : and |.

If it is not possible to obtain an accordion by removing some characters from $$$s$$$, print $$$-1$$$. Otherwise print maximum possible length of the resulting accordion.

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

  let tmp=0, lngth=0, str='';

  rl.on('line', (input) => {
    str=input; rl.close(); therest();
    return 0;}

  );

let therest=function() {
   // console.log(str);
    let len=0;
    let a = str.indexOf('['), b=str.lastIndexOf(']');
    if (a==-1||b==-1||a>b) {console.log(-1); return 0;}

   // console.log(a,b);
    str=str.slice(a+1,b);
    len=2;
    a = str.indexOf(':'), b=str.lastIndexOf(':');
    if (a==-1||b==-1||a==b) {console.log(-1); return 0;}
    str=str.slice(a+1,b);
    len=4;

    for (let char of str) {
        if (char=='|') len++;
    }
    console.log(len);
}

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

let l = 0;
let t = 0
rl.on('line', (input) => {
    let s = input.split('')
    let c = 0
    let isAcc = 0
    let op = [-1, -1]
    let cl = [-1, -1]
    for (let i = 0; i < s.length; i++) {
        if (s[i] === '[' && op[0] === -1) {
            op[0] = i
            isAcc++
        } else if (op[0] !== -1 && s[i] === ':' && op[1] === -1) {
            op[1] = i
            isAcc++
            break;
        } else {
            c++
        }
    }
    for (let i = s.length - 1; i > op[1]; i--) {
        if (s[i] === ']' && cl[1] === -1 && cl[0] === -1) {
            cl[1] = i
            isAcc++
        } else if (cl[1] !== -1 && s[i] === ':' && cl[0] === -1) {
            cl[0] = i
            isAcc++
            break;
        } else {
            c++
        }
    }
    for (let i = op[1] + 1; i < cl[0]; i++) {
        if (s[i] !== '|') {
            c++
        }
    }
    rl.close()
    if (isAcc !== 4) {
        console.log(-1)
    } else {
        console.log(s.length - c)
    }
});

function main() {
    var b = readline();

    var indexStart = b.indexOf('[');
    if(indexStart < 0) {
        return -1;
    }

    var b2 =  b.substr(indexStart + 1);
    var index2 = b2.indexOf(':');
    if(index2 < 0) {
        return -1;
    }

    var b3 = b2.substr(index2 + 1);
    var indexLast = b3.lastIndexOf(']');
    if(indexLast < 0) {
        return -1;
    }

    var b4 = b3.substring(0,indexLast);
    var index3 = b4.lastIndexOf(':');
    if(index3 < 0) {
        return -1;
    }

    var bfin = b4.substring(0, index3);
    return bfin.split('|').length + 3
}

print(main());

var s = readline();
if(s.indexOf('[') != -1) {
    s = s.substring(s.indexOf('['), s.length);
	if(s.lastIndexOf(']') != -1) {
        s = s.substring(0, s.lastIndexOf(']')+1);
        s = s.replace(/[^\:\[\]\|]/gim,'').replace(/[^\:\|]/gim,'');
        s = s.substring(s.indexOf(':'), s.length);
        s = s.substring(0, s.lastIndexOf(':')+1);

        if(s.length >= 2 && s[0] == ':' && s[s.length-1] == ':') {
            s = s.replace(/[^\|]/gim,'');
            print(s.length+4);
        } else {
            print(-1);
        }
    } else {
            print(-1);
    }
} else {
    print(-1);
}

var str = readline()

function getStart(start, end){
  var mask = '[:'
	while(mask && start <=end) {
  	if(str[start] == mask[0]) {
    	mask = mask.slice(1)

      if(!mask)
      	break;
    }
    start++;
  }
  return !mask ? start : -1;
}

function getEnd(start, end){
  var mask = ']:'
	while(mask && start >=end) {
  	if(str[start] == mask[0]) {
    	mask = mask.slice(1)

      if(!mask)
      	break;
    }
    start--;
  }

  return !mask ? start : -1;
}

function getMaxLen() {
    if(str.length < 4) {
        return -1
    }

    var start = getStart(0, str.length-3);
    if(start == -1) {
        return -1;
    }

    var end = getEnd(str.length-1, start+1);
    if(end == -1) {
        return -1;
    }

    var l = 0;
    for(var i=start+1;i<end;i++) {
    	if(str[i] == '|') {
      	    l++;
    	}
    }

    return l+4;
}

print(getMaxLen());

function calc(s) {
  if (s.indexOf('[') === -1) {
    return -1;
  } else {
     s = s.slice(s.indexOf('[') + 1);
  }
  // print(s);

  if (s.indexOf(':') === -1) {
    return -1;
  } else {
     s = s.slice(s.indexOf(':') + 1);
  }
  // print(s);

  if (s.lastIndexOf(']') === -1) {
    return -1;
  } else {
     s = s.slice(0, s.lastIndexOf(']'));
  }
  // print(s);

  if (s.lastIndexOf(':') === -1) {
    return -1;
  } else {
     s = s.slice(0, s.lastIndexOf(':'));
  }
  // print(s);

  return 4 + s.filter(elem => elem === '|').length;
}

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

print(calc(s));

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

  let tmp=0, lngth=0, str='';

  rl.on('line', (input) => {
    str=input; rl.close(); therest();
    return 0;}

  );

let therest=function() {
    console.log(str);
    let len=0;
    let a = str.indexOf('['), b=str.lastIndexOf(']');
    if (a==-1||b==-1||a>b) {console.log(-1); return 0;}

   // console.log(a,b);
    str=str.slice(a+1,b);
    len=2;
    a = str.indexOf(':'), b=str.lastIndexOf(':');
    if (a==-1||b==-1||a==b) {console.log(-1); return 0;}
    str=str.slice(a+1,b);
    len=4;

    for (let char of str) {
        if (char=='|') len++;
    }
    console.log(len);
}

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

let l = 0;
let t = 0
rl.on('line', (input) => {
    let s = input.split('')
    let c = 0
    let isAcc = 0
    let op = [0, 0]
    let cl = [0, 0]
    for (let i = 0; i < s.length; i++) {
        if (s[i] === '[' && op[0] === 0) {
            op[0] = i
            isAcc++
        } else if (op[0] !== 0 && s[i] === ':' && op[1] === 0) {
            op[1] = i
            isAcc++
            break;
        } else {
            c++
        }
    }
    for (let i = s.length - 1; i > op[1]; i--) {
        if (s[i] === ']' && cl[1] === 0 && cl[0] === 0) {
            cl[1] = i
            isAcc++
        } else if (cl[1] !== 0 && s[i] === ':' && cl[0] === 0) {
            cl[0] = i
            isAcc++
            break;
        } else {
            c++
        }
    }
    for (let i = op[1]+1; i < cl[0]; i++) {
        if (s[i] !== '|') {
            c++
      }
    }
    rl.close()
    if (isAcc !== 4) {
        console.log(-1)
    } else {
        console.log(c)
    }
});

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

let l = 0;
let t = 0
rl.on('line', (input) => {
    let s = input.split('')
    let c = 0
    let isAcc = 0
    let op = [0, 0]
    let cl = [0, 0]
    for (let i = 0; i < s.length; i++) {
        if (s[i] === '[' && op[0] === 0) {
            op[0] = i
            isAcc++
        } else if (op[0] !== 0 && s[i] === ':' && op[1] === 0) {
            op[1] = i
            isAcc++
            break;
        } else {
            c++
        }
    }
    for (let i = s.length - 1; i > op[1]; i--) {
        if (s[i] === ']' && cl[1] === 0 && cl[0] === 0) {
            cl[1] = i
            isAcc++
        } else if (cl[1] !== 0 && s[i] === ':' && cl[0] === 0) {
            cl[0] = i
            isAcc++
            break;
        } else {
            c++
        }
    }
    for (let i = op[1]+1; i < cl[0]; i++) {
        if (s[i] !== '|') {
            c++
      }
    }
    rl.close()
    if (isAcc !== 4) {
        console.log(-1)
    } else {
        console.log(s.length-c)
    }
});

var s = readline();
s = s.substring(s.indexOf('['), s.length);
s = s.substring(0, s.lastIndexOf(']')+1);
s = s.replace(/[^\:\[\]\|]/gim,'').replace(/[^\:\|]/gim,'');
s = s.substring(s.indexOf(':'), s.length);
s = s.substring(0, s.lastIndexOf(':')+1);
if((s.match(/\:/g) || []).length != 2) {
    print(-1);
} else {
    print(s.length+2);
}

var s = readline();
s = s.substring(s.indexOf('['), s.length);
s = s.substring(0, s.lastIndexOf(']')+1);
s = s.replace(/[^\:\[\]\|]/gim,'').replace(/[^\:\|]/gim,'');
s = s.substring(s.indexOf(':'), s.length);
s = s.substring(0, s.lastIndexOf(':')+1);

if(s.length >= 2 && s[0] == ':' && s[s.length-1] == ':') {
	s = s.replace(/[^\|]/gim,'');

    print(s.length+4);
} else {
	print(-1);
}

function calc(s) {
  if (s.indexOf('[') === -1) {
    return -1;
  } else {
     s = s.slice(s.indexOf('['));
  }

  if (s.indexOf(':') === -1) {
    return -1;
  } else {
     s = s.slice(s.indexOf(':'));
  }

  if (s.lastIndexOf(']') === -1) {
    return -1;
  } else {
     s = s.slice(0, s.lastIndexOf(']') + 1);
  }

  if (s.lastIndexOf(':') === -1) {
    return -1;
  } else {
     s = s.slice(0, s.lastIndexOf(':') + 1);
  }

  return 4 + s.filter(elem => elem === '|').length;
}

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

print(calc(s));


Pak Chanek is playing one of his favourite board games. In the game, there is a directed graph with $$$N$$$ vertices and $$$M$$$ edges. In the graph, edge $$$i$$$ connects two different vertices $$$U_i$$$ and $$$V_i$$$ with a length of $$$W_i$$$. By using the $$$i$$$-th edge, something can move from $$$U_i$$$ to $$$V_i$$$, but not from $$$V_i$$$ to $$$U_i$$$.To play this game, initially Pak Chanek must place both of his hands onto two different vertices. In one move, he can move one of his hands to another vertex using an edge. To move a hand from vertex $$$U_i$$$ to vertex $$$V_i$$$, Pak Chanek needs a time of $$$W_i$$$ seconds. Note that Pak Chanek can only move one hand at a time. This game ends when both of Pak Chanek's hands are on the same vertex.Pak Chanek has several questions. For each $$$p$$$ satisfying $$$2 \leq p \leq N$$$, you need to find the minimum time in seconds needed for Pak Chanek to end the game if initially Pak Chanek's left hand and right hand are placed on vertex $$$1$$$ and vertex $$$p$$$, or report if it is impossible.

The first line contains two integers $$$N$$$ and $$$M$$$ ($$$2 \leq N \leq 10^5$$$, $$$0 \leq M \leq 2 \cdot 10^5$$$) — the number of vertices and edges in the graph. The $$$i$$$-th of the next $$$M$$$ lines contains three integers $$$U_i$$$, $$$V_i$$$, and $$$W_i$$$ ($$$1 \le U_i, V_i \le N$$$, $$$U_i \neq V_i$$$, $$$1 \le W_i \le 10^9$$$) — a directed edge that connects two different vertices $$$U_i$$$ and $$$V_i$$$ with a length of $$$W_i$$$. There is no pair of different edges $$$i$$$ and $$$j$$$ such that $$$U_i = U_j$$$ and $$$V_i = V_j$$$.

Output a line containing $$$N-1$$$ integers. The $$$j$$$-th integer represents the minimum time in seconds needed by Pak Chanek to end the game if initially Pak Chanek's left hand and right hand are placed on vertex $$$1$$$ and vertex $$$j+1$$$, or $$$-1$$$ if it is impossible.

NoteIf initially Pak Chanek's left hand is on vertex $$$1$$$ and his right hand is on vertex $$$5$$$, Pak Chanek can do the following moves:   Move his right hand to vertex $$$4$$$ in $$$1$$$ second.  Move his left hand to vertex $$$2$$$ in $$$2$$$ seconds.  Move his left hand to vertex $$$4$$$ in $$$1$$$ second. In total it needs $$$1+2+1=4$$$ seconds. It can be proven that there is no other way that is faster.

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

function _defineProperty(obj, key, value) {
  if (key in obj) {
    Object.defineProperty(obj, key, {
      value: value,
      enumerable: true,
      configurable: true,
      writable: true
    });
  } else {
    obj[key] = value;
  }

  return obj;
}

async function solve(read) {
  const rns = async () => {
    return (await read()).split(' ').filter(s => s !== '').map(Number);
  };
  const [n, m] = await rns();
  const M = 2 * m + n + 10;
  let h = new Array(2 * n).fill(-1),
      te = new Array(M),
      ne = new Array(M),
      w = new Array(M);
  let idx = 0;
  const add = (i, j, c) => {
    te[idx] = j, w[idx] = c, ne[idx] = h[i], h[i] = idx++;
  };
  for (let i = 0; i < m; i++) {
    let [u, v, w] = await rns();
    u--, v--;
    add(u, v, w);
    add(v + n, u + n, w);
  }
  for (let i = 0; i < n; i++) add(i, i + n, 0);
  const djk = () => {
    const dist = new Array(2 * n).fill(Infinity);
    const queue = new Heap((a, b) => a[1] - b[1]);
    dist[0] = 0;
    queue.push([0, 0]);
    const vis = new Array(2 * n);
    while (queue.size()) {
      const [u, d] = queue.pop();
      if (vis[u]) continue;
      vis[u] = 1;
      for (let i = h[u]; ~i; i = ne[i]) {
        const v = te[i];
        if (vis[v]) continue;
        if (dist[v] > dist[u] + w[i]) {
          dist[v] = dist[u] + w[i];
          queue.push([v, dist[v]]);
        }
      }
    }
    return dist;
  };
  const dist = djk();
  return dist.slice(n + 1).map(num => num === Infinity ? -1 : num).join(' ');
}
class Heap {
  constructor(_comparator, arr) {
    _defineProperty(this, "_heap", []);
    this._comparator = _comparator;
    if (arr) {
      this._heap = [...arr];
      for (let i = arr.length >> 1; i; i--) this.down(i);
    }
  }
  swap(i, j) {
    [this._heap[i], this._heap[j]] = [this._heap[j], this._heap[i]];
  }
  _has(i) {
    return Object.prototype.hasOwnProperty.call(this._heap, i);
  }
  comparator(i, j) {
    return this._comparator(this._heap[i], this._heap[j]) < 0;
  }
  parent(i) {
    return i - 1 >> 1;
  }
  children(i) {
    return [2 * i + 1, 2 * i + 2];
  }
  up(i) {
    let parent = this.parent(i);
    while (i > 0 && this.comparator(i, parent)) {
      this.swap(i, parent);
      [i, parent] = [parent, parent - 1 >> 1];
    }
  }
  down(i) {
    let [left, right] = this.children(i);
    while (left < this._heap.length) {
      if (!this._has(right)) right = left;
      if (this.comparator(right, left)) [left, right] = [right, left];
      if (this.comparator(i, left)) break;
      this.swap(i, left);
      i = left;
      [left, right] = [2 * i + 1, 2 * i + 2];
    }
  }
  push(node) {
    this._heap.push(node);
    this.up(this._heap.length - 1);
  }
  pop() {
    if (this.size() === 0) return null;
    let res = this._heap[0];
    this.swap(0, this._heap.length - 1);
    this._heap.pop();
    this.down(0);
    return res;
  }
  remove(i) {
    if (i >= this.size()) return;
    let res = this._heap[i];
    this.swap(i, this._heap.length - 1);
    this._heap.pop();
    this.down(i);
    this.up(i);
    return res;
  }
  modify(i, val) {
    if (i >= this.size()) return;
    let res = this._heap[i];
    this._heap[i] = val;
    this.down(i);
    this.up(i);
    return res;
  }
  top() {
    if (this.size() === 0) return null;
    return this._heap[0];
  }
  size() {
    return this._heap.length;
  }
}

async function main(r) {
  try {
    let t = 1;
    let res = new Array(t);
    for (let i = 0; i < t; i++) {
      res[i] = await solve(r);
    }
    return res.join('\n');
  } catch (error) {
    console.log('zdebug' + error);
  }
}

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

'use strict';

var readline = require('readline');

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

var readline__default = /*#__PURE__*/_interopDefaultLegacy(readline);

function _defineProperty(obj, key, value) {
  if (key in obj) {
    Object.defineProperty(obj, key, {
      value: value,
      enumerable: true,
      configurable: true,
      writable: true
    });
  } else {
    obj[key] = value;
  }

  return obj;
}

async function solve(read) {
  const rns = async () => {
    return (await read()).split(' ').filter(s => s !== '').map(Number);
  };
  const [n, m] = await rns();
  const M = 2 * m + n + 10;
  let h = new Array(2 * n).fill(-1),
      te = new Array(M),
      ne = new Array(M),
      w = new Array(M);
  let idx = 0;
  const add = (i, j, c) => {
    te[idx] = j, w[idx] = c, ne[idx] = h[i], h[i] = idx++;
  };
  for (let i = 0; i < m; i++) {
    let [u, v, w] = await rns();
    u--, v--;
    add(u, v, w);
    add(v + n, u + n, w);
  }
  for (let i = 0; i < n; i++) add(i, i + n, 0);
  const djk = () => {
    const dist = new Array(2 * n).fill(Infinity);
    const queue = new Heap((a, b) => a[1] - b[1]);
    dist[0] = 0;
    queue.push([0, 0]);
    const vis = new Array(2 * n);
    while (queue.size()) {
      const [u, d] = queue.pop();
      if (vis[u]) continue;
      vis[u] = 1;
      for (let i = h[u]; ~i; i = ne[i]) {
        const v = te[i];
        if (vis[v]) continue;
        if (dist[v] > dist[u] + w[i]) {
          dist[v] = dist[u] + w[i];
          queue.push([v, dist[v]]);
        }
      }
    }
    return dist;
  };
  const dist = djk();
  return dist.slice(n + 1).map(num => num === Infinity ? -1 : num).join(' ');
}
class Heap {
  constructor(_comparator, arr) {
    _defineProperty(this, "_heap", []);
    this._comparator = _comparator;
    if (arr) {
      this._heap = [...arr];
      for (let i = arr.length >> 1; i; i--) this.down(i);
    }
  }
  swap(i, j) {
    [this._heap[i], this._heap[j]] = [this._heap[j], this._heap[i]];
  }
  _has(i) {
    return Object.prototype.hasOwnProperty.call(this._heap, i);
  }
  comparator(i, j) {
    return this._comparator(this._heap[i], this._heap[j]) < 0;
  }
  parent(i) {
    return i - 1 >> 1;
  }
  children(i) {
    return [2 * i + 1, 2 * i + 2];
  }
  up(i) {
    let parent = this.parent(i);
    while (i > 0 && this.comparator(i, parent)) {
      this.swap(i, parent);
      [i, parent] = [parent, parent - 1 >> 1];
    }
  }
  down(i) {
    let [left, right] = this.children(i);
    while (left < this._heap.length) {
      if (!this._has(right)) right = left;
      if (this.comparator(right, left)) [left, right] = [right, left];
      if (this.comparator(i, left)) break;
      this.swap(i, left);
      i = left;
      [left, right] = [2 * i + 1, 2 * i + 2];
    }
  }
  push(node) {
    this._heap.push(node);
    this.up(this._heap.length - 1);
  }
  pop() {
    if (this.size() === 0) return null;
    let res = this._heap[0];
    this.swap(0, this._heap.length - 1);
    this._heap.pop();
    this.down(0);
    return res;
  }
  remove(i) {
    if (i >= this.size()) return;
    let res = this._heap[i];
    this.swap(i, this._heap.length - 1);
    this._heap.pop();
    this.down(i);
    this.up(i);
    return res;
  }
  modify(i, val) {
    if (i >= this.size()) return;
    let res = this._heap[i];
    this._heap[i] = val;
    this.down(i);
    this.up(i);
    return res;
  }
  top() {
    if (this.size() === 0) return null;
    return this._heap[0];
  }
  size() {
    return this._heap.length;
  }
}

async function main(r) {
  try {
    let t = 1;
    let res = new Array(t);
    for (let i = 0; i < t; i++) {
      res[i] = await solve(r);
    }
    return res.join('\n');
  } catch (error) {
    console.log('zdebug' + error);
  }
}

const rl = readline__default["default"].createInterface({
  input: process.stdin,
  output: process.stdout
});
const it = rl[Symbol.asyncIterator]();
async function read() {
  return (await it.next()).value;
}
void async function () {
  const output = await main(read);
  process.stdout.write(output);
}();

'use strict';

var readline = require('readline');

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

var readline__default = /*#__PURE__*/_interopDefaultLegacy(readline);

function _defineProperty(obj, key, value) {
  if (key in obj) {
    Object.defineProperty(obj, key, {
      value: value,
      enumerable: true,
      configurable: true,
      writable: true
    });
  } else {
    obj[key] = value;
  }

  return obj;
}

async function solve(read) {
  const rns = async () => {
    return (await read()).split(' ').filter(s => s !== '').map(Number);
  };
  const [n, m] = await rns();
  let h = new Array(n).fill(-1),
      hs = new Array(n).fill(-1),
      e = [],
      ne = [],
      w = [];
  const add = (h, i, j, c) => {
    e.push(j), w.push(c), ne.push(h[i]), h[i] = ne.length - 1;
  };
  const time = new Date().valueOf();
  for (let i = 0; i < m; i++) {
    const [u, v, w] = await rns();
    add(h, u - 1, v - 1, w);
    add(hs, v - 1, u - 1, w);
  }
  if (n === 100000) console.log(new Date().valueOf() - time);
  const djk = (dist, queue, h) => {
    const vis = new Array(n);
    while (queue.size()) {
      const [u, d] = queue.pop();
      if (vis[u]) continue;
      vis[u] = 1;
      for (let i = h[u]; ~i; i = ne[i]) {
        const v = e[i];
        if (vis[v]) continue;
        if (dist[v] > dist[u] + w[i]) {
          dist[v] = dist[u] + w[i];
          queue.push([v, dist[v]]);
        }
      }
    }
  };
  const dist = new Array(n).fill(Infinity);
  {
    const queue = new Heap((a, b) => a[1] - b[1]);
    dist[0] = 0;
    queue.push([0, 0]);
    djk(dist, queue, h);
  }
  if (n !== 100000) {
    const queue = new Heap((a, b) => a[1] - b[1], dist.map((d, i) => [i, d]));
    djk(dist, queue, hs);
  }
  return dist.slice(1).map(num => num === Infinity ? -1 : num).join(' ');
}
class Heap {
  constructor(_comparator, arr) {
    _defineProperty(this, "_heap", []);
    _defineProperty(this, "_map", new Map());
    this._comparator = _comparator;
    if (arr) {
      this._heap = [...arr];
      for (let i = arr.length >> 1; i; i--) this.down(i);
    }
  }
  swap(i, j) {
    this._map.set(this._heap[i], j);
    this._map.set(this._heap[j], i);
    [this._heap[i], this._heap[j]] = [this._heap[j], this._heap[i]];
  }
  _has(i) {
    return Object.prototype.hasOwnProperty.call(this._heap, i);
  }
  comparator(i, j) {
    return this._comparator(this._heap[i], this._heap[j]) < 0;
  }
  parent(i) {
    return i - 1 >> 1;
  }
  children(i) {
    return [2 * i + 1, 2 * i + 2];
  }
  up(i) {
    let parent = this.parent(i);
    while (i > 0 && this.comparator(i, parent)) {
      this.swap(i, parent);
      [i, parent] = [parent, parent - 1 >> 1];
    }
  }
  down(i) {
    let [left, right] = this.children(i);
    while (left < this._heap.length) {
      if (!this._has(right)) right = left;
      if (this.comparator(right, left)) [left, right] = [right, left];
      if (this.comparator(i, left)) break;
      this.swap(i, left);
      i = left;
      [left, right] = [2 * i + 1, 2 * i + 2];
    }
  }
  push(node) {
    this._map.set(node, this._heap.length);
    this._heap.push(node);
    this.up(this._heap.length - 1);
  }
  pop() {
    if (this.size() === 0) return null;
    let res = this._heap[0];
    this.swap(0, this._heap.length - 1);
    this._heap.pop();
    this.down(0);
    return res;
  }
  remove(i) {
    if (i >= this.size()) return;
    let res = this._heap[i];
    this.swap(i, this._heap.length - 1);
    this._heap.pop();
    this.down(i);
    this.up(i);
    return res;
  }
  modify(i, val) {
    if (i >= this.size()) return;
    let res = this._heap[i];
    this._heap[i] = val;
    this._map.set(val, i);
    this.down(i);
    this.up(i);
    return res;
  }
  top() {
    if (this.size() === 0) return null;
    return this._heap[0];
  }
  size() {
    return this._heap.length;
  }
  getIndex(val) {
    return this._map.get(val);
  }
}

async function main(r) {
  try {
    let t = 1;
    let res = new Array(t);
    for (let i = 0; i < t; i++) {
      res[i] = await solve(r);
    }
    return res.join('\n');
  } catch (error) {
    console.log('zdebug' + error);
  }
}

const rl = readline__default["default"].createInterface({
  input: process.stdin,
  output: process.stdout
});
const it = rl[Symbol.asyncIterator]();
async function read() {
  return (await it.next()).value;
}
void async function () {
  const output = await main(read);
  process.stdout.write(output);
}();

'use strict';

var readline = require('readline');

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

var readline__default = /*#__PURE__*/_interopDefaultLegacy(readline);

function _defineProperty(obj, key, value) {
  if (key in obj) {
    Object.defineProperty(obj, key, {
      value: value,
      enumerable: true,
      configurable: true,
      writable: true
    });
  } else {
    obj[key] = value;
  }

  return obj;
}

async function solve(read) {
  const rns = async () => {
    return (await read()).split(' ').filter(s => s !== '').map(Number);
  };
  const [n, m] = await rns();
  let h = new Array(n).fill(-1),
      hs = new Array(n).fill(-1),
      e = [],
      ne = [],
      w = [];
  const add = (h, i, j, c) => {
    e.push(j), w.push(c), ne.push(h[i]), h[i] = ne.length - 1;
  };
  const time = new Date().valueOf();
  for (let i = 0; i < m; i++) {
    const [u, v, w] = await rns();
    add(h, u - 1, v - 1, w);
    add(hs, v - 1, u - 1, w);
  }
  if (n === 100000) console.log(new Date().valueOf() - time);
  const djk = (dist, queue, h) => {
    const vis = new Array(n);
    while (queue.size()) {
      const [u, d] = queue.pop();
      if (vis[u]) continue;
      vis[u] = 1;
      for (let i = h[u]; ~i; i = ne[i]) {
        const v = e[i];
        if (vis[v]) continue;
        if (dist[v] > dist[u] + w[i]) {
          dist[v] = dist[u] + w[i];
          queue.push([v, dist[v]]);
        }
      }
    }
  };
  const dist = new Array(n).fill(Infinity);
  {
    const queue = new Heap((a, b) => a[1] - b[1]);
    dist[0] = 0;
    queue.push([0, 0]);
    djk(dist, queue, h);
  }
  if (n !== 100000) {
    const queue = new Heap((a, b) => a[1] - b[1], dist.map((d, i) => [i, d]));
    djk(dist, queue, hs);
  }
  return dist.slice(1).map(num => num === Infinity ? -1 : num).join(' ');
}
const n = 100000,
      m = 200000;
const edges = [`${n} ${m}`];
for (let i = 0; i < m; i++) {
  let x = Math.floor(Math.random() * n),
      y = Math.floor(Math.random() * n);
  while (x === y) {
    y = Math.floor(Math.random() * n);
  }
  edges.push(`${x} ${y} ${Math.floor(Math.random() * 100000)}`);
}
let i = 0;
const read$1 = () => edges[i++];
void async function () {
  console.time('test');
  await solve(read$1);
  console.timeEnd('test');
}();
class Heap {
  constructor(_comparator, arr) {
    _defineProperty(this, "_heap", []);
    _defineProperty(this, "_map", new Map());
    this._comparator = _comparator;
    if (arr) {
      this._heap = [...arr];
      for (let i = arr.length >> 1; i; i--) this.down(i);
    }
  }
  swap(i, j) {
    this._map.set(this._heap[i], j);
    this._map.set(this._heap[j], i);
    [this._heap[i], this._heap[j]] = [this._heap[j], this._heap[i]];
  }
  _has(i) {
    return Object.prototype.hasOwnProperty.call(this._heap, i);
  }
  comparator(i, j) {
    return this._comparator(this._heap[i], this._heap[j]) < 0;
  }
  parent(i) {
    return i - 1 >> 1;
  }
  children(i) {
    return [2 * i + 1, 2 * i + 2];
  }
  up(i) {
    let parent = this.parent(i);
    while (i > 0 && this.comparator(i, parent)) {
      this.swap(i, parent);
      [i, parent] = [parent, parent - 1 >> 1];
    }
  }
  down(i) {
    let [left, right] = this.children(i);
    while (left < this._heap.length) {
      if (!this._has(right)) right = left;
      if (this.comparator(right, left)) [left, right] = [right, left];
      if (this.comparator(i, left)) break;
      this.swap(i, left);
      i = left;
      [left, right] = [2 * i + 1, 2 * i + 2];
    }
  }
  push(node) {
    this._map.set(node, this._heap.length);
    this._heap.push(node);
    this.up(this._heap.length - 1);
  }
  pop() {
    if (this.size() === 0) return null;
    let res = this._heap[0];
    this.swap(0, this._heap.length - 1);
    this._heap.pop();
    this.down(0);
    return res;
  }
  remove(i) {
    if (i >= this.size()) return;
    let res = this._heap[i];
    this.swap(i, this._heap.length - 1);
    this._heap.pop();
    this.down(i);
    this.up(i);
    return res;
  }
  modify(i, val) {
    if (i >= this.size()) return;
    let res = this._heap[i];
    this._heap[i] = val;
    this._map.set(val, i);
    this.down(i);
    this.up(i);
    return res;
  }
  top() {
    if (this.size() === 0) return null;
    return this._heap[0];
  }
  size() {
    return this._heap.length;
  }
  getIndex(val) {
    return this._map.get(val);
  }
}

async function main(r) {
  try {
    let t = 1;
    let res = new Array(t);
    for (let i = 0; i < t; i++) {
      res[i] = await solve(r);
    }
    return res.join('\n');
  } catch (error) {
    console.log('zdebug' + error);
  }
}

const rl = readline__default["default"].createInterface({
  input: process.stdin,
  output: process.stdout
});
const it = rl[Symbol.asyncIterator]();
async function read() {
  return (await it.next()).value;
}
void async function () {
  const output = await main(read);
  process.stdout.write(output);
}();

'use strict';

var readline = require('readline');

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

var readline__default = /*#__PURE__*/_interopDefaultLegacy(readline);

function _defineProperty(obj, key, value) {
  if (key in obj) {
    Object.defineProperty(obj, key, {
      value: value,
      enumerable: true,
      configurable: true,
      writable: true
    });
  } else {
    obj[key] = value;
  }

  return obj;
}

async function solve(read) {
  const rns = async () => {
    return (await read()).split(' ')
    .map(Number);
  };
  const [n, m] = await rns();
  const M = 2 * m + 10;
  let h = new Array(n).fill(-1),
      hs = new Array(n).fill(-1),
      e = new Array(M),
      ne = new Array(M),
      w = new Array(M);
  let idx = 0;
  const add = (h, i, j, c) => {
    e[idx] = j, w[idx] = c, ne[idx] = h[i], h[i] = idx++;
  };
  for (let i = 0; i < m; i++) {
    const [u, v, w] = await rns();
    add(h, u - 1, v - 1, w);
    add(hs, v - 1, u - 1, w);
  }
  const djk = (dist, queue, h, nodes = new Array(n)) => {
    const vis = new Array(n);
    while (queue.size()) {
      const [u, d] = queue.pop();
      if (vis[u]) continue;
      vis[u] = 1;
      for (let i = h[u]; ~i; i = ne[i]) {
        const v = e[i];
        if (vis[v]) continue;
        if (dist[v] > dist[u] + w[i]) {
          dist[v] = dist[u] + w[i];
          if (!nodes[v]) {
            nodes[v] = [v, dist[v]];
            queue.push(nodes[v]);
          } else {
            const j = queue.getIndex(nodes[v]);
            nodes[v][1] = dist[v];
            queue.modify(j, nodes[v]);
          }
        }
      }
    }
  };
  const dist = new Array(n).fill(Infinity);
  {
    const queue = new Heap((a, b) => a[1] - b[1]);
    dist[0] = 0;
    queue.push([0, 0]);
    djk(dist, queue, h);
  }
  {
    const nodes = dist.map((d, i) => [i, d]);
    const queue = new Heap((a, b) => a[1] - b[1], nodes);
    djk(dist, queue, hs, nodes);
  }
  return dist.slice(1).map(num => num === Infinity ? -1 : num).join(' ');
}
class Heap {
  constructor(_comparator, arr) {
    _defineProperty(this, "_heap", []);
    _defineProperty(this, "_map", new Map());
    this._comparator = _comparator;
    if (arr) {
      this._heap = [...arr];
      for (let i = arr.length >> 1; i; i--) {
        this.down(i);
        this._map.set(arr[i], i);
      }
    }
  }
  swap(i, j) {
    this._map.set(this._heap[i], j);
    this._map.set(this._heap[j], i);
    [this._heap[i], this._heap[j]] = [this._heap[j], this._heap[i]];
  }
  _has(i) {
    return Object.prototype.hasOwnProperty.call(this._heap, i);
  }
  comparator(i, j) {
    return this._comparator(this._heap[i], this._heap[j]) < 0;
  }
  parent(i) {
    return i - 1 >> 1;
  }
  children(i) {
    return [2 * i + 1, 2 * i + 2];
  }
  up(i) {
    let parent = this.parent(i);
    while (i > 0 && this.comparator(i, parent)) {
      this.swap(i, parent);
      [i, parent] = [parent, parent - 1 >> 1];
    }
  }
  down(i) {
    let [left, right] = this.children(i);
    while (left < this._heap.length) {
      if (!this._has(right)) right = left;
      if (this.comparator(right, left)) [left, right] = [right, left];
      if (this.comparator(i, left)) break;
      this.swap(i, left);
      i = left;
      [left, right] = [2 * i + 1, 2 * i + 2];
    }
  }
  push(node) {
    this._map.set(node, this._heap.length);
    this._heap.push(node);
    this.up(this._heap.length - 1);
  }
  pop() {
    if (this.size() === 0) return null;
    let res = this._heap[0];
    this.swap(0, this._heap.length - 1);
    this._heap.pop();
    this.down(0);
    return res;
  }
  remove(i) {
    if (i >= this.size()) return;
    let res = this._heap[i];
    this.swap(i, this._heap.length - 1);
    this._heap.pop();
    this.down(i);
    this.up(i);
    return res;
  }
  modify(i, val) {
    if (i >= this.size()) return;
    let res = this._heap[i];
    this._heap[i] = val;
    this._map.set(val, i);
    this.down(i);
    this.up(i);
    return res;
  }
  top() {
    if (this.size() === 0) return null;
    return this._heap[0];
  }
  size() {
    return this._heap.length;
  }
  getIndex(val) {
    return this._map.get(val);
  }
}

async function main(r) {
  try {
    let t = 1;
    let res = new Array(t);
    for (let i = 0; i < t; i++) {
      res[i] = await solve(r);
    }
    return res.join('\n');
  } catch (error) {
    console.log('zdebug' + error);
  }
}

const rl = readline__default["default"].createInterface({
  input: process.stdin,
  output: process.stdout
});
const it = rl[Symbol.asyncIterator]();
async function read() {
  return (await it.next()).value;
}
void async function () {
  const output = await main(read);
  process.stdout.write(output);
}();

'use strict';

var readline = require('readline');

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

var readline__default = /*#__PURE__*/_interopDefaultLegacy(readline);

function _defineProperty(obj, key, value) {
  if (key in obj) {
    Object.defineProperty(obj, key, {
      value: value,
      enumerable: true,
      configurable: true,
      writable: true
    });
  } else {
    obj[key] = value;
  }

  return obj;
}

async function solve(read) {
  const rns = async () => {
    return (await read()).split(' ')
    .map(Number);
  };
  const [n, m] = await rns();
  const M = 2 * m + 10;
  let h = new Array(n).fill(-1),
      hs = new Array(n).fill(-1),
      e = new Array(M),
      ne = new Array(M),
      w = new Array(M);
  let idx = 0;
  const add = (h, i, j, c) => {
    e[idx] = j, w[idx] = c, ne[idx] = h[i], h[i] = idx++;
  };
  for (let i = 0; i < m; i++) {
    const [u, v, w] = await rns();
    add(h, u - 1, v - 1, w);
    add(hs, v - 1, u - 1, w);
  }
  const djk = (dist, queue, h, nodes = new Array(n)) => {
    const vis = new Array(n);
    while (queue.size()) {
      const [u, d] = queue.pop();
      if (vis[u]) continue;
      vis[u] = 1;
      for (let i = h[u]; ~i; i = ne[i]) {
        const v = e[i];
        if (vis[v]) continue;
        if (dist[v] > dist[u] + w[i]) {
          dist[v] = dist[u] + w[i];
          if (!nodes[v]) {
            nodes[v] = [v, dist[v]];
            queue.push(nodes[v]);
          } else {
            const j = queue.getIndex(nodes[v]);
            nodes[v][1] = dist[v];
            queue.modify(j, nodes[v]);
          }
        }
      }
    }
  };
  const dist = new Array(n).fill(Infinity);
  {
    const queue = new Heap((a, b) => a[1] - b[1]);
    dist[0] = 0;
    queue.push([0, 0]);
    djk(dist, queue, h);
  }
  {
    const nodes = dist.map((d, i) => [i, d]);
    const queue = new Heap((a, b) => a[1] - b[1], nodes);
    djk(dist, queue, hs, nodes);
  }
  return dist.slice(1).map(num => num === Infinity ? -1 : num).join(' ');
}
class Heap {
  constructor(_comparator, arr) {
    _defineProperty(this, "_heap", []);
    _defineProperty(this, "_map", new Map());
    this._comparator = _comparator;
    if (arr) {
      this._heap = [...arr];
      for (let i = arr.length >> 1; i; i--) this.down(i);
    }
  }
  swap(i, j) {
    this._map.set(this._heap[i], j);
    this._map.set(this._heap[j], i);
    [this._heap[i], this._heap[j]] = [this._heap[j], this._heap[i]];
  }
  _has(i) {
    return Object.prototype.hasOwnProperty.call(this._heap, i);
  }
  comparator(i, j) {
    return this._comparator(this._heap[i], this._heap[j]) < 0;
  }
  parent(i) {
    return i - 1 >> 1;
  }
  children(i) {
    return [2 * i + 1, 2 * i + 2];
  }
  up(i) {
    let parent = this.parent(i);
    while (i > 0 && this.comparator(i, parent)) {
      this.swap(i, parent);
      [i, parent] = [parent, parent - 1 >> 1];
    }
  }
  down(i) {
    let [left, right] = this.children(i);
    while (left < this._heap.length) {
      if (!this._has(right)) right = left;
      if (this.comparator(right, left)) [left, right] = [right, left];
      if (this.comparator(i, left)) break;
      this.swap(i, left);
      i = left;
      [left, right] = [2 * i + 1, 2 * i + 2];
    }
  }
  push(node) {
    this._map.set(node, this._heap.length);
    this._heap.push(node);
    this.up(this._heap.length - 1);
  }
  pop() {
    if (this.size() === 0) return null;
    let res = this._heap[0];
    this.swap(0, this._heap.length - 1);
    this._heap.pop();
    this.down(0);
    return res;
  }
  remove(i) {
    if (i >= this.size()) return;
    let res = this._heap[i];
    this.swap(i, this._heap.length - 1);
    this._heap.pop();
    this.down(i);
    this.up(i);
    return res;
  }
  modify(i, val) {
    if (i >= this.size()) return;
    let res = this._heap[i];
    this._heap[i] = val;
    this._map.set(val, i);
    this.down(i);
    this.up(i);
    return res;
  }
  top() {
    if (this.size() === 0) return null;
    return this._heap[0];
  }
  size() {
    return this._heap.length;
  }
  getIndex(val) {
    return this._map.get(val);
  }
}

async function main(r) {
  try {
    let t = 1;
    let res = new Array(t);
    for (let i = 0; i < t; i++) {
      res[i] = await solve(r);
    }
    return res.join('\n');
  } catch (error) {
    console.log('zdebug' + error);
  }
}

const rl = readline__default["default"].createInterface({
  input: process.stdin,
  output: process.stdout
});
const it = rl[Symbol.asyncIterator]();
async function read() {
  return (await it.next()).value;
}
void async function () {
  const output = await main(read);
  process.stdout.write(output);
}();


Let's define a number ebne (even but not even) if and only if its sum of digits is divisible by $$$2$$$ but the number itself is not divisible by $$$2$$$. For example, $$$13$$$, $$$1227$$$, $$$185217$$$ are ebne numbers, while $$$12$$$, $$$2$$$, $$$177013$$$, $$$265918$$$ are not. If you're still unsure what ebne numbers are, you can look at the sample notes for more clarification.You are given a non-negative integer $$$s$$$, consisting of $$$n$$$ digits. You can delete some digits (they are not necessary consecutive/successive) to make the given number ebne. You cannot change the order of the digits, that is, after deleting the digits the remaining digits collapse. The resulting number shouldn't contain leading zeros. You can delete any number of digits between $$$0$$$ (do not delete any digits at all) and $$$n-1$$$.For example, if you are given $$$s=$$$222373204424185217171912 then one of possible ways to make it ebne is: 222373204424185217171912 $$$\rightarrow$$$ 2237344218521717191. The sum of digits of 2237344218521717191 is equal to $$$70$$$ and is divisible by $$$2$$$, but number itself is not divisible by $$$2$$$: it means that the resulting number is ebne.Find any resulting number that is ebne. If it's impossible to create an ebne number from the given number report about it.

The input consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1 \le t \le 1000$$$)  — the number of test cases. The description of the test cases follows. The first line of each test case contains a single integer $$$n$$$ ($$$1 \le n \le 3000$$$)  — the number of digits in the original number. The second line of each test case contains a non-negative integer number $$$s$$$, consisting of $$$n$$$ digits. It is guaranteed that $$$s$$$ does not contain leading zeros and the sum of $$$n$$$ over all test cases does not exceed $$$3000$$$.

For each test case given in the input print the answer in the following format:  If it is impossible to create an ebne number, print "-1" (without quotes); Otherwise, print the resulting number after deleting some, possibly zero, but not all digits. This number should be ebne. If there are multiple answers, you can print any of them. Note that answers with leading zeros or empty strings are not accepted. It's not necessary to minimize or maximize the number of deleted digits.

NoteIn the first test case of the example, $$$1227$$$ is already an ebne number (as $$$1 + 2 + 2 + 7 = 12$$$, $$$12$$$ is divisible by $$$2$$$, while in the same time, $$$1227$$$ is not divisible by $$$2$$$) so we don't need to delete any digits. Answers such as $$$127$$$ and $$$17$$$ will also be accepted.In the second test case of the example, it is clearly impossible to create an ebne number from the given number.In the third test case of the example, there are many ebne numbers we can obtain by deleting, for example, $$$1$$$ digit such as $$$17703$$$, $$$77013$$$ or $$$17013$$$. Answers such as $$$1701$$$ or $$$770$$$ will not be accepted as they are not ebne numbers. Answer $$$013$$$ will not be accepted as it contains leading zeroes.Explanation: $$$1 + 7 + 7 + 0 + 3 = 18$$$. As $$$18$$$ is divisible by $$$2$$$ while $$$17703$$$ is not divisible by $$$2$$$, we can see that $$$17703$$$ is an ebne number. Same with $$$77013$$$ and $$$17013$$$; $$$1 + 7 + 0 + 1 = 9$$$. Because $$$9$$$ is not divisible by $$$2$$$, $$$1701$$$ is not an ebne number; $$$7 + 7 + 0 = 14$$$. This time, $$$14$$$ is divisible by $$$2$$$ but $$$770$$$ is also divisible by $$$2$$$, therefore, $$$770$$$ is not an ebne number.In the last test case of the example, one of many other possible answers is given. Another possible answer is: 222373204424185217171912 $$$\rightarrow$$$ 22237320442418521717191 (delete the last digit).

const readline = require('readline');
const rl = readline.createInterface({
  input: process.stdin,
  output: process.stdout,
  terminal: false
});
let c = 0;
let ans = '';

rl.on('line', (d) => {
  if (c === 0) {
    c++;
    return;
  }

  if (c % 2 === 1) {
    c++;
    return;
  }

  const odd = [];
  for (let i = 0; i < d.length; i++) {
    if (d[i] % 2) {
      odd.push(d[i]);
    }

    if (odd.length === 2) {
      break;
    }
  }

  if (odd.length === 2) {
    ans += odd.join('') + '\n';
  }
  else {
    ans += '-1\n';
  }

  c++;
});

rl.on('close', () => {
  console.log(ans);
});

'use strict';

const { createInterface } = require('readline');

const rl = createInterface({
  input: process.stdin,
  crlfDelay: Infinity
})
const lines = [];
let nextLine = 0;
rl.on('line', (line) => {
  lines.push(line);
});

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

function readline() {
  return lines[nextLine++];
}

function solve (nStr) {
  const nArr = nStr.split('').map(Number);
  while ((nArr.length > 1) && (nArr[nArr.length-1] % 2 === 0)) {
    nArr.pop();
  }
  if (nArr.length < 2) {
    return '-1';
  }
  const sum = nArr.reduce((a, b) => a + b, 0);
  if (sum % 2 === 1) {
    for(let i = nArr.length - 2; i >= 0; i--) {
      if (nArr[i] % 2 === 1) {
        nArr.splice(i, 1);
        return nArr.join('');
      }
    }
    return '-1';
  } else {
    return nArr.join('');
  }
}

function main() {
  const t = parseInt(readline());
  for(let i = 0; i < t; i++) {
    readline();
    const line = readline();
    const res = solve(line);
    console.log(res);
  }
}

function getSum(num, digits) {
  var sum = 0;

  for (var i = 0; i < digits; ++i) {
    sum += Number(num[i]);
  }

  return sum;
}

function isEvenNumber(sum) {
  return sum % 2 === 0;
}

function isOddNumber(sum) {
  return sum % 2 !== 0;
}

function isOdd(num, digits) {
  return isOddNumber(num[digits - 1]);
}

function isStrange(num, digits, sum) {
  return isOdd(num, digits) && isEvenNumber(sum);
}

function processItem() {
  var digits = +readline();
  var num = readline();
  var tempNum = num;
  var tempSum = getSum(num, digits);
  var tempDigits = digits;

  while (!isOdd(tempNum, tempDigits, tempSum) && tempDigits > 1) {
    tempSum = tempSum - tempNum[tempDigits - 1];
    tempNum = tempNum.slice(0, tempDigits - 1);
    tempDigits--;
  }

  var currentIndex = tempDigits - 2;

  while (isOddNumber(tempSum) && tempDigits > 1 && currentIndex >= 0) {
    var n = Number(tempNum[currentIndex]);

    if (isOddNumber(n) || n === 0) {
      tempSum = tempSum - tempNum[currentIndex];
      tempNum = tempNum.slice(0, currentIndex) + tempNum.slice(currentIndex + 1);
      tempDigits--;
    }

    currentIndex--;
  }

  print(isStrange(tempNum, tempDigits, tempSum) ? tempNum : '-1');
}

function processItems() {
  var itemsCount = +readline();
  var items = [];

  for (var i = 0; i < itemsCount; ++i) {
    processItem();
  }

  return items;
}

processItems();

var numRun= readline();

for(var n=0;n<numRun;n++){
    var k=readline();
    var s=prepNum(readline());
    var sum=0;
    var cur="";
    var found=false;
    out:for(var i=0;i<s.length;i++){
        sum=parseInt(s[i]);
        cur=s[i];
        //check(cur,sum);
        if(check(cur,sum)){break out;}
       // if(check(cur,sum)){print("TRUE:"+cur);};
        for(var k=i+1;k<s.length;k++){
            sum+=parseInt(s[k]);
            cur+=s[k];
            //check(cur,sum);
           if(check(cur,sum)){break out;}
            //if(check(cur,sum)){print("TRUE:"+cur);};
        }
    }//out
    if(found){print(cur);}
    else{print(-1);}
}//num runs

//want overall number (str) to be odd and sum of digits (sum) to be even
function check(str,sum){
   // print(str);
   // print("CHECK:"+str+":"+sum);
    if(parseInt(str)%2===1&&sum%2===0){found=true;return true;}
    return false;
}

//can remove even numbers as they don't do anything and 0's
function prepNum(str){
    var newStr="";
    for(var i=0;i<str.length;i++){
        if(parseInt(str[i])%2!==0){newStr+=str[i];}
    }
    return newStr;
}

Main();
function myout(t){print(t);}//standard output
function next(){return readline();}
//[no]param
//不明値:何もしない  1:数値へ変換  2:半角SPで分割  3:改行で分割  4:半角SPで分割し、数値配列へ
//5:改行で分割し、数値配列へ  6:1文字に分割  7:1文字に分割し、数値配列へ
//8:半角SPで結合　9:改行で結合　0:文字なしで結合
function myconv(i,no){switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 3:return i.split("\n");case 4:return i.split(" ").map((a)=>Number(a));case 5:return i.split("\n").map((a)=>Number(a));case 6:return i.split("");case 7:return i.split("").map((a)=>Number(a));case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}
function Main() {
    var t = myconv(next(),1);
    var output = new Array(t);
    for(var i = 0; i < t; i++){
        var N = myconv(next(),1);
        var s = next();
        if(N == 1){
            output[i] = "-1";
            continue;
        }
        var list = myconv(s,7);
        var sum = 0;
        var odds = new Set();
        var evens = new Set();
        var outputS = "";
        for(var j = 0; j < N; j++){
            sum += list[j];
            outputS += list[j].toString();
            if(list[j] % 2 != 0 && sum % 2 == 0){
                output[i] = outputS;
                break;
            }
        }
        if(output[i] == null){
            output[i] = "-1";
        }
    }
    myout(myconv(output,9));
}

function main() {
  var testCasesNum = +readline();
  for (var i = 0; i < testCasesNum; i++) {
    var len = +readline(); // длина
    var s = readline(); // строка
    s = removeLastEvens(s, len);
    findResult(s, s.length);
  }
}

function removeLastEvens(str, len) {
  while (str && Number(str.slice(-1)) % 2 === 0) {
    str = str.substring(0, len - 1);
    len -= 1;
  }
  return str;
}

function findResult(str, len) {
  if (!str) {
    print(-1);
    return;
  }
  var sum = 0;
  for (var j = 0; j < len; j++) {
    sum += Number(str[j]);
  }
  if (sum % 2 === 0) {
    print(str);
  } else {
    str = removeOdd(str, str.length);
    if (!str || Number(str[str.length - 1]) % 2 === 0) {
      print(-1);
    } else {
      str = str.replace(/^(0+)/, "");
      print(str);
    }
  }
}

function removeOdd(str, len) {
  for (var k = 0; k < len; k++) {
    if (str[k] % 2 === 1) {
      str = str.substring(0, k) + str.substring(k + 1);
      return str;
    }
  }
  return 0;
};

main();

function check(digits) {
  var num = "";
  var sum = 0;

  for (var i = digits.length - 1; i >= 0; i--) {
    var d = parseInt(digits[i]);
    if (num.length < 1 && d % 2 < 1) continue;

    num = d.toString() + num;
    sum += d;
    if (sum % 2 < 1) return num;
  }
  return -1;
}

var t = parseInt(readline());
var l = 0;
while (t > 0) {
  if (l == 0) {
    readline();
    l = 1;
  } else {
    l = 0;
    t--;
    print(check(readline()));
  }
}

var numRun= readline();

for(var n=0;n<numRun;n++){
    var k=readline();
    var s=delZer(readline());
    var sum=0;
    var cur="";
    var found=false;
    out:for(var i=0;i<s.length;i++){
        sum=parseInt(s[i]);
        cur=s[i];
        check(cur,sum);
        //if(check(cur,sum)){break out;}
       // if(check(cur,sum)){print("TRUE:"+cur);};
        for(var k=i+1;k<s.length;k++){
            sum+=parseInt(s[k]);
            cur+=s[k];
            check(cur,sum);
           // if(check(cur,sum)){break out;}
            //if(check(cur,sum)){print("TRUE:"+cur);};
        }
    }//out
    if(found){print(cur);}
    else{print(-1);}
}//num runs

//want overall number (str) to be odd and sum of digits (sum) to be even
function check(str,sum){
    print(str);
   // print("CHECK:"+str+":"+sum);
    if(parseInt(str)%2===1&&sum%2===0){found=true;return true;}
    return false;
}

function delZer(str){
    var newStr="";
    for(var i=0;i<str.length;i++){
        if(str[i]!=="0"){newStr+=str[i];}
    }
    return newStr;
}

var numRun= readline();

for(var n=0;n<numRun;n++){
    var k=readline();
    var s=delZer(readline());
    var sum=0;
    var cur="";
    var found=false;
    out:for(var i=0;i<s.length;i++){
        sum=parseInt(s[i]);
        cur+=s[i];
        if(check(cur,sum)){break out;}
       // if(check(cur,sum)){print("TRUE:"+cur);};
        for(var j=i+1;j<s.length;j++){
            for(var k=j;k<s.length;k++){
                sum+=parseInt(s[k]);
                cur+=s[k];
                if(check(cur,sum)){break out;}
                //if(check(cur,sum)){print("TRUE:"+cur);};
            }
        }
    }//out
    if(found){print(cur);}
    else{print(-1);}
}//num runs

//want overall number (str) to be odd and sum of digits (sum) to be even
function check(str,sum){
   // print("CHECK:"+str+":"+sum);
    if(parseInt(str)%2===1&&sum%2===0){found=true;return true;}
    return false;
}

function delZer(str){
    var newStr="";
    for(var i=0;i<str.length;i++){
        if(str[i]!=="0"){newStr+=str[i];}
    }
    return newStr;
}

var numRun= readline();

for(var n=0;n<numRun;n++){
    var k=readline();
    var s=readline();
    var sum=0;
    var cur="";
    var found=false;
    out:for(var i=0;i<s.length;i++){
        sum=parseInt(s[i]);
        cur+=s[i];
        if(check(cur,sum)){break out;}
       // if(check(cur,sum)){print("TRUE:"+cur);};
        for(var j=i+1;j<s.length;j++){
            for(var k=j;k<s.length;k++){
                sum+=parseInt(s[k]);
                cur+=s[k];
                if(check(cur,sum)){break out;}
                //if(check(cur,sum)){print("TRUE:"+cur);};
            }
        }
    }//out
    if(found){print(cur);}
    else{print(-1);}
}//num runs

//want overall number (str) to be odd and sum of digits (sum) to be even
function check(str,sum){
   // print("CHECK:"+str+":"+sum);
    if(parseInt(str)%2===1&&sum%2===0){found=true;return true;}
    return false;
}

Main();
function myout(t){print(t);}//standard output
function next(){return readline();}
//[no]param
//不明値:何もしない  1:数値へ変換  2:半角SPで分割  3:改行で分割  4:半角SPで分割し、数値配列へ
//5:改行で分割し、数値配列へ  6:1文字に分割  7:1文字に分割し、数値配列へ
//8:半角SPで結合　9:改行で結合　0:文字なしで結合
function myconv(i,no){switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 3:return i.split("\n");case 4:return i.split(" ").map((a)=>Number(a));case 5:return i.split("\n").map((a)=>Number(a));case 6:return i.split("");case 7:return i.split("").map((a)=>Number(a));case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}
function Main() {
    var t = myconv(next(),1);
    var output = new Array(t);
    for(var i = 0; i < t; i++){
        var N = myconv(next(),1);
        var s = next();
        if(N == 1){
            output[i] = "-1";
            continue;
        }
        var list = myconv(s,7);
        var sum = 0;
        var odds = new Set();
        var evens = new Set();
        for(var j = 0; j < N; j++){
            sum += list[j];
            if(list[j] % 2 == 0){
                evens.add(list[j]);
            }else{
                if(i < N - 1){
                    odds.add(j);
                }
            }
        }
        if(sum % 2 == 0){
            while(s.length > 0){
                var migihasi = myconv(s.slice(-1));
                if(migihasi % 2 != 1){
                    s = s.slice(0,s.length - 1);
                }else{
                    break;
                }
            }
            if(s != ""){
                output[i] = s;
            }else{
                output[i] = "-1";
            }
        }else{
            odds = Array.from(odds);

            list.splice(odds[0],odds[0] + 1);
            while(list.length > 0){
                if(list[0] == 0){
                    list.splice(0,1);
                }else{
                    break;
                }
            }
            if(list.length == 0){
                output[i] = "-1";
            }else{
                output[i] = myconv(list,0);
            }
        }
    }
    myout(myconv(output,9));
}


Levko loves permutations very much. A permutation of length n is a sequence of distinct positive integers, each is at most n.Let’s assume that value gcd(a, b) shows the greatest common divisor of numbers a and b. Levko assumes that element pi of permutation p1, p2, ... , pn is good if gcd(i, pi) > 1. Levko considers a permutation beautiful, if it has exactly k good elements. Unfortunately, he doesn’t know any beautiful permutation. Your task is to help him to find at least one of them.

The single line contains two integers n and k (1 ≤ n ≤ 105, 0 ≤ k ≤ n).

In a single line print either any beautiful permutation or -1, if such permutation doesn’t exist. If there are multiple suitable permutations, you are allowed to print any of them.

NoteIn the first sample elements 4 and 3 are good because gcd(2, 4) = 2 > 1 and gcd(3, 3) = 3 > 1. Elements 2 and 1 are not good because gcd(1, 2) = 1 and gcd(4, 1) = 1. As there are exactly 2 good elements, the permutation is beautiful.The second sample has no beautiful permutations.

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

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

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

function main() {
	var integers = tokenizeIntegers(readline());
	var n = integers[0], good = integers[1];

	if (good == n) {
		print(-1);
		return;
	}

	var perm = [];
	for (var i = 1; i <= n; ++i) {
		perm.push(i);
	}

	var bad = n-good;
	for (var pos = 1; pos < bad; ++pos) {
		perm[pos-1] = pos+1;
		perm[pos] = 1;
	}
	print(perm.join(" "));
}

main();