You are given an array $$$a$$$ consisting of $$$n$$$ positive integers. Find a non-empty subset of its elements such that their sum is even (i.e. divisible by $$$2$$$) or determine that there is no such subset.Both the given array and required subset may contain equal values.

The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 100$$$), number of test cases to solve. Descriptions of $$$t$$$ test cases follow. A description of each test case consists of two lines. The first line contains a single integer $$$n$$$ ($$$1 \leq n \leq 100$$$), length of array $$$a$$$. The second line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$1 \leq a_i \leq 100$$$), elements of $$$a$$$. The given array $$$a$$$ can contain equal values (duplicates).

For each test case output $$$-1$$$ if there is no such subset of elements. Otherwise output positive integer $$$k$$$, number of elements in the required subset. Then output $$$k$$$ distinct integers ($$$1 \leq p_i \leq n$$$), indexes of the chosen elements. If there are multiple solutions output any of them.

NoteThere are three test cases in the example.In the first test case, you can choose the subset consisting of only the second element. Its sum is $$$4$$$ and it is even.In the second test case, there is only one non-empty subset of elements consisting of the first element, however sum in it is odd, so there is no solution.In the third test case, the subset consisting of all array's elements has even sum.

function readStringArray() {
  return readline().split(" ");
}
function readNumArray() {
  return readStringArray().map(Number);
}

function main() {
  var testCasesNum = +readline();
  for (var i = 0; i < testCasesNum; i++) {
    var els = +readline();
    var arr = readNumArray();
    check(arr);
  }
}

function check(arr) {
  if (!arr.length || (arr.length === 1 && arr[0] % 2 === 1)) {
    print(-1);
    return;
  }
  for (var j = 0; j < 2; j++) {
    if (arr[j] % 2 === 0) {
      print(1);
      print(j + 1);
      return;
    } else if (j == 1) {
      print(2);
      print("1 2");
    }
  }
}

main()

function readStrs(){
    return readline().split(" ");
}
function readInts(){
    return readStrs().map(Number);
}
function main(){
    var t = +readline();
    while(t > 0){
        var n = 0 + readline();
        arr = readInts();

        var res = -1;
        var i;
        for(i=0; i<n; i++){
            if(arr[i]%2 === 0){
                res = i + 1;
                break;
            }
        }
        if(res == -1 && n >= 2){
            print("2\n1 2");
        }else if(res == -1){
            print(-1)
        }else{
            print("1\n" + res);
        }
        t = t - 1;
    }

}

main();

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

//Don't have to see. end------------------------------------------
function Main(){
  var t = nextInt();
  var output = [];
  for(var i = 0; i < t; i++){
    var n = nextInt();
    var list = nextIntArray();
    var odd = [];
    var even = [];
    for(var j = 0; j < n; j++){
      if(list[j] % 2 == 0){
        even.push(j + 1);
      }else{
        odd.push(j + 1);
      }
    }
    if(even.length >= 1){
      output.push(even.length);
      output.push(even.join(" "));
    }else if(odd.length >= 2){
      if(odd.length % 2 == 1){
        odd.pop();
      }
      output.push(odd.length);
      output.push(odd.join(" "));
    }else{
      output.push(-1);
    }
  }
  myout(myconv(output, 9));
}

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

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

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

  const arr = d.split(' ').map(Number);
  let prev = -1;
  const ans = [];

  for (let i = 0; i < arr.length; i++) {
    if (arr[i] % 2 === 0) {
      ans.push(i + 1);
    }
    else {
      if (prev === -1) {
        prev = i + 1;
      }
      else {
        ans.push(prev);
        ans.push(i + 1);
        prev = -1;
      }
    }
  }

  if (ans.length === 0) {
    console.log(-1);
  }
  else {
    console.log(ans.length);
    console.log(ans.sort((a , b) => a - b).join(' '));
  }

  c++;
});

const readline = require('readline');

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

let answer = "";

let lines = [];

rl.on('line', (t)=>{
    lines.push(t);
}).on('close', ()=>{
    let t = parseInt(lines[0]);

    for(let i = 0; i < t; i++){
        let n = parseInt(lines[i * 2 + 1]);
        let a = lines[i * 2 + 2].split(" ").map( function (x) {
            return parseInt(x);
        });
        if(a[0] % 2 === 0)
            answer += '1' + '\n' + '1' + '\n';
        else{
            if(n === 1) answer += '-1' + '\n';
            else {
                for(let j = 1; j < n; j++){
                    if(a[j] % 2 !== 0) {
                        answer += '2' + '\n' + '1 ' + (j + 1) + '\n';
                        break;
                    }
                    else{
                        answer += '1' + '\n' + (j + 1) + '\n';
                        break;
                    }
                }
            }
        }
    }

    console.log(answer);

});

const processData = (lines) => {
  const num = +lines[0]
  for (let j =0; j<num; j++) {
    const a = lines[j*2 + 2].split(' ').map(x => +x)
    let prev = null
    let found = false
    for (let k = 0; k<a.length; k++) {
      const n = a[k]
      if (n % 2 === 0) {
        found = true
        console.log(1)
        console.log(k+1)
        break
      }
      if (prev && (prev + n) % 2 === 0){
        found = true
        console.log(2)
        console.log(k, k+1)
        break
      }
      prev = n
    }
    if (!found) {
      console.log(-1)
    }
  }
}

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

const init = () => {
  process.stdin.resume();
  process.stdin.setEncoding('utf-8');

  let inputString = '';
  let currentLine = 0;

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

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

    main();
  });

  global.readline = () => {
    return inputString[currentLine++];
  }
};

if (typeof readline === 'undefined') {
  init();
}

const print = (...args) => {
  console.log(...args);
};

const main = () => {
  let t = parseInt(readline());
  while(t--) {
    const n = parseInt(readline());
    const a = readline().split(' ').map(x => parseInt(x));
    const evens = [];
    const odds = [];
    for (let i = 0; i < n; i++) {
      if (a[i] % 2 === 0) evens.push([a[i], i])
      if (a[i] % 2 === 1) odds.push([a[i], i])
    }
    if (evens.length > 0) {
      print(1);
      print(evens[0][1] + 1);
    } else if (odds.length >= 2) {
      print(2)
      print(odds.slice(0, 2).map(x => x[1] + 1).join(' '));
    } else {
      print(-1);
    }
  }
};

function main(raw) {
    var lines = raw.trim().split("\n").map(function (l) { return l.split(" ").map(function (u) { return parseInt(u, 10); }); });
    var t = lines.shift()[0];
    while (t > 0) {
        var n = lines.shift()[0];
        var a = lines.shift();
        var odds = [];
        var evn = [];
        var i = 0;
        while (odds.length < 2 && i < n && evn.length === 0) {
            if (a[i] % 2 === 1) {
                odds.push(i + 1);
            }
            else {
                evn.push(i + 1);
            }
            i++;
        }
        if (evn.length > 0) {
            console.log(1);
            console.log(evn[0]);
        }
        else if (odds.length < 2) {
            console.log("-1");
        }
        else {
            console.log(odds.length);
            console.log(odds.join(" "));
        }
        t--;
    }
}
(function () {
    var d = "";
    process.stdin.on("data", function (c) { return d += c; });
    process.stdin.on("end", function () { return main(d); });
})();


Alice is playing with some stones.Now there are three numbered heaps of stones. The first of them contains $$$a$$$ stones, the second of them contains $$$b$$$ stones and the third of them contains $$$c$$$ stones.Each time she can do one of two operations:  take one stone from the first heap and two stones from the second heap (this operation can be done only if the first heap contains at least one stone and the second heap contains at least two stones);  take one stone from the second heap and two stones from the third heap (this operation can be done only if the second heap contains at least one stone and the third heap contains at least two stones). She wants to get the maximum number of stones, but she doesn't know what to do. Initially, she has $$$0$$$ stones. Can you help her?

The first line contains one integer $$$t$$$ ($$$1 \leq t \leq 100$$$)  — the number of test cases. Next $$$t$$$ lines describe test cases in the following format: Line contains three non-negative integers $$$a$$$, $$$b$$$ and $$$c$$$, separated by spaces ($$$0 \leq a,b,c \leq 100$$$) — the number of stones in the first, the second and the third heap, respectively. In hacks it is allowed to use only one test case in the input, so $$$t = 1$$$ should be satisfied.

Print $$$t$$$ lines, the answers to the test cases in the same order as in the input. The answer to the test case is the integer  — the maximum possible number of stones that Alice can take after making some operations.

NoteFor the first test case in the first test, Alice can take two stones from the second heap and four stones from the third heap, making the second operation two times. Then she can take one stone from the first heap and two stones from the second heap, making the first operation one time. The summary number of stones, that Alice will take is $$$9$$$. It is impossible to make some operations to take more than $$$9$$$ stones, so the answer is $$$9$$$.

'use strict'

const problem = (a, b, c) => {
    if (c >= 2 * b) return 3 * b;
    b -= c / 2 | 0;
    if (b >= 2 * a) return 3 * (a + c / 2 | 0);
    return 3 * ((b / 2 | 0) + (c / 2 | 0));
}

const t = +readline();

for (let i = 0; i < t; i++) {
    const x = readline().split(' ').map(Number);
    print(problem(x[0], x[1], x[2]));
}

var queries = parseInt(readline());

function main(query) {
  var sum = 0;

  if (query[2] > (query[1].length * 2) - 1) {
      return write((3*query[1]) + '\n');
  } else {
    var add = Math.min(Math.floor(query[2]/2), query[1]);
    sum += add*3;
    query[1] -= add;
    if (query[1] > (query[0] * 2) - 1) {
      return write((3*query[0] + sum) + '\n');
    } else {
      return write (sum + (3 * Math.min(Math.floor(query[1]/2), query[0])) + '\n')
    }
  }
}

// main([1, 4, 2])

for (var i = 0; i < queries; i++) {
  var query = readline().split(' ').map(function(num) {
    return parseInt(num);
  })
  main(query)
}

 var _t = readline();
    var t = parseInt(_t);

    for(var _=0;_<t;_++)
    {
        var Heap = readline().split(" ").map(function(x) { return parseInt(x); });
        var _Heap = Heap.slice();

        var count = 0;
        var _count;

       // print(Heap);
        while(Heap[2]-2>=0&&Heap[1]-1>=0)
        {
            count+=3;
            Heap[2]-=2;
            Heap[1]-=1;
           // print(`1: ${Heap} ${_Heap}`)
        }
        while(Heap[1]-2>=0&&Heap[0]-1>=0)
        {
            count+=3;
            Heap[1]-=2;
            Heap[0]-=1;
           // print(`2: ${Heap}`)
        }
       // print(`${count}`)
        _count = count;
        count=0;
        Heap=_Heap;

        while(Heap[1]-2>=0&&Heap[0]-1>=0)
        {
            count+=3;
            Heap[1]-=2;
            Heap[0]-=1;
           // print(`3: ${Heap}`)
        }

        while(Heap[2]-2>=0&&Heap[1]-1>=0)
        {
            count+=3;
            Heap[2]-=2;
            Heap[1]-=1;
           // print(`4: ${Heap}`)
        }
       // print(`${count}`)

        if(count<_count)count = _count;
        print (count);

    }

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

//Don't have to see. end------------------------------------------
function Main(){
  var t = nextInt();
  var output = new Array(t);
  for(var i = 0; i < t; i++){
    var one = nextIntArray();
    var count = 0;
    while(one[1] > 0 && one[2] > 1){
      one[1]--;
      one[2] -= 2;
      count += 3;
    }
    while(one[0] > 0 && one[1] > 1){
      one[0]--;
      one[1] -= 2;
      count += 3;
    }
    output[i] = count;
  }
  myout(myconv(output, 9));
}

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

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

  let [a, b, c] = d.split(' ').map(Number);
  let ans = 0;

  while (b > 0 && c > 1) {
    b -= 1;
    c -= 2;

    ans += 3;
  }

  while (a > 0 && b > 1) {
    a -= 1;
    b -= 2;

    ans += 3;
  }

  console.log(ans);

  count++;
});

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

function sol() {
  const [[T], ...S] = input
    .split('\n')
    .map(line => line
      .split(' ')
      .map(Number));

  const result = [];

  for (let i = 0; i < T; ++i) {
    const [a, b, c] = S[i];
    let Y = Math.floor(c / 2);
    if (b < Y) Y = b;
    let X = Math.floor((b - Y) / 2);
    if (a < X) X = a;
    result.push(3 * (X + Y));
  }

  process.stdout.write(
    result.join('\n'),
    'utf8',
    () => process.stdout.end()
  );
}

'use strict'

const problem = (a, b, c) => {
    if (c >= 2 * b) return 3 * b;
    b -= c / 2 | 0;
    if (b >= 2 * a) return 3 * (a + c / 2 | 0);
    return 3 * ((b / 2 | 0) + (c / 2 | 0));
}

const t = +readline();

for (let i = 0; i < t; i++) {
    print(problem(+readline(), +readline(), +readline()));
}

var queries = parseInt(readline());

function main(query) {
  var sum = 0;

  if (query[2] > (query[1].length * 2) - 1) {
      return write((3*query[1]) + '\n');
  } else {
    var add = Math.min(Math.floor(query[2]/2), query[1]);
    sum += add*3;
    query[1] -= add;
    if (query[1] > (query[0] * 2) - 1) {
      return write((3*query[1] + sum) + '\n');
    } else {
      return write (sum + (3 * Math.min(Math.floor(query[1]/2), query[0])) + '\n')
    }
  }
}

// main([5, 3, 2])

for (var i = 0; i < queries; i++) {
  var query = readline().split(' ').map(function(num) {
    return parseInt(num);
  })
  main(query)
}

var queries = parseInt(readline());

function main(query) {
  var sum = 0;

  if (query[2] > (query[1].length * 2) - 1) {
      return write((3*query[1]) + '\n');
  } else {
    var add = Math.min(Math.floor(query[2]/2), query[1]);
    sum += add*3;
    query[1] -= add;
    if (query[1] > (query[0].length * 2) - 1) {
      return write((3*query[1] + sum) + '\n');
    } else {
      return write (sum + (3 * Math.floor(query[1]/2)) + '\n')
    }
  }
}

// main([5, 3, 2])

for (var i = 0; i < queries; i++) {
  var query = readline().split(' ').map(function(num) {
    return parseInt(num);
  })
  main(query)
}

   var t =readline().split("").map(function(x) { return parseInt(x); });

    for(var _=0;_<t[0];_++)
    {
        var Heap = readline().split(" ").map(function(x) { return parseInt(x); });

        var a=Heap[0];
        var b=Heap[1];
        var c =Heap[2];
        var count = 0;
        var comp=0;

            if(b>=Math.floor(c/2))
            {
                count+= 3*Math.floor(c/2);
                b=b-Math.floor(c/2);
                c=c-2*Math.floor(c/2);
            }

            if(a>=Math.floor(b/2))
            {
                count+= 3*Math.floor(b/2);
                a=a-Math.floor(b/2);
                b=b-2*Math.floor(b/2);

            }
            comp = count;
            a=Heap[0];
            b=Heap[1];
            c =Heap[2];
            count = 0;

            if(a>=Math.floor(b/2))
            {
                count+= 3*Math.floor(b/2);
                a=a-Math.floor(b/2);
                b=b-2*Math.floor(b/2);

            }

            if(b>=Math.floor(c/2))
            {
                count+= 3*Math.floor(c/2);
                b=b-Math.floor(c/2);
                c=c-2*Math.floor(c/2);

            }
            if(comp>count)count=comp;

        print(count);

    }

 var _t = readline();
    var t = parseInt(_t);

    for(var _=0;_<t;_++)
    {
        var Heap = readline().split(" ").map(function(x) { return parseInt(x); });
        var _Heap = Heap.slice();

        var count = 0;
        var _count;

        print(Heap);
        while(Heap[2]>1&&Heap[1]>0)
        {
            count+=3;
            Heap[2]-=2;
            Heap[1]-=1;
            print(`1: ${Heap} ${_Heap}`)
        }
        while(Heap[1]>1&&Heap[0]>0)
        {
            count+=3;
            Heap[1]-=2;
            Heap[0]-=1;
            print(`2: ${Heap}`)
        }
        print(`${count}`)
        _count = count;
        count=0;
        Heap=_Heap;

        while(Heap[1]>1&&Heap[0]>0)
        {
            count+=3;
            Heap[1]-=2;
            Heap[0]-=1;
            print(`3: ${Heap}`)
        }

        while(Heap[2]>0&&Heap[1]>1)
        {
            count+=3;
            Heap[2]-=2;
            Heap[1]-=1;
            print(`4: ${Heap}`)
        }
        print(`${count}`)

        if(count<_count)count = _count;
        print (count);

    }

 var t =readline().split("").map(function(x) { return parseInt(x); });

    for(var _=0;_<t[0];_++)
    {
        var Heap = readline().split(" ").map(function(x) { return parseInt(x); });

        var count = 0;

        while(Heap[2]>1&&Heap[1]>1)
        {
            count+=3;
            Heap[2]-=2;
            Heap[1]-=1;
        }

        while(Heap[1]>1&&Heap[0]>1)
        {
            count+=3;
            Heap[1]-=2;
            Heap[0]-=1;
        }

        print (count);

    }

 var _t = readline();
    var t = parseInt(_t);

    for(var _=0;_<t;_++)
    {
        var Heap = readline().split(" ").map(function(x) { return parseInt(x); });
        var _Heap = Heap.slice();

        var count = 0;
        var _count;

       // print(Heap);
        while(Heap[2]>1&&Heap[1]>0)
        {
            count+=3;
            Heap[2]-=2;
            Heap[1]-=1;
           // print(`1: ${Heap} ${_Heap}`)
        }
        while(Heap[1]>1&&Heap[0]>0)
        {
            count+=3;
            Heap[1]-=2;
            Heap[0]-=1;
           // print(`2: ${Heap}`)
        }
       // print(`${count}`)
        _count = count;
        count=0;
        Heap=_Heap;

        while(Heap[1]>1&&Heap[0]>0)
        {
            count+=3;
            Heap[1]-=2;
            Heap[0]-=1;
          //  print(`3: ${Heap}`)
        }

        while(Heap[2]>0&&Heap[1]>1)
        {
            count+=3;
            Heap[2]-=2;
            Heap[1]-=1;
          //  print(`4: ${Heap}`)
        }
       // print(`${count}`)

        if(count<_count)count = _count;
        print (count);

    }

    var _t = readline();
    var t = parseInt(_t);

    for(var _=0;_<t[0];_++)
    {
        var Heap = readline().split(" ").map(function(x) { return parseInt(x); });
        var _Heap = Heap.slice();

        var count = 0;
        var _count;

       // print(Heap);
        while(Heap[2]>1&&Heap[1]>0)
        {
            count+=3;
            Heap[2]-=2;
            Heap[1]-=1;
          //  print(`1: ${Heap} ${_Heap}`)
        }
        while(Heap[1]>1&&Heap[0]>0)
        {
            count+=3;
            Heap[1]-=2;
            Heap[0]-=1;
            print(`2: ${Heap}`)
        }
        //print(`${count}`)
        _count = count;
        count=0;
        Heap=_Heap;

        while(Heap[1]>1&&Heap[0]>0)
        {
            count+=3;
            Heap[1]-=2;
            Heap[0]-=1;
           // print(`3: ${Heap}`)
        }

        while(Heap[2]>0&&Heap[1]>1)
        {
            count+=3;
            Heap[2]-=2;
            Heap[1]-=1;
          //  print(`4: ${Heap}`)
        }
      //  print(`${count}`)

        if(count<_count)count = _count;
        print (count);

    }

var t =readline().split("").map(function(x) { return parseInt(x); });

    for(var _=0;_<t[0];_++)
    {
        var Heap = readline().split(" ").map(function(x) { return parseInt(x); });

        var a=Heap[0];
        var b=Heap[1];
        var c =Heap[2];
        var count = 0;

        if(a<b)
        {
            if(b>=Math.floor(c/2))
            {
                count+= 3*Math.floor(c/2);
                b=b-Math.floor(c/2);
                c=c-2*Math.floor(c/2);
            }

            if(a>=Math.floor(b/2))
            {
                count+= 3*Math.floor(b/2);
                a=a-Math.floor(b/2);
                b=b-2*Math.floor(b/2);

            }
        }
        else
        {
            if(a>=Math.floor(b/2))
            {
                count+= 3*Math.floor(b/2);
                a=a-Math.floor(b/2);
                b=b-2*Math.floor(b/2);

            }

            if(b>=Math.floor(c/2))
            {
                count+= 3*Math.floor(c/2);
                b=b-Math.floor(c/2);
                c=c-2*Math.floor(c/2);

            }

        }

        print(count);

    }

 var t =readline().split("").map(function(x) { return parseInt(x); });

    for(var _=0;_<t[0];_++)
    {
        var Heap = readline().split(" ").map(function(x) { return parseInt(x); });
        var _Heap = Heap.slice();

        var count = 0;
        var _count;

       // print(Heap);
        while(Heap[2]>1&&Heap[1]>0)
        {
            count+=3;
            Heap[2]-=2;
            Heap[1]-=1;
           // print(`1: ${Heap} ${_Heap}`)
        }
        while(Heap[1]>1&&Heap[0]>0)
        {
            count+=3;
            Heap[1]-=2;
            Heap[0]-=1;
            //print(`2: ${Heap}`)
        }
        //print(`${count}`)
        _count = count;
        count=0;
        Heap=_Heap;

        while(Heap[1]>1&&Heap[0]>0)
        {
            count+=3;
            Heap[1]-=2;
            Heap[0]-=1;
            //print(`3: ${Heap}`)
        }

        while(Heap[2]>0&&Heap[1]>1)
        {
            count+=3;
            Heap[2]-=2;
            Heap[1]-=1;
           // print(`4: ${Heap}`)
        }
       // print(`${count}`)

        if(count<_count)count = _count;
        print (count);

    }


A number is called 2050-number if it is $$$2050$$$, $$$20500$$$, ..., ($$$2050 \cdot 10^k$$$ for integer $$$k \ge 0$$$).Given a number $$$n$$$, you are asked to represent $$$n$$$ as the sum of some (not necessarily distinct) 2050-numbers. Compute the minimum number of 2050-numbers required for that.

The first line contains a single integer $$$T$$$ ($$$1\le T\leq 1\,000$$$) denoting the number of test cases. The only line of each test case contains a single integer $$$n$$$ ($$$1\le n\le 10^{18}$$$) denoting the number to be represented.

For each test case, output the minimum number of 2050-numbers in one line.  If $$$n$$$ cannot be represented as the sum of 2050-numbers, output $$$-1$$$ instead.

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

let inputString = '';
let currentLine = 0;

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

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

    main();
});

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

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

    for(let i = 0; i < n; i++){
        let t = BigInt(readline());

        if(t % 2050n != 0n) console.log(-1);
        else{
            let product = String(t / 2050n);
            let sum = 0;
            for(let num of product) {
                sum += Number(num);
            }
            console.log(sum);
        }
    }
}

/******/ (() => { // webpackBootstrap
/******/ 	"use strict";
/******/ 	var __webpack_modules__ = ({

/***/ 747:
/***/ ((module) => {

module.exports = require("fs");;

/***/ })

/******/ 	});
/************************************************************************/
/******/ 	// The module cache
/******/ 	var __webpack_module_cache__ = {};
/******/
/******/ 	// The require function
/******/ 	function __webpack_require__(moduleId) {
/******/ 		// Check if module is in cache
/******/ 		var cachedModule = __webpack_module_cache__[moduleId];
/******/ 		if (cachedModule !== undefined) {
/******/ 			return cachedModule.exports;
/******/ 		}
/******/ 		// Create a new module (and put it into the cache)
/******/ 		var module = __webpack_module_cache__[moduleId] = {
/******/ 			// no module.id needed
/******/ 			// no module.loaded needed
/******/ 			exports: {}
/******/ 		};
/******/
/******/ 		// Execute the module function
/******/ 		__webpack_modules__[moduleId](module, module.exports, __webpack_require__);
/******/
/******/ 		// Return the exports of the module
/******/ 		return module.exports;
/******/ 	}
/******/
/************************************************************************/
/******/ 	/* webpack/runtime/compat get default export */
/******/ 	(() => {
/******/ 		// getDefaultExport function for compatibility with non-harmony modules
/******/ 		__webpack_require__.n = (module) => {
/******/ 			var getter = module && module.__esModule ?
/******/ 				() => (module['default']) :
/******/ 				() => (module);
/******/ 			__webpack_require__.d(getter, { a: getter });
/******/ 			return getter;
/******/ 		};
/******/ 	})();
/******/
/******/ 	/* webpack/runtime/define property getters */
/******/ 	(() => {
/******/ 		// define getter functions for harmony exports
/******/ 		__webpack_require__.d = (exports, definition) => {
/******/ 			for(var key in definition) {
/******/ 				if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
/******/ 					Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
/******/ 				}
/******/ 			}
/******/ 		};
/******/ 	})();
/******/
/******/ 	/* webpack/runtime/hasOwnProperty shorthand */
/******/ 	(() => {
/******/ 		__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
/******/ 	})();
/******/
/************************************************************************/
var __webpack_exports__ = {};
// This entry need to be wrapped in an IIFE because it need to be isolated against other modules in the chunk.
(() => {

// EXTERNAL MODULE: external "fs"
var external_fs_ = __webpack_require__(747);
var external_fs_default = /*#__PURE__*/__webpack_require__.n(external_fs_);
;// CONCATENATED MODULE: ./src/lib/io.ts

class IO {
  constructor() {
    this.i = 0;
    this.text = void 0;
    this.out = '';
    this.text = __webpack_require__(747).readFileSync(0, 'utf8');
  }

  nextToken() {
    let ret = '';

    while (this.text[this.i].charCodeAt(0) <= 32) {
      this.i++;
    }

    while (this.i < this.text.length && this.text[this.i].charCodeAt(0) > 32) {
      ret += this.text[this.i];
      this.i++;
    }

    return ret;
  }

  nextNum() {
    return Number(this.nextToken());
  }

  nextBigInt() {
    return BigInt(this.nextToken());
  }

  nextNumArray(n) {
    let ret = [];

    while (n--) {
      ret.push(this.nextNum());
    }

    return ret;
  }

  _write(x) {
    this.out += x;
  }

  write(x) {
    this._write(x + ' ');
  }

  writeLine(x) {
    this._write(x + '\n');
  }

  flush() {
    external_fs_default().writeFileSync(1, this.out);
    this.out = '';
  }

}
;// CONCATENATED MODULE: ./src/cf-1517/1517-a.ts
 //////////// LIBS

const io = new IO();

function solve(n) {
  let ret = 0n;
  let max = 2050n * 10n ** 15n;

  for (let k = 15; k >= 0; k--, max /= 10n) {
    let count = n / max;
    ret += count;
    n %= max;
  }

  if (n) {
    io.writeLine(-1);
  } else {
    io.writeLine(ret.toString());
  }
}

function main() {
  try {
    var _t;

    let t = io.nextNum();
    let x = (_t = t) !== null && _t !== void 0 ? _t : 2;

    while (t--) {
      let n = io.nextBigInt();
      solve(n);
    }

    io.flush();
  } catch (e) {
    console.log(e.stack);
  }
}

main();

})();

/******/ })()
;

"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const fs_1 = __importDefault(require("fs"));
//////////// LIBS
class IO {
    constructor() {
        this.i = 0;
        this.out = '';
        this.text = require('fs').readFileSync(0, 'utf8');
    }
    nextToken() {
        let ret = '';
        while (this.text[this.i].charCodeAt(0) <= 32) {
            this.i++;
        }
        while (this.i < this.text.length && this.text[this.i].charCodeAt(0) > 32) {
            ret += this.text[this.i];
            this.i++;
        }
        return ret;
    }
    nextNum() {
        return Number(this.nextToken());
    }
    nextBigInt() {
        return BigInt(this.nextToken());
    }
    nextNumArray(n) {
        let ret = [];
        while (n--) {
            ret.push(this.nextNum());
        }
        return ret;
    }
    _write(x) {
        this.out += x;
    }
    write(x) {
        this._write(x + ' ');
    }
    writeLine(x) {
        this._write(x + '\n');
    }
    flush() {
        fs_1.default.writeFileSync(1, this.out);
        this.out = '';
    }
}
function binarySearch(array, pred) {
    let lo = -1, hi = array.length;
    while (1 + lo < hi) {
        const mi = lo + ((hi - lo) >> 1);
        if (pred(array[mi])) {
            hi = mi;
        }
        else {
            lo = mi;
        }
    }
    return hi;
}
function lowerBound(array, item) {
    return binarySearch(array, (j) => item <= j);
}
function upperBound(array, item) {
    return binarySearch(array, (j) => item < j);
}
//////////// LIBS
const io = new IO();
function solve(n) {
    let ret = 0n;
    let max = 2050n * 10n ** 15n;
    for (let k = 15; k >= 0; k--, max /= 10n) {
        let count = n / max;
        ret += count;
        n %= max;
    }
    if (n) {
        io.writeLine(-1);
    }
    else {
        io.writeLine(ret.toString());
    }
}
function main() {
    try {
        let t = io.nextNum();
        while (t--) {
            let n = io.nextBigInt();
            solve(n);
        }
        io.flush();
    }
    catch (e) {
        console.log(e.stack);
    }
}
main();

"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const fs_1 = __importDefault(require("fs"));
//////////// LIBS
class IO {
    constructor() {
        this.i = 0;
        this.out = '';
        this.text = require('fs').readFileSync(0, 'utf8');
    }
    nextToken() {
        let ret = '';
        while (this.text[this.i].charCodeAt(0) <= 32) {
            this.i++;
        }
        while (this.i < this.text.length && this.text[this.i].charCodeAt(0) > 32) {
            ret += this.text[this.i];
            this.i++;
        }
        return ret;
    }
    nextNum() {
        return Number(this.nextToken());
    }
    nextBigInt() {
        return BigInt(this.nextToken());
    }
    nextNumArray(n) {
        let ret = [];
        while (n--) {
            ret.push(this.nextNum());
        }
        return ret;
    }
    _write(x) {
        this.out += x;
    }
    write(x) {
        this._write(x + ' ');
    }
    writeLine(x) {
        this._write(x + '\n');
    }
    flush() {
        fs_1.default.writeFileSync(1, this.out);
        this.out = '';
    }
}
function binarySearch(array, pred) {
    let lo = -1, hi = array.length;
    while (1 + lo < hi) {
        const mi = lo + ((hi - lo) >> 1);
        if (pred(array[mi])) {
            hi = mi;
        }
        else {
            lo = mi;
        }
    }
    return hi;
}
function lowerBound(array, item) {
    return binarySearch(array, (j) => item <= j);
}
function upperBound(array, item) {
    return binarySearch(array, (j) => item < j);
}
//////////// LIBS
const io = new IO();
function solve(n) {
    let ret = 0;
    let max = 2050n * 10n ** 15n;
    for (let k = 15; k >= 0; k--, max /= 10n) {
        while (n >= max) {
            n -= max;
            ret++;
        }
    }
    if (n) {
        io.writeLine(-1);
    }
    else {
        io.writeLine(ret);
    }
}
function main() {
    try {
        let t = io.nextNum();
        while (t--) {
            let n = io.nextBigInt();
            solve(n);
        }
        io.flush();
    }
    catch (e) {
        console.log(e.stack);
    }
}
main();

"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const fs_1 = __importDefault(require("fs"));
//////////// LIBS
class IO {
    constructor() {
        this.i = 0;
        this.out = '';
        this.text = require('fs').readFileSync(0, 'utf8');
    }
    nextToken() {
        let ret = '';
        while (this.text[this.i].charCodeAt(0) <= 32) {
            this.i++;
        }
        while (this.i < this.text.length && this.text[this.i].charCodeAt(0) > 32) {
            ret += this.text[this.i];
            this.i++;
        }
        return ret;
    }
    nextNum() {
        return Number(this.nextToken());
    }
    nextBigInt() {
        return BigInt(this.nextToken());
    }
    nextNumArray(n) {
        let ret = [];
        while (n--) {
            ret.push(this.nextNum());
        }
        return ret;
    }
    _write(x) {
        this.out += x;
    }
    write(x) {
        this._write(x + ' ');
    }
    writeLine(x) {
        this._write(x + '\n');
    }
    flush() {
        fs_1.default.writeFileSync(1, this.out);
        this.out = '';
    }
}
function binarySearch(array, pred) {
    let lo = -1, hi = array.length;
    while (1 + lo < hi) {
        const mi = lo + ((hi - lo) >> 1);
        if (pred(array[mi])) {
            hi = mi;
        }
        else {
            lo = mi;
        }
    }
    return hi;
}
function lowerBound(array, item) {
    return binarySearch(array, (j) => item <= j);
}
function upperBound(array, item) {
    return binarySearch(array, (j) => item < j);
}
//////////// LIBS
const io = new IO();
function solve(n) {
    let ret = 0;
    for (let k = BigInt(15); k >= 0; k--) {
        let p = 2050n * 10n ** k;
        while (n >= p) {
            n -= p;
            ret++;
        }
    }
    if (n) {
        io.writeLine(-1);
    }
    else {
        io.writeLine(ret);
    }
}
function main() {
    try {
        let t = io.nextNum();
        while (t--) {
            let n = io.nextBigInt();
            solve(n);
        }
        io.flush();
    }
    catch (e) {
        console.log(e.stack);
    }
}
main();

"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const fs_1 = __importDefault(require("fs"));
//////////// LIBS
class IO {
    constructor() {
        this.i = 0;
        this.out = '';
        this.text = require('fs').readFileSync(0, 'utf8');
    }
    nextToken() {
        let ret = '';
        while (this.text[this.i].charCodeAt(0) <= 32) {
            this.i++;
        }
        while (this.i < this.text.length && this.text[this.i].charCodeAt(0) > 32) {
            ret += this.text[this.i];
            this.i++;
        }
        return ret;
    }
    nextNum() {
        return Number(this.nextToken());
    }
    nextBigInt() {
        return BigInt(this.nextToken());
    }
    nextNumArray(n) {
        let ret = [];
        while (n--) {
            ret.push(this.nextNum());
        }
        return ret;
    }
    _write(x) {
        this.out += x;
    }
    write(x) {
        this._write(x + ' ');
    }
    writeLine(x) {
        this._write(x + '\n');
    }
    flush() {
        fs_1.default.writeFileSync(1, this.out);
        this.out = '';
    }
}
function binarySearch(array, pred) {
    let lo = -1, hi = array.length;
    while (1 + lo < hi) {
        const mi = lo + ((hi - lo) >> 1);
        if (pred(array[mi])) {
            hi = mi;
        }
        else {
            lo = mi;
        }
    }
    return hi;
}
function lowerBound(array, item) {
    return binarySearch(array, (j) => item <= j);
}
function upperBound(array, item) {
    return binarySearch(array, (j) => item < j);
}
//////////// LIBS
const io = new IO();
function solve(n) {
    let ret = 0;
    for (let k = 15; k >= 0; k--) {
        let p = 2050n * 10n ** BigInt(k);
        while (n >= p) {
            n -= p;
            ret++;
        }
    }
    if (n) {
        io.writeLine(-1);
    }
    else {
        io.writeLine(ret);
    }
}
function main() {
    try {
        let t = io.nextNum();
        while (t--) {
            let n = io.nextBigInt();
            solve(n);
        }
        io.flush();
    }
    catch (e) {
        console.log(e.stack);
    }
}
main();

let input = '';
process.stdin.on('data', str => input += str)
process.stdin.on('end', () => {
	const lines = input.trim().split('\n').slice(1);

	for (let i=0; i<lines.length; i++) {
		let num = BigInt(lines[i].trim());

		if (num === BigInt(0)) {
			console.log(-1);
			continue;
		}

		let count = 0;
		while (num > BigInt(0)) {
			let mult = BigInt(2050);
			const len = num.toString().length-4;

			if (len > 0) {
				mult = BigInt(2050 * (10**len));

				if (num < mult) {
					mult = BigInt(2050 * (10**(len-1)));
				}
			}

			num -= BigInt(mult);
			count++;
		}

		if (num === BigInt(0)) {
			console.log(count);
		} else {
			console.log(-1);
		}
	}
})

const readline = require("readline");
const rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
})
let input = [];
rl.on('line', line => {
    input.push(line);
})
rl.on('close', line => {
    var t = Number(input[0]);
    for (var k = 1; k < input.length; k++) {
        var n = BigInt(input[k]);
        var mod = BigInt(2050);
        if (n % mod !== BigInt(0)) {
            console.log(-1);
            continue;
        }
        var count = n / mod;
        var str = count.toString();
        var result = 0;
        for (var i = 0; i < str.length; i++) {
            result += Number(str[i]);
        }
        console.log(result);
    }
});

'use-strict'

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

let data = '';
let currentLine = 0;

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

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

    let testCases = parseInt(readLine());
    while(testCases--)
    {
        let n = BigInt(readLine());
        n % 2050n === 0n ? print((n/2050n).toString().split('').map(Number).reduce((a,b) => a + b)) : print(-1);
    }
});

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

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

function print(c){
    return console.log(c)
}

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

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

let count = -1
let inputArr = []

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

function solve(num) {
    if (num < 2050n) {
        console.log('-1')
        return
    }
    if (num % 2050n != 0) {
        console.log('-1')
        return
    }
    let count = 0n
    while (num) {
        let a = 2050n
        while (a < num) a *= 10n
        if (a != num) a /= 10n
        num -= a
        count++
    }
    console.log(count.toString())
}

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

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

function* nextLine() {
	let lines = data.trim().split(/\n/g);
	for(let l of lines){
		yield l.trim();
	}
}

let nl = nextLine();

nl.elem = function(funParse) {
		return funParse(this.next().value);
	};

nl.array = function(funParse) {
		return this.next().value.split(/\s/g).map(funParse||(x => x));
	};

nl.num = function() {
		return nl.elem(Number);
	};

nl.nums = function() {
		return nl.array(Number);
	};

nl.line = function() {
		return this.next().value;
	};

const sol = () => {
	//your code this
	let t = nl.num();
	let ans = [];
	for(let i = 0; i < t; i++){
		let x = nl.elem(BigInt);
		let cnt = 0;
		for(let y = 2050n * (10n ** 18n); y >= 2050n; y /= 10n){
			while (x >= y) {
				x -= y;
				cnt++;
			}
		}
		ans.push(x > 0?-1:cnt);

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

process.stdin.on('end', sol);

'use strict';

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

let inputString = '';
let currentLine = 0;

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

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

  main();
});

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

var maxN = 2 * 1e5 + 10
var mod = 1e9 + 7

function main() {
  const xx = readline();
  Array(Number(xx)).fill(1).map((t, i) => {
    var n = BigInt(readline());
    // var [n, k] = readline().split(' ').map((x, iii) => {
    //   return parseInt(x)
    // })
    // var a = readline().split(' ').map((x, iii) => {
    //   return parseInt(x)
    // })
    var array = new Array(18)
    var value = 2050n
    for (let j = 0; j < 18; j++) {
      array[j] = value
      value *= 10n
    }
    var i = 17
    var ans = 0
    while (n > 0 && i>=0) {

      while (n >= array[i]) {
        ans++
        n -= array[i]
      }
      // console.log(i, n, array[i])
      i--
    }
if(n!==0n) return console.log(-1)
    console.log(ans)
  })
}

var t = parseInt(readline());

for(i = 0; i < t; i++) {
    var n = readline();
    if(n.length > 12) {
        var temp = Math.floor(n / Math.pow(10, 9));
        var div = Math.floor(temp / 2050);
        if(((temp % 2050) * Math.pow(10, 9) + parseInt(n.slice(n.length - 9, n.length))) % 2050 !== 0) print(-1);
        else {
            var sum = 0;
            for(j = 0; j <= Math.log10(div); j++) {
                sum += Math.floor((div / Math.pow(10, j))) % 10;
            }
            n = parseInt(n.slice(n.length - 9, n.length));
            n += (temp % 2050) * Math.pow(10, 9);
            if(n % 2050 !== 0) print(-1);
            else {
                n /= 2050;
                for(j = 0; j <= Math.log10(n); j++) {
                    sum += Math.floor((n / Math.pow(10, j))) % 10;
                }
                print(sum);
            }
        }
    }
    else if(n % 2050 !== 0) print(-1);
    else {
        n /= 2050;
        var sum = 0;
        for(j = 0; j <= Math.log10(n); j++) {
            sum += Math.floor((n / Math.pow(10, j))) % 10;
        }
        print(sum);
    }
}

var testCount = parseInt(readline());
for (var i = 0; i < testCount; i++) {
    var n = readline();
    print(compute(n));
    //console.debug(i, n, compute(n))
}
function compute(nstr) {
    var digits = nstr.split('');
    var m = 0, r = 0;
    while (digits.length > 0) {
        m = m * 10 + parseInt(digits.shift());
        var _a = divide(m), div_1 = _a[0], rest_1 = _a[1];
        r += div_1;
        m = rest_1;
    }
    var _b = divide(m), div = _b[0], rest = _b[1];
    if (rest > 0)
        return -1;
    return r + div;
}
function divide(n) {
    var div = Math.floor(n / 2050);
    return [div, n - (div * 2050)];
}

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

let inputString = '';
let currentLine = 0;

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

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

    main();
});

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

/*
function main(){
    const n = Number(readline());

    for(let i = 0; i < n; i++){
        const t = Number(readline());
        if(t < 2050) console.log(-1);
        else {
            const product = String(t / 2050);
            let sum = 0;
            for(let num of product){
                sum += Number(num);
            }
            console.log(sum || -1);
        }
    }
}

*/

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

    for(let i = 0; i < n; i++){
        let t = Number(readline());

        if(t % 2050 != 0) console.log(-1);
        else {
            let product = Math.floor(t/ 2050);
            let sum = 0;
            while(product >= 1){
                sum += product % 10;
                product = Math.floor(product / 10);
            }
            console.log(sum);
        }
    }
}

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

let inputString = '';
let currentLine = 0;

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

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

    main();
});

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

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

    for(let i = 0; i < n; i++){
        const t = Number(readline());
        if(t < 2050) console.log(-1);
        else {
            const product = String(t / 2050);
            let sum = 0;
            for(let num of product){
                sum += Number(num);
            }
            console.log(sum || -1);
        }
    }
}

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

let inputString = '';
let currentLine = 0;

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

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

    main();
});

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

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

    for(let i = 0; i < n; i++){
        const t = Number(readline());
        if(t < 2050) console.log(-1);
        else {
            const product = String(t / 2050);
            let sum = 0;
            for(let num of product){
                sum += Number(num);
            }
            console.log(sum);
        }
    }
}

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

let inputString = '';
let currentLine = 0;

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

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

    main();
});

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

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

    for(let i = 0; i < n; i++){
        const t = Number(readline());
        if(t % 2050 != 0) console.log(-1);
        else {
            const product = String(t / 2050);
            let sum = 0;
            for(let num of product){
                sum += Number(num);
            }
            console.log(sum);
        }
    }
}

// cat input.txt | node problem1.js
process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';
let currentLine = 0;

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

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

    main();
});

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

/*
function main(){
    const n = Number(readline());
    for(let i = 0 ; i < n ; i++){
        let t = readline();
        let counter = 0;

        console.log(t);
        while(Number(t) >= 2050){
            let sub = 2050 * 10**(t.length - 4);
            t = String(Number(t) >= sub ? Number(t) - sub : Number(t) - (sub/10));
            counter++;
        }
        if(t == 0) console.log(counter);
        else console.log(-1);
    }
} */

function main(){
    const n = Number(readline());
    for(let i = 0 ; i < n ; i++){
        let t = Number(readline());
        let abs = t / 2050;

        let counter = 0;

        if(t % 2050 != 0) console.log(-1);
        else {
            for(let char of String(abs)){
                counter += Number(char);
            }
            console.log(counter);
        }
    }
}

// cat input.txt | node problem1.js
process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';
let currentLine = 0;

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

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

    main();
});

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

function main(){
    const n = Number(readline());
    for(let i = 0 ; i < n ; i++){
        let t = readline();
        let counter = 0;
        while(Number(t) >= 2050){
            let sub = 2050 * 10**(t.length - 4);
            t = String(Number(t) >= sub? Number(t) - sub : Number(t) - (sub/10));
            counter++;
        }
        if(t == 0) console.log(counter);
        else console.log(-1);
    }
}

"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const fs_1 = __importDefault(require("fs"));
//////////// LIBS
class IO {
    constructor() {
        this.i = 0;
        this.out = '';
        this.text = require('fs').readFileSync(0, 'utf8');
    }
    nextToken() {
        let ret = '';
        while (this.text[this.i].charCodeAt(0) <= 32) {
            this.i++;
        }
        while (this.i < this.text.length && this.text[this.i].charCodeAt(0) > 32) {
            ret += this.text[this.i];
            this.i++;
        }
        return ret;
    }
    nextNum() {
        return Number(this.nextToken());
    }
    nextBigInt() {
        return BigInt(this.nextToken());
    }
    nextNumArray(n) {
        let ret = [];
        while (n--) {
            ret.push(this.nextNum());
        }
        return ret;
    }
    _write(x) {
        this.out += x;
    }
    write(x) {
        this._write(x + ' ');
    }
    writeLine(x) {
        this._write(x + '\n');
    }
    flush() {
        fs_1.default.writeFileSync(1, this.out);
        this.out = '';
    }
}
function binarySearch(array, pred) {
    let lo = -1, hi = array.length;
    while (1 + lo < hi) {
        const mi = lo + ((hi - lo) >> 1);
        if (pred(array[mi])) {
            hi = mi;
        }
        else {
            lo = mi;
        }
    }
    return hi;
}
function lowerBound(array, item) {
    return binarySearch(array, (j) => item <= j);
}
function upperBound(array, item) {
    return binarySearch(array, (j) => item < j);
}
//////////// LIBS
const io = new IO();
function solve(n) {
    let ret = 0;
    for (let k = 15; k >= 0; k--) {
        let p = 2050 * 10 ** k;
        while (n >= p) {
            n -= p;
            ret++;
        }
    }
    if (n) {
        io.writeLine(-1);
    }
    else {
        io.writeLine(ret);
    }
}
function main() {
    try {
        let t = io.nextNum();
        while (t--) {
            let n = io.nextNum();
            solve(n);
        }
        io.flush();
    }
    catch (e) {
        console.log(e.stack);
    }
}
main();

let input = '';
process.stdin.on('data', str => input += str)
process.stdin.on('end', () => {
	const lines = input.trim().split('\n').slice(1);

	for (let i=0; i<lines.length; i++) {
		let num = +lines[i].trim();

		if (num === 0) {
			console.log(-1);
			continue;
		}

		let count = 0;
		while (num > 0) {
			let mult = 2050;
			const len = lines[i].length-4;

			if (len > 0) {
				mult = 2050 * (10**len);

				if (num < mult) {
					mult = 2050 * (10**(len-1));
				}
			}

			num -= mult;
			count++;
		}

		if (num === 0) {
			console.log(count);
		} else {
			console.log(-1);
		}
	}
})

let input = '';
process.stdin.on('data', str => input += str)
process.stdin.on('end', () => {
	const lines = input.trim().split('\n').slice(1);

	for (let i=0; i<lines.length; i++) {
		let num = +lines[i].trim();

		if (num === 0) {
			console.log(-1);
			continue;
		}

		let count = 0;
		while (num > 0) {
			let mult = 2050;
			const len = `${num}`.length-4;

			if (len > 0) {
				mult = 2050 * 10**len;

				if (num < mult) {
					mult = 2050 * 10**(len-1);
				}
			}

			num -= mult;
			count++;
		}

		if (num === 0) {
			console.log(count);
		} else {
			console.log(-1);
		}
	}
})

let input = '';
process.stdin.on('data', str => input += str)
process.stdin.on('end', () => {
	const lines = input.trim().split('\n').slice(1);

	for (let i=0; i<lines.length; i++) {
		let num = +lines[i].trim();

		let count = 0;
		while (num > 0) {
			let mult = 2050;
			const len = `${num}`.length-4;

			if (len > 0) {
				mult = 2050 * 10**len;

				if (num < mult) {
					mult = 2050 * 10**(len-1);
				}
			}

			num -= mult;
			count++;
		}

		if (num === 0) {
			console.log(count);
		} else {
			console.log(-1);
		}
	}
})

let input = '';
process.stdin.on('data', str => input += str)
process.stdin.on('end', () => {
	const lines = input.trim().split('\n').slice(1);

	for (let i=0; i<lines.length; i++) {
		let num = +lines[i];

		let count = 0;
		while (num > 0) {
			let mult = 2050;
			const len = `${num}`.length-4;

			if (len > 0) {
				mult = 2050 * 10**len;

				if (num < mult) {
					mult = 2050 * 10**(len-1);
				}
			}

			num -= mult;
			count++;
		}

		if (num === 0) {
			console.log(count);
		} else {
			console.log(-1);
		}
	}
})

let input = '';
process.stdin.on('data', str => input += str)
process.stdin.on('end', () => {
	const lines = input.trim().split('\n').slice(1);

	for (let i=0; i<lines.length; i++) {
		let num = +lines[i];

		if (lines[i].length < 4 || num < 2050) {
			console.log(-1);
			continue;
		}

		let count = 0;
		while (num > 0) {
			let mult = 2050;
			const len = `${num}`.length-4;

			if (len > 0) {
				mult = 2050 * 10**len;

				if (num < mult) {
					mult = 2050 * 10**(len-1);
				}
			}

			num -= mult;
			count++;
		}

		if (num === 0) {
			console.log(count);
		} else {
			console.log(-1);
		}
	}
})

'use strict';

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

let inputString = '';
let currentLine = 0;

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

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

  main();
});

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

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

function main() {

    var t=readline();
    while(t--){
        var n=0;
        n=readline();
        if(n%2050!=0){
            console.log(-1);
        }
        else{
    var ans=0;
    var a=n/2050;
    var str = a.toString();
    for(var i=0;i<str.length;i++){
        ans+=Number(str[i]);
    }
    console.log(ans);
}
    }

}

'use strict';

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

let inputString = '';
let currentLine = 0;

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

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

  main();
});

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

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

function main() {

    function sum(n){
        var s=0;
        while(n>0){
            var a=n%10;
            s+=a;
            n/=10;
             n = Math.floor(n);
        }
        return s;
    }

    var t=readline();
    while(t--){
        var n=0;
        n=readline();
        if(n%2050!=0){
            console.log(-1);
        }
        else{
            var a=n/2050;
            var ans=sum(a);
            console.log(ans);
        }
    }

}

'use-strict'

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

let data = '';
let currentLine = 0;

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

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

    let testCases = parseInt(readLine());
    while(testCases--)
    {
        let n = parseInt(readLine());
        n % 2050 === 0 ? print((n/2050).toString().split('').map(Number).reduce((a,b) => a + b)) : print(-1);
    }
});

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

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

function print(c){
    return console.log(c)
}

function isEqual(arr){
     let flag = true;
        for(let i = 0 ; i < arr.length - 1; i++){
            if(arr[i] !== arr[i + 1]){
                flag = false;
                break;
            }
        }
    return flag;
}

const readline = require("readline");
const rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
})
let input = [];
rl.on('line', line => {
    input.push(line);
})
rl.on('close', line => {
    var t = Number(input[0]);
    for (var k = 1; k < input.length; k++) {
        var n = BigInt(Number(input[k]));
        var mod = BigInt(2050);
        if (n % mod !== BigInt(0)) {
            console.log(-1);
            continue;
        }
        var count = n / mod;
        var str = count.toString();
        var result = 0;
        for (var i = 0; i < str.length; i++) {
            result += Number(str[i]);
        }
        console.log(result);
    }
});

var t = parseInt(readline());

for(i = 0; i < t; i++) {
    var n = readline();
    if(n.length > 12) {
        var temp = n / Math.pow(10, 9);
        var div = temp / 2050;
        var sum = 0;
        for(j = 0; j <= Math.log10(div); j++) {
            sum += Math.floor((div / Math.pow(10, j))) % 10;
        }
        n = parseInt(n.slice(n.length - 9, n.length));
        n += (temp % 2050) * Math.pow(10, 9);
        if(n % 2050 !== 0) print(-1);
        else {
            n /= 2050;
            for(j = 0; j <= Math.log10(n); j++) {
                sum += Math.floor((n / Math.pow(10, j))) % 10;
            }
            print(sum);
        }
    }
    else if(n % 2050 !== 0) print(-1);
    else {
        n /= 2050;
        var sum = 0;
        for(j = 0; j <= Math.log10(n); j++) {
            sum += Math.floor((n / Math.pow(10, j))) % 10;
        }
        print(sum);
    }
}

var t = parseInt(readline());

for(i = 0; i < t; i++) {
    var n = readline();
    if(n.length > 12) {
        var temp = n / Math.pow(10, 9);
        var div = temp / 2050;
        var sum = 0;
        for(j = 0; j <= Math.log10(div); j++) {
            sum += Math.floor((div / Math.pow(10, j))) % 10;
        }
        n = parseInt(n.slice(n.length - 9, n.length));
        n += (temp % 2050) * Math.pow(10, 9);
        n /= 2050;
        for(j = 0; j <= Math.log10(n); j++) {
            sum += Math.floor((n / Math.pow(10, j))) % 10;
        }
        print(sum);
    }
    else if(n % 2050 !== 0) print(-1);
    else {
        n /= 2050;
        var sum = 0;
        for(j = 0; j <= Math.log10(n); j++) {
            sum += Math.floor((n / Math.pow(10, j))) % 10;
        }
        print(sum);
    }
}

var t = parseInt(readline());

for(i = 0; i < t; i++) {
    var n = readline().split(" ");
    if(n % 2050 !== 0) print(-1);
    else {
        n /= 2050;
        var sum = 0;
        for(j = 0; j <= Math.log10(n); j++) {
            sum += Math.floor((n / Math.pow(10, j))) % 10;
        }
        print(sum);
    }
}

var testCount = parseInt(readline());
for (var i = 0; i < testCount; i++) {
    var n = parseInt(readline());
    print(compute(n));
}
function compute(n) {
    var d = n / 2050;
    if (d != Math.floor(d))
        return -1;
    var r = 0;
    while (d > 0) {
        r += d % 10;
        d = Math.floor(d / 10);
    }
    return r;
}


George is a cat, so he really likes to play. Most of all he likes to play with his array of positive integers b. During the game, George modifies the array by using special changes. Let's mark George's current array as b1, b2, ..., b|b| (record |b| denotes the current length of the array). Then one change is a sequence of actions:   Choose two distinct indexes i and j (1 ≤ i, j ≤ |b|; i ≠ j), such that bi ≥ bj.  Get number v = concat(bi, bj), where concat(x, y) is a number obtained by adding number y to the end of the decimal record of number x. For example, concat(500, 10) = 50010, concat(2, 2) = 22.  Add number v to the end of the array. The length of the array will increase by one.  Remove from the array numbers with indexes i and j. The length of the array will decrease by two, and elements of the array will become re-numbered from 1 to current length of the array. George played for a long time with his array b and received from array b an array consisting of exactly one number p. Now George wants to know: what is the maximum number of elements array b could contain originally? Help him find this number. Note that originally the array could contain only positive integers.

The first line of the input contains a single integer p (1 ≤ p < 10100000). It is guaranteed that number p doesn't contain any leading zeroes.

Print an integer — the maximum number of elements array b could contain originally.

NoteLet's consider the test examples:   Originally array b can be equal to {5, 9, 5, 5}. The sequence of George's changes could have been: {5, 9, 5, 5} → {5, 5, 95} → {95, 55} → {9555}.  Originally array b could be equal to {1000000000, 5}. Please note that the array b cannot contain zeros.  Originally array b could be equal to {800, 10, 1}.  Originally array b could be equal to {45}. It cannot be equal to {4, 5}, because George can get only array {54} from this array in one operation. Note that the numbers can be very large.

var n=readline();
var i=n.length-1;
var ans=0;
var e='';
while(i>=0){
	var f=false;
	while(n[i]==='0'){
		e=n[i]+e;
		i--;
	}
	e=n[i]+e;
	if(e.length<i || +e<=+n.substring(0,i)){
		ans++;
		e='';
	}
	i--;
}
print(ans+1)


Polycarpus has n markers and m marker caps. Each marker is described by two numbers: xi is the color and yi is the diameter. Correspondingly, each cap is described by two numbers: aj is the color and bj is the diameter. Cap (aj, bj) can close marker (xi, yi) only if their diameters match, that is, bj = yi. Besides, a marker is considered to be beautifully closed, if the cap color and the marker color match, that is, aj = xi.Find the way to close the maximum number of markers. If there are several such ways, then choose the one that has the maximum number of beautifully closed markers.

The first input line contains two space-separated integers n and m (1 ≤ n, m ≤ 105) — the number of markers and the number of caps, correspondingly.  Next n lines describe the markers. The i-th line contains two space-separated integers xi, yi (1 ≤ xi, yi ≤ 1000) — the i-th marker's color and diameter, correspondingly. Next m lines describe the caps. The j-th line contains two space-separated integers aj, bj (1 ≤ aj, bj ≤ 1000) — the color and diameter of the j-th cap, correspondingly.

Print two space-separated integers u, v, where u is the number of closed markers and v is the number of beautifully closed markers in the sought optimal way. Remember that you have to find the way to close the maximum number of markers, and if there are several such ways, you should choose the one where the number of beautifully closed markers is maximum.

NoteIn the first test sample the first marker should be closed by the fourth cap, the second marker should be closed by the first cap and the third marker should be closed by the second cap. Thus, three markers will be closed, and two of them will be beautifully closed — the first and the third markers.

(function main() {
    var l = readline().split(' ');
    var n = parseInt(l[0]);
    var m = parseInt(l[1]);
    var pens = new Array();
    var covers = new Array();
    for (var i = 0; i < n; ++i) {
        l = readline().split(' ');
        var a = parseInt(l[0]);
        var b = parseInt(l[1]);
        if (!(b in pens))
            pens[b] = new Array();
        pens[b][a] = (pens[b][a] || 0) + 1;
    };
    var nice = 0;
    for (var i = 0; i < m; ++i) {
        l = readline().split(' ');
        var a = parseInt(l[0]);
        var b = parseInt(l[1]);
        if (!(b in pens))
            continue;
        if (pens[b][a]) {
            --pens[b][a];
            ++nice;
        } else {
            covers[b] = (covers[b] || 0) + 1;
        }
    }
    var bad = 0;
    for (var x in covers) {
        var q = pens[x].reduce(function(a,b){return a+b;});
        bad += Math.min(q, covers[x]);
    }
    print(bad + nice, nice);
})();


The name of one small but proud corporation consists of n lowercase English letters. The Corporation has decided to try rebranding — an active marketing strategy, that includes a set of measures to change either the brand (both for the company and the goods it produces) or its components: the name, the logo, the slogan. They decided to start with the name.For this purpose the corporation has consecutively hired m designers. Once a company hires the i-th designer, he immediately contributes to the creation of a new corporation name as follows: he takes the newest version of the name and replaces all the letters xi by yi, and all the letters yi by xi. This results in the new version. It is possible that some of these letters do no occur in the string. It may also happen that xi coincides with yi. The version of the name received after the work of the last designer becomes the new name of the corporation.Manager Arkady has recently got a job in this company, but is already soaked in the spirit of teamwork and is very worried about the success of the rebranding. Naturally, he can't wait to find out what is the new name the Corporation will receive.Satisfy Arkady's curiosity and tell him the final version of the name.

The first line of the input contains two integers n and m (1 ≤ n, m ≤ 200 000) — the length of the initial name and the number of designers hired, respectively. The second line consists of n lowercase English letters and represents the original name of the corporation. Next m lines contain the descriptions of the designers' actions: the i-th of them contains two space-separated lowercase English letters xi and yi.

11 6
abacabadaba
a b
b c
a d
e g
f a
b b

NoteIn the second sample the name of the corporation consecutively changes as follows:

var count, firstLetter, i, length, letter, map, name, origin, ref, ref1, ref2, ref3, secondLetter;

ref = readline().split(' '), length = ref[0], count = ref[1];

name = readline();

map = [];

for (letter = i = ref1 = 'a'.charCodeAt(), ref2 = 'z'.charCodeAt(); ref1 <= ref2 ? i <= ref2 : i >= ref2; letter = ref1 <= ref2 ? ++i : --i) {
  map[String.fromCharCode(letter)] = String.fromCharCode(letter);
}

while (count--) {
  ref3 = readline().split(' '), firstLetter = ref3[0], secondLetter = ref3[1];
  for (origin in map) {
    if (map[origin] === firstLetter) {
      map[origin] = secondLetter;
    } else if (map[origin] === secondLetter) {
      map[origin] = firstLetter;
    }
  }
}

print(((function() {
  var j, len, results;
  results = [];
  for (j = 0, len = name.length; j < len; j++) {
    letter = name[j];
    results.push(map[letter]);
  }
  return results;
})()).join(''));

var input = readline().split(' ');
var n = parseInt(input[0]);
var m = parseInt(input[1]);

var word = readline();
var startCharCode = 'a'.charCodeAt(0);
var indices = [];
for (var i = 0; i < 26; i++) {
    indices[i] = [];
}

for (var i = 0; i < n; i++) {
    indices[word.charCodeAt(i) - startCharCode].push(i);
}

for (var i = 0; i < m; i++) {
    var input2 = readline().split(' ');
    var x = input2[0].charCodeAt(0) - startCharCode;
    var y = input2[1].charCodeAt(0) - startCharCode;
    //swap
    var tmp = indices[x];
    indices[x] = indices[y];
    indices[y] = tmp;
}

var output = [];
for (var i = 0; i < 26; i++) {
    for (var j = 0; j < indices[i].length; j++) {
        output[indices[i][j]] = String.fromCharCode(i + startCharCode);
    }
}

print(output.join(''));

try {require('codef');} catch (e){global = this};
function readLineAsArray(separator){return readline().split(typeof separator == "undefined" ? ' ' : separator)}
function readLineAsIntegerArray(separator){return readLineAsArray(separator).map(function(v){return +v})}
Array.prototype.list = function() {var length = arguments.length; for(var i=0; i < length; i++){global[arguments[i]] = this[i]}};
String.prototype.repeat = function(n){return new Array(n + 1).join(this);}

var n, m, s = '', alphabet, alph = [];
for(var i = 97; i <= 122; i++) {
    alph.push(String.fromCharCode(i));
}

m = readLineAsIntegerArray();

n = m[0];
m = m[1];

s = readline();
alphabet = alph = alph.join('');

for(var i=0; i < m; i++) {
    var tmp = readline().split(' ');
    if (tmp[0] !== tmp[1]) {
        alph = alph.replace(tmp[0], '.').replace(tmp[1], tmp[0]).replace('.', tmp[1]);
    }
}

var hash = {};
for(var i in alph) {
    hash[alphabet[i]] = alph[i];
}

var result = '', length = s.length;

for(var i = 0; i < length; i ++) {
    result += hash[s[i]];
}

write(result);

var count, length, originName, ref;

ref = readline().split(' '), length = ref[0], count = ref[1];

originName = readline();

while (count--) {
  "".replace.apply(originName, readline().split(' '));
}

print(originName);

var count, length, originName, ref;

ref = readline().split(' '), length = ref[0], count = ref[1];

originName = readline();

while (count--) {
  originName = "".replace.apply(originName, readline().split(' '));
}

print(originName);

var params = readline().split(' ').map(function(i) { return parseInt(i); });

var n = params[0];
var m = params[1];

var originalWord = readline().split('');
var pairs = [];

for (var i = 0; i < m; i++) {
    var param = readline().split(' ');
    pairs.push({
        x : param[0][0],
        y : param[1][0]
    });
}

for (var i = 0; i < pairs.length; i++) {
    if (i+1 < pairs.length && (pairs[i].x === pairs[i+1].y && pairs[i].y === pairs[i+1].x) ) {
        i++;
    }

    if (pairs[i].x !== pairs[i].y) {
        for (var j=0; j < originalWord.length; j++) {
            if (originalWord[j] === pairs[i].x) {
                originalWord[j] = pairs[i].y;
            } else if (originalWord[j] === pairs[i].y) {
                originalWord[j] = pairs[i].x;
            }
        }
    }
}
print(originalWord.join(''));