In an ICPC contest, balloons are distributed as follows:   Whenever a team solves a problem, that team gets a balloon.  The first team to solve a problem gets an additional balloon.  A contest has 26 problems, labelled $$$\textsf{A}$$$, $$$\textsf{B}$$$, $$$\textsf{C}$$$, ..., $$$\textsf{Z}$$$. You are given the order of solved problems in the contest, denoted as a string $$$s$$$, where the $$$i$$$-th character indicates that the problem $$$s_i$$$ has been solved by some team. No team will solve the same problem twice.Determine the total number of balloons that the teams received. Note that some problems may be solved by none of the teams.

The first line of the input contains an integer $$$t$$$ ($$$1 \leq t \leq 100$$$) — the number of testcases. The first line of each test case contains an integer $$$n$$$ ($$$1 \leq n \leq 50$$$) — the length of the string. The second line of each test case contains a string $$$s$$$ of length $$$n$$$ consisting of uppercase English letters, denoting the order of solved problems.

For each test case, output a single integer — the total number of balloons that the teams received.

6

3

ABA

1

A

3

ORZ

5

BAAAA

4

BKPT

10

CODEFORCES

NoteIn the first test case, $$$5$$$ balloons are given out:   Problem $$$\textsf{A}$$$ is solved. That team receives $$$2$$$ balloons: one because they solved the problem, an an additional one because they are the first team to solve problem $$$\textsf{A}$$$.  Problem $$$\textsf{B}$$$ is solved. That team receives $$$2$$$ balloons: one because they solved the problem, an an additional one because they are the first team to solve problem $$$\textsf{B}$$$.  Problem $$$\textsf{A}$$$ is solved. That team receives only $$$1$$$ balloon, because they solved the problem. Note that they don't get an additional balloon because they are not the first team to solve problem $$$\textsf{A}$$$.  The total number of balloons given out is $$$2+2+1=5$$$.In the second test case, there is only one problem solved. The team who solved it receives $$$2$$$ balloons: one because they solved the problem, an an additional one because they are the first team to solve problem $$$\textsf{A}$$$.

process.stdin.on("data", (data) => {
  const [testCount, ...testCases] = data.toString().trim().split("\n");

  const tests = [];
  for (let i = 1; i < testCount * 2; i += 2) {
    tests.push(testCases[i]);
  }

  for (let test of tests) {
    console.log(getScore(test.trim()));
  }
});

function getScore(input) {
  let solved = "";
  let score = 0;
  for (let i = 0; i < input.length; i++) {
    const char = input[i];
    if (solved.includes(char)) {
      score += 1;
    } else {
      solved += char;
      score += 2;
    }
  }
  return score;
}

let i = '';
process.stdin.on('data', c => i += c);
process.stdin.on('end', () => {
    const {EOL} = require('os');
    const lines = i.split(EOL);
    var n = lines[0], e = 0, biggest = 0, g = 0, a = new Map()
    for(j = 1; j <= n * 2; j++){
        if(j % 2 == 1){
            e = lines[j]
        }else{
            g = 0
            a = new Map()
            var k = lines[j].split('')
            for(l = 0; l < e; l++){
                if(a.has(k[l])){
                    temp = a.get(k[l])
                    temp++

                    a.set(k[l], temp)
                }else{
                    a.set(k[l], 1)
                    g++
                }
            }

            for(var [key, value] of a){
                g+=value
            }
            console.log(g)

        }
    }

});

function Solution() {
  const N = Number(lines[0]);
  const res = [];
  for (let i = 1; i <= 2 * N; i += 2) {
    const n = Number(lines[i]);
    const str = lines[i + 1];
    res.push(new Set(str).size + n);
  }
  return res.join('\n');
}

const readline = require('readline')

const rl = readline.createInterface({
  input: process.stdin,
  output: process.stdout
})
const lines = []
rl.on('line', (input) => {
  lines.push(input);
})
rl.on('close', () => {
  console.log(Solution());
});

function Solution() {
  const N = Number(lines[0]);
  const res = [];
  for (let i = 1; i <= 2 * N; i += 2) {
    const n = Number(lines[i]);
    const str = lines[i + 1];
    const set = new Set();
    let count = 0;
    for (let i = 0; i < n; i++) {
      if (set.has(str[i])) {
        count += 1;
      } else {
        count += 2;
        set.add(str[i]);
      }
    }
    res.push(count);
  }
  return res.join('\n');
}

const readline = require('readline')

const rl = readline.createInterface({
  input: process.stdin,
  output: process.stdout
})
const lines = []
rl.on('line', (input) => {
  lines.push(input);
})
rl.on('close', () => {
  console.log(Solution());
});

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

let c = 0;

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

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

  const visited = {};
  let ans = 0;

  for (let i = 0; i < str.length; i++) {
    if (visited[str[i]]) {
      ans++;
    } else {
      ans += 2;
    }

    visited[str[i]] = true;
  }

  console.log(ans);
  c++;
});

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

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

let lines = []

const createReadLine = () => {
  i = 0;
  return () => lines[i++]
}

rl.on('line', line => lines.push(line))

rl.on("close", () => {
  const readLine = createReadLine();
  // const alphabet = "abcdefghijklmnopqrstuvwxyz".toUpperCase();
  let t = parseInt(readLine());
  while (t--) {
    readLine()
    let str = readLine();
    let problems = {};
    let ans = 0;
    for (const pr of str) {
      if (problems[pr]) {
        ans++;
      } else {
        problems[pr] = true;
        ans += 2;
      }
    }

    console.log(ans)
  }
});

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++){
		nl.num();
		let x = {};
		let y = 0;
		nl.line().split('').forEach(e =>
		{
			if (x[e]){
				y++;
			} else {
				x[e] = 1;
				y += 2;
			}
		});
		ans.push(y);

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

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

let stop = '';
process.stdin.on('data', c => stop += c);
process.stdin.on('end', () => {
    const {EOL} = require('os');
    const lines = stop.split(EOL);
    var t = lines[0];
    var n = 0;
    for(i = 1; i <= t * 2; i++){
        if(i % 2 == 1) {
            n = lines[i];
        }else{
            var k = lines[i].split('');
            var a = new Map();
            var ans = 0;
            for(j = 0; j < n; j++){
                if(a.get(k[j]) === undefined){
                    a.set(k[j], 1);
                    ans += 2;
                }else{
                    ans++;
                }
            }
            console.log(ans);
        }
    }
});

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

function print(x) {
  console.log(x);
}
let inputString = "";
let currentLine = 0;

process.stdin.on("data", (inputStdin) => {
  inputString += inputStdin;
});
process.stdin.on("end", () => {
  inputString = inputString.split("\n");
  main();
});
function readline() {
  return inputString[currentLine++];
}

// ********** Code Start **********

function main() {
    var tests = parseInt(readline());
    for (let t = 0;t < tests; ++t) {
      let n = parseInt(readline());
      let s = readline();
      let str = Array.from(s);
      let ans = 0;
      let hsh = Array(26).fill(false);

      for (let i = 0;i < s.length-1; ++i) {
        if (hsh[s.charCodeAt(i)-65]) {
          ans++;
        } else {
          hsh[s.charCodeAt(i)-65] = true;
          ans++;
          ans++;
        }
      }
      console.log(ans);
    }
}

const readline = require('readline')

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

function solve(n, str) {
    const map = {}
    for (let i = 0; i < str.length; i++) {
        map[str[i]] = 1
    }
    return str.length + Object.keys(map).length
}

'use strict';

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

let inputString = '';
let currentLine = 0;

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

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

    main();
});

function readline() {
    return inputString[currentLine++];
}
function main(){
    let t = readline()-0
    while(t--){
        let n = readline()
        let str = readline()
        let s = new Set()
        let res = 0
        for(let i=0;i<n;i++){
            if(s.has(str[i])){
                res++
            } else{
                s.add(str[i])
                res+=2
            }
        }
        console.log(res)

    }
}

const readline = require("readline");

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

let lineNum = 0;
let map = new Map();

rl.on("line", line => {
  if (lineNum === 0) {
    // skip
  } else {
    if (lineNum % 2 === 0) {
      map.clear();
      for (let char of line) {
        map.set(char, (map.get(char) || 0) + 1);
      }
      let cnt = 0;
      for (let c of map.values()) {
        cnt += c + 1;
      }
      console.log(cnt);
    }
  }

  lineNum++;
});

// https://stackoverflow.com/questions/20086849/how-to-read-from-stdin-line-by-line-in-node
// // cat .\input.txt | node .\script.js
const state = {
    i: 0,
    acc: []
}
const readline = require('readline');
const rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout,
    terminal: false
});
rl.on('line',
    function (line) {
        const alphabet = {
            A: 0,
            B: 0,
            C: 0,
            D: 0,
            E: 0,
            F: 0,
            G: 0,
            H: 0,
            I: 0,
            J: 0,
            K: 0,
            L: 0,
            M: 0,
            N: 0,
            O: 0,
            P: 0,
            Q: 0,
            R: 0,
            S: 0,
            T: 0,
            U: 0,
            V: 0,
            W: 0,
            X: 0,
            Y: 0,
            Z: 0
        }
        if (state.i > 0) {
            state.acc.push(line)
            if (state.acc.length == 2) {
                //
                let sum = 0
                let [t, n] = state.acc
                for (let i = 0; i < n.length; i++) {
                    let current = n[i]
                    if (alphabet[current] == 0) {
                        sum++
                        alphabet[current]++
                    }
                    sum++
                }
                console.log(sum)
                //
                state.acc = []
            }

        }
        state.i++
    })

process.stdin.resume();
process.stdin.setEncoding("ascii");

_input = "";
process.stdin.on("data", function (input) {
   _input += input;
});

process.stdin.on("end", function () {
    processData(_input);
});

function processData(input) {
    const lines = input.split("\n");
    for (let i = 1; i <= lines[0]; i++) {
        processTC(lines, (2*i-1));
    }
}

function processTC(lines, startLine) {
    const n = Number(lines[startLine]);
    const str = lines[startLine+1];
    checkSolved(str, n);
}

function checkSolved(str, n) {
    let map = {};
    let count = 0;
    for (let i = 0; i < n; i++) {
        const char = str.charAt(i);
        if (!map[char]) map[char]=0;
        map[char]++;
        if (map[char] === 1) count++;
        count++;
    }
    console.log(count);
}

const fs = require("fs");
const input = fs.readFileSync(0, 'utf8').trim().split('\r\n');
let currentline = 0;
function readline(){
      return input[currentline++];
}

function alph() {
  var f = 'abcdefghijklmnopqrstuvwxyz';
  return f;
}
function Alph() {
  var f = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
  return f;
}
function max(x,y) {
  return x >=y ? x : y;
}
function min(x,y) {
  return x <=y ? x : y;
}
function abs(x) {
  return x < 0 ? x*(-1) : x;
}
// console.log(input)
var T = readline();
// var inf = 1000000000000;
for(var tc=1;tc<=T;tc++) {
  // var nul = readline();
  var a = readline()
  var n = readline()//.split(' ').map((x) => parseInt(x));
  // var a = readline().split(' ').map((x) => parseInt(x));
  var ans = 0;
  var f = Alph();
  var mp = new Map();
  for(var i=0;i<a;i++) {
    if(!mp.has(n[i])) {
      ans += 2;
      mp.set(n[i], 0)
    } else {
      ans++;
    }
  }
  console.log(ans)
}

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

'use strict';

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

let inputString = '';
let currentLine = 0;

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

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

  main();
});

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

function main() {
  let times = parseInt(readline());
  for (let i = 0; i < times; i++) {
    let len = parseInt(readline());
    let distinct = new Set(readline().split(''));
    console.log(distinct.size + len);
  }
}

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

//Don't have to see. end------------------------------------------
function Main(){
	var t = nextInt();
	while(hasNext()){
		var N = nextInt();
		var S = next();
		var output = 0;
		var set = new Set();
		for(var i = 0; i < N; i++){
			output++;
			if(!set.has(S[i])){
				output++;
				set.add(S[i]);
			}
		}
		myout(output);
	}
}

'use strict';

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

let inputString = '';
let currentLine = 0;

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

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

    main();
});

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

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

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

    for (let test = 0; test < N; test++) {
        let seen = {};
        let total = 0;
        readline();
        let solved = readline();
        for (let i = 0; i < solved.length; i++) {
            let c = solved[i];
            if (seen[c]) {
                total += 1;
            } else {
                seen[c] = true;
                total += 2;
            }
        }
        output(total);
    }
}

function getBalloons(numbers) {
    var balloons = [];
    for (var element of numbers) {
        if (balloons.indexOf(element) == -1) {
            balloons.push(element);
        }

    }
    return balloons.length;

}
var test = readline();
for (var i = 1; i <= test; i++) {
    var n = readline();
    var numbers = readline().split('');
    print(parseInt(n) + getBalloons(numbers));
}

var test = readline();
for (var i = 1; i <= test; i++) {
    var n = readline();
    var numbers = readline().split('');
    var balloons = [];
    for (var element of numbers) {
        if (balloons.indexOf(element) == -1) {
            balloons.push(element);
        }

    }
    //var result = getBalloons(numbers) + parseInt(n);

    print(parseInt(n) + balloons.length);
}

var test = readline()
for(var i=0; i<test; i++){
    var n = readline();
    var ballon = readline();
    var k = ballon.split('');
    var z = []
    for( var element of k){
        if(z.indexOf(element) == -1){
            z.push(element);
        }
    }
    print(parseInt(n)+z.length)

}

var limit = parseInt(readline());
for (var i = 0; i < limit; i++)
{
    var caseLength = parseInt(readline());
    var caseString = readline();
    var caseMap = new Map();
    var count = 0;
    for (var j = 0; j < caseLength; j++)
    {
        if (caseMap.has(caseString[j]))
        {
            count++;
        }
        else
        {
            caseMap.set(caseString[j], 1);
            count += 2;
        }
    }
    print(count);
}

var n = parseInt(readline());

for (var i = 0; i < n; i++) {
    var len = parseInt(readline());
    var str = readline();
    var set = new Set(str);

    print(len + set.size);
}

var print = this.print || require('lol-io').print
var readline = this.readline || require('lol-io').readline

var T = parseInt(readline());

for (var tt = 0; tt < T; tt++) {
  var n = parseInt(readline());
  var s = readline();
  var freq = new Array(26);
  for (var i = 0; i < 26; i++) freq[i] = false;
  var ans = 0;
  for (var i = 0; i < n; i++) {
      var idx = s.charCodeAt(i) - 65;
      if (freq[idx] == false) {
          ans += 2;
          freq[idx] = true;
      } else {
          ans += 1;
      }
  }
  print(ans);
}

var t = readline();
var n , s;
for(var i = 0 ; i < t ; i++) {
n = readline();
s = readline();
print([... new Set(s)].length + parseInt(n));
}

var tests = parseInt(readline());
    for (var t=0; t<tests;t++) {
        var n = readline();
        var balls = readline();
        var set = new Set();
        var points = balls.length;
        for (var i = 0;i < balls.length;i++) {
            var c = balls.charAt(i);
            set.add(c);
        }
        print(points + set.size);
    }

var t = +readline();

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

    var t1 = readline();
    var t2 = readline();
    print(checkStr(t2));

}

function checkStr(str) {

  var set = new Set();
  var count = 0;
  for(var each of str){
    if (!set.has(each)){
      count+=2;
    }else {
      count+=1;
    }
    set.add(each);
  }
  return count;
}

T = readline()

while(T--){
      n = readline()
      str = readline().split('')

      set = new Set()
      str.forEach(el => {
            set.add(el)
      })

      ans = set.size + str.length
      print(ans)
}

process.stdin.on("data", (data) => {
  const [testCount, ...testCases] = data.toString().trim().split("\n");

  const tests = [];
  for (let i = 1; i < testCount * 2; i += 2) {
    tests.push(testCases[i]);
  }

  for (let test of tests) {
    console.log(getScore(test));
  }
});

function getScore(input) {
  let solved = "";
  let score = 0;
  for (let i = 0; i < input.length; i++) {
    const char = input[i];
    if (solved.includes(char)) {
      score += 1;
    } else {
      solved += char;
      score += 2;
    }
  }
  return score;
}

process.stdin.on("data", (data) => {
  const [testCount, ...testCases] = data.toString().trim().split("\n");

  const tests = [];
  for (let i = 1; i < testCount * 2; i += 2) {
    tests.push(testCases[i]);
  }

  for (let test of tests) {
    let solved = "";
    let score = 0;
    for (let i = 0; i < test.length - 1; i++) {
      const char = test[i];
      if (solved.includes(char)) {
        score += 1;
      } else {
        solved += char;
        score += 2;
      }
    }
    console.log(score);
  }
});

process.stdin.on("data", (data) => {
  const [testCount, ...testCases] = data.toString().trim().split("\n");

  const tests = [];
  for (let i = 1; i < testCount; i += 2) {
    tests.push(testCases[i]);
  }

  console.log("tests:", tests);

  for (let test of tests) {
    let solved = "";
    let score = 0;
    for (let i = 0; i < test.length - 1; i++) {
      const char = test[i];
      if (solved.includes(char)) {
        score += 1;
      } else {
        solved += char;
        score += 2;
      }
    }
    console.log(score);
  }
});

process.stdin.on("data", (data) => {
  const [testCount, ...testCases] = data.toString().trim().split("\n");

  const tests = [];
  for (let i = 1; i < testCount; i += 2) {
    tests.push(testCases[i]);
  }

  for (let test of tests) {
    let solved = "";
    let score = 0;
    for (let i = 0; i < test.length - 1; i++) {
      const char = test[i];
      if (solved.includes(char)) {
        score += 1;
      } else {
        solved += char;
        score += 2;
      }
    }
    console.log(score);
  }
});

process.stdin.on("data", (data) => {
  const [testCount, ...testCases] = data.toString().trim().split("\n");

  const tests = [];
  for (let i = 1; i < testCount; i += 2) {
    tests.push(testCases[i]);
  }

  for (let test of tests) {
    let solved = "";
    let score = 0;
    for (let i = 0; i < test.length - 1; i++) {
      console.log("Test:", test, "i:", i, "solved:", solved, "score:", score);
      const char = test[i];
      if (solved.includes(char)) {
        score += 1;
      } else {
        solved += char;
        score += 2;
      }
    }
    console.log(score);
  }
});

process.stdin.on("data", (data) => {
  const [testCount, ...testCases] = data.toString().trim().split("\n");

  const tests = [];
  for (let i = 1; i < testCount; i += 2) {
    tests.push(testCases[i]);
  }

  for (let test of tests) {
    let solved = "";
    let score = 0;
    for (let i = 0; i < test.length; i++) {
      console.log("Test:", test, "i:", i, "solved:", solved, "score:", score);
      const char = test[i];
      if (solved.includes(char)) {
        score += 1;
      } else {
        solved += char;
        score += 2;
      }
    }
    console.log(score);
  }
});

process.stdin.on("data", (data) => {
  const [testCount, ...testCases] = data.toString().trim().split("\n");

  const tests = [];
  for (let i = 1; i < testCount; i += 2) {
    tests.push(testCases[i]);
  }

  for (let test of tests) {
    let solved = "";
    let score = 0;
    for (let i = 0; i < test.length; i++) {
      const char = test[i];
      if (solved.includes(char)) {
        score += 1;
      } else {
        solved += char;
        score += 2;
      }
    }
    console.log(score);
  }
});

process.stdin.on("data", (data) => {
  const [testCount, ...testCases] = data.toString().trim().split("\n");

  const tests = [];
  for (let i = 1; i < testCount; i += 2) {
    tests.push(testCases[i]);
  }

  for (let test of tests) {
    console.log(test);
  }
});

let i = '';
process.stdin.on('data', c => i += c);
process.stdin.on('end', () => {
    const {EOL} = require('os');
    const lines = i.split(EOL);
    var n = lines[0], e = 0, biggest = 0, g = 0, a = new Map()
    for(j = 1; j <= n * 2; j++){
        if(j % 2 == 1){
            e = lines[j]
        }else{
            g = 0
            var k = lines[j].split('')
            for(l = 0; l < e; l++){
                if(a.has(k[l])){
                    temp = a.get(k[l])
                    temp++

                    a.set(k[l], temp)
                }else{
                    a.set(k[l], 1)
                    g++
                }
            }

            for(var [key, value] of a){
                g+=value
            }
            console.log(g)

        }
    }

});

let i = '';
process.stdin.on('data', c => i += c);
process.stdin.on('end', () => {
    const {EOL} = require('os');
    const lines = i.split(EOL);
    var n = lines[0], e = 0, biggest = 0, g = 0, a = new Map()
    for(j = 1; j <= n * 2; j++){
        if(j % 2 == 1){
            e = lines[j]
        }else{
            var k = lines[j].split('').map(String)
            for(l = 0; l < e; l++){
                if(a.has(k[l])){
                    temp = a.get(k[l])
                    temp++
                    if(temp == 2){
                        g++
                    }
                    a.set(k[l], temp)
                }else{
                    a.set(k[l], 1)
                }
            }

            for(var [key, value] of a){
                g++
            }
        }
        console.log(g)
    }

});

/*
function getBalloons(numbers) {
    var balloons = [];
    for (const element of numbers) {
        if (balloons.indexOf(element) == -1) {
            balloons.push(element);
        }

    }
    return balloons.length;

}*/
var test = readline();
for (var i = 1; i <= test; i++) {
    var n = readline();
    var numbers = readline().split('');
    var balloons = [];
    for (const element of numbers) {
        if (balloons.indexOf(element) == -1) {
            balloons.push(element);
        }

    }
    //var result = getBalloons(numbers) + parseInt(n);

    print(parseInt(n) + balloons.length);
}

        var t = readline()
        for (var i=0; i<t; i++){
            var n = readline();
            var s = readline();
            const uniqueCount = new Set(s).size;
            print(uniqueCount);
            print(uniqueCount*2+(n-uniqueCount));
        }

    var t = readline()
    for (var i=0; i<t; i++){
        var n = readline();
        var s = readline();
        const uniqueCount = new Set(s).size;
        print(uniqueCount*2+(n-uniqueCount));
    }

t = readline();
for (i = 0; i < t; i++) {
    n = readline();
    s = readline().split('').sort().join('');
    print(s);
    z = n * 2;
    for (j = 0; j < n; j++) {
        if (s[j] === s[j + 1]) {
            z = z - 1;
        }
    }
    print(z);
}

var n = parseInt(readline());

for (var i = 0; i < n; i++) {
    var len = readline();
    var str = readline();
    var set = new Set(str);

    print(len + set.size);
}


A big football championship will occur soon! $$$n$$$ teams will compete in it, and each pair of teams will play exactly one game against each other.There are two possible outcomes of a game:  the game may result in a tie, then both teams get $$$1$$$ point;  one team might win in a game, then the winning team gets $$$3$$$ points and the losing team gets $$$0$$$ points. The score of a team is the number of points it gained during all games that it played.You are interested in a hypothetical situation when all teams get the same score at the end of the championship. A simple example of that situation is when all games result in ties, but you want to minimize the number of ties as well.Your task is to describe a situation (choose the result of each game) so that all teams get the same score, and the number of ties is the minimum possible.

The first line contains one integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. Then the test cases follow. Each test case is described by one line containing one integer $$$n$$$ ($$$2 \le n \le 100$$$) — the number of teams.

For each test case, print $$$\frac{n(n - 1)}{2}$$$ integers describing the results of the games in the following order: the first integer should correspond to the match between team $$$1$$$ and team $$$2$$$, the second — between team $$$1$$$ and team $$$3$$$, then $$$1$$$ and $$$4$$$, ..., $$$1$$$ and $$$n$$$, $$$2$$$ and $$$3$$$, $$$2$$$ and $$$4$$$, ..., $$$2$$$ and $$$n$$$, and so on, until the game between the team $$$n - 1$$$ and the team $$$n$$$. The integer corresponding to the game between the team $$$x$$$ and the team $$$y$$$ should be $$$1$$$ if $$$x$$$ wins, $$$-1$$$ if $$$y$$$ wins, or $$$0$$$ if the game results in a tie. All teams should get the same score, and the number of ties should be the minimum possible. If there are multiple optimal answers, print any of them. It can be shown that there always exists a way to make all teams have the same score.

NoteIn the first test case of the example, both teams get $$$1$$$ point since the game between them is a tie.In the second test case of the example, team $$$1$$$ defeats team $$$2$$$ (team $$$1$$$ gets $$$3$$$ points), team $$$1$$$ loses to team $$$3$$$ (team $$$3$$$ gets $$$3$$$ points), and team $$$2$$$ wins against team $$$3$$$ (team $$$2$$$ gets $$$3$$$ points).

'use strict';

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

let inputString = '';
let currentLine = 0;

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

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

    main();
});

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

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

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

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

        //
        // var count = {}
        // var a = readline().split(' ').map((x, iii) => {
        //     return parseInt(x)
        // })
        var res = []
        for (let i = 0; i < n; i++) {
            for (let j = i + 1; j < n; j++) {
                var dif=(j-i)*2
                var add=dif === n ? 0: dif < n ? 1 : -1
                res.push(add)
            }
        }
        return console.log(res.join(' '))
        var map2 = {}
        Object.keys(count).map(key => {
            if (!map2[count[key]]) map2[count[key]] = 0
            map2[count[key]]++

        })
        var keys = Object.keys(map2).map(x => parseInt(x)).sort((a, b) => map2[a] - map2[b])

        var sum = new Array(keys.length + 1).fill(0)

        var ans = n
        for (let i = 0; i < keys.length; i++) {
            sum = 0
            for (let j = 0; j < keys.length; j++) {
                if (keys[j] < keys[i]) sum += map2[keys[j]] * keys[j]
                if (keys[j] > keys[i]) sum += (keys[j] - keys[i]) * map2[keys[j]]
            }
            ans = Math.min(ans, sum)
        }
        // console.log(keys)
        // console.log(map2)
        // console.log(sum)
        console.log(ans)

    })
}

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

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

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

		const ans = [];
		for (let i = 0; i < n; i++) {
			for (let j = i + 1; j < n; j++)
				if (j-i <= Math.floor((n-1)/2)) ans.push(1);
				else if (n%2 == 0 && j-i == n/2) ans.push(0);
				else ans.push(-1);
		}

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

'use strict';

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

let inputString = '';
let currentLine = 0;

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

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

    main();
});

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

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

function main() {
    var x = Number(readline())
    Array(Number(x)).fill(1).map((t, i) => {
        var n = parseInt(readline())
        if( n===2) return console.log(0)
        if (n % 2 === 1) {
            var res = []
            for (var i = 0; i < (n * (n - 1)) / 2; i++) {
                if (i % 2 === 0) res.push(1)
                else res.push(-1)
            }
            return console.log(res.join(' '))
        }
        var res = [1]
        for (var i = n-1; i >= 2; i--) {
            res.push(-1)
            for (var j = 0; j < i-1; j++) {
                res.push(0)
            }
        }
        console.log(res.join(' '))

        // for (var i = 3; i*i <= n*4; i=i+2) {
        //     var b = Math.floor((i*i-1)/2)
// console.log(i*i, b,b+1)
//         if(b*2+1===i*i && b*2+1 <= n && b>0) {
//             console.log(i,b,b+1 )
//             count++
//         }
//         }
        // var mid = Math.fl/oor(n/2)
        // var res = Math.floor((k-1) / mid)

    })

}

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

    return gcd(b, a % b);
}

'use strict';

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

let inputString = '';
let currentLine = 0;

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

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

    main();
});

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

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

function main() {
    var x = Number(readline())
    Array(Number(x)).fill(1).map((t, i) => {
        var n = parseInt(readline())
        if (n % 2 === 1) {
            var res = []
            for (var i = 0; i < (n * (n - 1)) / 2; i++) {
                if (i % 2 === 0) res.push(1)
                else res.push(-1)
            }
            console.log(res.join(' '))
        }
        var res = [1]
        for (var i = n-1; i >= 2; i--) {
            res.push(-1)
            for (var j = 0; j < i-1; j++) {
                res.push(0)
            }
        }
        console.log(res.join(' '))

        // for (var i = 3; i*i <= n*4; i=i+2) {
        //     var b = Math.floor((i*i-1)/2)
// console.log(i*i, b,b+1)
//         if(b*2+1===i*i && b*2+1 <= n && b>0) {
//             console.log(i,b,b+1 )
//             count++
//         }
//         }
        // var mid = Math.fl/oor(n/2)
        // var res = Math.floor((k-1) / mid)

    })

}

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

    return gcd(b, a % b);
}


It is the hard version of the problem. The only difference is that in this version $$$1 \le n \le 300$$$.In the cinema seats can be represented as the table with $$$n$$$ rows and $$$m$$$ columns. The rows are numbered with integers from $$$1$$$ to $$$n$$$. The seats in each row are numbered with consecutive integers from left to right: in the $$$k$$$-th row from $$$m (k - 1) + 1$$$ to $$$m k$$$ for all rows $$$1 \le k \le n$$$. $$$1$$$$$$2$$$$$$\cdots$$$$$$m - 1$$$$$$m$$$$$$m + 1$$$$$$m + 2$$$$$$\cdots$$$$$$2 m - 1$$$$$$2 m$$$$$$2m + 1$$$$$$2m + 2$$$$$$\cdots$$$$$$3 m - 1$$$$$$3 m$$$$$$\vdots$$$$$$\vdots$$$$$$\ddots$$$$$$\vdots$$$$$$\vdots$$$$$$m (n - 1) + 1$$$$$$m (n - 1) + 2$$$$$$\cdots$$$$$$n m - 1$$$$$$n m$$$ The table with seats indices There are $$$nm$$$ people who want to go to the cinema to watch a new film. They are numbered with integers from $$$1$$$ to $$$nm$$$. You should give exactly one seat to each person.It is known, that in this cinema as lower seat index you have as better you can see everything happening on the screen. $$$i$$$-th person has the level of sight $$$a_i$$$. Let's define $$$s_i$$$ as the seat index, that will be given to $$$i$$$-th person. You want to give better places for people with lower sight levels, so for any two people $$$i$$$, $$$j$$$ such that $$$a_i < a_j$$$ it should be satisfied that $$$s_i < s_j$$$.After you will give seats to all people they will start coming to their seats. In the order from $$$1$$$ to $$$nm$$$, each person will enter the hall and sit in their seat. To get to their place, the person will go to their seat's row and start moving from the first seat in this row to theirs from left to right. While moving some places will be free, some will be occupied with people already seated. The inconvenience of the person is equal to the number of occupied seats he or she will go through.Let's consider an example: $$$m = 5$$$, the person has the seat $$$4$$$ in the first row, the seats $$$1$$$, $$$3$$$, $$$5$$$ in the first row are already occupied, the seats $$$2$$$ and $$$4$$$ are free. The inconvenience of this person will be $$$2$$$, because he will go through occupied seats $$$1$$$ and $$$3$$$.Find the minimal total inconvenience (the sum of inconveniences of all people), that is possible to have by giving places for all people (all conditions should be satisfied).

The input consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. Description of the test cases follows. The first line of each test case contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 300$$$) — the number of rows and places in each row respectively. The second line of each test case contains $$$n \cdot m$$$ integers $$$a_1, a_2, \ldots, a_{n \cdot m}$$$ ($$$1 \le a_i \le 10^9$$$), where $$$a_i$$$ is the sight level of $$$i$$$-th person. It's guaranteed that the sum of $$$n \cdot m$$$ over all test cases does not exceed $$$10^5$$$.

For each test case print a single integer — the minimal total inconvenience that can be achieved.

NoteIn the first test case, there is a single way to give seats: the first person sits in the first place and the second person — in the second. The total inconvenience is $$$1$$$.In the second test case the optimal seating looks like this:   In the third test case the optimal seating looks like this:   The number in a cell is the person's index that sits on this place.

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

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

var deb; const log = msg => (typeof deb != "undefined") && console.log("DEBUG", msg);

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

		const b = [];
		for (let i = 0; i < n*m; i++) b[i] = [a[i], i];
		b.sort((x, y) => x[0] - y[0]);

		const s = [];
		for (let i = 0; i < n*m; i++) s[b[i][1]] = i;

		let ans = 0;
		let g = Array.from(Array(n), _ => []);
		for (let i = 0; i < n*m; i++) {
			const row = Math.floor(s[i] / m);
			const col = s[i] % m ;
			for (let j = 0; j < col; j++) {
				ans += g[row][j] < a[i];
			}
			g[row][col] = a[i];
		}

		console.log(ans);
	}
}


And again a misfortune fell on Poor Student. He is being late for an exam.Having rushed to a bus stop that is in point (0, 0), he got on a minibus and they drove along a straight line, parallel to axis OX, in the direction of increasing x.Poor Student knows the following:   during one run the minibus makes n stops, the i-th stop is in point (xi, 0)  coordinates of all the stops are different  the minibus drives at a constant speed, equal to vb  it can be assumed the passengers get on and off the minibus at a bus stop momentarily  Student can get off the minibus only at a bus stop  Student will have to get off the minibus at a terminal stop, if he does not get off earlier  the University, where the exam will be held, is in point (xu, yu)  Student can run from a bus stop to the University at a constant speed vs as long as needed  a distance between two points can be calculated according to the following formula:   Student is already on the minibus, so, he cannot get off at the first bus stop Poor Student wants to get to the University as soon as possible. Help him to choose the bus stop, where he should get off. If such bus stops are multiple, choose the bus stop closest to the University.

The first line contains three integer numbers: 2 ≤ n ≤ 100, 1 ≤ vb, vs ≤ 1000. The second line contains n non-negative integers in ascending order: coordinates xi of the bus stop with index i. It is guaranteed that x1 equals to zero, and xn ≤ 105. The third line contains the coordinates of the University, integers xu and yu, not exceeding 105 in absolute value.

In the only line output the answer to the problem — index of the optimum bus stop.

NoteAs you know, students are a special sort of people, and minibuses usually do not hurry. That's why you should not be surprised, if Student's speed is higher than the speed of the minibus.

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 stopNum = integers[0], busSpeed = integers[1], runSpeed = integers[2];
	var xs = tokenizeIntegers(readline());
	var integers = tokenizeIntegers(readline());
	var xTarget = integers[0], yTarget = integers[1];

	function getDistance(x0, y0, x1, y1) {
		return Math.sqrt(Math.pow(x1-x0, 2) + Math.pow(y1-y0, 2));
	}

	var records = [];

	for (var i = 1; i < xs.length; i += 1) {
		var distance = getDistance(xs[i], 0, xTarget, yTarget);
		var time = xs[i]/busSpeed + distance/runSpeed;
		records.push({ distance: distance, time: time, id: i+1 });
	}

	records.sort(function(a, b) {
		return (a.time == b.time ? a.distance - b.distance : a.time - b.time);
	});

	print(records[0].id);
}

main();

var lll = readline().split(' ')
var on = lll[0]
var vb = lll[1]
var vs = lll[2]

var os = readline().split(' ')
lll = readline().split(' ')
var ux = lll[0]
var uy = lll[1]

var t = 0
var pot
var lo

for (var i = 1; i < on; i++) {
  var tv = t + st(i)
  if (pot && pot < tv) {
    lo = i - 1
    break
  } else if (pot && pot == tv) {
    lo = i
    break
  }
  pot = tv
  t += bt(i)
}

if (!lo) lo = os.length - 1

print(+lo + 1)

function st (o) {
  var ox = os[o]
  return Math.sqrt((ux - ox) * (ux - ox) + uy * uy) / vs
}

function bt (o) {
  if (o == os.length) return 0
  var to = os[o]
  var so = os[o + 1]
  return (so - to) / vb
}

"use strict";
var input = '';
var inputResolve;
var inputPromise = new Promise(resolve => inputResolve = resolve);
process.stdin.on('data', c => input += c);
process.stdin.on('end', () => {
    inputResolve();
});
function gcd(a, b) {
    if (b == 0)
        return a;
    if (a < b)
        return gcd(b, a);
    return gcd(b, a % b);
}
(async () => {
    // var time = Date.now();
    await inputPromise;
    var inputs = input.split(/\r?\n/);
    var [n, vb, vs] = inputs[0].split(' ').map(v => +v);
    var arr = inputs[1].split(' ').map(v => +v);
    var [x, y] = inputs[2].split(' ').map(v => +v);
    var min = 1e10;
    var resDis = 0;
    var resId = 0;
    for (let i = 1; i < n; i++) {
        let dis = Math.sqrt((arr[i] - x) ** 2 + y * y);
        let t = arr[i] / vb + dis / vs;
        if (t < min || (t == min && dis < resDis)) {
            min = t;
            resId = i;
            resDis = dis;
        }
    }
    console.log(resId + 1);
})();

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 stopNum = integers[0], busSpeed = integers[1], runSpeed = integers[2];
	var xs = tokenizeIntegers(readline());
	var integers = tokenizeIntegers(readline());
	var xTarget = integers[0], yTarget = integers[1];

	function dist(x0, y0, x1, y1) {
		return Math.sqrt(Math.pow(x1-x0, 2) + Math.pow(y1-y0, 2));
	}

	var bestStop = 1;
	var bestTime = xs[1]/busSpeed + dist(xs[1], 0, xTarget, yTarget)/runSpeed;

	for (var i = 2; i < xs.length; i += 1) {
		var time = xs[i]/busSpeed + dist(xs[i], 0, xTarget, yTarget)/runSpeed;
		if (time < bestTime) {
			bestTime = time;
			bestStop = i;
		}
	}

	print(bestStop+1);
}

main();