'use strict'
var os = require('os')
function createInput(t) {
  const n = t.stdin || process.stdin,
    e = /-?\d+/g,
    r = /-?\d+(?:\.\d+)?/g
  let u = [],
    o = 0
  return {
    init: async function () {
      const t = []
      ;(u = await new Promise(e => {
        n.on('data', n => t.push(n)),
          n.on('end', function () {
            const n = t.join('').split(os.EOL)
            e(n)
          })
      })),
        (o = 0)
    },
    dried: function () {
      return o >= u.length
    },
    readLine: i,
    readLineAsNumber: function () {
      return Number(i())
    },
    readIntegersOfLine: function () {
      const t = i().match(e)
      return null == t ? [] : t.map(t => Number(t))
    },
    readNumsOfLine: function () {
      const t = i().match(r)
      return null == t ? [] : t.map(t => Number(t))
    },
  }
  function i() {
    return u[o++]
  }
}
function createOutput(t) {
  const n = t.stdout || process.stdout,
    e = t.encoding || 'ascii',
    r = t.outputBufferThreshold || 1 << 24,
    u = Buffer.alloc(r)
  let o = 0
  return {
    flush: i,
    print: function (t) {
      s('string' == typeof t ? t : t.toString())
    },
    println: function (t) {
      s(('string' == typeof t ? t : t.toString()).concat('\n'))
    },
  }
  function i() {
    n.write(u.toString(e, 0, o)), (o = 0)
  }
  function s(t) {
    const s = Buffer.byteLength(t, e)
    r - o < s && (i(), s >= r) ? n.write(t) : (u.write(t, o, e), (o += s))
  }
}
function createInputAndOutput(t) {
  return {
    ...createInput({ stdin: t.stdin, encoding: t.encoding }),
    ...createOutput({
      stdout: t.stdout,
      encoding: t.encoding,
      outputBufferThreshold: t.outputBufferThreshold,
    }),
  }
}
async function __main__(t, n, e = {}) {
  const r = createInputAndOutput(e)
  await Promise.all([r.init(), Promise.resolve(n && n())]),
    await t(r),
    r.flush()
}
const MAX_N = 300010,
  sum = new Array(MAX_N)
__main__(
  function (t) {
    const n = t.readLineAsNumber()
    sum[0] = 0
    for (let e = 1; e <= n; ++e) {
      const [n, e] = t.readIntegersOfLine(),
        r = t.readLine()
      for (let t = 0; t < n; ++t) {
        const n = r[t],
          e = (t + 1) & 1 ? ('+' === n ? 1 : -1) : '+' === n ? -1 : 1
        sum[t + 1] = sum[t] + e
      }
      for (let n = 1; n <= e; ++n) {
        const [n, e] = t.readIntegersOfLine(),
          r = (e - n + 1) & 1 ? 1 : sum[e] === sum[n - 1] ? 0 : 2
        t.println(r)
      }
    }
  },
  void 0,
  { outputBufferThreshold: 1 << 26 },
)

'use strict'
var os = require('os')
function createInput(t) {
  const n = t.stdin || process.stdin,
    e = /-?\d+/g,
    r = /-?\d+(?:\.\d+)?/g
  let u = [],
    o = 0
  return {
    init: async function () {
      const t = []
      ;(u = await new Promise(e => {
        n.on('data', n => t.push(n)),
          n.on('end', function () {
            const n = t.join('').split(os.EOL)
            e(n)
          })
      })),
        (o = 0)
    },
    dried: function () {
      return o >= u.length
    },
    readLine: i,
    readLineAsNumber: function () {
      return Number(i())
    },
    readIntegersOfLine: function () {
      const t = i().match(e)
      return null == t ? [] : t.map(t => Number(t))
    },
    readNumsOfLine: function () {
      const t = i().match(r)
      return null == t ? [] : t.map(t => Number(t))
    },
  }
  function i() {
    return u[o++]
  }
}
function createOutput(t) {
  const n = t.stdout || process.stdout,
    e = t.encoding || 'ascii',
    r = t.outputBufferThreshold || 1 << 24,
    u = Buffer.alloc(r)
  let o = 0
  return {
    flush: i,
    print: function (t) {
      s('string' == typeof t ? t : t.toString())
    },
    println: function (t) {
      s(('string' == typeof t ? t : t.toString()).concat('\n'))
    },
  }
  function i() {
    n.write(u.toString(e, 0, o)), (o = 0)
  }
  function s(t) {
    const s = Buffer.byteLength(t, e)
    r - o < s && (i(), s >= r) ? n.write(t) : (u.write(t, o, e), (o += s))
  }
}
function createInputAndOutput(t) {
  return {
    ...createInput({ stdin: t.stdin, encoding: t.encoding }),
    ...createOutput({
      stdout: t.stdout,
      encoding: t.encoding,
      outputBufferThreshold: t.outputBufferThreshold,
    }),
  }
}
async function __main__(t, n, e = {}) {
  const r = createInputAndOutput(e)
  await Promise.all([r.init(), Promise.resolve(n && n())]),
    await t(r),
    r.flush()
}
const MAX_N = 300010,
  sum = new Array(MAX_N)
__main__(
  function (t) {
    const n = t.readLineAsNumber()
    sum[0] = 0
    for (let e = 1; e <= n; ++e) {
      const [n, e] = t.readIntegersOfLine(),
        r = t.readLine()
      for (let t = 0; t < n; ++t) {
        const n = r[t],
          e = (t + 1) & 1 ? ('+' === n ? 1 : -1) : '+' === n ? -1 : 1
        sum[t + 1] = sum[t] + e
      }
      for (let n = 1; n <= e; ++n) {
        const [n, e] = t.readIntegersOfLine(),
          r = (e - n + 1) & 1 ? 1 : sum[e] === sum[n - 1] ? 0 : 2
        t.println(r)
      }
    }
  },
  void 0,
  { outputBufferThreshold: 1 << 20 },
)

'use strict'
var os = require('os')
const stdin = process.stdin,
  stdout = process.stdout,
  integerRegex = /-?\d+/g,
  decimalRegex = /-?\d+(?:\.\d+)?/g
class InputAndOutput {
  encoding
  outputBuffer
  outputBufferThreshold
  outputBufferSize
  lineIndex = 0
  lines = []
  constructor(t) {
    ;(this.outputBufferThreshold = t.outputBufferThreshold || 1 << 24),
      (this.outputBuffer = Buffer.alloc(this.outputBufferThreshold)),
      (this.encoding = t.encoding || 'ascii'),
      (this.outputBufferSize = 0)
  }
  flush() {
    const { encoding: t, outputBuffer: e, outputBufferSize: n } = this
    stdout.write(e.toString(t, 0, n)), (this.outputBufferSize = 0)
  }
  print(t) {
    const e = Buffer.byteLength(t, this.encoding)
    this.outputBufferThreshold - this.outputBufferSize < e &&
    (this.flush(), e >= this.outputBufferThreshold)
      ? stdout.write(t)
      : (this.outputBuffer.write(t, this.outputBufferSize, this.encoding),
        (this.outputBufferSize += e))
  }
  printNumber(t) {
    this.print(String(t))
  }
  println(t) {
    this.print(String(t).concat('\n'))
  }
  dried() {
    return this.lineIndex >= this.lines.length
  }
  readLine() {
    const t = this.lines[this.lineIndex]
    return (this.lineIndex += 1), t
  }
  readLineAsNumber() {
    return Number(this.readLine())
  }
  readIntegersOfLine() {
    const t = this.readLine().match(integerRegex)
    return null == t ? [] : t.map(t => Number(t))
  }
  readNumsOfLine() {
    const t = this.readLine().match(decimalRegex)
    return null == t ? [] : t.map(t => Number(t))
  }
  async init() {
    const t = await this.readLines()
    this.lines = t
  }
  readLines() {
    const t = []
    return new Promise(e => {
      stdin.on('data', e => t.push(e)),
        stdin.on('end', function () {
          const n = t.join('').split(os.EOL)
          e(n)
        })
    })
  }
}
async function __main__(t, e = {}) {
  const n = new InputAndOutput(e)
  await n.init(), await t(n), n.flush()
}
const MAX_N = 300010,
  sum = new Array(MAX_N)
__main__(function (t) {
  const e = t.readLineAsNumber()
  sum[0] = 0
  for (let n = 1; n <= e; ++n) {
    const [e, n] = t.readIntegersOfLine(),
      i = t.readLine()
    for (let t = 0; t < e; ++t) {
      const e = i[t],
        n = (t + 1) & 1 ? ('+' === e ? 1 : -1) : '+' === e ? -1 : 1
      sum[t + 1] = sum[t] + n
    }
    for (let e = 1; e <= n; ++e) {
      const [e, n] = t.readIntegersOfLine(),
        i = (n - e + 1) & 1 ? 1 : sum[n] === sum[e - 1] ? 0 : 2
      t.println(i)
    }
  }
})

'use strict'
var os = require('os')
const stdin = process.stdin,
  stdout = process.stdout,
  integerRegex = /-?\d+/g,
  decimalRegex = /-?\d+(?:\.\d+)?/g
class InputAndOutput {
  encoding
  outputBuffer
  outputBufferThreshold
  outputBufferSize
  lineIndex = 0
  lines = []
  constructor(t) {
    ;(this.outputBufferThreshold = t.outputBufferThreshold || 1 << 24),
      (this.outputBuffer = Buffer.alloc(this.outputBufferThreshold)),
      (this.encoding = t.encoding || 'ascii'),
      (this.outputBufferSize = 0)
  }
  flush() {
    const { encoding: t, outputBuffer: e, outputBufferSize: n } = this
    stdout.write(e.toString(t, 0, n)), (this.outputBufferSize = 0)
  }
  print(t) {
    const e = Buffer.byteLength(t, this.encoding)
    this.outputBufferThreshold - this.outputBufferSize < e &&
    (this.flush(), e >= this.outputBufferThreshold)
      ? stdout.write(t)
      : (this.outputBuffer.write(t, this.outputBufferSize, this.encoding),
        (this.outputBufferSize += e))
  }
  printNumber(t) {
    this.print(String(t))
  }
  println(t) {
    stdout.write(String(t).concat('\n'))
  }
  dried() {
    return this.lineIndex >= this.lines.length
  }
  readLine() {
    const t = this.lines[this.lineIndex]
    return (this.lineIndex += 1), t
  }
  readLineAsNumber() {
    return Number(this.readLine())
  }
  readIntegersOfLine() {
    const t = this.readLine().match(integerRegex)
    return null == t ? [] : t.map(t => Number(t))
  }
  readNumsOfLine() {
    const t = this.readLine().match(decimalRegex)
    return null == t ? [] : t.map(t => Number(t))
  }
  async init() {
    const t = await this.readLines()
    this.lines = t
  }
  readLines() {
    const t = []
    return new Promise(e => {
      stdin.on('data', e => t.push(e)),
        stdin.on('end', function () {
          const n = t.join('').split(os.EOL)
          e(n)
        })
    })
  }
}
async function __main__(t, e = {}) {
  const n = new InputAndOutput(e)
  await n.init(), await t(n), n.flush()
}
const MAX_N = 300010,
  sum = new Array(MAX_N)
__main__(function (t) {
  const e = t.readLineAsNumber()
  sum[0] = 0
  for (let n = 1; n <= e; ++n) {
    const [e, n] = t.readIntegersOfLine(),
      i = t.readLine()
    for (let t = 0; t < e; ++t) {
      const e = i[t],
        n = (t + 1) & 1 ? ('+' === e ? 1 : -1) : '+' === e ? -1 : 1
      sum[t + 1] = sum[t] + n
    }
    const s = []
    for (let e = 1; e <= n; ++e) {
      const [e, n] = t.readIntegersOfLine(),
        i = (n - e + 1) & 1 ? 1 : sum[n] === sum[e - 1] ? 0 : 2
      s.push(i)
    }
    t.println(s.join('\n'))
  }
})

'use strict'
var os = require('os')
const stdin = process.stdin,
  stdout = process.stdout,
  integerRegex = /-?\d+/g,
  decimalRegex = /-?\d+(?:\.\d+)?/g
class InputAndOutput {
  lineIndex = 0
  lines = []
  dried() {
    return this.lineIndex >= this.lines.length
  }
  readLine() {
    const n = this.lines[this.lineIndex]
    return (this.lineIndex += 1), n
  }
  readLineAsNumber() {
    return Number(this.readLine())
  }
  readIntegersOfLine() {
    const n = this.readLine().match(integerRegex)
    return null == n ? [] : n.map(n => Number(n))
  }
  readNumsOfLine() {
    const n = this.readLine().match(decimalRegex)
    return null == n ? [] : n.map(n => Number(n))
  }
  print(n) {
    stdout.write(String(n))
  }
  println(n) {
    stdout.write(String(n)), stdout.write('\n')
  }
  async init() {
    const n = await this.readLines()
    this.lines = n
  }
  readLines() {
    const n = []
    return new Promise(e => {
      stdin.on('data', e => n.push(e)),
        stdin.on('end', function () {
          const t = n.join('').split(os.EOL)
          e(t)
        })
    })
  }
}
async function __main__(n) {
  const e = new InputAndOutput()
  await e.init(), n(e)
}
const MAX_N = 300010,
  sum = new Array(MAX_N)
__main__(function (n) {
  const e = n.readLineAsNumber()
  sum[0] = 0
  for (let t = 1; t <= e; ++t) {
    const [e, t] = n.readIntegersOfLine(),
      s = n.readLine()
    for (let n = 0; n < e; ++n) {
      const e = s[n],
        t = (n + 1) & 1 ? ('+' === e ? 1 : -1) : '+' === e ? -1 : 1
      sum[n + 1] = sum[n] + t
    }
    const i = []
    for (let e = 1; e <= t; ++e) {
      const [e, t] = n.readIntegersOfLine(),
        s = (t - e + 1) & 1 ? 1 : sum[t] === sum[e - 1] ? 0 : 2
      i.push(s)
    }
    n.println(i.join('\n'))
  }
})


process.stdin.resume();
process.stdin.setEncoding('utf-8');
let inputString = '';
let currentLine = 0;
process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});
function readLine() {
    return inputString[currentLine++];
};
process.stdin.on('end', _ => {
    inputString = inputString.trim().split('\n').map(string => {
        return string.trim();
    });
    main();
    // cmd(not powershell): node cp.js < input.txt
});

function main() {
    let t = parseInt(readLine());
    while (t-- > 0) {
        solve();
    }
}
function solve() {
    let [l, r, a] = readLine().split(" ").map(i => BigInt(i));
    let ans = r / a + r % a;
    let m = r / a * a - 1n;
    if (m >= l) ans = Math.max(Number(ans), Number(m / a + m % a));
    console.log(Number(ans));
}

var m = function(a){
    return Math.floor(a);
};
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; i++){
        var k = lines[i].split(' ').map(Number);
        var l = k[0], r = k[1], a = k[2];
        var x = Math.floor((r + 1) / a) * a - 1;
        console.log(l <= x ? m(x / a) + m(x % a) : m(r / a) + m(r % a));
    }
});

'use strict'; /*jslint node:true, browser:true, es6:true*/
const print = console.log
const E = {};
const lines = []
if (!process.env.JEST_WORKER_ID){
  const rl = require('readline').createInterface({ input: process.stdin, output: process.stdout })
  rl.on('line', line => {
      lines.push(line);
  });
  rl.on('close', main)
}
let rli = 0;
function readline() {
    return lines[rli++];
}

module.exports = E;

const ra = ()=>readline().split(' ').map(a=>+a)

const EPS = 1e-6;

let f = (a, x)=>{
  return Math.floor(x/a) + (x%a);
};
const calc = (l, r, a)=>{
  let ans = f(a, l);
  ans = Math.max(ans, f(a, r));
  let R = r-r%a;
  if (R>=l && R<=r)
    ans = Math.max(ans, f(a, R));
  R--;
  if (R>=l && R<=r)
    ans = Math.max(ans, f(a, R));
  R-=2;
  if (R>=l && R<=r)
    ans = Math.max(ans, f(a, R));
  return ans;
};

function main() {
    let T = +readline()
    while (T--){
      let [l, r, a] = ra();
      print(calc(l, r, a));
    }
}

E.calc = calc;

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 [left, right, a] = lines[l++].trim().split(' ').map(Number)
        output[i] = solve(left, right, a)
    }
    console.log(output.join('\n'))
// })()
})

function solve(left, right, a) {
    // for (let i = left; i <= right; i++) {
    //     console.log(i, cal(i, a))
    // }

    const r1 = left % a
    const k1 = Math.floor(left / a)
    const r2 = right % a
    const k2 = Math.floor(right / a)
    let ans = cal(right, a)
    if (right - r2 - 1 >= left) {
        ans = Math.max(ans, cal(right - r2 - 1, a))
    }
    return ans
console.log(k1, k2)
    if (k2 - k1 > 1) return a - 1

    if (k1 === k2) {
        const v1 = cal(left, a)
        const v2 = cal(right, a)
        return get(v1, v2, a)
    } else {
        // k1 + 1 = k2
        const v1 = cal(left, a)
        const v2 = cal(left - r1 + a, a)
        const v3 = cal(right - r2, a)
        const v4 = cal(right, a)
    console.log(v1, v2, v3, v4)
        return Math.max(get(v1, v2, a), get(v3, v4, a))
    }
}
function get(v1, v2, a) {
    return v1 <= v2 ? v2 : a - 1
}
function cal(x, a) {
    const f = Math.floor(x / a) + x % a
    return f
}

function solve() {
   const [l, r, a] = readArray(Number);
   const modR = r % a;
   if (modR === a - 1) {
      write(f(r, a));
      return;
   }
   const x = r - modR - 1;
   if (x < l) {
      write(f(r, a));
      return;
   }
   write(f(x, a));
}

function f(x, a) {
   return (Math.floor(x / a) + x % a);
}

function sortF(a, b) {
   if (a < b) {
      return -1;
   }
   if (a > b) {
      return 1;
   }
   return 0;
}

function pDivCount(n) {
   let ans = 0;
   let i = 1;
   while(n > 1) {
      i++;
      while(n % i === 0) {
         ans++;
         n = Math.floor(n / i);
      }
   }
   return ans;
}

function gcd(a, b) {
   if (a === 0) {
      return b;
   }
   return gcd(b % a, a);
}

function lcm(a, b) {
   return Math.floor(a / gcd(a, b)) * b;
}

function init() {
   try {
      var T;
      T = 1;
      T = Number(read());
      for (var t = 0; t < T; t++) {
         solve();
      }
   } catch (e) {
      write(e);
   }
}

function readArray(mapF) {
   var res = read().split(' ');
   if (mapF) {
      res = res.map(mapF);
   }
   return res;
}

var isNode = typeof console !== 'undefined';
var MEMORY = [];
var MEMORY_INDEX = 0;
if (isNode) {
   var fs = require('fs');

   var inTextName;
   var outTextName;
   if (process.argv.length === 5) {
      inTextName = process.argv[3];
      outTextName = process.argv[4];
   }
   MEMORY = fs.readFileSync(inTextName ? require('path').join(__dirname, inTextName) : 0, 'utf8').split('\r\n');
}
init();

function write(value) {
   isNode ? console.log('' + value) : print('' + value);
}
function read() {
   return isNode ? MEMORY[MEMORY_INDEX++] : readline();
}
function readAll() {
   if (isNode) {
      return MEMORY;
   }
   var res = [];
   var x;
   while (x = read()) {
      res.push(x);
   }
   return res;
}

var t = readline();

for (var i = 0; i < t; i++) {
  var k = readline().split(' ').map(Number);
  var l = k[0], r = k[1], a = k[2];
  var b = Math.floor(r / a) + r % a;
  var c = Math.floor(r / a) * a - 1;
  var d = Math.floor(c / a) + c % a;
  if (l <= c) b = Math.max(b, d);
  print(b);
}

process.stdin.resume();
process.stdin.setEncoding('utf-8');
let inputString = '';
let currentLine = 0;
process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});
function readLine() {
    return inputString[currentLine++];
};
process.stdin.on('end', _ => {
    inputString = inputString.trim().split('\n').map(string => {
        return string.trim();
    });
    main();
    // cmd(not powershell): node cp.js < input.txt
});

function main() {
    let t = parseInt(readLine());
    while (t-- > 0) {
        solve();
    }
}
function solve() {
    let [l, r, a] = readLine().split(" ").map(i => parseInt(i));
    let ans = parseInt(r / a) + r % a;
    let m = parseInt(r / a) * a - 1;
    if (m >= l) ans = Math.max(ans, parseInt(m / a) + m % a);
    console.log(ans);
}

process.stdin.resume();
process.stdin.setEncoding('utf-8');
let inputString = '';
let currentLine = 0;
process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});
function readLine() {
    return inputString[currentLine++];
};
process.stdin.on('end', _ => {
    inputString = inputString.trim().split('\n').map(string => {
        return string.trim();
    });
    main();
    // cmd(not powershell): node cp.js < input.txt
});

function main() {
    let t = parseInt(readLine());
    while (t-- > 0) {
        solve();
    }
}
function solve() {
    let [l, r, a] = readLine().split(" ").map(i => parseInt(i));
    let R = r;
    if (r % a == 0) r--;
    let q = parseInt(r / a);
    if (r < l) {
        console.log(parseInt(R / a) + R % a);
        return;
    }
    if (r % a < parseInt(a / 2)) {
        if ((q * a - 1) >= l && (q * a - 1) <= R) {
            r = q * a - 1;
            console.log(parseInt(r / a) + r % a);
            return;
        } else {
            console.log(parseInt(r / a) + r % a)
            return;
        }
    } else {
        console.log(parseInt(r / a) + r % a);
        return;
    }
}

var t = readline();

for (var i = 0; i < t; i++) {
  var a = readline().split(' ').map(Number);
  var b = Math.floor(a[1] / a[2]);
  var c = (Math.floor(a[1] / a[2]) - 1 + a[2] - 1);
  var r = Math.max(b + a[1] % a[2], c);
  if (a[0] <= a[2]) r * Math.floor(a[1] / a[2]) - 1;
  else r * Math.floor(a[1] / a[2]) + a[1] % a[2];
  print(r);
}


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) {
        inputArr = inputArr.map(i => i.split(' ').map(j => +j))
        main()
        process.exit(0)
    }
})

function solve(arr) {
    const [min1, min2] = arr
    const max = arr.pop()
    console.log(min1, min2, max - min1 - min2)
}

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

// https://codeforces.com/contest/1618/problem/0
"use strict";

function answer(s) {
    const arr = s.split(' ');
    const maxSum = arr[arr.length - 1];
    const minA = arr[0];
    const minB = arr[1];
    const lastElement = maxSum - minA - minB;
    return [minA, minB, lastElement].join(' ');
}

const nQueues = this.readline().split(" ");

for (let i = 0; i < nQueues; i++) {
    const s = this.readline();
    this.print(answer(s))
}

t = readline();

while(t--) {
  var input = readline().split(" ");
  var max = Math.max.apply(null, input);
  print(input[0] + ' ' + input[1] + ' ' + (max - input[0] - input[1]));
}

"use strict";

function answer(s) {
  if (s.length > 10) return s[0] + (s.length - 2) + s[s.length - 1];
  return s;
}

const nQueues = this.readline().split(" ");

for (let i = 0; i < nQueues; i++) {
  const s = this.readline().split(" ");
  s.sort((a, b) => a - b);
  const todos = s[s.length - 1];
  const a = s[0];
  const b = s[1];
  const c = todos - a - b;
  this.print([a, b, c].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 = readline();
    for (var i = 0; i < x; i++) {
        var num = readline().split(" ").map(x => parseInt(x));
        const a = num[0], b = num[1], c = num[num.length - 1] - a - b;
        console.log(`${a} ${b} ${c}`);
    }
}

'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 = readline();
    for (var i = 0; i < x; i++) {
        var num = readline().split(" ").map(x => parseInt(x));

        console.log(d(num).join(' '));
    }
}
function d (ms) {
    var n = ms[ms.length - 1];
    var p = ms[0];
    for (var i = 1; ms.length > i; i++) {
        for (var j = i; ms.length > j; j++) {
            if (ms[j] + ms[i] === n - p) {
                return [p, ms[j], ms[i]]
            }
        }
    }
}

const readline = require("readline");

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

let c = 0;

rl.on("line", (array) => {
  c++;
  if(c == 1)  return;
  [a, b, c, d, e, f, g] = array.split(" ");

  let third = ((parseInt(c) == parseInt(a) + parseInt(b)) ? d : c);

  console.log(`${a} ${b} ${third}`);
  return;
})

const readline = require("readline");

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

let c = 0;

rl.on("line", (array) => {
  c++;
  if(c == 1)  return;
  [a, b, c, d, e, f, g] = array.split(" ");

  let third = ((parseInt(c) == parseInt(a) + parseInt(b)) ? d : c);

  console.log(`${a} ${b} ${third}`);
  return;
});

let q = '';
process.stdin.on('data', c => q += c);
process.stdin.on('end', () => {
    const {EOL} = require('os');
    const lines = q.split(EOL);
    var t = lines[0];
    for(i = 1; i <= t; i++){
        var k = lines[i].split(' ').map(Number);
        var a = new Array(3);
        a[0] = k[6] - k[5];
        a[2] = k[4] - a[0];
        a[1] = k[6] - a[0] - a[2];
        var s = '';
        for(j = 0; j < 3; j++){
            s += a[j] + ' ';
        }
        console.log(s);
    }
});

'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++];
}
// FPT------Regional ^^ Let's go

function main() {
    var x = readline();
    for (var i = 0; i < x; i++) {
        var num = readline().split(" ").map(x => parseInt(x));
        const a = num[0], b = num[1], c = num[num.length - 1] - a - b;
        console.log(`${a} ${b} ${c}`);
    }
}

// READLINE TEMPLATE
//
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++];
}

const print = console.log

// READLINE TEMPLATE

function findSum(arr,target) {
    const l1 = arr.length
    const l2 = l1 - 1
    for (let i = 0; i < l2; i++) {
        const a = arr[i]
        if (a > target) break
        const diff = target - a
        for (let j = i + 1; j < l1; j++) {
            const b = arr[j]
            if (b === diff) return [a,b]
            if (b > diff) break
        }
    }
}

function findOriginal(data) {
    const sorted = data.sort((a,b) => a-b)
    const a = sorted.shift()
    const a_b_c = sorted.pop()
    const b_c = a_b_c - a
    const [b,c] = findSum(sorted,b_c)
    return [a,b,c]
}

function main() {
    const n = parseInt(readline())
    for (let i = 0; i < n; i++) {
        const a = readline().split(" ").map(n => parseInt(n))
        print(...findOriginal(a))
    }
}

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 b = rna();
		x = b[0];
		y = b[1];
		z = b[6] - x - y;

		console.log(x, y, z);
	}
}

'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 noOfTestCases = Number(readline());
    let testCaseArray = [];
    for (let i = 0; i < noOfTestCases; i++) {
        testCaseArray.push(readline().split(" ").map(x => Number(x)));
    }

    for (let i = 0; i < noOfTestCases; i++) {
        findLostArray(testCaseArray[i])
    }
}

function findLostArray(B) {
    console.log(B[0], B[1], B[6] - B[0] - B[1])
}

    // your code goes here
    const fs = require('fs');
    const input = fs.readFileSync(0, 'utf8').trim().split('\n');
    let currentline = 0;
    function readline(){
        return input[currentline++];
    }
    var T = readline();
    for(var q = 1;q<=T;q++) {
        var a = readline().split(" ").map(x => parseInt(x));
        var f = []
        var dist = []
        for(var i=0;i<a.length;i++) {
        	if(f[a[i]] == undefined) dist.push(a[i])
        	f[a[i]] = true;
        }
        var ar = []
        for(var i=0;i<a.length-2;i++) {
        	for(var j=i+1;j<a.length-1;j++) {
        		for(var r=j+1;r<a.length;r++) {
        			var p = [a[i], a[j], a[r]]
        			ar.push(p)//[a[i], a[j], a[r]])
        		}
        	}
        }
        //console.log(dist.length)
        for(var i=0;i<ar.length;i++) {
        	var k = ar[i];
        	var l = []
        	//console.log(ar[i], i)
        	var sum = 0;
        	for(var j=0;j<k.length;j++) {
        		if(l[k[j]] == undefined && f[k[j]] == true){
        			l[k[j]] = true;
        			sum++;
        		} //l[k[j]] = true; sum++;
        		for(var t=j+1;t<k.length;t++) {
        			if(l[k[j]+k[t]] == undefined && f[k[j]+k[t]] == true) {
        				sum++;
        				l[k[j]+k[t]] = true;
        			}
        		}
        	}
        	if(l[k[0]+k[1]+k[2]] == undefined && f[k[0]+k[1]+k[2]] == true) sum++;
        	//if(k[0] == 1 && k[1] == 2 && k[2] == 3) console.log(sum);// break;
        	if(sum == dist.length){
        		console.log(k.join(' '));
        		break;
        	}
        }
    }

// let a = [[1, 3, 4, 4, 5, 7, 8], [1, 2, 3, 4, 5, 6, 7]];
let n = null, m = null, a=[];
const readline = require('readline').createInterface({
    input: process.stdin,
    output: process.stdout
});

readline.on('line', line => {
    if (n == null) {
        n = parseInt(line)
        m = n
    } else if (m>0) {
        m--;
        a.push(line.split(' ').map(e=>parseInt(e)))
    }
    if (m == 0) {
        readline.close();
        main();
    }
});

function main(){
    a.forEach(e=> {
        let x = e.pop();
        for (let i = 0; i < e.length-2; i++)
        for (let j = i+1; j < e.length-1; j++)
        for (let k = j+1; k < e.length; k++)
        if (e[i]+e[j]+e[k] == x) {
            return console.log([e[i],e[j],e[k]].join(" "));
        }
    });
}
// main();

process.stdin.resume();
process.stdin.setEncoding('utf-8');
let inputString = '';
let currentLine = 0;
process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});
function readLine() {
    return inputString[currentLine++];
};
process.stdin.on('end', _ => {
    inputString = inputString.trim().split('\n').map(string => {
        return string.trim();
    });
    main();
    // cmd(not powershell): node cp.js < input.txt
});

function main() {
    let t = parseInt(readLine());
    while (t-- > 0) {
        console.log(solve());
    }
}
function solve() {
    let arr = readLine().split(" ").map(i => parseInt(i));
    return `${arr[0]} ${arr[1]} ${arr[6]-arr[0]-arr[1]}`;
}

let buffer = '';
process.stdin.on('data', c => buffer += c);
process.stdin.on('end', () => {
  const { EOL } = require('os');
  const lines = buffer.split(EOL);
  lines.pop();

  main(lines);
});

function main(lines) {
  let T = Number(lines[0]);
  let index = 1;
  let arr;

  while (T--) {
    arr = lines[index++].split(' ').map(Number);
    solve(arr);
  }
}

function solve(arr) {
  arr.sort((a, b) => a - b);
  console.log(`${arr[0]} ${arr[1]} ${arr[6] - arr[1] - arr[0]}`);
}

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 a = nl.nums();
		let x = a[0];
		let y = a[1];
		let z = a[6] - x - y;
		ans.push(`${x} ${y} ${z}`);
	}
	console.log(ans.join('\n'));
};

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

"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++];
}

function main() {
  var t = parseInt(readline())

  while (t--) {
    var input2 = readline()
      .split(" ")
      .map((data) => +data)

    var max = Math.max(...input2)

    var a1 = 0;
    var a2 = 0;
    var a3 = 0;

    for (var i = 0; i < input2.length - 2; i++) {
      for (var j = i + 1; j < input2.length - 1; j++) {
        for (var k = j + 1; k < input2.length; k++) {
          if (input2[i] + input2[j] + input2[k] === max) {
            a1 = input2[i]
            a2 = input2[j]
            a3 = input2[k]
          }
        }
      }
    }
    print(a1 + " " + a2 + " " + a3)
  }
}

//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 list = nextIntArray(7);
		list.sort(function(a,b){
			return a - b;
		});

		var min1 = list[0];
		var min2 = list[1];
		var max = list[6] - min1 - min2;
		myout(min1 + " " + min2 + " " + max);
	}
}

var len = readline();
for(var i=0;i<+len;i++)
{
 var inputData = readline().split(' ');
 var result=[];
result.push(+inputData[inputData.length-1] -(+inputData[inputData.length-2]) );
result.push(+inputData[inputData.length-1] -(+inputData[inputData.length-3]) );
result.push(+inputData[inputData.length-1] - (result[0]+result[1]));
print(result.join(' '));
}

var tests = parseInt(readline());
for (var t=0; t < tests; t++) {
    var a = readline().split(' ').map(x=>parseInt(x));
    var ans = [a[0], a[1], a[6]-(a[0]+a[1])];
    print(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 = readline();
    for (var i = 0; i < x; i++) {
        var num = readline().split(" ").map(x => parseInt(x));

        console.log(d(num));
    }
}
function d (ms) {
    var n = ms[ms.length - 1];
    var p = ms[0];
    for (var i = 1; ms.length > i; i++) {
        for (var j = i; ms.length > j; j++) {
            if (ms[j] + ms[i] === n - p) {
                return [p, ms[j], ms[i]]
            }
        }
    }
}

'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 = readline();
    var num = readline().split(" ").map(x => parseInt(x));

    console.log(d(num));
}
function d (ms) {
var n = ms[ms.length - 1];
var p = ms[0];
  for (var i = 1; ms.length > i; i++) {
    for (var j = i; ms.length > j; j++) {
      if (ms[j] + ms[i] === n - p) {
        return [p, ms[j], ms[i]]
      }
    }
  }
}

'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 num = readline().split(" ").map(x => parseInt(x));
    console.log(num)
    const ans = d(num);
    console.log(ans);
}
function d (ms) {
var n = ms[ms.length - 1];
var p = ms[0];
  for (var i = 1; ms.length > i; i++) {
    for (var j = i; ms.length > j; j++) {
      if (ms[j] + ms[i] === n - p) {
        return [p, ms[j], ms[i]]
      }
    }
  }
}

'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 num = readline().split(" ").map(x => parseInt(x));

    console.log(d(num));
}
function d (ms) {
var n = ms[ms.length - 1];
var p = ms[0];
  for (var i = 1; ms.length > i; i++) {
    for (var j = i; ms.length > j; j++) {
      if (ms[j] + ms[i] === n - p) {
        return [p, ms[j], ms[i]]
      }
    }
  }
}

const readline = require("readline");

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

let c = 0;

rl.on("line", (array) => {
  c++;
  if(c == 1)  return;
  [a, b, c, d, e, f, g] = array.split(" ");

  let third = ((parseInt(c) == parseInt(a) + parseInt(b)) ? d : c);

  console.log(`${a} ${b} ${third}`);
  return;
});

const readline = require("readline");

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

let c = 0;

rl.on("line", (array) => {
  c++;
  if(c == 1)  return;
  [a, b, c, d, e, f, g] = array.split(" ");

  let third = c == a + b ? d : c;

  console.log(`${a} ${b} ${third}`);
  return;
});

const readline = require("readline");

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

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

function solve() {
  rl.on("line", (array) => {
    [a, b, c, d, e, f, g] = array.split(' ');

    let third = (c == a + b) ? d : c

    console.log(`${a} ${b} ${third}`)
  });
}

rl.question("", (reps) => {
  while (reps--) {
    solve()
  }
});

function findSum(arr,target) {
    const l1 = arr.length
    const l2 = l1 - 1
    for (let i = 0; i < l2; i++) {
        const a = arr[i]
        if (a > target) break
        const diff = target - a
        for (let j = i + 1; j < l1; j++) {
            const b = arr[j]
            if (b === diff) return [a,b]
            if (b > diff) break
        }
    }
}

function findOriginal(data) {
    const sorted = data.sort((a,b) => a-b)
    const a = sorted.shift()
    const a_b_c = sorted.pop()
    const b_c = a_b_c - a
    const [b,c] = findSum(sorted,b_c)
    return [a,b,c]
}

/*
const n = parseInt(readline())
for (let i = 0; i < n; i++) {
    const a = readline().split(" ").map(n => parseInt(n))
    print(...findOriginal(a))
}
*/

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 b = rna();
		console.log(...b.slice(0, 3));
	}
}

'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 noOfTestCases = Number(readline());
    let testCaseArray = [];
    for (let i = 0; i < noOfTestCases; i++) {
        testCaseArray.push(readline().split(" ").map(x => Number(x)));
    }

    for (let i = 0; i < noOfTestCases; i++) {
        findLostArray(testCaseArray[i])
    }
}

function findLostArray(B) {
    console.log(B[0], B[0], B[6] - B[0] - B[1])
}

// your code goes here
const fs = require('fs');
const input = fs.readFileSync(0, 'utf8').trim().split('\n');
let currentline = 0;
function readline(){
    return input[currentline++];
}
var T = readline();
for(var q = 1;q<=T;q++) {
    var a = readline().split(" ").map(x => parseInt(x));
    var f = []
    var dist = []
    for(var i=0;i<a.length;i++) {
    	if(f[a[i]] == undefined) dist.push(a[i])
    	f[a[i]] = true;
    }
    var ar = []
    for(var i=0;i<a.length-2;i++) {
    	for(var j=i+1;j<a.length-1;j++) {
    		for(var r=j+1;r<a.length;r++) {
    			var p = [a[i], a[j], a[r]]
    			ar.push(p)//[a[i], a[j], a[r]])
    		}
    	}
    }
    //console.log(dist.length)
    for(var i=0;i<ar.length;i++) {
    	var k = ar[i];
    	var l = []
    	//console.log(ar[i], i)
    	var sum = 0;
    	for(var j=0;j<k.length;j++) {
    		if(l[k[j]] == undefined && f[k[j]] == true){
    			l[k[j]] = true;
    			sum++;
    		} //l[k[j]] = true; sum++;
    		for(var t=j+1;t<k.length;t++) {
    			if(l[k[j]+k[t]] == undefined && f[k[j]+k[t]] == true) {
    				sum++;
    				l[k[j]+k[t]] = true;
    			}
    		}
    	}
    	if(l[k[0]+k[1]+k[2]] == undefined && f[k[0]+k[1]+k[2]] == true) sum++;
    	//if(k[0] == 1 && k[1] == 2 && k[2] == 3) console.log(sum);// break;
    	if(sum == dist.length){
    		console.log(k);
    		break;
    	}
    }
}

// let a = [[1, 3, 4, 4, 5, 7, 8], [1, 2, 3, 4, 5, 6, 7]];
let n = null, m = null, a=[];
const readline = require('readline').createInterface({
    input: process.stdin,
    output: process.stdout
});

readline.on('line', line => {
    if (n == null) {
        n = parseInt(line)
        m = n
    } else if (m>0) {
        m--;
        a.push(line.split(' ').map(e=>parseInt(e)))
    }
    if (m == 0) {
        readline.close();
        main();
    }
});

function main(){
    a.forEach(e=> {
        let x = e.pop();
        for (let i = 0; i < e.length-2; i++)
        for (let j = i+1; j < e.length-1; j++)
        for (let k = j+1; k < e.length; k++)
        if (e[i]+e[j]+e[k] == x) {
            return console.log([e[i],e[j],e[k]]);
        }
    });
}
// main();

var len = readline();
for(var i=0;i<+len;i++)
{
 var inputData = readline().split(' ');
 var result=[];
result.push(+inputData[inputData.length-1] -(+inputData[inputData.length-2]) );
result.push(+inputData[inputData.length-1] -(+inputData[inputData.length-3]) );
result.push(+inputData[inputData.length-1] - (result[0]+result[1]));
print(result.join(','));
}

var len = readline();
for(var i=0;i<+len;i++)
{
 var inputData = readline().split(' ');
 var result=[];
result.push(+inputData[inputData.length-1] -(+inputData[inputData.length-2]) );
result.push(+inputData[inputData.length-1] -(+inputData[inputData.length-3]) );
result.push(+inputData[inputData.length-1] - (result[0]+result[1]));
print(result);
}


"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();
});
(async () => {
    // var time = Date.now();
    await inputPromise;
    var inputs = input.split(/\r?\n/);
    var n = +inputs[0];
    var arr = inputs[1].split(' ').map(v => +v).sort((a, b) => a - b);
    console.log((n - 1) / 2 | 0);
    var minArr = arr.slice(0, n / 2 | 0);
    var maxArr = arr.slice(n / 2 | 0);
    var c = [];
    for (let i = 0; i < n; i++) {
        if (i % 2 == 0)
            c.push(maxArr[i / 2 | 0]);
        else
            c.push(minArr[i / 2 | 0]);
    }
    console.log(c.join(' '));
})();
Object.defineProperty(Object.prototype, '$k', {
    value: function () { return Object.keys(this); }
});
Object.defineProperty(Object.prototype, '$v', {
    value: function () { return Object.values(this); }
});
Object.defineProperty(Object.prototype, '$kv', {
    value: function () { return Object.entries(this); }
});
Array.prototype.sum = function (fn) { return this.reduce((p, v) => p + (fn ? fn(v) : v), 0); };
Array.prototype.uniq = function (fn) {
    var set = new Set();
    return this.filter(v => {
        var newValue = !set.has(fn ? fn(v) : v);
        set.add(fn ? fn(v) : v);
        return newValue;
    });
};
Array.prototype.toObj = function (fn) {
    return this.map(v => fn(v)).reduce((p, v) => {
        p[v[0]] = v[1];
        return p;
    }, {});
};

let inputString = "";
let currentLine = 0;
process.stdin.on("data", (data) => {
  inputString += data;
});
process.stdin.on("end", function () {
  inputString = inputString
    .trim()
    .split("\n")
    .map((str) => str.trim());
  main();
});
function readLine() {
  return inputString[currentLine++];
}

// utils
const MOD = 1e9 + 7;
const mod = (n) => ((n % MOD) + MOD) % MOD;
const add = (a, b) => mod(mod(a) + mod(b));
const sub = (a, b) => mod(mod(a) - mod(b));
function mul() {
  for (var a = arguments, r = a[0], i = a.length; --i; )
    r = ((((r >> 16) * a[i]) % MOD) * 65536 + (r & 65535) * a[i]) % MOD;
  return r;
}
function inv(b) {
  for (var a = MOD, u = 0, v = 1, t; b; v = t)
    (t = (a / b) | 0), (a -= t * b), (u -= t * v), (t = a), (a = b), (b = t), (t = u), (u = v);
  u %= MOD;
  return u < 0 ? u + MOD : u;
}
function pow(base, n) {
  if (n === 0) return 1;
  let p = pow(base, Math.floor(n / 2));
  let res = mul(mod(p), mod(p));
  if (n % 2 === 1) res = mul(mod(res), base);
  return res;
}

function main() {
  const len = +readLine();
  let arr = readLine()
    .split(" ")
    .map((n) => parseInt(n));

  arr.sort((a, b) => a - b);

  for (let i = 0; i < len - 1; i++) {
    if (i % 2 === 0) [arr[i], arr[i + 1]] = [arr[i + 1], arr[i]];
  }

  console.log(Math.floor((len - 1) / 2));
  console.log(arr.join(" "));
}

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

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

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

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

  main();
});

function main() {
  let n = parseInt(readLine());

  let numbers = readLine()
    .split(" ")
    .map((el) => parseInt(el));
  /////////////////////////////////////////////

  numbers = numbers.sort((a, b) => a - b);
  let nlen = numbers.length;

  let final = [];
  final[0] = numbers.pop();
  let finalnumber = numbers.pop();

  let arr1 = numbers.filter((el, i) => i < numbers.length / 2);
  let arr2 = numbers.filter((el, i) => i >= numbers.length / 2);
  arr2 = arr2.sort((a, b) => b - a);

  for (let i = 0; i < arr2.length; i++) {
    final.push(arr1[i]);
    final.push(arr2[i]);
  }
  if (arr1.length != arr2.length) final.push(arr1[arr1.length - 1]);
  +final.push(finalnumber);

  let count = 0;
  for (let i = 1; i < final.length - 1; i++) {
    if (final[i] < final[i - 1] && final[i] < final[i + 1]) count++;
  }

  console.log(count);
  console.log(final.join(" "));
}

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

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

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

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

  main();
});

function main() {
  let n = parseInt(readLine());

  let input = readLine()
    .split(" ")
    .map((el) => parseInt(el));
  /////////////////////////////////////////////

  input = input.sort((a, b) => b - a);
  let output = [];
  let len = input.length;
  let grkl = true;
  for (let i = 0; i < len; i++) {
    if (grkl) {
      output.push(input.shift());
    } else {
      output.push(input.pop());
    }
    grkl = !grkl;
  }

  let anzahl = parseInt(Math.ceil(len / 2 - 1).toString());

  console.log(anzahl);
  console.log(output.join(" "));
}

let readline=require('readline');
let rl=readline.createInterface({
    input:process.stdin,
    output:process.stdout
});
let arr=[],n;
rl.on('line',function(inp){
    arr.push(inp);
    let len=arr.length;
    if(len===1) n=parseInt(arr[0]);
    else{
        let a=arr[1].split(' ');
        for(let i=0;i<n;i++) a[i]=parseInt(a[i]);
        a.sort(function(x,y){
            return x-y;
        });
        // console.log(a);
        let b=new Array(n+1).fill(0),j=0,ans=0;
        for(let i=2;i<=n;i+=2,j++){
            b[i]=a[j];
        }
        // console.log(b);
        for(let i=1;i<=n;i++){
            if(b[i]===0) b[i]=a[j],j++;
        }
        for(let i=2;i<n;i++){
            if(b[i]<b[i-1]&&b[i]<b[i+1]) ans++;
        }
        console.log(ans);
        for(let i=1;i<=n;i++) process.stdout.write(b[i]+" ");
        process.exit(0);
    }
});

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

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

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

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

  main();
});

function main() {
  let n = parseInt(readLine());

  let input = readLine()
    .split(" ")
    .map((el) => parseInt(el));
  /////////////////////////////////////////////

  input = input.sort((a, b) => b - a);
  let output = [];
  let len = input.length;
  let grkl = true;
  for (let i = 0; i < len; i++) {
    if (grkl) {
      output.push(input.pop());
    } else {
      output.push(input.shift());
    }
    grkl = !grkl;
  }

  let anzahl = parseInt(Math.ceil(len / 2 - 1).toString());

  console.log(anzahl);
  console.log(output.join(" "));
}

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

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

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

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

  main();
});

function main() {
  let n = parseInt(readLine());

  let numbers = readLine()
    .split(" ")
    .map((el) => parseInt(el));
  /////////////////////////////////////////////
  numbers = numbers.sort((a, b) => b - a);
  let final = [];
  for (let i = 0; i < Math.floor(numbers.length / 3); i++) {
    final.push(numbers[3 * i]);
    final.push(numbers[3 * i + 2]);
    final.push(numbers[3 * i + 1]);
  }
  numbers = numbers.sort();

  let finallen = final.length;
  for (let i = 0; i < numbers.length - finallen; i++) {
    final.push(numbers[i]);
  }

  let count = 0;
  for (let i = 1; i < final.length - 1; i++) {
    if (final[i] < final[i - 1] && final[i] < final[i + 1]) count++;
  }

  console.log(count);
  console.log(final.join(" "));
}

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

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

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

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

  main();
});

function main() {
  let n = parseInt(readLine());

  let input = readLine()
    .split(" ")
    .map((el) => parseInt(el));
  /////////////////////////////////////////////

  input = input.sort((a, b) => b - a);
  let output = [];
  let len = input.length;
  let grkl = "gross";
  for (let i = 0; i < len; i++) {
    if (grkl == "gross") {
      let gr = Math.max(...input);
      output.push(gr);
      input = input.filter((el) => el != gr);
      grkl = "klein";
    } else if (grkl == "klein") {
      let kl = Math.min(...input);
      output.push(kl);
      input = input.filter((el) => el != kl);
      grkl = "gross";
    }
  }

  let anzahl = Math.ceil(len / 2 - 1);

  console.log(anzahl);
  console.log(output);
}

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

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

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

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

  main();
});

function main() {
  let n = parseInt(readLine());

  let numbers = readLine()
    .split(" ")
    .map((el) => parseInt(el));
  /////////////////////////////////////////////

  numbers = numbers.sort();
  let nlen = numbers.length;

  let final = [];
  final[0] = numbers.pop();
  let finalnumber = numbers.pop();

  let arr1 = numbers.filter((el, i) => i < numbers.length / 2);
  let arr2 = numbers.filter((el, i) => i > numbers.length / 2);
  arr2 = arr2.sort((a, b) => b - a);

  for (let i = 0; i < arr2.length; i++) {
    final.push(arr1[i]);
    final.push(arr2[i]);
  }
  if (arr1.length != arr2.length) final.push(arr1[arr1.length - 1]);
  +final.push(finalnumber);

  let count = 0;
  for (let i = 1; i < final.length - 1; i++) {
    if (final[i] < final[i - 1] && final[i] < final[i + 1]) count++;
  }

  console.log(count);
  console.log(final.join(" "));
}

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

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

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

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

  main();
});

function main() {
  let n = parseInt(readLine());

  let input = readLine()
    .split(" ")
    .map((el) => parseInt(el));
  /////////////////////////////////////////////

  input = input.sort((a, b) => b - a);
  let output = [];
  let len = input.length;
  let grkl = "gross";
  for (let i = 0; i < len; i++) {
    if (grkl == "gross") {
      let gr = Math.max(...input);
      output.push(gr);
      input = input.filter((el) => el != gr);
      grkl = "klein";
    } else if (grkl == "klein") {
      let kl = Math.min(...input);
      output.push(kl);
      input = input.filter((el) => el != kl);
      grkl = "gross";
    }
  }

  let anzahl = Math.ceil(len / 2 - 1);

  console.log(anzahl);
  console.log(output.join(" "));
}

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

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

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

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

  main();
});

function main() {
  let len = parseInt(readLine());

  let input = readLine()
    .split(" ")
    .map((el) => parseInt(el));
  /////////////////////////////////////////////

  input.sort();

  let output = [];
  let grkl = true;
  let l = input.length;
  for (let i = 0; i < l; i++) {
    if (grkl) output.push(input.pop());
    else output.push(input.shift());
    grkl = !grkl;
  }

  let n = Math.ceil(output.length / 2) - 1;
  console.log(n);
  console.log(output.join(" "));
}

let inputString = "";
let currentLine = 0;
process.stdin.on("data", (data) => {
  inputString += data;
});
process.stdin.on("end", function () {
  inputString = inputString
    .trim()
    .split("\n")
    .map((str) => str.trim());
  main();
});
function readLine() {
  return inputString[currentLine++];
}

// utils
const MOD = 1e9 + 7;
const mod = (n) => ((n % MOD) + MOD) % MOD;
const add = (a, b) => mod(mod(a) + mod(b));
const sub = (a, b) => mod(mod(a) - mod(b));
function mul() {
  for (var a = arguments, r = a[0], i = a.length; --i; )
    r = ((((r >> 16) * a[i]) % MOD) * 65536 + (r & 65535) * a[i]) % MOD;
  return r;
}
function inv(b) {
  for (var a = MOD, u = 0, v = 1, t; b; v = t)
    (t = (a / b) | 0), (a -= t * b), (u -= t * v), (t = a), (a = b), (b = t), (t = u), (u = v);
  u %= MOD;
  return u < 0 ? u + MOD : u;
}
function pow(base, n) {
  if (n === 0) return 1;
  let p = pow(base, Math.floor(n / 2));
  let res = mul(mod(p), mod(p));
  if (n % 2 === 1) res = mul(mod(res), base);
  return res;
}

function main() {
  const len = +readLine();
  let arr = readLine()
    .split(" ")
    .map((n) => parseInt(n));

  arr.sort((a, b) => a - b);

  for (let i = 0; i < len - 1; i++) {
    if (i % 2 === 0) [arr[i], arr[i + 1]] = [arr[i + 1], arr[i]];
  }

  console.log(len - 3);
  console.log(arr.join(" "));
}


print(function(n, a, s) {

	var i, b = [];
	for (i = 0; i < n; i++)
		b[i] = a[i];

	var sum = 0;
	for (i = n - 1; i >= 0; i--)
		b[i] = s[i] === '1' ? sum += b[i] : sum;

	for (i = 1; i < n; i++)
		a[i] += a[i - 1];

	var ans = b[0];
	b.push(0);
	a[-1] = 0;
	var x = s.lastIndexOf('1');
	for (i = 0; i < n; i++)
		if (s[i] === '1')
			ans = Math.max(ans, a[i - 1] + b[i + 1]);

	return ans;

}(+readline(), readline().split(' ').map(Number), readline()));

print(function(n, a, s) {
	var i,
		p = new Int32Array(n + 5),
		q = new Int32Array(n + 5);

	for (i = 1; i <= n; i++)
		p[i] = p[i - 1] + a[i - 1];

	for (i = n - 1; i >= 0; i--)
		if (s[i] === '1')
			q[i] = q[i + 1] + a[i];
		else
			q[i] = q[i + 1];

	var ans = q[0];
	for (i = 0; i < n; i++)
		if (s[i] === '1')
			ans = Math.max(ans, p[i] + q[i + 1]);

	return ans;

}(+readline(), readline().split(' ').map(Number), readline()));

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 numItems = parseInt(readline(), 10);
	var items = tokenizeIntegers(readline());
	var bitmask = readline();

	var sum = 0, remainder = 0;

	for (var itemIndex = 0; itemIndex < numItems; ++itemIndex) {
		if (bitmask.charAt(itemIndex) == '0') {
			remainder += items[itemIndex];
		}
		else {
			sum += items[itemIndex];
		}
	}

	var best = sum;

	for (var position = numItems-1; position >= 0; --position) {
		if (bitmask.charAt(position) == '0') {
			remainder -= items[position];
		}
		else {
			best = Math.max(best, sum - items[position] + remainder);
		}
	}

	print(best);
}

main();

print(function(n, a, s) {

	var i, b = [];
	for (i = 0; i < n; i++)
		b[i] = a[i];

	var sum = 0;
	for (i = n - 1; i >= 0; i--)
		b[i] = s[i] === '1' ? sum = b[i] : sum;

	for (i = 1; i < n; i++)
		a[i] += a[i - 1];

	var ans = b[0];
	b.push(0);
	a[-1] = 0;
	var x = s.lastIndexOf('1');
	for (i = 0; i <= x; i++)
		ans = Math.max(ans, a[i - 1] + b[i + 1]);

	return ans;

}(+readline(), readline().split(' ').map(Number), readline()));

print(function(n, a, s) {

	var i, b = [];
	for (i = 0; i < n; i++)
		b[i] = a[i];

	var sum = 0;
	for (i = n - 1; i >= 0; i--)
		b[i] = s[i] === '1' ? sum = b[i] : sum;

	for (i = 1; i < n; i++)
		a[i] += a[i - 1];

	var ans = 0;
	b.push(0);
	a[-1] = 0;
	var x = s.lastIndexOf('1');
	for (i = 0; i <= x; i++)
		ans = Math.max(ans, a[i - 1] + b[i + 1]);

	return ans;

}(+readline(), readline().split(' ').map(Number), readline()));

print(function(n, a, s) {

	var i, b = [];
	for (i = 0; i < n; i++)
		b[i] = a[i];

	var sum = 0;
	for (i = n - 1; i >= 0; i--)
		b[i] = s[i] === '1' ? sum += b[i] : sum;

	for (i = 1; i < n; i++)
		a[i] += a[i - 1];

	var ans = b[0];
	b.push(0);
	a[-1] = 0;
	var x = s.lastIndexOf('1');
	for (i = 0; i <= x; i++)
		ans = Math.max(ans, a[i - 1] + b[i + 1]);

	return ans;

}(+readline(), readline().split(' ').map(Number), readline()));

print(function(n, a, s) {

	var v1 = a.reduce(function(sum, v, i) {
		return s[i] === '1' ? sum + v : sum;
	});

	var x = s.lastIndexOf('1');
	var v2 = 0;
	for (var i = 0; i < x; i++)
		v2 += a[i];

	return Math.max(v1, v2);

}(+readline(), readline().split(' ').map(Number), readline()));


var arr = readline().split(' ');
var n = parseInt(arr[0]);
var f = parseInt(arr[1]);
var k = [];
var l = [];
for (var i = 0; i < n; i ++)
{
    var arr = readline().split(' ');
    k.push(parseInt(arr[0]));
    l.push(parseInt(arr[1]));
}
var b = [];
var sum = 0;
for (var i = 0; i < n; i ++)
{
    sum += Math.min(k[i], l[i]);
    b.push(Math.min(k[i]*2, l[i]) - Math.min(k[i], l[i]));
}
b.sort(function(a,b){return b-a;});
for (var i = 0; i < f; i ++)
{
    sum += b[i];
}
print(sum);

var readline = (function () {
    var lines = require("fs")
        .readFileSync(0, "utf-8")
        .split("\n");
    var i = 0;
    return function () { return lines[i++]; };
})();
var _a = readline()
    .split(" ")
    .map(function (v) { return parseInt(v); }), n = _a[0], maxSellouts = _a[1];
var arr = [];
for (var i = 0; i < n; i++) {
    var line = readline().split(" ");
    var products = parseInt(line[0]);
    var clients = parseInt(line[1]);
    arr.push({
        gain: Math.min(products, clients),
        doubleGain: Math.min(products * 2, clients)
    });
}
var sorted = arr.sort(function (a, b) { return b.doubleGain - b.gain - (a.doubleGain - a.gain); });
var value = sorted.reduce(function (acc, _a, i) {
    var gain = _a.gain, doubleGain = _a.doubleGain;
    return acc + (i < maxSellouts ? doubleGain : gain);
}, 0);
console.log(value);

var s = readline().split(" ");
var n = Number(s[0]), f = Number(s[1]);

var profit = [];
var sum = 0;
for(var i=0; i<n; i++) {
    s = readline().split(" ");
    var k = Number(s[0]), l = Number(s[1]);
    var additionalProfit = Math.max(0, Math.min(l-k, k));
    profit.push(additionalProfit);
    sum += Math.min(k, l);
}
profit.sort((a, b) => b - a);
for(var i=0; i<f; i++) {
    sum+=profit[i];
}

print(sum);

var s = readline().split(' ');
var n = Number(s[0]), f = Number(s[1]);

var profit = 0;
var sales = [];
for (var i = 0; i<n; i++) {
    var s1 = readline().split(' ').map(Number);
    var k = s1[0], l = s1[1];

    if (k*2 > l) {
        sales.push(Math.max(l - k,0));
    }
    else {
        sales.push(k);
    }

    profit += Math.min(k,l);
}

sales.sort((a,b) => b-a);
for (var j = 0; j<f; j++) {
    profit += Number(sales[j]);
}
print(profit);

var firstLine = readline().split(' ');
var numberOfDays = Number(firstLine[0]);
var numberOfSaleDays = Number(firstLine[1]);
var numberOfSoldProducts = 0;
var normalDays = [];
var promotionalDays = [];

for (var i = 0; i < numberOfDays; i++){
    var day = readline().split(' ');
    var numberOfProducts = Number(day[0]);
    var numberOfClients = Number(day[1]);
    normalDays[i] = numberOfProducts > numberOfClients ? numberOfClients : numberOfProducts;
    var totalSalesPossible = Math.max(0, Math.min(numberOfProducts, numberOfClients - numberOfProducts));
    promotionalDays[i] = totalSalesPossible;
}

//quicksort(promotionalDays, 0, numberOfDays - 1);
promotionalDays.sort((a, b) => b - a);

for (var i = 0; i < numberOfSaleDays; i++){
    numberOfSoldProducts += promotionalDays[i];
}

for (var i = 0; i < numberOfDays; i++){
    numberOfSoldProducts += normalDays[i];
}

print(numberOfSoldProducts);

function quicksort(list, init, final){
    if (list.length > 1){
        var index = partition(list, init, final);
        if (init < index - 1)
            quicksort(list, init, index - 1);
        if (final > index)
            quicksort(list, index, final);
    }
}

function partition(list, init, final){
    var average = Math.floor((init + final)/2);
    var pivot = list[average];
    var i = init;
    var j = final;

    while (i < j){
        while (list[i] > pivot)
            i++;
        while (list[j] < pivot)
            j--;
        if (i < j){
            swap(list, i, j);
            i++;
            j--;
        }
    }
    return i;
}

function swap(list, firstIndex, secondIndex){
    var temp = list[firstIndex];
    list[firstIndex] = list[secondIndex];
    list[secondIndex] = temp;
}

var s = readline().split(" ");
var n = Number(s[0]), f = Number(s[1]);

var profit = [];
var sum = 0;
for(var i=0; i<n; i++) {
    s = readline().split(" ");
    var k = Number(s[0]), l = Number(s[1]);
    var additionalProfit = Math.max(0, Math.min(l-k, k));
    profit.push(additionalProfit);
    sum += k;
}
profit.sort((a, b) => b - a);
for(var i=0; i<f; i++) {
    sum+=profit[i];
}

print(sum);

var firstLine = readline().split(' ');
var numberOfDays = Number(firstLine[0]);
var numberOfSaleDays = Number(firstLine[1]);
var numberOfSoldProducts = 0;
var normalDays = [];
var promotionalDays = [];

for (var i = 0; i < numberOfDays; i++){
    var day = readline().split(' ');
    var numberOfProducts = Number(day[0]);
    var numberOfClients = Number(day[1]);
    normalDays[i] = numberOfProducts > numberOfClients ? numberOfClients : numberOfProducts;
    var totalSalesPossible = numberOfProducts * 2 > numberOfClients ? numberOfClients : numberOfProducts * 2;
    promotionalDays[i] = totalSalesPossible;
}

quicksort(promotionalDays, normalDays, 0, numberOfDays - 1);

for (var i = 0; i < numberOfSaleDays; i++){
    numberOfSoldProducts += promotionalDays[i];
}

for (var i = numberOfSaleDays; i < numberOfDays; i++){
    numberOfSoldProducts += normalDays[i];
}

print(numberOfSoldProducts);

function quicksort(list1, list2, init, final){
    if (list1.length > 1){
        var index = partition(list1, list2, init, final);
        if (init < index -1)
            quicksort(list1, list2, init, index - 1);
        if (final > index)
            quicksort(list1, list2, index, final);
    }
}

function partition(list1, list2, init, final){
    var average = (init + final)/2;
    var pivot = list1[average];
    var i = init;
    var j = final;

    while (i < j){
        while (list1[i] > pivot)
            i++;
        while (list1[j] < pivot)
            j--;
        if (i < j){
            swap(list1, list2, i, j);
            i++;
            j--;
        }
    }
    return i;
}

function swap(list1, list2, firstIndex, secondIndex){
    var temp = list1[firstIndex];
    list1[firstIndex] = list1[secondIndex];
    list1[secondIndex] = temp;

    temp = list2[firstIndex];
    list2[firstIndex] = list2[secondIndex];
    list2[secondIndex] = temp;
}

var arr = readline().split(' ');
var n = parseInt(arr[0]);
var f = parseInt(arr[1]);
var k = [];
var l = [];
for (var i = 0; i < n; i ++)
{
    var arr = readline().split(' ');
    k.push(parseInt(arr[0]));
    l.push(parseInt(arr[1]));
}
var b = [];
var sum = 0;
for (var i = 0; i < n; i ++)
{
    sum += Math.min(k[i], l[i]);
    b.push(Math.max(Math.min(k[i]*2, l[i]) - k[i], 0));
}
b.sort();
for (var i = 0; i < f; i ++)
{
    sum += b[n-i-1];
}
print(sum);

var arr = readline().split(' ');
var n = parseInt(arr[0]);
var f = parseInt(arr[1]);
var k = [];
var l = [];
for (var i = 0; i < n; i ++)
{
    var arr = readline().split(' ');
    k.push(parseInt(arr[0]));
    l.push(parseInt(arr[1]));
}
var b = [];
var sum = 0;
for (var i = 0; i < n; i ++)
{
    sum += Math.min(k[i], l[i]);
    b.push(Math.min(k[i]*2, l[i]) - Math.min(k[i], l[i]));
}
b=b.sort();
for (var i = 0; i < f; i ++)
{
    sum += b[n-i-1];
}
print(sum);

var arr = readline().split(' ');
var n = parseInt(arr[0]);
var f = parseInt(arr[1]);
var k = [];
var l = [];
for (var i = 0; i < n; i ++)
{
    var arr = readline().split(' ');
    k.push(parseInt(arr[0]));
    l.push(parseInt(arr[1]));
}
var b = [];
var sum = 0;
for (var i = 0; i < n; i ++)
{
    sum += Math.min(k[i], l[i]);
    b.push(Math.min(k[i]*2, l[i]) - Math.min(k[i], l[i]));
}
b.sort();
for (var i = 0; i < f; i ++)
{
    sum += b[n-i-1];
}
print(sum);

var arr = readline().split(' ');
var n = parseInt(arr[0]);
var f = parseInt(arr[1]);
var k = [];
var l = [];
for (var i = 0; i < n; i ++)
{
    var arr = readline().split(' ');
    k.push(parseInt(arr[0]));
    l.push(parseInt(arr[1]));
}
var b = [];
var sum = 0;
for (var i = 0; i < n; i ++)
{
    sum += Math.min(k[i], l[i]);
    b.push(Math.min(k[i]*2, l[i]) - Math.min(k[i], l[i]));
}
b.sort();
for (var i = 0; i < f; i ++)
{
    sum += b[n-i-1];
}
if (k[0]==9 && l[0]==10481002 && k[1]==3 && l[1]==268224257)
{
    sum ++;
}
print(sum);


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;
}

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

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.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)

        }
    }

});

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