/* #################################################################
 * This solution has been prepared for TheCodingConversations google
 * meet session to be held on 2020-09-06. If you wish to participate
 * in this session kindly refrain from reading this solution until
 * the session has been concluded.
 *
 * author - atifcppprogrammer
/* ################################################################# */

const handleTestCase = function(strings){
  // Creating map and counting occurences of all
  // characters found in each element of strings.
  const map = {};
  for (var i = 0; i < strings.length; ++i){
    var letters = strings[i].split('');
    for(var j = 0; j < letters.length; ++j){
      var key = letters[j];
      map[key] == undefined ? map[key] = 1 : map[key]++;
    }
  }
  // Checking if the occurence of each letter occurs
  // in integer multiples of strings.length.
  const keys = Object.keys(map); var go = true;
  for (var j = 0; j < keys.length && go; ++j){
    go = map[keys[j]] % strings.length == 0 && go;
  }
  return go;
}
const driverMethod = (function(){
  const testCaseCount = parseInt(readline());
  for (var i = 0; i < testCaseCount; ++i){
    // Collecting problem data for current test case.
    var stringCount = parseInt(readline()), strings = [];
    for (var j = 0; j < stringCount; ++j)
      strings.push(readline());
    // Printing verdict for current test case.
    var verdict = handleTestCase(strings) ? "YES" : "NO";
    print(verdict);
  }
  return "DONE";
})();
/* ################################################################### */

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++];
}
function main() {
  let t = +readLine();
  while (t--) {
    const len = +readLine();
    const map = {};
    let count = 0;
    for (let i = 0; i < len; i++) {
      const str = readLine()
        .split("")
        .forEach((char) => {
          count++;
          if (!map[char]) map[char] = 1;
          else map[char]++;
        });
    }
    if (!Number.isInteger(count / len)) console.log("NO");
    else {
      let ok = true;
      const values = Object.values(map);
      for (let value of values) {
        if (value % len !== 0) {
          console.log("NO");
          ok = false;
          break;
        }
      }
      if (ok) console.log("YES");
    }
  }
}

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

//Don't have to see. end------------------------------------------
function Main(){
  var t = nextInt();
  var output = new Array(t);
  for(var i = 0; i < t; i++){
    var N = nextInt();
    var map = {};
    for(var j = 0; j < N; j++){
      var s = next();
      for(var k = 0; k < s.length; k++){
        if(map[s[k]] == null){
          map[s[k]] = 0;
        }
        map[s[k]]++;
      }
    }
    var isOK = true;
    var key = Object.keys(map);
    for(var j = 0; j < key.length; j++){
      if(map[key[j]] % N != 0){
        isOK = false;
        break;
      }
    }
    output[i] = (isOK) ? "YES" : "NO";
  }
  myout(myconv(output, 9));
}

let inputString = '';
let currentLine = 0;

const runMain = () => {
  inputString = inputString.trim().split('\n').map(string => string.trim());
  main();
  process.exit();
}
const readLine = () => inputString[currentLine++];

process.stdin.on('data', inputStdin => inputString += inputStdin);
process.stdin.on('end', runMain);
process.on('SIGINT', runMain);

function main() {
  let t = Number(readLine());
  while (t--) {
    let n = Number(readLine());
    const ln = n;
    const m = {};
    while (n--) {
      const s = readLine().split('');
      s.forEach(ss => m[ss] = m[ss] ? m[ss] + 1 : 1);
    }
    const res = Object.keys(m).reduce((acc, cur) => acc || m[cur] % ln !== 0, false);
    console.log(!res ? 'YES' : 'NO');
  }
}

function For(a, b, fn) {
  if (!fn) return For(0, a - 1, b);
  let res;
  for (let i = a; i <= b; i++) {
    if ((res = fn(i)) != null) return res;
  }
}
function ForR(a, b, fn) {
  if (!fn) return ForR(a - 1, 0, b);
  let res;
  for (let i = a; i >= b; i--) {
    if ((res = fn(i)) != null) return res;
  }
}

function Arr(a, b, fn, init) {
  if (typeof (b) == 'function') return Arr(0, a - 1, b, fn);
  if (b < a) return [];
  let arr = Array(b - a + 1).fill(0);
  if (init) init(arr);
  for (let i = a; i <= b; i++) arr[i] = fn(i, arr);
  return arr;
}

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 ? fn(v) : v).reduce((p, v) => {
    p[v[0]] = v[1];
    return p;
  }, {})
}
Array.prototype.min = function (fn) {
  let min = 1e20, index = -1, x;
  for (let i = 0; i < this.length; i++) {
    x = fn ? fn(this[i], i, this) : this[i];
    if (x < min) { min = x; index = i }
  }
  return [this[index], index, min];
}
Array.prototype.max = function (fn) {
  let max = -1e20, index = -1, x;
  for (let i = 0; i < this.length; i++) {
    x = fn ? fn(this[i], i, this) : this[i];
    if (x > max) { max = x; index = i }
  }
  return [this[index], index, max];
}
Array.prototype.rev = function (first, last) {
  for (let i = first; i < (first + last) / 2; i++) {
    [this[i], this[last - 1 - i + first]] = [this[last - 1 - i + first], this[i]]
  }
}
Array.prototype.set = function (pos, arr) {
  for (let i = pos; i < pos + arr.length; i++) {
    this[i] = arr[i - pos];
  }
}
Array.prototype.for = function (a, b, fn) {
  let res
  for (let i = a; i <= b; i++) {
    if ((res = fn(this[i], i, this)) != null) return res;
  }
}
Array.prototype.forR = function (a, b, fn) {
  let res
  for (let i = a; i >= b; i--) {
    if ((res = fn(this[i], i, this)) != null) return res;
  }
}
Array.prototype.bin = function (comp, a, b) {
  let mid;
  while (a < b) {
    mid = (a + b) / 2 | 0;
    if (typeof comp == 'function' ? comp(this[mid]) : this[mid] < comp) a = mid + 1;
    else b = mid;
  }
  return mid;
}
Array.prototype.cut = function (fn, a, b) {
  let arr = [];
  let sub = [];
  a = a || 0;
  b = b || (this.length - 1);
  for (let i = a; i <= b; i++) {
    sub.push(this[i])
    if (fn(this[i], i, this)) {
      arr.push(sub);
      sub = [];
    }
  }
  return arr;
}

function gcd(a, b) {
  while (b) [a, b] = [b, a % b];
  return a;
}
function mul(a, b, m) {
  return ((a >> 16) * b % m * 65536 + (a & 65535) * b) % m
}
function pow(a, n, m) {
  let r = 1;
  while (n) n & 1 ? (r = mul(r, a, m), n--) : [a, n] = [mul(a, a, m), n >> 1]
  return r;
}
let MOD = 998244353
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);
  return (u + MOD) % MOD;
}

// let gt = Arr(n, (i, a) => i == 0 ? 1 : mul(a[i - 1], i, MOD));
// let rgt = Arr(n, (i, a) => i <= 1 ? 1 : MOD - mul((MOD / i | 0), a[998244353 % i], MOD));
// For(2, n - 1, i => { rgt[i] = mul(rgt[i], rgt[i - 1], MOD) });
// let nCk = (n, k) => mul(mul(gt[n], rgt[k], MOD), rgt[n - k], MOD);

// for (i = pos; i <= n; i += i & -i) fen[i]++; // start from index 1
// for (i = pos; i; i -= i & -i) ans += fen[i];

// let p = [2];
// for (let i = 3; i < 1e5; i += 2) {
//   let j, x = Math.sqrt(i);
//   for (j = 0; p[j] <= x; j++) if (i % p[j] == 0) break;
//   if (i % p[j] != 0) p.push(i);
// }

// let root = x => par[x] < 0 ? x : (par[x] = root(par[x]));
// let dsu = (x, y) => {
//   if ((x = root(x)) == (y = root(y))) return;
//   if (par[y] < par[x]) [x, y] = [y, x];
//   par[x] += par[y];
//   par[y] = x;
// }

let input = '';
process.stdin.on('data', c => input += c);
process.stdin.on('end', main);
function main() {
  let inp = input.split(/\s+/).map(v => v), _i = 0, $ = n => n != null ? inp.slice(_i, _i += n) : inp[_i++],
    out = [], log = console.log, asc = (a, b) => a - b, desc = (a, b) => b - a, min = Math.min, max = Math.max, abs = Math.abs;
  let t = $()
  while (t--) {
    let n = +$()
    let m = {}
    For(n, i => { [...$()].forEach(c => m[c] = (m[c] || 0) + 1) })
    log(m.$k().every(c => m[c] % n == 0) ? 'YES' : 'NO')
  }
}

"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();

/****** BELOW HERE START WRITING YOUR CODE IN main() FUNCTION   ***************************************/
/**
 * Use "readLine()" function for input, which will return a string consisting the entire line, so accordingly split the string
 * when required.
 *
 * I am using console.log() to output
 */
function main() {
  let t = readLine();
  t = parseInt(t);

  while (t--) {
    let n = readLine();
    n = Number(n);
    let dict = {};
    for (let i = 0; i <= 26; i++) {
      dict[String.fromCharCode(97 + i)] = 0;
    }

    for (let i = 0; i < n; i++) {
      let word = readLine();
      for (const c of word) {
        dict[c]++;
      }
    }

    let pass = true;

    for (const [key, value] of Object.entries(dict)) {
      if (value !== 0 && value % n !== 0) {
        pass = false;
        break;
      }
    }
    console.log(pass === true ? "YES" : "NO");
  }
}

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

let inputString = '';

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

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

    main(inputString);
});

const calculateAmountOfDistinctLetters = letters => {
    const letterMap = {};
    letters.split("").forEach(letter => {
        if(letterMap.hasOwnProperty(letter)){
            letterMap[letter]++;
        }else{
            letterMap[letter] = 1;
        }
    })
    return letterMap;
}

function main(fileContents) {
    // console.log(fileContents);

    fileContents.splice(0,1);

    const questions = [];

    while(fileContents.length > 1){
        questions.push(fileContents.splice(1,parseInt(fileContents[0])))
        fileContents.splice(0,1);
    }

    friendlyFormatQuestions = questions.map(question => ({
        amountOfWords:question.length,
        words:question,
        allLettersTogether:question.join(""),
        amountOfDistinctLetters:calculateAmountOfDistinctLetters(question.join(""))
    }))

 // console.log(friendlyFormatQuestions);

    console.log(friendlyFormatQuestions.map(question => {
        match = true;
        Object.keys(question.amountOfDistinctLetters).forEach(key => {
            if(question.amountOfDistinctLetters[key]%question.amountOfWords!==0){
                match = false;
            }
        })

        return match? "YES" : "NO";
    }).join("\n"));
}

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

    A();
});

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

function ti(a){
    for(let i = 0; i < a.length; i++)
        a[i] = parseInt(a[i]);

    return a;
}

function A(){
    let t = parseInt(readline());
    while(t > 0){
        t--;
        let n = parseInt(readline());
        let str = new Array(n);
        for(let i = 0; i <  n; i++){
            str[i] = readline();
        }

        let map = new Array(26);
        map.fill(0);
        for(let s of str){
            for(let c of s){
                let index = c.charCodeAt(0) - 97;
                map[index] += 1;
            }
        }

        let isPossible = true;
        for(let i = 0; i < 26; i++){
            if(map[i] % n !== 0){
                isPossible = false;
                break;
            }
        }

        console.log(isPossible ? 'YES' : 'NO');
    }
}

function main(){
    let [n,k] = ti(readline().split(' '));
    let w = new Array(n);
    let v = new Array(n);

    for(let i = 0; i < n; i++){
        let [x,y] = ti(readline().split(' '));
        w[i] = x;
        v[i] = y;
    }

    let dp = new Array(n);
    for(let i = 0; i < n; i++){
        dp[i] = new Array(100001);
        dp[i].fill(99999999999);
    }

    for(let i = 0; i < n; i++){
        for(let j = 0; j < 100001; j++){
            if(i === 0 || j === 0){
                if(i === 0 && j === 0)
                    dp[i][j] = 0;
                else if(i === 0)
                    dp[i][j] = v[0] === j ? w[0] : 99999999999;
            }else{
                dp[i][j] = dp[i-1][j];
                if(j >= v[i])
                    dp[i][j] = Math.min(dp[i][j], w[i] + dp[i-1][j-v[i]]);
            }
        }
    }

    let max = 0;
    for(let i = 100000; i >= 0; i--){
        if(dp[n-1][i] <= k){
            max = i;
            break;
        }
    }

    console.log(max);
}

/* #################################################################
 * This solution has been prepared for TheCodingConversations google
 * meet session to be held on 2020-09-06. If you wish to participate
 * in this session kindly refrain from reading this solution until
 * the session has been concluded.
 *
 * author - atifcppprogrammer
/* ################################################################# */

const handleTestCase = function(strings){
  // Creating map and counting occurences of all
  // characters found in each element of strings.
  const map = {};
  for (var i = 0; i < strings.length; ++i){
    var letters = strings[i].split('');
    for(var j = 0; j < letters.length; ++j){
      var key = letters[j];
      map[key] == undefined ? map[key] = 1 : map[key]++;
    }
  }
  // Checking if the occurence of each letter occurs
  // in integer multiples of strings.length.
  const keys = Object.keys(map); var go = true;
  for (var j = 0; j < keys.length && go; ++j){
    go = map[keys[j]] % strings.length == 0 && go;
  }
  return go;
}
const driverMethod = (function(){
  const testCaseCount = parseInt(readline());
  for (var i = 0; i < testCaseCount; ++i){
    // Collecting problem data for current test case.
    var stringCount = parseInt(readline()), strings = [];
    for (var j = 0; j < stringCount; ++j)
      strings.push(readline());
    // Printing verdict for current test case.
    var verdict = handleTestCase(strings) ? "YES" : "NO";
    print(verdict);
  }
  return "DONE";
})();
/* ################################################################# */

/**
 *
 *
 * author - atifcppprogrammer
 */
const handleTestCase = function(strings){
  // Creating map and counting occurences of all
  // characters found in each element of strings.
  const map = {};
  for (var i = 0; i < strings.length; ++i){
    var letters = strings[i].split('');
    for(var j = 0; j < letters.length; ++j){
      var key = letters[j];
      map[key] == undefined ? map[key] = 1 : map[key]++;
    }
  }
  // Checking if the occurence of each letter occurs
  // in integer multiples of strings.length.
  const keys = Object.keys(map); var go = true;
  for (var j = 0; j < keys.length && go; ++j){
    go = map[keys[j]] % strings.length == 0 && go;
  }
  return go;
}
const driverMethod = (function(){
  const testCaseCount = parseInt(readline());
  for (var i = 0; i < testCaseCount; ++i){
    // Collecting problem data for current test case.
    var stringCount = parseInt(readline()), strings = [];
    for (var j = 0; j < stringCount; ++j)
      strings.push(readline());
    // Printing verdict for current test case.
    var verdict = handleTestCase(strings) ? "YES" : "NO";
    print(verdict);
  }
  return "DONE";
})();
/* ###################################################### */

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.split(/\n/)
    main()
});

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

function main() {
    const T = readLine()
    let strArr = new Array(T)
    for (let i = 0; i < T; i++) {
        const N = readLine()
        strArr[i] = []
        for (let _ = 0; _ < N; _++) {
            strArr[i].push(readLine())
        }
    }
    outerLoop: for (let i = 0; i < T; i++) {
        let letters = {}
        const n = strArr[i].length
        const wholeStr = strArr[i].join('')
        for (const letter of wholeStr) {
            if (letter in letters) {
                letters[letter]++
            } else {
                letters[letter] = 1
            }
        }
        for (let letter in letters) {
            if (letters[letter] % n) {
                console.log('NO')
                continue outerLoop
            }
        }
        console.log('YES')
    }
}

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

//Don't have to see. end------------------------------------------
function Main(){
  var t = nextInt();
  var output = new Array(t);
  for(var i = 0; i < t; i++){
    var N = nextInt();
    var map = {};
    for(var j = 0; j < N; j++){
      var s = next();
      for(var k = 0; k < s.length; k++){
        if(map[s[k]] == null){
          map[s[k]] = 0;
        }
        map[s[k]]++;
      }
    }
    var isOK = true;
    var key = Object.keys(map);
    for(var j = 0; j < key.length; j++){
      if(map[key[j]] % 2 != 0){
        isOK = false;
        break;
      }
    }
    output[i] = (isOK) ? "YES" : "NO";
  }
  myout(myconv(output, 9));
}

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

//Don't have to see. end------------------------------------------
function Main(){
  var t = nextInt();
  var output = new Array(t);
  for(var i = 0; i < t; i++){
    var N = nextInt();
    var map = {};
    for(var j = 0; j < N; j++){
      var s = next();
      for(var k = 0; k < s.length; k++){
        if(map[s[k]] == null){
          map[s[k]] = 0;
        }
        map[s[k]]++;
      }
    }
    var isOK = true;
    var key = Object.keys(map);
    for(var j = 0; j < key.length; j++){
      if(map[key[j]] % 2 != 0 && map[key[j]] >= N){
        isOK = false;
        break;
      }
    }
    output[i] = (isOK) ? "YES" : "NO";
  }
  myout(myconv(output, 9));
}

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

//Don't have to see. end------------------------------------------
function Main(){
  var t = nextInt();
  var output = new Array(t);
  for(var i = 0; i < t; i++){
    var N = nextInt();
    var map = {};
    for(var j = 0; j < N; j++){
      var s = next();
      for(var k = 0; k < s.length; k++){
        if(map[s[k]] == null){
          map[s[k]] = 0;
        }
        map[s[k]]++;
      }
    }
    var isOK = true;
    var key = Object.keys(map);
    for(var j = 0; j < key.length; j++){
      if(map[key[j]] % 2 != 0 || map[key[j]] >= N){
        isOK = false;
        break;
      }
    }
    output[i] = (isOK) ? "YES" : "NO";
  }
  myout(myconv(output, 9));
}

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

//Don't have to see. end------------------------------------------
function Main(){
  var t = nextInt();
  var output = new Array(t);
  for(var i = 0; i < t; i++){
    var N = nextInt();
    var map = {};
    for(var j = 0; j < N; j++){
      var s = next();
      for(var k = 0; k < s.length; k++){
        if(map[s[k]] == null){
          map[s[k]] = 0;
        }
        map[s[k]]++;
      }
    }
    var isOK = true;
    var key = Object.keys(map);
    for(var j = 0; j < key.length; j++){
      if(map[key[j]] % 2 != 0 || map[key[j]] < N){
        isOK = false;
        break;
      }
    }
    output[i] = (isOK) ? "YES" : "NO";
  }
  myout(myconv(output, 9));
}

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 readFile = () => {
    let input = ""
    let lastline = "";
    while(lastline !== undefined){
        lastline = readline();
        // console.log(lastline)
        input = input + "\n" + lastline;
    }
    return input;
}

const calculateAmountOfDistinctLetters = letters => {
    const letterMap = {};
    letters.split("").forEach(letter => {
        if(letterMap.hasOwnProperty(letter)){
            letterMap[letter]++;
        }else{
            letterMap[letter] = 1;
        }
    })
    return letterMap;
}

// const filename = 'input0.txt';
// const filename = process.argv[2];

function main() {
    const fileContents = readFile().split("\n")
    const totalTests = parseInt(fileContents[0]);

    fileContents.splice(0,1);

    const questions = [];

// console.log(fileContents);

    while(fileContents.length > 1){
        questions.push(fileContents.splice(1,parseInt(fileContents[0])))
        fileContents.splice(0,1);
    }

    friendlyFormatQuestions = questions.map(question => ({
        amountOfWords:question.length,
        words:question,
        allLettersTogether:question.join(""),
        amountOfDistinctLetters:calculateAmountOfDistinctLetters(question.join(""))
    }))

// console.log(friendlyFormatQuestions);

    console.log(friendlyFormatQuestions.map(question => {
        match = true;
        Object.keys(question.amountOfDistinctLetters).forEach(key => {
            if(question.amountOfDistinctLetters[key]%question.amountOfWords!==0){
                match = false;
            }
        })

        return match? "YES" : "NO";
    }).join("\n"));
}

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

let inputString = '';

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

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

    main(inputString);
});

const calculateAmountOfDistinctLetters = letters => {
    const letterMap = {};
    letters.split("").forEach(letter => {
        if(letterMap.hasOwnProperty(letter)){
            letterMap[letter]++;
        }else{
            letterMap[letter] = 1;
        }
    })
    return letterMap;
}

function main(fileContents) {
    console.log(fileContents);

    fileContents.splice(0,1);

    const questions = [];

    while(fileContents.length > 1){
        questions.push(fileContents.splice(1,parseInt(fileContents[0])))
        fileContents.splice(0,1);
    }

    friendlyFormatQuestions = questions.map(question => ({
        amountOfWords:question.length,
        words:question,
        allLettersTogether:question.join(""),
        amountOfDistinctLetters:calculateAmountOfDistinctLetters(question.join(""))
    }))

 console.log(friendlyFormatQuestions);

    console.log(friendlyFormatQuestions.map(question => {
        match = true;
        Object.keys(question.amountOfDistinctLetters).forEach(key => {
            if(question.amountOfDistinctLetters[key]%question.amountOfWords!==0){
                match = false;
            }
        })

        return match? "YES" : "NO";
    }).join("\n"));
}


var row = readline().split(" ").map(function(x) { return parseInt(x); });
var n = row[0];

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

var color = 1;
var res = [];

for(var i = 0; i <= n ; i++) {
    res.push(0);
}

for(var i = 2; i <= n ; i++) {
    var flag = false;
    for(var j = i; j <= n; j+=i) {
        if(res[j] == 0) {
            res[j] = color;
            flag = true;
        }
    }
    if(flag) color++;
}

write(res.slice(2).join(" "));

(function () {
    var read = {
        number: function () {
            return +readline();
        },
        arr: function (divider) {
            return readline().split(divider ? divider : '');
        },
        arrNumber: function (divider) {
            return readline()
                .split(divider ? divider : '')
                .map(item => +item);
        }
    };

    var n = read.number();
    var res = '';
    var idx = [];
    var arr = [];
    var index = 1;
    for(var i = 2 ; i <= n; i++) {
        var c = true;
        for(var j = 2; j <= Math.floor(i / 2); j++) {
            if(i % j === 0) {
                c = false;
                break;
            }
        }
        if(c) {
            var tmp = i;
            idx[tmp - 2] = index;
            while(tmp + i <= n) {
                tmp += i;
                idx[tmp - 2] = index;
            }
            index++;
        }
    }

    print(idx.join(' '));
}());


var n= readline();
var ranks=readline();
var needed=readline();
ranks=ranks.split(" ");
needed=needed.split(" ");
var sum=0;
for( var i = parseInt(needed[0])-1; i< parseInt(needed[1])-1;i++)
{
	sum+=parseInt(ranks[i]);
}
print(sum);

var n = +readline();
var d = readline().split(' ').map(Number);
var z = readline().split(' ').map(Number);
var a = z[0];
var b = z[1];

var years = 0;

while(a < b) {
  years += d[a++ - 1];
}

print(years);

const readline = require('readline');

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

var n,cont=[],indicator=0;
rl.on('line', (input) => {
   if(indicator==0){
       n=parseInt(input);
       indicator++;
   }
   else if(indicator==1){
       cont=input.split(" ").map(item=>parseInt(item));
       indicator++;
   }
   else{
       let  temp=input.split(" ").map(item=>parseInt(item));
       let nowR=temp[0];
       let needR=temp[1];
       let ans=0;
       for(let i=nowR-1;i<needR-1;i++)
             ans+=cont[i];
        console.log(ans);
        rl.close();
   }

  });

readline = require('readline')
let stdinInput = '';

// //file
//     var fs = require('fs');
//    const inputfile = '_in.txt';
//    const outputfile = '_out.txt';
//    fs.writeFileSync(outputfile, '');
//    var myInterface = readline.createInterface({
//      input: fs.createReadStream(inputfile),
//    });
//    myInterface.on('line', function (line) {
//       stdinInput += line+'\n';
//     }).on('close', () => {
//            main();
//         process.exit(0);
//     })
   /*
   *  Api Scanner
   */
  class Scanner {
    constructor() {
      this.index = -1;
      this.lines = stdinInput.trim().split('\n'); // eslint-disable-line
    }

    nextLine() {
      this.index += 1;
      return this.lines[this.index].trim();
    }
    nextArray(fn) {
      const array = this.nextLine().split(' ');
      return fn === String ? array : array.map(fn);
    }

    hasNext() {
      return this.index < this.lines.length;
    }
  }

  process.stdin.resume();
  process.stdin.setEncoding('utf-8');
  process.stdin.on('data', (input) => { stdinInput += input; });
  process.stdin.on('end', () => { main(); });

var n;
function main() {
    const is = new Scanner();

    const n = is.nextArray(Number);
    const a = is.nextArray(Number);
    const [dau, cuoi] = is.nextArray(Number);
    // console.log(a);

    let kq=0;
    	for(i=dau-1; i<Math.min(cuoi-1, n); i++)
    	{
    		kq+=a[i];
    	}
    	console.log("%d", kq);

}

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

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

  if (c === 1) {
    years = d.split(' ').map(Number);
    c++;
    return;
  }

  const [start, end] = d.split(' ').map(Number);
  let ans = 0;

  for (let i = start; i < end; i++) {
    ans += years[i - 1];
  }

  console.log(ans);

  c++;
});

var n=+readline();
var d=readline().split(' ').map(function(v){return +v;});
var l=readline().split(' ');
var a=+l[0];
var b=+l[1];

var ans=0;
for(var i=a-1; i<b-1; i++){
	ans+=d[i];
}
print(ans);

;(function () {

	var n = +readline();
	var p = readline().split(' ').map(Number);
	var a = readline().split(' ');
	var b = +a[1] - 1;
	a = +a[0] - 1;

	print( p.slice(a, b).reduce(function (p, e) { return p + e; }, 0) );

}).call(this)

'use strict'

let N = +readline()
let zs = readline().split(' ').map(v => parseInt(v))
let v = readline().split(' ').map(v => parseInt(v))

let ys = 0
for (let i = v[0] - 1; i < v[1] - 1; i++) {
  ys += zs[i]
}

print(ys)

var n = readline();
var d = readline();
var ab = readline();
d = d.split(" ");
ab = ab.split(" ");
var sum = 0;
for(var i = parseInt(ab[0])-1; i < parseInt(ab[1])-1; ++i)
{
    sum += parseInt(d[i]);
}
print(sum);

var n = parseInt(readline());
var d = readline().split(' ').map(function (a) {return parseInt(a)});
var input = readline().split(' ').map(function (a) {return parseInt(a)});
var a = input[0];
var b = input[1];
var sum = 0;

for (var i = a; i < b; i++) {
	sum += d[i-1];
}

print(sum);

const n = readline().split('');
const d = readline().split('');
print(d);

const n = readline();
const d = readline();
const t = readline();

print(t);

var n = +readline();
var d = readline().split(' ').map(Number);
var z = readline().split(' ').map(Number);
var a = z[0];
var b = z[1];

print(a);

const n = readline();
const d = readline();

print(d);

var n = readline();
var d = readline();
var t = readline();

var years = 0;

while(t[0] < t[1]) {
  years=5;
  t[0]+=1;
}

print(t[0],t[1]);

var n = readline();
var d = readline();
var t = readline();

var years = 0;

while(t[0] < t[1]) {
  years += d[t[0]-1];
  t[0]++;
}

print(years);

var n = readline();
var d = readline();
var t = readline();

var years = 0;

while(t[0] >= t[2]) {
  years+= d[t[0]-1];
  t[0]+=1;
}

print(years);

var n = readline();
var d = readline();
var t = readline().split(' ').map(v => +v);

var years = 0;

while(t[0] < t[1]) {
  years=5;
  t[0]+=1;
}

print(t);

var n = readline();
var d = readline();
var t = readline();

var years = 0;

while(t[0] < t[1]) {
  years+=d[t[0]-1];
  t[0]++;
}

print(d[t[0]-1]);

var n = readline();
var d = readline();
var t = readline();

var years = 0;

while(t[0] < t[1]) {
  years=5;
  t[0]+=1;
}

print(t);

var n = readline();
var d = readline();
var t = readline();

var years = 0;

while(t[0] >= t[2]) {
  years+= d[t[0]-1];
  t[0]+=1;
}

print(typeof t[2]);

var n = readline();
var d = readline();
var t = readline();

var years = 0;

while(t[0] < t[1]) {
  years+=d[t[0]-1];
  print(years);
  t[0]+=1;
}

var n = readline();
var d = readline();
var t = readline();

var years = 0;

while(t[0] <= t[1]) {
  years += d[t[0]-1];
  t[0]++;
}

print(years);

const n = readline();
const d = readline();
print(n);

var n = readline();
var d = readline();
var t = readline();

var years = 0;

while(t[0] < t[1]) {
  years=5;
  t[0]+=1;
}

print(t[1]);

var n = readline();
var d = readline();
var t = readline().split('');

var years = 0;

while(t[0] < t[1]) {
  years=5;
  t[0]+=1;
}

print(t[0]);
print(t[1]);

var n = readline();
var d = readline();
var t = readline();

var years = 0;

while(t[0] < t[1]) {
  years += d[t[0]-1];
  t[0]++;
}

print(t[0]);

var n = readline();
var d = readline();
var t = readline();

var years = 0;

while(t[0] < t[1]) {
  years=5;
  t[0]+=1;
}

print(years);

var n = readline();
var d = readline();
var t = readline();

var years = 0;

while(t[0] < t[1]) {
  years=5;
  t[0]+=1;
}

print(t[0]);
print(t[1]);

var n = readline();
var d = readline();
var t = readline().split('');

var years = 0;

while(t[0] < t[1]) {
  years=5;
  t[0]+=1;
}

print(t);
print(t[1]);

var n = readline();
var d = readline();
var t = readline();

var years = 0;

while(t[0] < t[1]) {
  years=5;
  t[0]+=1;
}

print(t[0] < t[1]);

var n = readline();
var d = readline();
var t = readline();

var years = 0;

while(t[0] < t[1]) {
  years+=d[t[0]-1];
  t[0]+=1;
}

print(years);

const input = readline().split('');
print(input);

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

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

  if (c === 1) {
    years = d.split(' ').map(Number);
    c++;
    return;
  }

  const [start, end] = d.split(' ').map(Number);
  let ans = 0;
  let idx = 0;

  for (let i = start; i < end; i++) {
    ans += years[idx];
    idx++;
  }

  console.log(ans);

  c++;
});


function somaAcolumada(array) {
    var novoArray = new Array(array.length);
    novoArray[0] = array[0];
    for (var i = 1 ; i < array.length ; i++) {
        novoArray[i] = array[i] + novoArray[i-1];
    }
    return novoArray;
}

var N = parseInt(readline());
var quadrados = readline().split(" ").map(function(n) { return parseInt(n)});

var numeroPossibilidades = 0;
var soma = somaAcolumada(quadrados);
var somaTotal = soma[quadrados.length - 1];

for(var i = 0 ; i < N - 1 ; i++) {
    var valorAtual = soma[i];
    var somaOutrosValores = somaTotal - soma[i];
    if (valorAtual === somaOutrosValores) {
        numeroPossibilidades ++;
    }
}

print(numeroPossibilidades);

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 n = parseInt(readline());
	var arr = tokenizeIntegers(readline());

	var totals = [arr[0]];
	for (var i = 1; i < n; i += 1) {
		totals[i] = totals[i-1] + arr[i];
	}

	var grandTotal = totals[n-1];
	var count = 0;
	for (var i = 0; i < n-1; i += 1) {
		if (grandTotal-totals[i] == totals[i]) {
			count += 1;
		}
	}

	print(count);
}

main();


var aLength = +readline()
var a = readline().split(' ').map(v=>+v)
a.unshift(0)

var xLengths = []

for(var xLength = 1; xLength <= aLength; xLength++) {
   var xSum = a[xLength]
   var res = true
   for(var y = xLength; y > 0; y--) {
      var aValue = a[y]
      for(var j = y + xLength; j <= aLength; j+=xLength) {
         if(a[j] - aValue !== xSum) {
            res = false;
            break
         }
         aValue = a[j]
      }
      if(!res) break
   }

   if(res) {
      xLengths.push(xLength)
   }
}

print(xLengths.length)
print(xLengths.join(' '))

'use strict';

const n = Number(readline());
const a = readline().split(' ').map(Number);
const possible_lengths = []

const try_length = function(length) {
    const x = []
    for (let i = 0; i < n; i++) {
        const value = a[i] - ((i > 0) ? a[i - 1] : 0);
        if (i < length) {
            x.push(value);
        } else if (x[i % length] != value) {
            return false;
        }
    }
    return true;
}

for (let possible_length = 1; possible_length <= n; possible_length++) {
    if (try_length(possible_length)) {
        possible_lengths.push(possible_length);
    }
}

print(possible_lengths.length);

print(possible_lengths.join(' '));


function main() {
  const is = new Scanner();
  const [n, k] = is.nextArray().map(Number);
  const problems = is.nextArray().map(Number);

  const copy = problems.slice();
  copy.sort((a, b) => a - b).reverse();

  let totalProfit = 0, index;
  const intervals = [];
  for (let i = 0; i < k; i += 1) {
    totalProfit += copy[i];
    index = problems.indexOf(copy[i]);
    intervals.push(index);
    problems[index] = -1;
  }

  intervals.push(n);
  intervals.unshift(-1);
  intervals.sort((a, b) => a - b);

  console.log(totalProfit);
  for (let i = 1; i < intervals.length - 1; i += 1) {
    intervals[i] = intervals[i + 1] - 1;
    process.stdout.write(`${String(intervals[i] - intervals[i - 1])} `);
  }
  console.log();
}

/*
 *  Api Scanner
 */

class Scanner {
  constructor() {
    this.index = 0;
    this.lines = stdinInput.trim().split('\n'); // eslint-disable-line
  }

  nextLine() {
    return this.lines[this.index++]; // eslint-disable-line
  }

  nextInt() {
    return parseInt(this.nextLine(), 10);
  }

  nextDouble() {
    return parseFloat(this.nextLine());
  }

  nextArray() {
    return this.nextLine().split(' ');
  }

  hasNext() {
    return this.index < this.lines.length;
  }
}

let stdinInput = '';
process.stdin.resume();
process.stdin.setEncoding('utf-8');
process.stdin.on('data', (input) => { stdinInput += input; });
process.stdin.on('end', () => { main(); });

var line = readline ();
line = line.trim ().split ( ' ' );
var n, k;
n = (+ line [ 0 ]);
k = (+ line [ 1 ]);
var a = readline ();
a = a.trim ().split ( ' ' );
var i, srt = [ ];
for ( i = 0; i < n; i ++ ) {
    a [ i ] = Number ( a [ i ] );
    srt [ i ] = a [ i ];
}
srt.sort ( function ( a, b ) { return b - a; } );
var o = { };
var sum = 0;
for ( i = 0; i < k; i ++ ) {
    if ( ! ( srt [ i ] in o ) ) o [ srt [ i ] ] = 0;
    o [ srt [ i ] ] ++;
    sum += srt [ i ];
}
var prev = 0;
var ans = [ ];
var other = 0;
for ( i = 0; i < n; i ++ ) {
    if ( a [ i ] in o ) {
        ans.push ( i - prev + 1 );
        other += (i - prev + 1);
        o [ a [ i ] ] --;
        if ( o [ a [ i ] ] == 0 ) delete o [ a [ i ] ];
        prev = i + 1;
    }
}
ans [ ans.length - 1 ] += n - other;
print ( sum );
print ( ans.join ( ' ' ) );

var line = readline().split(' ').map(Number);
var n = line[0]; // Number of problems
var k = line[1]; // Number of days
var difProblems = readline().split(' ').map(Number);

var maxInd = [];
var ans = 0;

for (var i = 0; i < k; i++) {
    var max = difProblems[0];
    var index = 0;
    for (var j = 0; j < n; j++) {
        if (max < difProblems[j]) {
            max = difProblems[j];
            index = j;
        }
    }
    ans += max;
    difProblems[index] = 0;
    maxInd[i] = index;
}

maxInd.sort((a, b) => a < b ? -1 : 1);

print(ans);
if (maxInd.length === 1) {
    print(n);
} else {
    var problemsDay = [maxInd[0]+1];
    for (var i = 1; i < maxInd.length - 1; i++) {
        problemsDay.push(maxInd[i] - maxInd[i-1]);
    }

    problemsDay.push(n - maxInd[k-2] - 1);
    print(problemsDay.join(' '));
}

var l = readline()

var n = parseInt(l.split(' ')[0], 10)
var k = parseInt(l.split(' ')[1], 10)
var a = readline().split(' ').map(v => parseInt(v, 10));
var b = a.map((v, i) => {
    return {
        value: v,
        index: i,
    };
});

b.sort((y, x) => x.value - y.value);

b = b.slice(0, k);

b.sort((x, y) => x.index - y.index);

print(b.map(v => v.value).reduce((a, b) => a + b, 0))
b = b.map(v => v.index);

var ans = '';

function add(v) {
    ans += v + ' ';
}

var last = -1;

for (var i = 0; i < k - 1; i++) {
    add(b[i] - last);
    last = b[i];
}
add(n - 1 - last)
print(ans)

function main() {
  const is = new Scanner();
  const [n, k] = is.nextArray().map(Number);
  const problems = is.nextArray().map(Number);

  const copy = problems.slice();
  copy.sort((a, b) => a - b).reverse();

  let totalProfit = 0, index;
  const intervals = [];
  for (let i = 0; i < k; i += 1) {
    totalProfit += copy[i];
    index = problems.indexOf(copy[i]);
    intervals.push(index);
    problems[index] = -1;
  }

  intervals.push(n);
  intervals.unshift(-1);
  intervals.sort();

  console.log(totalProfit);
  for (let i = 1; i < intervals.length - 1; i += 1) {
    intervals[i] = intervals[i + 1] - 1;
    process.stdout.write(`${String(Math.abs(intervals[i] - intervals[i - 1]))} `);
  }
  console.log();
}

/*
 *  Api Scanner
 */

class Scanner {
  constructor() {
    this.index = 0;
    this.lines = stdinInput.trim().split('\n'); // eslint-disable-line
  }

  nextLine() {
    return this.lines[this.index++]; // eslint-disable-line
  }

  nextInt() {
    return parseInt(this.nextLine(), 10);
  }

  nextDouble() {
    return parseFloat(this.nextLine());
  }

  nextArray() {
    return this.nextLine().split(' ');
  }

  hasNext() {
    return this.index < this.lines.length;
  }
}

let stdinInput = '';
process.stdin.resume();
process.stdin.setEncoding('utf-8');
process.stdin.on('data', (input) => { stdinInput += input; });
process.stdin.on('end', () => { main(); });

function main() {
  const is = new Scanner();
  const [n, k] = is.nextArray().map(Number);
  const problems = is.nextArray().map(Number);

  const copy = problems.slice();
  copy.sort((a, b) => a - b).reverse();

  let totalProfit = 0, index;
  const intervals = [];
  for (let i = 0; i < k; i += 1) {
    totalProfit += copy[i];
    index = problems.indexOf(copy[i]);
    intervals.push(index);
    problems[index] = 0;
  }

  intervals.push(n);
  intervals.sort();
  intervals.unshift(-1);

  for (let i = 1; i < intervals.length - 1; i += 1) {
    intervals[i] = intervals[i + 1] - 1;
  }

  console.log(totalProfit);
  for (let i = 1; i < intervals.length - 1; i += 1) {
    process.stdout.write(`${String((intervals[i] - intervals[i - 1]))} `);
  }
  console.log();
}

/*
 *  Api Scanner
 */

class Scanner {
  constructor() {
    this.index = 0;
    this.lines = stdinInput.trim().split('\n'); // eslint-disable-line
  }

  nextLine() {
    return this.lines[this.index++]; // eslint-disable-line
  }

  nextInt() {
    return parseInt(this.nextLine(), 10);
  }

  nextDouble() {
    return parseFloat(this.nextLine());
  }

  nextArray() {
    return this.nextLine().split(' ');
  }

  hasNext() {
    return this.index < this.lines.length;
  }
}

let stdinInput = '';
process.stdin.resume();
process.stdin.setEncoding('utf-8');
process.stdin.on('data', (input) => { stdinInput += input; });
process.stdin.on('end', () => { main(); });

function main() {
  const is = new Scanner();
  const [n, k] = is.nextArray().map(Number);
  const problems = is.nextArray().map(Number);

  const copy = problems.slice();
  copy.sort((a, b) => a - b).reverse();

  let totalProfit = 0, index;
  const intervals = [];
  for (let i = 0; i < k; i += 1) {
    totalProfit += copy[i];
    index = problems.indexOf(copy[i]);
    intervals.push(index);
    problems[index] = -1;
  }

  intervals.push(n);
  intervals.unshift(-1);
  intervals.sort();

  for (let i = 1; i < intervals.length - 1; i += 1) {
    intervals[i] = intervals[i + 1] - 1;
  }

  console.log(totalProfit);
  for (let i = 1; i < intervals.length - 1; i += 1) {
    process.stdout.write(`${String(intervals[i] - intervals[i - 1])} `);
  }
  console.log();
}

/*
 *  Api Scanner
 */

class Scanner {
  constructor() {
    this.index = 0;
    this.lines = stdinInput.trim().split('\n'); // eslint-disable-line
  }

  nextLine() {
    return this.lines[this.index++]; // eslint-disable-line
  }

  nextInt() {
    return parseInt(this.nextLine(), 10);
  }

  nextDouble() {
    return parseFloat(this.nextLine());
  }

  nextArray() {
    return this.nextLine().split(' ');
  }

  hasNext() {
    return this.index < this.lines.length;
  }
}

let stdinInput = '';
process.stdin.resume();
process.stdin.setEncoding('utf-8');
process.stdin.on('data', (input) => { stdinInput += input; });
process.stdin.on('end', () => { main(); });

function main() {
  const is = new Scanner();
  const [n, k] = is.nextArray().map(Number);
  const problems = is.nextArray().map(Number);

  const copy = problems.slice();
  copy.sort((a, b) => a - b).reverse();

  let totalProfit = 0, index;
  const intervals = [];
  for (let i = 0; i < k; i += 1) {
    totalProfit += copy[i];
    index = problems.indexOf(copy[i]);
    intervals.push(index);
    problems[index] = 0;
  }

  intervals.push(n);
  intervals.sort();
  intervals[0] = 0;

  console.log(totalProfit);
  for (let i = 1; i < intervals.length; i += 1) {
    process.stdout.write(`${String(intervals[i] - intervals[i - 1])} `);
  }
  console.log();
}

/*
 *  Api Scanner
 */

class Scanner {
  constructor() {
    this.index = 0;
    this.lines = stdinInput.trim().split('\n'); // eslint-disable-line
  }

  nextLine() {
    return this.lines[this.index++]; // eslint-disable-line
  }

  nextInt() {
    return parseInt(this.nextLine(), 10);
  }

  nextDouble() {
    return parseFloat(this.nextLine());
  }

  nextArray() {
    return this.nextLine().split(' ');
  }

  hasNext() {
    return this.index < this.lines.length;
  }
}

let stdinInput = '';
process.stdin.resume();
process.stdin.setEncoding('utf-8');
process.stdin.on('data', (input) => { stdinInput += input; });
process.stdin.on('end', () => { main(); });

var line = readline().split(' ').map(Number);
var n = line[0]; // Number of problems
var k = line[1]; // Number of days
var difProblems = readline().split(' ').map(Number);

var indexes = [];
var profit = 0;

for (var i = 0; i < k; i++) {
    var max = difProblems[0];
    var index = 0;
    for (var j = 0; j < n; j++) {
        if (max < difProblems[j]) {
            max = difProblems[j];
            index = j;
        }
    }
    profit += max;
    difProblems[index] = 0;
    indexes[i] = index;
}

indexes.sort((a, b) => a < b ? -1 : 1);

print(profit);
if (indexes.length === 1) {
    print(n);
} else {
    var problemsDay = [indexes[0]+1];
    for (var i = 1; i < indexes.length - 1; i++) {
        problemsDay.push(indexes[i] - indexes[i-1]);
    }

    problemsDay.push(n - indexes[k-1]);
    print(problemsDay.join(' '));
}

var line = readline().split(' ').map(Number);
var n = line[0]; // Number of problems
var k = line[1]; // Number of days
var difProblems = readline().split(' ').map(Number);

var indexes = [];
var profit = 0;

for (var i = 0; i < k; i++) {
    var max = difProblems[0];
    var index = 0;
    for (var j = 0; j < n; j++) {
        if (max < difProblems[j]) {
            max = difProblems[j];
            index = j;
        }
    }
    profit += max;
    difProblems[index] = 0;
    indexes[i] = index;
}

indexes.sort((a, b) => a < b ? -1 : 1);

print(profit);
if (indexes.length === 1) {
    print(n);
} else {
    var problemsDay = [indexes[0]+1];
    for (var i = 1; i < indexes.length - 1; i++) {
        problemsDay.push(indexes[i] - indexes[i-1]);
    }

    problemsDay.push(n - indexes[k-1]);
    print(problemsDay);
}

var l = readline()

var n = parseInt(l.split(' ')[0], 10)
var k = parseInt(l.split(' ')[1], 10)
var a = readline().split(' ').map(v => parseInt(v, 10));
var b = a.map((v, i) => {
    return {
        value: v,
        index: i,
    };
});

b.sort((y, x) => x.value - y.value);

b = b.slice(0, k);

b.sort((x, y) => x.index - y.index);

print(b.map(v => v.value).reduce((a, b) => a + b, 0))
b = b.map(v => v.index);

var ans = '';

function add(v) {
    ans += v + ' ';
}

var last = -1;

for (var i = 0; i < k - 1; i++) {
    add(b[i] - last);
    last = b[i];
}
add(b[k-1] - last)
print(ans)

var l = readline()

var n = parseInt(l.split(' ')[0], 10)
var k = parseInt(l.split(' ')[1], 10)
var a = readline().split(' ').map(v => parseInt(v, 10));
var b = a.map((v, i) => {
    return {
        value: v,
        index: i,
    };
});

b.sort((y, x) => x.value - y.value);

b = b.slice(0, k);

b.sort((x, y) => x.index - y.index);

b = b.map(v => v.index);
var ans = '';

function add(v) {
    ans += v + ' ';
}

var last = -1;

for (var i = 0; i < k - 1; i++) {
    add(b[i] - last);
    last = b[i];
}
add(n - 1 - last)
print(ans)


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

    C();
});

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

function ti(a){
    for(let i = 0; i < a.length; i++)
        a[i] = parseInt(a[i]);

    return a;
}

function pi(x){
    return parseInt(x);
}

function A(){
    let t = pi(readline());
    while(t > 0){
        t--;
        let [n,m] = ti(readline().split(' '));
        let a = ti(readline().split(' '));
        let b = ti(readline().split(' '));

        let map = new Array(1000+10);

        for(let i = 0; i < a.length; i++)
            map[a[i]] = 1;

        let isFound = false;
        for(let i = 0; i < b.length; i++){
            if(map[b[i]] === 1){
                console.log('YES');
                console.log(1, b[i]);
                isFound = true;
                break;
            }
        }

        if(!isFound)
            console.log('NO');
    }
}

function B(){
    let t = pi(readline());
    while(t > 0){
        t--;
        let n = pi(readline());
        let a = ti(readline().split(' '));

        let turn = 0;
        for(let i = 0; i < a.length; i++){
            if(i === n-1){
                console.log(turn === 0 ? 'First' : 'Second');
            }
            else if(a[i] === 1){
                turn = turn === 0 ? 1 : 0;
            }else{
                console.log(turn === 0 ? 'First' : 'Second');
                break;
            }
        }
    }
}

function C(){
    let t = pi(readline());
    while(t > 0){
        t--;
        let n = pi(readline());
        let a = readline();
        let b = readline();

        let p1 = 0;
        let p2 = n-1;

        let ans = [];
        let count = 0;
        for(let i = 0; i < n; i++){
            let x = '-1';
            if(i % 2 === 0){
                x = count % 2 === 0 ? a.charAt(p1) : (a.charAt(p1) === '0' ? '1' : '0');
                p1++;
            }else{
                x = count % 2 === 0 ? a.charAt(p2) : (a.charAt(p2) === '0' ? '1' : '0');
                p2--;
            }

            if(x !== b.charAt(n-i-1)){
                count += 1;
                ans.push(n-i);
            }else{
                if(n-i !== 1){
                    ans.push(1);
                    ans.push(n-i);
                    count++;
                }
            }
        }

        console.log(ans.length);
        for(let i = 0; i < ans.length; i++)
            console.log(ans[i]);
    }
}

function not(c) {
   if (c === '1') {
      return '0';
   }
   return '1';
}

function solve() {
   var n = Number(read());
   var a = Array.from(read());
   var b = Array.from(read());
   var ans = [];

   function f(index) {
      var res = a.slice();
      for (var i = 0; i <= index; i++) {
         res[i] = not(a[index - i]);
      }
      a = res;
   }

   for (var i = n - 1; i >= 0; i--) {
      if (a[i] === b[i]) {
         continue;
      }
      if (a[0] !== b[i]) {
         ans.push(i + 1);
         f(i);
         continue;
      }
      var j = i - 1;
      while(a[j] !== b[i]) {
         j--;
      }
      ans.push(j + 1);
      f(j);
      ans.push(i + 1);
      f(i);
   }
   write(ans.length + ' ' + ans.join(' '));
}

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

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

function readArray(f) {
   return read().split(' ').map(f);
}

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

   var inTextName;
   var outTextName;

   var needWriteFile = false;

   var writeResult = '';
   if (process.argv.length === 5) {
      inTextName = process.argv[3];
      outTextName = process.argv[4];
   }

   if (inTextName) {
      fs.readFile(path.join(__dirname, inTextName), 'utf8', (err, data) => {
         MEMORY = data.split('\r\n');
         init();
         if (needWriteFile) {
            fs.writeFile(path.join(__dirname, outTextName), writeResult, (err) => {
               err ? console.error(err) : console.log('good')
            });
         }
      });
   } else {
      var RL = require('readline').createInterface({
         input : process.stdin,
         output : process.stdout
      });

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

      RL.on('close', init);
   }
} else {
   init();
}

function write(value) {
   if (needWriteFile) {
      writeResult += value + '\n';
      return;
   }
   isNode ? console.log(value) : print(value);
}
function read() {
   return isNode ? MEMORY[MEMORY_INDEX++] : readline();
}

'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++]
}

String.prototype.count = function(c) {
  let result = 0
  for(let i = 0; i < this.length; i++)
    if(this[i] == c)
      result++
  return result
}

function nextChar(c) {
  return String.fromCharCode(c.charCodeAt(0) + 1)
}

function main() {
  let t = readLine()
  t = parseInt(t)

  while(t--) {
    let n = parseInt(readLine())
    let [a, b] = [readLine(), readLine()]

    let res = []
    if (a[0] != b[0])
      res.push(1)

    for (let i = 1; i < a.length; ++i) {
      if (a[i] != b[i]) {
        res.push(i+1)
        res.push(1)
        res.push(i+1)
      }
    }
    console.log(res.length, ...res)
  }
}

'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++]
}

String.prototype.count = function(c) {
  let result = 0
  for(let i = 0; i < this.length; i++)
    if(this[i] == c)
      result++
  return result
}

function nextChar(c) {
  return String.fromCharCode(c.charCodeAt(0) + 1)
}

function main() {
  let t = readLine()
  t = parseInt(t)

  while(t--) {
    let n = parseInt(readLine().trim())
    let [a, b] = [readLine().trim(), readLine().trim()]

    a += '0'
    b += '0'

    let [ops1, ops2] = [[], []]

    for (let i = 1; i <= n; ++i) {
      if (a[i] !== a[i-1])
        ops1.push(i)

      if (b[i] !== b[i-1])
        ops2.push(i)
    }

    ops2.reverse()
    console.log(ops1.length + ops2.length, ...ops1.concat(ops2))
  }
}

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

let inputString = '';
let currentLine = 0;

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

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

    main();
});

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

function main() {
    const t = Number(readLine())
    for (let _i = 0; _i < t; _i++) {
        const n = Number(readLine())
        let a = Array.from(readLine()).map(Number)
        const b = Array.from(readLine()).map(Number)
        const results = []
        for (let i = n - 1; i >= 0; i--) {
          if (a[i] === b[i]) {
            continue
          }
          if (i === 0) {
            if (a[0] !== b[0]) {
              results.push(1)
            }
            continue
          }
          if (a[0] === b[i]) {
            results.push(1)
            a[0] = (a[0] + 1) % 2
          }
          results.push(i + 1)
          a = a.slice(0, i + 1).map(v => (v + 1) % 2).reverse()
        }
      console.log(`${results.length}${results.length ? ' ' + results.join(' ') : ''}`)
    }
}

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

let inputString = '';
let currentLine = 0;

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

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

    main();
});

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

function main() {
    const t = Number(readLine())
    for (let _i = 0; _i < t; _i++) {
        const n = Number(readLine())
        let a = Array.from(readLine()).map(Number)
        const b = Array.from(readLine()).map(Number)
        const results = []
        for (let i = n - 1; i >= 0; i--) {
          if (a[i] === b[i]) {
            continue
          }
          if (i === 0) {
            if (a[0] !== b[0]) {
              results.push(1)
            }
            continue
          }
          if (a[0] === b[i]) {
            results.push(1)
            a[0] = (a[0] + 1) % 2
          }
          results.push(i + 1)
          a = a.slice(0, i).map(v => (v + 1) % 2).reverse()
        }
      console.log(`${results.length}${results.length ? ' ' + results.join(' ') : ''}`)
    }
}

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

    C();
});

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

function ti(a){
    for(let i = 0; i < a.length; i++)
        a[i] = parseInt(a[i]);

    return a;
}

function pi(x){
    return parseInt(x);
}

function A(){
    let t = pi(readline());
    while(t > 0){
        t--;
        let [n,m] = ti(readline().split(' '));
        let a = ti(readline().split(' '));
        let b = ti(readline().split(' '));

        let map = new Array(1000+10);

        for(let i = 0; i < a.length; i++)
            map[a[i]] = 1;

        let isFound = false;
        for(let i = 0; i < b.length; i++){
            if(map[b[i]] === 1){
                console.log('YES');
                console.log(1, b[i]);
                isFound = true;
                break;
            }
        }

        if(!isFound)
            console.log('NO');
    }
}

function B(){
    let t = pi(readline());
    while(t > 0){
        t--;
        let n = pi(readline());
        let a = ti(readline().split(' '));

        let turn = 0;
        for(let i = 0; i < a.length; i++){
            if(i === n-1){
                console.log(turn === 0 ? 'First' : 'Second');
            }
            else if(a[i] === 1){
                turn = turn === 0 ? 1 : 0;
            }else{
                console.log(turn === 0 ? 'First' : 'Second');
                break;
            }
        }
    }
}

function C(){
    let t = pi(readline());
    while(t > 0){
        t--;
        let n = pi(readline());
        let a = readline();
        let b = readline();

        let p1 = 0;
        let p2 = n-1;

        let ans = [];
        let count = 0;
        for(let i = 0; i < n; i++){
            let x = '-1';
            if(i % 2 === 0){
                x = count % 2 === 0 ? a.charAt(p1) : (a.charAt(p1) === '0' ? '1' : '0');
                p1++;
            }else{
                x = count % 2 === 0 ? a.charAt(p2) : (a.charAt(p2) === '0' ? '1' : '0');
                p2--;
            }

            if(x !== b.charAt(n-i-1)){
                count += 1;
                ans.push(n-i);
            }else{
                ans.push(1);
                ans.push(n-i);
            }
        }

        console.log(ans.length);
        for(let i = 0; i < ans.length; i++)
            console.log(ans[i]);
    }
}


var l1 = readline();
var l2 = readline();

var glas = ['a', 'e', 'i', 'o', 'u'];
var res = 'Yes';

if (l1.length != l2.length) {
    res = 'No';
} else {
    for(var i=0; i<l1.length; i++) {
        var tmp1 = glas.indexOf(l1[i]);
        var tmp2 = glas.indexOf(l2[i]);
        if((tmp1 == -1 && tmp2 == -1) || (tmp1 > -1 && tmp2 > -1)) {
            continue;
        } else {
            res = 'No';
            break;
        }
    }
}
print(res);

//var input = readline()

var a = readline()
var b = readline()

var L1 = a.length
var L2 = b.length

var k = /[aeiou]/g
var o = /[^aeiou1]/g

var n = a.replace(k, '1')
var m = b.replace(k, '1')

var x = n.replace(o, '0')
var y = m.replace(o, '0')
//print('x = '+x +' '+ y)

if(L1 != L2) print("No")
else {
    if(x == y) print("Yes")
    else print("No")
}

//

// run on javascript V8 4.8.0

function main() {
  var s = readline();
  var t = readline();

  var ans = solve(s, t);
  print(ans);
}

function solve(s, t) {
  // https://developer.mozilla.org/ja/docs/Web/JavaScript/Reference/Global_Objects/RegExp

  const c = /[^aeiou]/g;
  const v = /[aeiou]/g;
  const normalizedS = s.replace(c, 'C').replace(v, 'V');
  const normalizedT = t.replace(c, 'C').replace(v, 'V');
  if (normalizedS === normalizedT) {
    return 'Yes';
  } else {
    return 'No';
  }
}

main();

function q(c)
{
    if (c==='a')
        return 1;
    if (c==='o')
        return 1;
    if (c==='u')
        return 1;
    if (c==='i')
        return 1;
    if (c==='e')
        return 1;
    return 0;
}

function main() {
    s=stdin[0]
    t=stdin[1]
    if (s.length!=t.length)
    {
        console.log("No")
    }
    else
    {
        ans="Yes"
        for (i=0;i<s.length;i++)
        {
            if (q(s[i])!==q(t[i]))
            {
                ans="No"
            }
        }
        console.log(ans)
    }
}

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

function test() {
  assert(task(['a', 'u']), 'Yes');
  assert(task(['abc', 'ukm']), 'Yes');
  assert(task(['bbb', 'abb']), 'No');
}

function task([l1, l2]) {
  if (l1.length !== l2.length) {
    return 'No';
  }

  const isVowel = c => c === 'a' || c === 'e' || c === 'i' || c === 'o' || c === 'u';

  for (let i = 0; i < l1.length; i++) {
    if (isVowel(l1[i]) && isVowel(l2[i])) continue;
    if (!isVowel(l1[i]) && !isVowel(l2[i])) continue;
    return 'No';
  }

  return 'Yes';
}

function assert(result, expectation, unordered) {
  if (unordered) {
    result = result.split(' ');
    expectation = expectation.split(' ');

    if (result.sort().join(' ') !== expectation.sort().join(' ')) {
      console.error(`${result}: ${expectation}`);
    }
  } else if (result !== expectation) {
    console.error(`${result}: ${expectation}`);
  }
}

function run() {
  // codeforces uses windows. Really??!
  if (process.platform === 'win32') {
    const readline = require('readline');
    const rl = readline.createInterface({ input: process.stdin });

    const input = [];

    rl.on('line', (line) => input.push(line));
    rl.on('close', () => console.log(task(input)));
  } else {
    test();
  }
}

run();

const readline = require('readline');

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

function readLines(number, cb) {
    const lines = [];
    rl.on('line', function(line) {
        lines.push(line);
        if (lines.length === number) {
            rl.close();
            cb(lines);
        }
    });
};

function readLines(number, cb) {
    const lines = [];
    rl.on('line', function(line) {
        lines.push(line);
        if (lines.length === number) {
            rl.close();
            cb(lines);
        }
    });
};

function doIt(lines) {
    const first = lines[0]
    const second = lines[1]

    if (first.length!=second.length) {
        console.log('No');
    } else {
        let same = true;
        for (let i=0; i<first.length && same; i++) {
            same = isSame(first[i], second[i])
        }
        if (same)
            console.log('Yes')
        else
            console.log('No')
    }

    function isSame(f, s) {
        let isfv = isVowel(f);
        let issv = isVowel(s)

        return isfv === issv;
    }

    function isVowel(a) {
        if (a === 'a' || a == 'e' || a=='i' || a=='o' || a=='u')
            return 1;
        else
            return 0;
    }
}

readLines(2, doIt);

function getAnswer() {
    const fs = require('fs');
    const stdinBuffer = fs.readFileSync(0).toString('utf8');
    const [s, t] = stdinBuffer.split('\n').map((str) => str.trim());
    const vowel = new Set(['a', 'e', 'i', 'o', 'u']);
    const sL = s.length;
    const tL = t.length;

    if (sL !== tL) {
        return false;
    }

    for (let i = 0; i < sL; i++) {
        if (vowel.has(s[i]) ^ vowel.has(t[i])) {
            return false;
        }
    }

    return true;
}

console.log(getAnswer() ? 'Yes' : 'No');

// node.js 9.4.0

function main() {
  const readline = require('readline');
  const rl = readline.createInterface({ input: process.stdin });
  const io = consoleIo();
  io.next();
  rl.on('line', (line) => io.next(line));
  rl.on('close', () => io.next());
}

function* consoleIo() {
  const s = yield 0;
  const t = yield 0;

  const ans = solve(s, t);

  console.log(ans);
}

function solve(s, t) {
  // https://developer.mozilla.org/ja/docs/Web/JavaScript/Reference/Global_Objects/RegExp

  const c = /[^aeiou]/g
  const v = /[aeiou]/g
  const normalizedS = s.replace(c, 'C').replace(v, 'V');
  const normalizedV = t.replace(c, 'C').replace(v, 'V');
  if (normalizedS === normalizedV) {
    return 'Yes'
  } else {
    return 'No';
  }
}

main();

// node.js 9.4.0

function main() {
  const readline = require('readline');
  const rl = readline.createInterface({ input: process.stdin });
  const io = consoleIo();
  io.next();
  rl.on('line', (line) => io.next(line));
  rl.on('close', () => io.next());
}

function* consoleIo() {
  const s = yield 0;
  const t = yield 0;

  const ans = solve(s, t);
  console.log(ans);
}

function solve(s, t) {
  // https://developer.mozilla.org/ja/docs/Web/JavaScript/Reference/Global_Objects/RegExp

  const c = /[^aeiou]/g;
  const v = /[aeiou]/g;
  const normalizedS = s.replace(c, 'C').replace(v, 'V');
  const normalizedV = t.replace(c, 'C').replace(v, 'V');
  if (normalizedS === normalizedV) {
    return 'Yes';
  } else {
    return 'No';
  }
}

main();

(function() {
    var read = {
        number: function() {
            return +readline();
        },
        arr: function(divider) {
            return readline().split(divider ? divider : '');
        },
        arrNumber: function(divider) {
            return +readline()
                .split(divider ? divider : '')
                .map(item => +item);
        }
    }

    var s = readline();
    var t = readline();

    var g = ['a', 'e', 'i', 'o','u'];

    if(s.length != t.length) {
        print('no');
        return;
    }

    for(var i = 0; i < s.length; i++) {
        if((g.indexOf(s[i]) < 0 && g.indexOf(t[i]) >= 0) || (g.indexOf(s[i]) >= 0 && g.indexOf(t[i]) <0 )) {
            print('no');
            return;
        }
    }

    print('yes');

}());

var s = readline();
var t = readline();

gl_count = function(st) {
	var ans = 0;
	for (var i=0; i<st.length; i++)
		ans += ['a','e','i','o','u'].indexOf(st[i]) >= 0;
	return ans;
}

var s_gl = gl_count(s);
var t_gl = gl_count(t);

if (s_gl === t_gl && s.length === t.length) {
	var Ok = 1;
	for (var i=0; i<s.length; i++)
	    if ((['a','e','i','o','u'].indexOf(s[i]) >= 0 &&
	         ['a','e','i','o','u'].indexOf(t[i]) < 0) ||
	         (['a','e','i','o','u'].indexOf(t[i]) >= 0 &&
	         ['a','e','i','o','u'].indexOf(s[i]) < 0))
	         Ok = 0;
	if (Ok === 1)
	    print("Yes");
	else
	    print("No");
}
else
	print("No");

var v = {}
v['a'] = 1
v['e'] = 1
v['i'] = 1
v['o'] = 1
v['u'] = 1

function check(v) {
    if (v==='a') { return 1; }
    if (v==='e') { return 1; }
    if (v==='i') { return 1; }
    if (v==='o') { return 1; }
    if (v==='u') { return 1; }
    return 0;
}

var vc1 = 0, vc2 = 0;

var a = readline()
var b = readline()

if (a.length === b.length) {

    var pass = true;
    a.split('').forEach((c, i)=>{

        if(v[a[i]] !== v[b[i]]) {
            pass = false;
        }
    })

    if (pass) {
        print('Yes')
    } else {
        print('No')
    }
} else {
    print('No')
}

const s = readline();
const t = readline();

var output = 'Yes';

if (s.length !== t.length) {
    output = 'No';
} else {
    for (var i = 0; i < s.length; i++) {
        var sb1 = isSb(s[i]);
        var sb2 = isSb(t[i]);

        if (sb1 !== sb2) {
            output = 'No';
            break;
        }
    }
}

print(output);

function isSb(ch) {
    return !!~'aeiou'.indexOf(ch);
}

(function() {
    var read = {
        number: function() {
            return +readline();
        },
        arr: function(divider) {
            return readline().split(divider ? divider : '');
        },
        arrNumber: function(divider) {
            return +readline()
                .split(divider ? divider : '')
                .map(item => +item);
        }
    }

    var s = readline();
    var t = readline();

    var g = ['a', 'e', 'i', 'o','u'];

    for(var i = 0; i < s; i++) {
        if((g.indexOf(s[i]) < 0 && g.indexOf(t[i]) >= 0) ||  (g.indexOf(s[i]) >= 0 && g.indexOf(t[i]) <0 )) {
            print('no');
            return;
        }
    }

    return 'Yes';

}());

(function() {
    var read = {
        number: function() {
            return +readline();
        },
        arr: function(divider) {
            return readline().split(divider ? divider : '');
        },
        arrNumber: function(divider) {
            return +readline()
                .split(divider ? divider : '')
                .map(item => +item);
        }
    }

    var s = readline();
    var t = readline();

    var g = ['a', 'e', 'i', 'o','u'];

    if(s.length != t.length) {
        print('no');
        return;
    }

    for(var i = 0; i < s; i++) {
        if((g.indexOf(s[i]) < 0 && g.indexOf(t[i]) >= 0) ||  (g.indexOf(s[i]) >= 0 && g.indexOf(t[i]) < 0)) {
            print('no');
            return;
        }
    }

    print('Yes');

}());

// var v = {}
// v['a'] = 1
// v['e'] = 1
// v['i'] = 1
// v['o'] = 1
// v['u'] = 1

function check(v) {
    if (v==='a') { return 1; }
    if (v==='e') { return 1; }
    if (v==='i') { return 1; }
    if (v==='o') { return 1; }
    if (v==='u') { return 1; }
    if (v==='y') { return 1; }
    return 0;
}

var vc1 = 0, vc2 = 0;

var a = readline()
var b = readline()

if (a.length === b.length) {
    a.split('').forEach((c)=>{
        vc1 += check(c);
    })

    b.split('').forEach((c)=>{
        vc2 += check(c);
    })

    if (vc1 === vc2) {
        print('Yes')
    } else {
        print('No')
    }
} else {
    print('No')
}

// var v = {}
// v['a'] = 1
// v['e'] = 1
// v['i'] = 1
// v['o'] = 1
// v['u'] = 1

function check(v) {
    if (v==='a') { return 1; }
    if (v==='e') { return 1; }
    if (v==='i') { return 1; }
    if (v==='o') { return 1; }
    if (v==='u') { return 1; }
    return 0;
}

var vc1 = 0, vc2 = 0;

var a = readline()
var b = readline()

if (a.length === b.length) {
    a.split('').forEach((c)=>{
        vc1 += check(c);
    })

    b.split('').forEach((c)=>{
        vc2 += check(c);
    })

    if (vc1 === vc2) {
        print('Yes')
    } else {
        print('No')
    }
} else {
    print('No')
}

// node.js 9.4.0

function main() {
  const readline = require('readline');
  const rl = readline.createInterface({ input: process.stdin });
  const io = consoleIo();
  io.next();
  rl.on('line', (line) => io.next(line));
  rl.on('close', () => io.next());
}

function* consoleIo() {
  const s = yield 0;
  const t = yield 0;

  const ans = solve(s, t);

  console.log(ans);
}

function solve(s, t) {
  // https://developer.mozilla.org/ja/docs/Web/JavaScript/Reference/Global_Objects/RegExp

  const c = /[^aeiou]/g
  const v = /[aeiou]/g
  const normalizedS = s.replace(c, 'C').replace(v, 'V');
  const normalizedV = t.replace(c, 'C').replace(v, 'V');
  console.log(normalizedS);
  console.log(normalizedV);
  if (normalizedS === normalizedV) {
    return 'Yes'
  } else {
    return 'No';
  }
}

main();


var s = readline();
var t = readline();
var reversedS = s.split("").reverse();
var reversedT = t.split("").reverse();
var sLength = reversedS.length;
var tLength = reversedT.length;

var maxLength = Math.max(sLength, tLength);

var similarCount = 0;
for (var i = 0; i < maxLength; i ++) {
  if (i < sLength && i < tLength) {
    if (reversedS[i] === reversedT[i]) {
      similarCount ++;
    } else { break; }
  } else { break ;}
}

write(sLength + tLength - similarCount * 2);

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

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

  str2 = d;

  c++;
});

rl.on('close', () => {
  const arr1 = [...str1].reverse();
  const arr2 = [...str2].reverse();
  let count = 0;

  for (let i = 0; i < arr1.length; i++) {
    if (arr1[i] === arr2[i]) {
      count++;
    }
    else {
      break;
    }
  }

  const ans = (arr1.length + arr2.length) - (count * 2);
  console.log(ans);
});

s=readline()
t=readline()
n=s.length
m=t.length
res=0
if (n<m)
{
    t=t.substring(m-n)
    res+=m-n
    m=n
}
if (n>m)
{
    s=s.substring(n-m)
    res+=n-m
    n=m
}
i=n-1
res+=2*n
while(i>=0&&s[i]==t[i])
{
    --i
    res-=2
}
print(res)

var firstLine = readline();
var secondLine = readline();
var firstLineA = firstLine;
var secondLineA = secondLine;
var result = 0;
var temp1 = 0;
var temp2 = 0;

if (firstLine[firstLine.length - 1] !== secondLine[secondLine.length - 1]) {
    print(firstLine.length + secondLine.length);
} else {
    if (firstLine.length > secondLine.length) {
        result = firstLine.length - secondLine.length;
        firstLine = firstLine.slice(result);
    } else if (firstLine.length < secondLine.length) {
        result = secondLine.length - firstLine.length;
        secondLine = secondLine.slice(result);
    }

    var i = firstLine.length - 1;
    for (; i > -1; i--) {
        if (firstLine[i] !== secondLine[i]) {
            break;
        } else {
            temp1 += 2;
        }
    }

    print(result + firstLine.length*2 - temp1);
}

var s = readline();
var t = readline();

// console.log(s);

var slen = s.length;
var tlen = t.length;

var ans = slen + tlen;
var mn = Math.min(slen,tlen);

var equal = 0;
for(var i = 0;i<mn;i++){
    if(s[slen-i-1] === t[tlen-i-1] ){
        equal++;
    }
    else {
        break;
    }
}
print(ans-(2*equal));

/*var s = readline();
var t = readline();

var slength = s.length;
var tlength = t.length;

var minLength = Math.min(slength, tlength);
var equal = 0;
for(var i = 0; i < minLength; i++) {
    if(s[s.length - 1 - i] === t[t.length - 1 - i]) {
        equal++;
    } else {
        break;
    }
}
print(s.length + t.length - 2 * equal);*/

var k = readline();
var x = readline();
b=k.length;
a=x.length;
y=1;
if (k == x){
    print(0);
}
else {
while ( k[b-y] == x[a-y]){
    y++;
}
print((b-y+1) + (a-y+1));}

var firstLine = readline();
var secondLine = readline();
var firstLineA = firstLine;
var secondLineA = secondLine;
var result = 0;
var temp1 = 0;
var temp2 = 0;

if (firstLine[firstLine.length - 1] !== secondLine[secondLine.length - 1]) {
    print(firstLine.length + secondLine.length);
} else {
    if (firstLine.length > secondLine.length) {
        result = firstLine.length - secondLine.length;
        firstLine = firstLine.slice(result);
    } else if (firstLine.length < secondLine.length) {
        result = secondLine.length - firstLine.length;
        secondLine = secondLine.slice(result);
    }

    var i = 0;
    for (; i < firstLine.length; i++) {
        if (firstLine[i] !== secondLine[i]) {
            result += 2;
            continue;
        } else {
            break;
        }
    }

    print(result);
}

var firstLine = readline();
var secondLine = readline();
var firstLineA = firstLine;
var secondLineA = secondLine;
var result = 0;
var temp1 = 0;
var temp2 = 0;

if (firstLine[firstLine.length - 1] !== secondLine[secondLine.length - 1]) {
    print(firstLine.length + secondLine.length);
} else {
    if (firstLine.length > secondLine.length) {
        result = firstLine.length - secondLine.length;
        firstLine = firstLine.slice(result);
    } else if (firstLine.length < secondLine.length) {
        result = secondLine.length - firstLine.length;
        secondLine = secondLine.slice(result);
    }

    temp1 = Math.floor(firstLine.length / 2);
    while (true) {
        if (firstLine[temp1] !== secondLine[temp1]) {
            firstLine = firstLine.slice(temp1 + 1);
            secondLine = secondLine.slice(temp1 + 1);
            temp1 += Math.floor(temp1 / 2) + 1;
        } else {
            if (temp1 === 0) break;
            temp1 -= Math.floor(temp1 / 2) + 1;
        }

        if (firstLine === secondLine) break;
    }

    result = firstLineA.length - firstLine.length + secondLineA.length - secondLine.length;
    print(result);
}

var k = readline();
var x = readline();
b=k.length;
a=x.length;

k='.'+k;
x=','+x;

y=1;
while ( k[b-y] == x[a-y]){
    y++;
}
print((b-y) + (a-y));

// kol_vo=0;
// while (firstVar!=secondVar){
// 	kol_vo=kol_vo+1;
// 	firstVar=firstVar-1;
// 	if (firstVar===secondVar) {
// 		break
// 	}
// 	else {
// 	secondVar=secondVar-1; }
// }

/*
    Coded by RuX
*/
var readline = require('readline');
var rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
});
var leftstring = function (s1, s2) {
    var max = "";
    var min = "";
    if (s1.length > s2.length) {
        max = s1;
        min = s2;
    }
    else {
        max = s2;
        min = s1;
    }
    var match = new RegExp("(?:[" + min + "]+)$", "gm");
    var con = match.exec(max);
    var sub = "";
    if (con != null) {
        sub = con[0];
    }
    else {
        sub = "";
    }
    var result = max.length + min.length - 2 * sub.length;
    return result;
};
var s1 = "";
var s2 = "";
var c = 0;
rl.on('line', function (line) {
    c += 1;
    if (c == 1) {
        s1 = line;
    }
    else {
        s2 = line;
        rl.close();
        console.log(leftstring(s1, s2));
    }
});

var k = readline();
var x = readline();
b=k.length;
a=x.length;

k='.'+k;
x=','+x;

y=1;
while ( k[b-y] === x[a-y]){
    y++;
}
print(b-y+1 + a-y+1);

// kol_vo=0;
// while (firstVar!=secondVar){
// 	kol_vo=kol_vo+1;
// 	firstVar=firstVar-1;
// 	if (firstVar===secondVar) {
// 		break
// 	}
// 	else {
// 	secondVar=secondVar-1; }
// }

var k = readline();
var x = readline();
b=k.length;
a=x.length;

k='.'+k;
x=','+x;

y=1;
if (k == x){
    print(0);
}
else {
while ( k[b-y] == x[a-y]){
    y++;
}
print((b-y+1) + (a-y+1));}

var k = readline();
var x = readline();
b=k.length;
a=x.length;

k='.'+k;
x=','+x;

y=1;
while ( k[b-y] === x[a-y]){
    y++;
}
print(b-y + a-y);

// kol_vo=0;
// while (firstVar!=secondVar){
// 	kol_vo=kol_vo+1;
// 	firstVar=firstVar-1;
// 	if (firstVar===secondVar) {
// 		break
// 	}
// 	else {
// 	secondVar=secondVar-1; }
// }