There is a grid, consisting of $$$n$$$ rows and $$$m$$$ columns. Each cell of the grid is either free or blocked. One of the free cells contains a lab. All the cells beyond the borders of the grid are also blocked.A crazy robot has escaped from this lab. It is currently in some free cell of the grid. You can send one of the following commands to the robot: "move right", "move down", "move left" or "move up". Each command means moving to a neighbouring cell in the corresponding direction.However, as the robot is crazy, it will do anything except following the command. Upon receiving a command, it will choose a direction such that it differs from the one in command and the cell in that direction is not blocked. If there is such a direction, then it will move to a neighbouring cell in that direction. Otherwise, it will do nothing.We want to get the robot to the lab to get it fixed. For each free cell, determine if the robot can be forced to reach the lab starting in this cell. That is, after each step of the robot a command can be sent to a robot such that no matter what different directions the robot chooses, it will end up in a lab.

The first line contains a single integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of testcases. The first line of each testcase contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 10^6$$$; $$$n \cdot m \le 10^6$$$) — the number of rows and the number of columns in the grid. The $$$i$$$-th of the next $$$n$$$ lines provides a description of the $$$i$$$-th row of the grid. It consists of $$$m$$$ elements of one of three types:    '.' — the cell is free;  '#' — the cell is blocked;  'L' — the cell contains a lab.  The grid contains exactly one lab. The sum of $$$n \cdot m$$$ over all testcases doesn't exceed $$$10^6$$$.

For each testcase find the free cells that the robot can be forced to reach the lab from. Given the grid, replace the free cells (marked with a dot) with a plus sign ('+') for the cells that the robot can be forced to reach the lab from. Print the resulting grid.

NoteIn the first testcase there is no free cell that the robot can be forced to reach the lab from. Consider a corner cell. Given any direction, it will move to a neighbouring border grid that's not a corner. Now consider a non-corner free cell. No matter what direction you send to the robot, it can choose a different direction such that it ends up in a corner.In the last testcase, you can keep sending the command that is opposite to the direction to the lab and the robot will have no choice other than move towards the lab.

const fs = require("fs");
process.stdin.resume();
process.stdin.setEncoding("utf-8");

let inputString = "";
let currentLine = 0;

fs.readFile("input.txt", "utf8", (err, data) => {
  if (err) {
    console.error(err);
    return;
  }
  inputString = data
    .trim()
    .split("\n")
    .map((string) => {
      return string.trim();
    });

  main();
});

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 findIndex = (N, M, A, target) => {
  for (let r = 0; r < N; r += 1) {
    for (let c = 0; c < M; c += 1) {
      if (A[r][c] == target) {
        return [r, c];
      }
    }
  }

  return [-1, -1];
};

const getNeibs = (N, M, A, R, C) => {
  const neibs = [];
  for (const [nr, nc] of [
    [R + 1, C],
    [R - 1, C],
    [R, C + 1],
    [R, C - 1],
  ]) {
    if (0 <= nr && nr < N && 0 <= nc && nc < M && A[nr][nc] == ".") {
      neibs.push([nr, nc]);
    }
  }

  return neibs;
};

const solve = (N, M, A) => {
  const target = findIndex(N, M, A, "L");

  const q = [target];
  const ans = Array.from(A, (row) => [...row]);

  while (q.length > 0) {
    const [r, c] = q.pop();
    for (const [nr, nc] of getNeibs(N, M, ans, r, c)) {
      const nbs = getNeibs(N, M, ans, nr, nc);
      if (nbs.length <= 1) {
        ans[nr][nc] = "+";
        q.push([nr, nc]);
      }
    }
  }

  return ans.map((row) => row.join("")).join("\n");
};

const main = () => {
  //   console.log(readline());
  const T = parseInt(readline());
  const ans = [];
  for (let t = 0; t < T; t += 1) {
    const [N, M] = readline()
      .split(" ")
      .map((x) => parseInt(x));
    const A = [];
    for (let r = 0; r < N; r += 1) {
      A.push([...readline().trim()]);
    }
    ans.push(solve(N, M, A));
  }
  console.log(ans.join("\n"));
};

// main();

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

const findIndex = (N, M, A, target) => {
  for (let r = 0; r < N; r += 1) {
    for (let c = 0; c < M; c += 1) {
      if (A[r][c] == target) {
        return [r, c];
      }
    }
  }

  return [-1, -1];
};

const getNeibs = (N, M, A, R, C) => {
  const neibs = [];
  for (const [nr, nc] of [
    [R + 1, C],
    [R - 1, C],
    [R, C + 1],
    [R, C - 1],
  ]) {
    if (0 <= nr && nr < N && 0 <= nc && nc < M && A[nr][nc] == ".") {
      neibs.push([nr, nc]);
    }
  }

  return neibs;
};

const solve = (N, M, A) => {
  const target = findIndex(N, M, A, "L");

  const q = [target];
  const ans = Array.from(A, (row) => [...row]);

  while (q.length > 0) {
    const [r, c] = q.pop();
    for (const [nr, nc] of getNeibs(N, M, ans, r, c)) {
      const nbs = getNeibs(N, M, ans, nr, nc);
      if (nbs.length <= 1) {
        ans[nr][nc] = "+";
        q.push([nr, nc]);
      }
    }
  }

  return ans.map((row) => row.join("")).join("\n");
};

const main = () => {
  //   console.log(readline());
  const T = parseInt(readline());
  const ans = [];
  for (let t = 0; t < T; t += 1) {
    const [N, M] = readline()
      .split(" ")
      .map((x) => parseInt(x));
    const A = [];
    for (let r = 0; r < N; r += 1) {
      A.push([...readline().trim()]);
    }
    ans.push(solve(N, M, A));
  }
  console.log(ans.join("\n"));
};

// main();

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

function solve(n, m, grid) {
    let row = 0
    let col = 0
    let found = false
    for (let i = 0; i < grid.length; i++) {
        for (let j = 0; j < grid[i].length; j++) {
            if (grid[i][j] === 'L') {
                found = true
                row = i
                col = j
                break
            }
        }
        if (found) break
    }
// console.log(grid, row, col)

    const visited = {}
    const connected = {}
    connected[key(row, col)] = 1
    const q = [[row, col, -1, -1]]
    const ans = []
    while (q.length) {
        const [i, j, pi, pj] = q.shift()
        const k = key(i, j)
        // if (visited[k]) continue
        // visited[k] = 1

        const tq = []
        check(n, m, grid, visited, tq, i + 1, j, pi, pj)
        check(n, m, grid, visited, tq, i - 1, j, pi, pj)
        check(n, m, grid, visited, tq, i, j + 1, pi, pj)
        check(n, m, grid, visited, tq, i, j - 1, pi, pj)
// console.log(i, j, tq.length)
        if (tq.length <= 1 || grid[i][j] === 'L') {
            // connected[k] = 1
            // ans.push([i, j])
            // if (grid[i][j] === '.') {
                grid[i][j] = '+'
            // }
        tq.forEach(([ci, cj]) => {
            // if (!visited[key(ci, cj)]) {
                q.push([ci, cj, i, j])
            // }
        })
        }
    }

    grid[row][col] = 'L'
    // ans.forEach(([i, j]) => {
    //     grid[i][j] = '+'
    // })
    return grid.map(r => r.join('')).join('\n')
}
function check(n, m, grid, visited, tq, i, j, pi, pj) {
    // if (i === pi && j === pj) return false
    if (i < 0 || i >= n || j < 0 || j >= m
        || grid[i][j] !== '.') return false
        // || '#+'.indexOf(grid[i][j]) >= 0) return false
    tq.push([i, j])

    return true
}
function key(i, j) {
    return i + ',' + j
}

"use strict";

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

let inputString = "";
let currentLine = 0;

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

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

  console.log("on end", inputString);

  main();
});

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

const findIndex = (N, M, A, target) => {
  for (let r = 0; r < N; r += 1) {
    for (let c = 0; c < M; c += 1) {
      if (A[r][c] == target) {
        return [r, c];
      }
    }
  }

  return [-1, -1];
};

const getNeibs = (N, M, A, R, C) => {
  const neibs = [];
  for (const [nr, nc] of [
    [R + 1, C],
    [R - 1, C],
    [R, C + 1],
    [R, C - 1],
  ]) {
    if (0 <= nr && nr < N && 0 <= nc && nc < M && A[nr][nc] == ".") {
      neibs.push([nr, nc]);
    }
  }

  return neibs;
};

const solve = (N, M, A) => {
  const target = findIndex(N, M, A, "L");

  const q = [target];
  const ans = Array.from(A, (row) => [...row]);

  while (q.length > 0) {
    const [r, c] = q.pop();
    for (const [nr, nc] of getNeibs(N, M, ans, r, c)) {
      const nbs = getNeibs(N, M, ans, nr, nc);
      if (nbs.length <= 1) {
        ans[nr][nc] = "+";
        q.push([nr, nc]);
      }
    }
  }

  return ans.map((row) => row.join("")).join("\n");
};

const main = () => {
  //   console.log(readline());
  const T = parseInt(readline());
  const ans = [];
  for (let t = 0; t < T; t += 1) {
    const [N, M] = readline()
      .split(" ")
      .map((x) => parseInt(x));
    const A = [];
    for (let r = 0; r < N; r += 1) {
      A.push([...readline().trim()]);
    }
    ans.push(solve(N, M, A));
  }
  console.log(ans.join("\n"));
};

// main();

// import * as readline from 'node:readline/promises';

const findIndex = (N, M, A, target) => {
    for (let r = 0; r < N; r += 1) {
        for (let c = 0; c < M; c += 1) {
            if (A[r][c] == target) {
                return [r, c];
            }
        }
    }

    return [-1, -1];
}

const getNeibs = (N, M, A, R, C) => {
    const neibs = [];
    for (const [nr, nc] of [[R+1, C], [R-1, C], [R, C+1], [R, C-1]]) {
        if (0 <= nr && nr < N && 0 <= nc && nc < M && A[nr][nc] == '.') {
            neibs.push([nr, nc]);
        }
    }

    return neibs;
}

const solve = (N, M, A) => {
    const target = findIndex(N, M, A, 'L');

    const q = [target];
    const ans = Array.from(A, row => [...row]);

    while (q.length > 0) {
        const [r, c] = q.pop();
        for (const [nr, nc] of getNeibs(N, M, ans, r, c)) {
            const nbs = getNeibs(N, M, ans, nr, nc);
            if (nbs.length <= 1) {
                ans[nr][nc] = '+';
                q.push([nr, nc]);
            }

        }
    }

    return ans.map(row => row.join('')).join('\n')
};

const main = () => {
  const T = parseInt(readline());
  const ans = [];
  for (let t = 0; t < T; t += 1) {
    const [N, M] = readline()
      .split(" ")
      .map((x) => parseInt(x));
    const A = [];
    for (let r = 0; r < N; r += 1) {
      A.push([...readline().trim()]);
    }
    ans.append(solve(N, M, A));
  }
  print(ans.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', () => {
// (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, m] = lines[l++].trim().split(' ').map(Number)
        const grid = lines.slice(l, l + n).map(str => str.trim().split(''))
        l += n
        output[i] = solve(n, m, grid)
    }
    console.log(output.join('\n'))
// })()
})

function solve(n, m, grid) {
    let row = 0
    let col = 0
    let found = false
    for (let i = 0; i < grid.length; i++) {
        for (let j = 0; j < grid[i].length; j++) {
            if (grid[i][j] === 'L') {
                found = true
                row = i
                col = j
                break
            }
        }
        if (found) break
    }
// console.log(grid, row, col)

    const visited = {}
    const connected = {}
    connected[key(row, col)] = 1
    const q = [[row, col, -1, -1]]
    const ans = []
    while (q.length) {
        const [i, j, pi, pj] = q.shift()
        const k = key(i, j)
        if (visited[k]) continue
        visited[k] = 1

        const tq = []
        check(n, m, grid, visited, tq, i + 1, j, pi, pj)
        check(n, m, grid, visited, tq, i - 1, j, pi, pj)
        check(n, m, grid, visited, tq, i, j + 1, pi, pj)
        check(n, m, grid, visited, tq, i, j - 1, pi, pj)

        if (tq.length <= 1) {
            // connected[k] = 1
            // ans.push([i, j])
            if (grid[i][j] === '.') {
                grid[i][j] = '+'
            }
        }
        tq.forEach(([ci, cj]) => {
            if (!visited[key(ci, cj)]) {
                q.push([ci, cj, i, j])
            }
        })
    }

    // ans.forEach(([i, j]) => {
    //     grid[i][j] = '+'
    // })
    return grid.map(r => r.join('')).join('\n')
}
function check(n, m, grid, visited, tq, i, j, pi, pj) {
    // if (i === pi && j === pj) return false
    if (i < 0 || i >= n || j < 0 || j >= m || grid[i][j] !== '.') return false
    tq.push([i, j])

    return true
}
function key(i, j) {
    return i + ',' + j
}

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

function solve(n, m, grid) {
    let row = 0
    let col = 0
    let found = false
    for (let i = 0; i < grid.length; i++) {
        for (let j = 0; j < grid[i].length; j++) {
            if (grid[i][j] === 'L') {
                found = true
                row = i
                col = j
                break
            }
        }
        if (found) break
    }
// console.log(grid, row, col)

    const visited = {}
    const connected = {}
    connected[key(row, col)] = 1
    const q = [[row, col, -1, -1]]
    const ans = []
    while (q.length) {
        const [i, j, pi, pj] = q.shift()
        const k = key(i, j)
        if (visited[k]) continue
        visited[k] = 1

        const tq = []
        check(n, m, grid, visited, tq, i + 1, j, pi, pj)
        check(n, m, grid, visited, tq, i - 1, j, pi, pj)
        check(n, m, grid, visited, tq, i, j + 1, pi, pj)
        check(n, m, grid, visited, tq, i, j - 1, pi, pj)

        if (connected[key(pi, pj)] && tq.length <= 1) {
            connected[k] = 1
            ans.push([i, j])
        }
        tq.forEach(([ci, cj]) => {
            if (!visited[key(ci, cj)]) {
                q.push([ci, cj, i, j])
            }
        })
    }

    ans.forEach(([i, j]) => {
        grid[i][j] = '+'
    })
    return grid.map(r => r.join('')).join('\n')
}
function check(n, m, grid, visited, tq, i, j, pi, pj) {
    if (i === pi && j === pj) return false
    if (i < 0 || i >= n || j < 0 || j >= m || grid[i][j] === '#') return false
    tq.push([i, j])

    return true
}
function key(i, j) {
    return i + ',' + j
}


In the army, it isn't easy to form a group of soldiers that will be effective on the battlefield. The communication is crucial and thus no two soldiers should share a name (what would happen if they got an order that Bob is a scouter, if there are two Bobs?).A group of soldiers is effective if and only if their names are different. For example, a group (John, Bob, Limak) would be effective, while groups (Gary, Bob, Gary) and (Alice, Alice) wouldn't.You are a spy in the enemy's camp. You noticed n soldiers standing in a row, numbered 1 through n. The general wants to choose a group of k consecutive soldiers. For every k consecutive soldiers, the general wrote down whether they would be an effective group or not.You managed to steal the general's notes, with n - k + 1 strings s1, s2, ..., sn - k + 1, each either "YES" or "NO".   The string s1 describes a group of soldiers 1 through k ("YES" if the group is effective, and "NO" otherwise).  The string s2 describes a group of soldiers 2 through k + 1.  And so on, till the string sn - k + 1 that describes a group of soldiers n - k + 1 through n. Your task is to find possible names of n soldiers. Names should match the stolen notes. Each name should be a string that consists of between 1 and 10 English letters, inclusive. The first letter should be uppercase, and all other letters should be lowercase. Names don't have to be existing names — it's allowed to print "Xyzzzdj" or "T" for example.Find and print any solution. It can be proved that there always exists at least one solution.

The first line of the input contains two integers n and k (2 ≤ k ≤ n ≤ 50) — the number of soldiers and the size of a group respectively. The second line contains n - k + 1 strings s1, s2, ..., sn - k + 1. The string si is "YES" if the group of soldiers i through i + k - 1 is effective, and "NO" otherwise.

Find any solution satisfying all given conditions. In one line print n space-separated strings, denoting possible names of soldiers in the order. The first letter of each name should be uppercase, while the other letters should be lowercase. Each name should contain English letters only and has length from 1 to 10. If there are multiple valid solutions, print any of them.

Adam Bob Bob Cpqepqwer Limak Adam Bob Adam

R Q Ccccccccc Ccocc Ccc So Strong Samples Ccc

NoteIn the first sample, there are 8 soldiers. For every 3 consecutive ones we know whether they would be an effective group. Let's analyze the provided sample output:  First three soldiers (i.e. Adam, Bob, Bob) wouldn't be an effective group because there are two Bobs. Indeed, the string s1 is "NO".  Soldiers 2 through 4 (Bob, Bob, Cpqepqwer) wouldn't be effective either, and the string s2 is "NO".  Soldiers 3 through 5 (Bob, Cpqepqwer, Limak) would be effective, and the string s3 is "YES".  ...,  Soldiers 6 through 8 (Adam, Bob, Adam) wouldn't be effective, and the string s6 is "NO".

// Polyfill for NodeJS
if (undefined == readline) {
	var rLines = require('fs').readFileSync("/dev/stdin", "utf8").split("\n"),
		rIndex = 0,
		readline = function() {
			rIndex ++
			return rLines[rIndex - 1]
		}
}
if (undefined == print) {
	var print = console.log
}

// Useful Read functions
var int = function() {
	return parseInt(readline())
}

var ints = function() {
	return readline().split(' ')
		.map(function(x) {
			return parseInt(x)
		})
}

// The answer
var names = ['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z',
'Aa','Ba','Ca','Da','Ea','Fa','Ga','Ha','Ia','Ja','Ka','La','Ma','Na','Oa','Pa','Qa','Ra','Sa','Ta','Ua','Va','Wa','Xa','Ya','Za',
'Ab','Bb','Cb','Db','Eb','Fb','Gb','Hb','Ib','Jb','Kb','Lb','Mb','Nb','Ob','Pb','Qb','Rb','Sb','Tb','Ub','Vb','Wb','Xb','Yb','Zb']

var ns = ints(),
	n = ns[0],
	k = ns[1],
	i = 0,
	j = 0,
	count = 1,
	words = [],
	notes = readline().split(' ').map(function(w) {
		return w == 'YES'
	})

for(i = 0; i < k - 1; i ++)
	words[i] = i

count = i
while (i < n) {
	if (notes[j]) {
		words[i] = count
		count ++
	} else {
		words[i] = words[i - k + 1]
	}
	i ++
	j ++
}

print(words.map(function(n) { return names[n] }).join(' '))

var input = readline().split(' ').map(Number);

var n = input[0]; //number of soldiers
var k = input[1]; //size of each group

var notes = readline().split(' ').map(String);

// Let's create 52 unique soldier names
var names = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'Aa', 'Ba', 'Ca', 'Da', 'Ea', 'Fa', 'Ga', 'Ha', 'Ia', 'Ja', 'Ka', 'La', 'Ma', 'Na', 'Oa', 'Pa', 'Qa', 'Ra', 'Sa', 'Ta', 'Ua', 'Va', 'Wa', 'Xa', 'Ya', 'Za'];

var soldiers = [];
var s_count = 0;
var n_count = 0;
var l = 0;

//Ititial Group
if (notes[0] == 'YES') {
	for (var j = 0; j < k; j++) {
		soldiers[s_count] = names[n_count];
		s_count ++;
		n_count ++;
	}
} else if (notes[0] == 'NO') {
	soldiers[s_count + k - 1] = names[n_count];
	while (l < k - 1) {
		soldiers[s_count] = names[n_count];
		s_count ++;
		n_count ++;
		l ++;
	}
	s_count ++;
}

//then attach either the first name of the group or the next name in the name list to the end for each group.

for (var i = 1; i < n - k + 1; i++) {
	if (notes[i] == 'YES') {
		soldiers[s_count] = names[n_count];
		s_count ++;
		n_count ++;
	} else if (notes[i] == 'NO') {
		soldiers[s_count] = soldiers[s_count - k + 1];
		s_count ++;
	}
}

var output = soldiers.join(" ");

print(output);

  var tmp = readline().split(' ').map(function(x) { return parseInt(x)});
  var n = tmp[0];
  var k = tmp[1];
  var d = readline().split(' ').map(function(x) { return x === 'YES'; });
  var names = [];
  for(var i = 0; i < k; i += 1) {
    names[i] = (i + 1).toString().split('').map(function(x) { return parseInt(x); }).map(function(x) { return String.fromCharCode(65 + x); }).join('').toLowerCase();
  }
  names = names.map(function(string) {
    return string.charAt(0).toUpperCase() + string.slice(1);
  });
  var res = [];
  var it = 0;
  for(var i = 0; i < k - 1; i += 1) {
    res.push(names[it]);
    it += 1;
    it %= k;
  }
  for(var i = k - 1; i < n; i += 1) {
    if(d[i - k + 1]) {
      res.push(names[it]);
      it += 1;
      it %= k;
    } else {
      var tmp = names[it];
      names[it] = names[(it + 1) % k];
      names[(it + 1) % k] = tmp;
      res.push(names[it]);
      it += 1;
      it %= k;
    }
  }
  print(res.join(' '));

var a = readline().trim().split(" ");
var n = +a[0], k = +a[1];
var effective = readline().trim().split(" ").map((val) => {
    return (val == "NO" ? false : true);
});
var big_letters = "QWERTYUIOPASDFGHJKLZXCVBNM";
var small_letters = "qwertyuiopasdfghjklzxcvbnm";

var names_i = 0;
var names = [];
for(var i = 0; i < 3; i++){
    var myname = big_letters[i];
    for(var j = 0; j < 26; j++){
        names[names_i++] = myname + small_letters[j];
    }
}

var soldier_names = [];
var name_link = 0;
var solider_has_name = [];

for(var i = 0; i < n; i++){
    solider_has_name[i] = false;
}

for(var i = 0; i < n - k + 1; i++){
    if(effective[i] === true){
        for(var j = 0; j < k; j++){
            var ij = i + j;
            if(!solider_has_name[ij]){
                soldier_names[ij] = names[name_link++];
                solider_has_name[ij] = true;
            }
        }
    }else{
        if(solider_has_name[i] === true){
            for(var j = 1; j < k; j++){
                var ij = i + j;
                if(solider_has_name[ij] === false){
                    soldier_names[ij] = soldier_names[i];
                    solider_has_name[ij] = true;
                    break;
                }
            }
        }else{
            var name_of_two_soldiers = names[name_link++];
            for(var j = 0; j < 2; j++){
                var ij = i + j;
                soldier_names[ij] = name_of_two_soldiers;
                solider_has_name[ij] = true;
            }
        }
    }
}

for(var i = 0; i < n; i++){
    if(solider_has_name[i] === false){
        soldier_names[i] = names[name_link++];
    }
}

print(soldier_names.join(" "));

// Polyfill for NodeJS
if (undefined == readline) {
	var rLines = require('fs').readFileSync("/dev/stdin", "utf8").split("\n"),
		rIndex = 0,
		readline = function() {
			rIndex ++
			return rLines[rIndex - 1]
		}
}
if (undefined == print) {
	var print = console.log
}

// Useful Read functions
var int = function() {
	return parseInt(readline())
}

var ints = function() {
	return readline().split(' ')
		.map(function(x) {
			return parseInt(x)
		})
}

// The answer
var names = ['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z',
'Aa','Ba','Ca','Da','Ea','Fa','Ga','Ha','Ia','Ja','Ka','La','Ma','Na','Oa','Pa','Qa','Ra','Sa','Ta','Ua','Va','Wa','Xa','Ya','Za',
'Ab','Bb','Cb','Db','Eb','Fb','Gb','Hb','Ib','Jb','Kb','Lb','Mb','Nb','Ob','Pb','Qb','Rb','Sb','Tb','Ub','Vb','Wb','Xb','Yb','Zb']

var ns = ints(),
	n = ns[0],
	k = ns[1],
	i = 0,
	count = 1,
	words = [],
	notes = readline().split(' ').map(function(w) {
		return w == 'YES'
	})

for(i = 0; i < k - 1; i ++)
	words[i] = i

count = k
i = 0
while (i < notes.length) {
	if (notes[i]) {
		words[k - 1 + i] = count
		count ++
	} else {
		words[k - 1 + i] = i
	}
	i ++
}

print(words.map(function(n) { return names[n] }).join(' '))

var input = readline().split(' ').map(Number);

var n = input[0]; //number of soldiers
var k = input[1]; //size of each group

var notes = readline().split(' ').map(String);

// Let's create 52 unique soldier names
var names = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'Aa', 'Ba', 'Ca', 'Da', 'Ea', 'Fa', 'Ga', 'Ha', 'Ia', 'Ja', 'Ka', 'La', 'Ma', 'Na', 'Oa', 'Pa', 'Qa', 'Ra', 'Sa', 'Ta', 'Ua', 'Va', 'Wa', 'Xa', 'Ya', 'Za'];

var soldiers = [];
var s_count = 0;
var n_count = 0;
var l = 0;

//Ititial Group
if (notes[0] == 'YES') {
	for (var j = 0; j < k; j++) {
		soldiers[s_count] = names[n_count];
		s_count ++;
		n_count ++;
	}
} else if (notes[0] == 'NO') {
	while (l < k - 1) {
		soldiers[s_count] = names[n_count];
		soldiers[s_count + k - 1] = names[n_count];
		s_count ++;
		n_count ++;
		l ++;
	}
	s_count ++;
}

//then attach either the first name of the group or the next name in the name list to the end for each group.

for (var i = 1; i < n - k + 1; i++) {
	if (notes[i] == 'YES') {
		soldiers[s_count] = names[n_count];
		s_count ++;
		n_count ++;
	} else if (notes[i] == 'NO') {
		soldiers[s_count] = soldiers[s_count - k + 1];
		s_count ++;
	}
}

var output = soldiers.join(" ");

print(output);


Vova had a pretty weird sleeping schedule. There are $$$h$$$ hours in a day. Vova will sleep exactly $$$n$$$ times. The $$$i$$$-th time he will sleep exactly after $$$a_i$$$ hours from the time he woke up. You can assume that Vova woke up exactly at the beginning of this story (the initial time is $$$0$$$). Each time Vova sleeps exactly one day (in other words, $$$h$$$ hours).Vova thinks that the $$$i$$$-th sleeping time is good if he starts to sleep between hours $$$l$$$ and $$$r$$$ inclusive.Vova can control himself and before the $$$i$$$-th time can choose between two options: go to sleep after $$$a_i$$$ hours or after $$$a_i - 1$$$ hours.Your task is to say the maximum number of good sleeping times Vova can obtain if he acts optimally.

The first line of the input contains four integers $$$n, h, l$$$ and $$$r$$$ ($$$1 \le n \le 2000, 3 \le h \le 2000, 0 \le l \le r < h$$$) — the number of times Vova goes to sleep, the number of hours in a day and the segment of the good sleeping time. The second line of the input contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i < h$$$), where $$$a_i$$$ is the number of hours after which Vova goes to sleep the $$$i$$$-th time.

Print one integer — the maximum number of good sleeping times Vova can obtain if he acts optimally.

NoteThe maximum number of good times in the example is $$$3$$$.The story starts from $$$t=0$$$. Then Vova goes to sleep after $$$a_1 - 1$$$ hours, now the time is $$$15$$$. This time is not good. Then Vova goes to sleep after $$$a_2 - 1$$$ hours, now the time is $$$15 + 16 = 7$$$. This time is also not good. Then Vova goes to sleep after $$$a_3$$$ hours, now the time is $$$7 + 14 = 21$$$. This time is good. Then Vova goes to sleep after $$$a_4 - 1$$$ hours, now the time is $$$21 + 19 = 16$$$. This time is not good. Then Vova goes to sleep after $$$a_5$$$ hours, now the time is $$$16 + 20 = 12$$$. This time is not good. Then Vova goes to sleep after $$$a_6$$$ hours, now the time is $$$12 + 11 = 23$$$. This time is good. Then Vova goes to sleep after $$$a_7$$$ hours, now the time is $$$23 + 22 = 21$$$. This time is also good.

'use strict'

const getLine = () => readline().split(' ')
const getInts = () => getLine().map(n => parseInt(n))
const getInt = () => getInts()[0]
const D = (...args) => { // D({name})
  [...args].forEach(cur => print.apply(print, [JSON.stringify(cur)]))
}

main()

function main() {
  const input = getInts()
  const arr = getInts()
  const ans = solve(...input, arr)
  print(ans)
}

function solve (n, h, l, r, arr) {
  const MX = n + 2
  const inf = MX
  const dp = []
  for (let i = 0; i < MX; ++i) {
    dp[i] = []
    for (let j = 0; j < MX; ++j) {
      dp[i].push(-inf)
    }
  }

  dp[0][0] = 0
  const isGood = good(h, l, r)
  let sum = 0

  for (let i = 0; i < n; ++i) {
    sum += arr[i]
    for (let j = 0; j <= n; ++j) {
      const a = isGood(sum - j)
      const b = isGood(sum - j - 1)
      dp[i + 1][j] = Math.max(dp[i + 1][j], dp[i][j] + a)
      dp[i + 1][j + 1] = Math.max(dp[i + 1][j + 1], dp[i][j] + b)
    }
  }

  return dp[n].reduce((ans, cur) => Math.max(ans, cur), -1)
}

function good (h, l, r, val) {
  return function (val) {
    val %= h
    return val >= l && val <= r
  }
}

var findMaxGoodSleeps = function(ts, h, l, r) {
  //hour will be manipulated with each table insertion
  //represents the hour of day that X is being woken up at
  //could be good or bad, attempting to maximize good days
  var hour = 0;
  //ts is the individual wait times while totalWaits is the sum up to each index
  var totalWaits = [];
  //table is where values for good waking times will be stored
  //the end of each row will include each potential maximum value
  var table = new Array(ts.length + 1);
  for (var i = 0; i < table.length; i++) {
    table[i] = [];
  }

  //creating array with the sums of the wait times up to current index
  totalWaits[0] = ts[0];
  for (var i = 1; i < ts.length; i++) {
    totalWaits[i] = totalWaits[i - 1] + ts[i];
  }
  //creating table for finding max value, setting first row which will include
  //the unaltered values and their corresponding maximum sums
  table[0][0] = 0;
  for (var i = 1; i <= ts.length; i++) {
    table[0][i] = table[0][i - 1];
    hour = totalWaits[i - 1] % h;
    if (hour >= l && hour <= r) {
      table[0][i]++;
    }
  }

  //setting the rest of the tables values
  for (var j = 1; j <= ts.length; j++) {
    table[j][j - 1] = 0;
    for (var i = j; i <= ts.length; i++) {
      table[j][i] = Math.max(table[j - 1][i - 1], table[j][i - 1]);
      hour = (totalWaits[i - 1] - j) % h;
      if (hour >= l && hour <= r) {
        table[j][i]++;
      }
    }
  }

  //finding max value by looking at end of rows
  var max = 0;
  for (var i = 0; i <= ts.length; i++) {
    if (table[i][ts.length] > max)
      max = table[i][ts.length];
  }
  return max;
}

var firstLine = readline();
var secondLine = readline();
var nums = secondLine.split(' ').map((x) => (parseInt(x)));
var info = firstLine.split(' ');
print(findMaxGoodSleeps(nums, parseInt(info[1]), parseInt(info[2]), parseInt(info[3])));

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

let input = ''
let ptr = 0
process.stdin.on('data', (i) => {
  input += i
})

process.stdin.on('end', () => {
  input = input.split('\n').map(a => a.replace(/(\r\n|\n|\r)/gm, ''))
  main()
})

function wr(...x) {
  console.log(...x)
}

function sort(a, inc = true) {
  if (inc) a.sort((a, b) => a - b)
  else a.sort((a, b) => b - a)
}

function readInt() {
  return parseInt(input[ptr++])
}

function readString() {
  return input[ptr++]
}

function readStrings() {
  return input[ptr++].split(' ')
}

function readInts() {
  return input[ptr++].split(' ').map(a => parseInt(a))
}

function main() {
  const [n, h, l, r] = readInts()
  const a = readInts()
  let dp = new Array(n + 1)
  for(let i = 0; i <= n; i++) dp[i] = new Array(n + 1).fill(-Infinity)

  dp[0][0] = 0
  let sum = 0
  for(let i = 0; i < n; i++) {
    sum += a[i]
    for(let j = 0; j <= i; j++) {
      dp[i + 1][j] = Math.max(dp[i + 1][j], dp[i][j] + inR((sum - j) % h))
      dp[i + 1][j + 1] = Math.max(dp[i + 1][j + 1], dp[i][j] + inR((sum - j - 1) % h))
    }
  }

  wr(Math.max(...dp[n]))

  function inR(x) {
    return x >= l && x <= r ? 1 : 0
  }
}


A sequence of $$$n$$$ numbers is called a permutation if it contains all integers from $$$1$$$ to $$$n$$$ exactly once. For example, the sequences [$$$3, 1, 4, 2$$$], [$$$1$$$] and [$$$2,1$$$] are permutations, but [$$$1,2,1$$$], [$$$0,1$$$] and [$$$1,3,4$$$] — are not.Polycarp lost his favorite permutation and found only some of its elements — the numbers $$$b_1, b_2, \dots b_m$$$. He is sure that the sum of the lost elements equals $$$s$$$.Determine whether one or more numbers can be appended to the given sequence $$$b_1, b_2, \dots b_m$$$ such that the sum of the added numbers equals $$$s$$$, and the resulting new array is a permutation?

The first line of input contains a single integer $$$t$$$ ($$$1 \le t \le 100$$$) —the number of test cases.  Then the descriptions of the test cases follow. The first line of each test set contains two integers $$$m$$$ and $$$s$$$ ($$$1 \le m \le 50$$$, $$$1 \le s \le 1000$$$)—-the number of found elements and the sum of forgotten numbers. The second line of each test set contains $$$m$$$ different integers $$$b_1, b_2 \dots b_m$$$ ($$$1 \le b_i \le 50$$$) — the elements Polycarp managed to find.

Print $$$t$$$ lines, each of which is the answer to the corresponding test set. Print as the answer YES if you can append several elements to the array $$$b$$$, that their sum equals $$$s$$$ and the result will be a permutation. Output NO otherwise. You can output the answer in any case (for example, yEs, yes, Yes and YES will be recognized as positive answer).

NoteIn the test case of the example, $$$m=3, s=13, b=[3,1,4]$$$. You can append to $$$b$$$ the numbers $$$6,2,5$$$, the sum of which is $$$6+2+5=13$$$. Note that the final array will become $$$[3,1,4,6,2,5]$$$, which is a permutation.In the second test case of the example, $$$m=1, s=1, b=[1]$$$. You cannot append one or more numbers to $$$[1]$$$ such that their sum equals $$$1$$$ and the result is a permutation.In the third test case of the example, $$$m=3, s=3, b=[1,4,2]$$$. You can append the number $$$3$$$ to $$$b$$$. Note that the resulting array will be $$$[1,4,2,3]$$$, which is a permutation.

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;
}
var T = readline();
var inf = 1000000000000;
for(var tc=1;tc<=T;tc++) {
	var [m, sum] = readline().split(" ").map(w => parseInt(w));
	var a = readline().split(" ").map(w => parseInt(w));
	var maxx = -inf;
	var num = [];
	for(var i=0;i<m;i++) {
		num[a[i]] = 1;
		maxx = max(a[i], maxx);
	}
	var ans = 0;
	for(var i=0;i<=maxx;i++) {
		if(!num[i]) ans += i;
	}
	while(sum > ans) sum -= (i++);
	console.log(sum===ans ? "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++];
}

function main() {
    const testCases = Number(readline());
    for (let i = 0; i < testCases; i++) {
        let a = readline().split(" ").map(elem => Number(elem));
        let b = readline().split(" ").map(elem => Number(elem));
        if (findLostPermutation(b, a[1])) console.log("YES")
        else console.log("NO")
    }
}

function findLostPermutation(arr, sum) {
    arr.sort((a, b) => a - b)

    let last = arr[arr.length - 1]

    for (let i = 1; i <= last; i++) {
        if (arr.indexOf(i) === -1) {
            sum -= i
        }
        if (sum < 0) break;
    }
    if (sum === 0) return true
    let i = 1
    while (sum > 0) {
        sum -= last + i;
        i++
    }

    if (sum === 0) return true
    else return false
}

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

function solve(n, s, arr) {
    const max = Math.max(...arr)
    const map = arr.reduce((o, x) => {
        o[x] = 1
        // o[x] = (o[x] || 0) + 1
        return o
    }, {})
    let i
    for (i = 1; i <= max; i++) {
        if (!map[i]) {
            s -= i
        }
    }
    while (s > 0) {
        s -= i++
    }
    // console.log(i, s)
    return !s ? 'YES' : 'NO'
}

'use strict';

var fs = require('fs');

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

var fs__default = /*#__PURE__*/_interopDefaultLegacy(fs);

function solve(read) {
  const [rn, rb, rns, re, rbs] = convertInput(read);
  const [m, s] = rns(),
        a = rns();
  const max = Math.max(...a),
        set = new Set(a);
  let sum = 0;
  for (let i = 1; i <= max; i++) {
    if (set.has(i)) continue;
    sum += i;
  }
  let i = max + 1;
  while (1) {
    if (sum > s) return 'NO';
    if (sum === s) return 'YES';
    sum += i++;
  }
}
function convertInput(read) {
  const rn = () => Number(read());
  const rb = () => BigInt(read());
  const rns = () => read().split(/\s+/).map(Number);
  const re = () => read().split(/\s+/).map(s => Number(s) - 1);
  const rbs = () => read().split(/\s+/).map(BigInt);
  return [rn, rb, rns, re, rbs];
}
function main(r) {
  try {
    let t = Number(r());
    let res = new Array(t);
    let limit = 0;
    for (let i = 0; i < t; i++) {
      let s = solve(r);
      if (s === undefined) s = '';
      if (t < limit) {
        process.stdout.write(s.toString());
        process.stdout.write('\n');
      } else {
        res[i] = s;
      }
    }
    if (t >= limit) {
      return res.join('\n');
    } else {
      return '';
    }
  } catch (error) {
    console.log(error);
  }
}

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

//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 = nextInt();
		var list = nextIntArray(N);
		var set = new Set();
		var max = 0;
		for(var i = 0; i < N; i++){
			set.add(list[i]);
			max = Math.max(max, list[i]);
		}
		for(var i = 1; i <= max; i++){
			if(!set.has(i)){
				S -= i;
			}
		}
		if(S < 0){
			myout("No");
			continue;
		}
		while(S > 0){
			max++;
			S -= max;
		}
		if(S == 0){
			myout("Yes");
		}else{
			myout("No");
		}
	}
}

var numOfCases = Number(readline());

for (var testCase = 0; testCase < numOfCases; testCase++) {
    var firstLine = readline().split(' ').map(Number);
    var m = firstLine[0];
    var s = firstLine[1];

    var secondLine = readline().split(' ').map(Number);

    var result = process(secondLine, s);
    print(result);
}

function process(arr, sum) {
    var freq = {}
    for (var i = 0; i < arr.length; i++) {
        freq[arr[i]] = 1;
    }

    var currentSum = 0;
    var j = 1;
    while (Object.keys(freq).length) {
        if (freq[j]) {
            delete freq[j];
        } else {
            currentSum += j;
        }

        j++;
    }

    while (currentSum < sum) {
        currentSum += j;
        j++;
    }

    return currentSum === sum ? 'YES' : 'NO';
}

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;
}
var T = readline();
var inf = 1000000000000;
for(var tc=1;tc<=T;tc++) {
	var [m, sum] = readline().split(" ").map(w => parseInt(w));
	var a = readline().split(" ").map(w => parseInt(w));
	var maxx = -inf;
	var num = [];
	for(var i=0;i<m;i++) {
		num[a[i]] = 1;
		maxx = max(a[i], maxx);
	}
	for(var i=1;sum>0;i++) {
		if(!num[i]) sum -= i;
	}
	console.log((i >= maxx && sum === 0) ? "Yes" : "No");
}

var numOfCases = Number(readline());

for (var testCase = 0; testCase < numOfCases; testCase++) {
    var firstLine = readline().split(' ').map(Number);
    var m = firstLine[0];
    var s = firstLine[1];

    var secondLine = readline().split(' ').map(Number);

    var result = process(secondLine, s);
    print(result);
}

function process(arr, sum) {
    var freq = {}
    for (var i = 0; i < arr.length; i++) {
        freq[arr[i]] = 1;
    }

    var currentSum = 0;

    var isNeedToCheckForPermutability = false
    for (var j = 1; currentSum <= sum; j++) {
        if (currentSum === sum) {
            if (Object.keys(freq).length === 0) {
                return 'YES';
            } else {
                isNeedToCheckForPermutability = true;
                break;
            }
        }

        if (!freq[j]) {
            currentSum += j;
        } else {
            delete freq[j];
        }
    }

    if (isNeedToCheckForPermutability) {
        while(Object.keys(freq).length) {
            if (freq[j]) {
                delete freq[j];
            } else {
                return 'NO';
            }
        }

        return 'YES';
    }

    return 'NO';
}


As a human, she can erase history of its entirety. As a Bai Ze (Hakutaku), she can create history out of nothingness.—Perfect Memento in Strict SenseKeine has the ability to manipulate history. The history of Gensokyo is a string $$$s$$$ of length $$$1$$$ initially. To fix the chaos caused by Yukari, she needs to do the following operations $$$n$$$ times, for the $$$i$$$-th time:  She chooses a non-empty substring $$$t_{2i-1}$$$ of $$$s$$$. She replaces $$$t_{2i-1}$$$ with a non-empty string, $$$t_{2i}$$$. Note that the lengths of strings $$$t_{2i-1}$$$ and $$$t_{2i}$$$ can be different.Note that if $$$t_{2i-1}$$$ occurs more than once in $$$s$$$, exactly one of them will be replaced.For example, let $$$s=$$$"marisa", $$$t_{2i-1}=$$$"a", and $$$t_{2i}=$$$"z". After the operation, $$$s$$$ becomes "mzrisa" or "marisz".After $$$n$$$ operations, Keine got the final string and an operation sequence $$$t$$$ of length $$$2n$$$. Just as Keine thinks she has finished, Yukari appears again and shuffles the order of $$$t$$$. Worse still, Keine forgets the initial history. Help Keine find the initial history of Gensokyo!Recall that a substring is a sequence of consecutive characters of the string. For example, for string "abc" its substrings are: "ab", "c", "bc" and some others. But the following strings are not its substring: "ac", "cba", "acb".HacksYou cannot make hacks in this problem.

Each test contains multiple test cases. The first line contains a single integer $$$T$$$ ($$$1 \leq T \leq 10^3$$$) — the number of test cases. The description of the test cases follows. The first line of each test case contains a single integer $$$n$$$ ($$$1 \le n < 10 ^ 5$$$) — the number of operations. The next $$$2n$$$ lines contains one non-empty string $$$t_{i}$$$ — the $$$i$$$-th string of the shuffled sequence $$$t$$$. The next line contains one non-empty string $$$s$$$ — the final string. It is guaranteed that the total length of given strings (including $$$t_i$$$ and $$$s$$$) over all test cases does not exceed $$$2 \cdot 10 ^ 5$$$. All given strings consist of lowercase English letters only. It is guaranteed that the initial string exists. It can be shown that the initial string is unique.

For each test case, print the initial string in one line.

2

2

a

ab

b

cd

acd

3

z

a

a

aa

yakumo

ran

yakumoran

NoteTest case 1:Initially $$$s$$$ is "a". In the first operation, Keine chooses "a", and replaces it with "ab". $$$s$$$ becomes "ab". In the second operation, Keine chooses "b", and replaces it with "cd". $$$s$$$ becomes "acd".So the final string is "acd", and $$$t=[$$$"a", "ab", "b", "cd"$$$]$$$ before being shuffled.Test case 2:Initially $$$s$$$ is "z". In the first operation, Keine chooses "z", and replaces it with "aa". $$$s$$$ becomes "aa". In the second operation, Keine chooses "a", and replaces it with "ran". $$$s$$$ becomes "aran". In the third operation, Keine chooses "a", and replaces it with "yakumo". $$$s$$$ becomes "yakumoran".So the final string is "yakumoran", and $$$t=[$$$"z", "aa", "a", "ran", "a", "yakumo"$$$]$$$ before being shuffled.

function handleString(str, lettersHash) {
    for (let letter of str) {
        if (!lettersHash[letter]) {
            lettersHash[letter] = 0;
        }

        ++lettersHash[letter];
    }
}

function findOriginalString(operationsData, resultString) {
    const lettersHash = [];
    for (let opData of operationsData) {
        handleString(opData, lettersHash);
    }

    handleString(resultString, lettersHash);

    for(let letterKey in lettersHash) {
        const letterCount = lettersHash[letterKey];
        if (letterCount % 2) {
            return letterKey;
        }
    }

    return null;
}

function main() {
    let t = +readline();
    while (t > 0) {
        const n = +readline();
        let i = 0;
        let operationsData = [];
        while (i < 2 * n) {
            operationsData.push(readline());
            ++i;
        }

        const resultString = readline();
        console.log(findOriginalString(operationsData, resultString));

        --t;
    }
}

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

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

const lines = [];
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++];
}

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

/*---------------------------------------------------*/

function div(val, by){
    return (val - val % by) / by;
}

const sumab = (a, b) => {
    if (a > b) return 0;
    let x = (b - a + 1);
    let y = a + b;
    if (x % 2 === 0) {
        x = Math.round(x / 2);
    } else {
        y = Math.round(y / 2);
    }
    return x * y;
}

const calc = (t)=>{
    /* read */
    let n = +rl();
    let freq = new Array(26).fill(0);
    let aCode = 'a'.charCodeAt(0);
    for (let i = 0; i <= 2*n; i++) {
        let s = rl();
        for (let i = 0; i < s.length; i++) {
            let code = s.charCodeAt(i);
            freq[code - aCode]++;
        }
    }
    for (let i = 0; i < 26; i++) {
        if (freq[i] % 2 === 1) {
            return String.fromCharCode(aCode + i);
        }
    }
};

function main() {
    let T = +readline();
    let out = [];
    for (let t = 1; t <= T; t++){
        out.push(calc(t));
        // process.stdout.write(`${calc(t)}\n`);
    }
    process.stdout.write(out.join('\n')+'\n');
}

'use strict';

function solve(n, a, s) {
  const count = new Array(26).fill(0);
  for (let word of a.concat(s)) {
    for (let char of word) {
      const num = char.charCodeAt(0) - 97;
      if (count[num]) {
        count[num]--;
      } else {
        count[num]++;
      }
    }
  }
  for (let [i, num] of count.entries()) {
    if (num) return String.fromCharCode(i + 97);
  }
}

async function main(read) {
  try {
    let res = [];
    let t = Number(await read());
    while (t--) {
      const n = Number(await read());
      const a = [];
      let tmp = 2 * n;
      while (tmp--) {
        a.push(await read());
      }
      const s = await read();
      res.push(solve(n, a, s));
    }
    console.log(res.join('\n'));
  } catch (error) {
    console.log(error);
  }
}

let inputs,
    str = '';
function read() {
  return inputs.next().value.trim();
}
process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', input => str += input);
process.stdin.on('end', () => {
  inputs = str.split('\n').values();
  main(read);
});

function replaceAt(str, index, length, replacement) {
    if (index >= str.length) {
        return str.valueOf();
    }

    return str.substring(0, index) + replacement + str.substring(index + length);
}

function printMask(mask) {
    let res = "";
    while(mask > 0) {
        res += mask & 1;
        mask >>= 1;
    }

    return res.split('').reverse().join('');
}

function doesMaskContainOnlyOnes(mask) {
    for (let elem of mask) {
        if (!elem) {
            return false
        }
    }

    return true;
}

function handleTraversalEntry(str, operationsData, remainingOpsMask, treeTraversalArray, opHistory) {
    if (operationsData.length <= 0 || str.length == 0) {
        return null;
    }

/* console.log('<<<<');
    console.log(str);
    console.log(treeTraversalArray.length);
    console.log(printMask(remainingOpsMask))*/

    if (str.length == 1 && doesMaskContainOnlyOnes(remainingOpsMask)) {
        return str;
    }

    operationsData.forEach((opData, idx) => {
        if (remainingOpsMask[idx]) {
            return;
        }

        const matches = str.matchAll(opData);

        for (const match of matches) {

            const remainingOps = remainingOpsMask.slice();
            remainingOps[idx] = true;
            /*  console.log("<<")
              console.log(opHistory)
              console.log("<<")*/
            makeReplacement(str, operationsData, remainingOps, treeTraversalArray, match.index, opData.length, opHistory);
        };
    });

    return null;
}

function makeReplacement(str, operationsData, remainingOpsMask, treeTraversalArray, replacementIdx, replacementLength, opHistory) {
    operationsData.forEach((opData, idx) => {
        if (remainingOpsMask[idx]) {
            return;
        }

        const remainingOps = remainingOpsMask.slice();
        remainingOps[idx] = true;

        const updatedStr = replaceAt(str, replacementIdx, replacementLength, opData);
       /* let opHistoryNew = opHistory.slice();
        opHistoryNew.push(updatedStr)*/

        treeTraversalArray.push({
            resultString: updatedStr,
            remainingOpsMask: remainingOps,
       //     opHistory: opHistoryNew
        });
    });
}

function findOriginalString(operationsData, resultString) {
    let treeTraversalArray = [];

    treeTraversalArray.push({
        resultString,
        remainingOpsMask: [],
      //  opHistory: [resultString]
    });

    while (treeTraversalArray.length > 0) {
        const currentTraversalEntry = treeTraversalArray.pop();

        const res = handleTraversalEntry(
            currentTraversalEntry.resultString,
            operationsData,
            currentTraversalEntry.remainingOpsMask,
            treeTraversalArray,
          //  currentTraversalEntry.opHistory,
        );

        if(res) {
            console.log(res);
            ///console.log(currentTraversalEntry.opHistory);
            return;
        }
    }
}

function main() {
    let t = +readline();
    while (t > 0) {
        const n = +readline();
        let i = 0;
        let operationsData = [];
        while (i < 2 * n) {
            operationsData.push(readline());
            ++i;
        }

        const resultString = readline();
        findOriginalString(operationsData, resultString);

        --t;
    }
}

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

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 replaceAt(str, index, length, replacement) {
    if (index >= str.length) {
        return str.valueOf();
    }

    return str.substring(0, index) + replacement + str.substring(index + length);
}

function handleTraversalEntry(str, operationsData, remainingOpsMask, treeTraversalArray) {
    if (operationsData.length <= 0 || str.length == 0) {
        return null;
    }

    if (str.length == 1) {
        return str;
    }

    operationsData.forEach((opData, idx) => {
        if ((1 << idx) & remainingOpsMask) {
            return;
        }

        const matches = str.matchAll(opData);

        for (const match of matches) {
            const remainingOps = (1 << idx) | remainingOpsMask;
            makeReplacement(str, operationsData, remainingOps, treeTraversalArray, match.index, opData.length);
        };
    });

    return null;
}

function makeReplacement(str, operationsData, remainingOpsMask, treeTraversalArray, replacementIdx, replacementLength) {
    operationsData.forEach((opData, idx) => {
        if ((1 << idx) & remainingOpsMask) {
            return;
        }

        const remainingOps = (1 << idx) | remainingOpsMask;

        const updatedStr = replaceAt(str, replacementIdx, replacementLength, opData);

        treeTraversalArray.push({
            resultString: updatedStr,
            remainingOpsMask: remainingOps,
        });
    });
}

function findOriginalString(operationsData, resultString) {
    let treeTraversalArray = [];

    treeTraversalArray.push({
        resultString,
        remainingOps: 0,
    });

    while (treeTraversalArray.length > 0) {
        const currentTraversalEntry = treeTraversalArray.pop();

        const res = handleTraversalEntry(
            currentTraversalEntry.resultString,
            operationsData,
            currentTraversalEntry.remainingOpsMask,
            treeTraversalArray
        );

        if(res) {
            console.log(res);
            return;
        }
    }
}

function main() {
    let t = +readline();
    while (t > 0) {
        const n = +readline();
        let i = 0;
        let operationsData = [];
        while (i < 2 * n) {
            operationsData.push(readline());
            ++i;
        }

        const resultString = readline();
        findOriginalString(operationsData, resultString);

        --t;
    }
}

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

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


Methodius received an email from his friend Polycarp. However, Polycarp's keyboard is broken, so pressing a key on it once may cause the corresponding symbol to appear more than once (if you press a key on a regular keyboard, it prints exactly one symbol).For example, as a result of typing the word "hello", the following words could be printed: "hello", "hhhhello", "hheeeellllooo", but the following could not be printed: "hell", "helo", "hhllllooo".Note, that when you press a key, the corresponding symbol must appear (possibly, more than once). The keyboard is broken in a random manner, it means that pressing the same key you can get the different number of letters in the result.For each word in the letter, Methodius has guessed what word Polycarp actually wanted to write, but he is not sure about it, so he asks you to help him.You are given a list of pairs of words. For each pair, determine if the second word could be printed by typing the first one on Polycarp's keyboard.

The first line of the input contains one integer $$$n$$$ ($$$1 \le n \le 10^5$$$) — the number of pairs to check. Further input contains $$$n$$$ descriptions of pairs. The first line of each description contains a single non-empty word $$$s$$$ consisting of lowercase Latin letters. The second line of the description contains a single non-empty word $$$t$$$ consisting of lowercase Latin letters. The lengths of both strings are not greater than $$$10^6$$$. It is guaranteed that the total length of all words $$$s$$$ in the input is not greater than $$$10^6$$$. Also, it is guaranteed that the total length of all words $$$t$$$ in the input is not greater than $$$10^6$$$.

Output $$$n$$$ lines. In the $$$i$$$-th line for the $$$i$$$-th pair of words $$$s$$$ and $$$t$$$ print YES if the word $$$t$$$ could be printed by typing the word $$$s$$$. Otherwise, print NO.

4
hello
hello
hello
helloo
hello
hlllloo
hello
helo

5
aa
bb
codeforces
codeforce
polycarp
poolycarpp
aaaa
aaaab
abcdefghijklmnopqrstuvwxyz
zabcdefghijklmnopqrstuvwxyz

(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 = '';

    for(var i = 0; i < n; i++) {
        var s = readline();
        var t = readline();
        var indexT = 0;
        var check = true;
        for(var j = 0; j < s.length; j++) {
            while(s[j] !== t[indexT] && t[indexT - 1] === t[indexT]) {
                indexT++;
            }

            if(s[j] !== t[indexT]) {
                check = false;
                break;
            }
            indexT++;
        }
        while(indexT < t.length) {
            if(t[indexT] !== s[s.length - 1]) {
                check = false;
                break;
            }
            indexT++;
        }
        res += (check ? 'YES' : 'NO') + '\n';
    }
    print(res);
}());

var number = readline();
var descriptions = [];

function matchesOrNot(word1, word2){
    var w1Arr = [word1[0], 1];
    var w2Arr = [word2[0], 1];

    if(word1.length === 0 && word2.length !== 0 || word2.length === 0 && word1.length !== 0){
        return "NO";
    }
    if(word1.length === 0 &&  word2.length === 0){
        return "YES";
    }

    var w1i = 0;
    var w2i = 0;

    for(var m = 1; m < word1.length; m++){
        if(word1[m] == w1Arr[w1i]){
            w1Arr[w1i+1] +=1;
        }
        else{
            w1Arr.push(word1[m], 1);
            w1i+=2;
        }
    }

    for(var n = 1; n < word2.length; n++){
        if(word2[n] == w2Arr[w2i]){
            w2Arr[w2i+1] +=1;
        }
        else{
            w2Arr.push(word2[n], 1);
            w2i+=2;
        }
    }

    if(w1Arr.length != w2Arr.length){
        return "NO";
    }

    for(var i = 1; i < w1Arr.length; i+=2){
        if(w1Arr[i-1] == w2Arr[i-1]){
            if(w1Arr[i] > w2Arr[i]) return "NO";
        }else{
            return "NO";
        }
    }

    return "YES";
}

for(var k = 0; k < number*2; k++){
    descriptions.push(readline());
}

for(var i = 1; i < number*2; i+=2){
    print(matchesOrNot(descriptions[i-1], descriptions[i]));
}

const DEBUG = false;
const { EOL } = require('os');
const fs = require('fs');

let r = process.stdin;
if (DEBUG) {
  r = fs.createReadStream('input');
}
let data = '';
function calc(s, t) {
  let idx1 = 0;
  let idx2 = 0;
  let cnt1 = 0;
  let cnt2 = 0;
  while (idx1 < s.length && idx2 < t.length) {
    const c = s[idx1];
    cnt1 = 0;
    cnt2 = 0;
    if (s[idx1] !== t[idx2]) {
      return 'NO';
    }
    while (idx1 + cnt1 < s.length && s[idx1 + cnt1] === c) {
      cnt1 += 1;
    }
    while (idx2 + cnt2 < t.length && t[idx2 + cnt2] === c) {
      cnt2 += 1;
    }
    if (cnt2 < cnt1) {
      return 'NO';
    }
    idx1 += cnt1;
    idx2 += cnt2;
  }
  if (idx2 < t.length || idx1 < s.length) {
    return 'NO';
  }
  return 'YES';
}
r.on('data', c => (data += c));
r.on('end', () => {
  const lines = data.split(EOL);
  const tests = Number(lines[0]);
  for (let i = 1; i <= tests; i += 1) {
    console.log(calc(lines[2 * i - 1], lines[2 * i]));
  }
});

const DEBUG = false
let readline = require('readline').createInterface({
  input: !DEBUG ? process.stdin : require('fs').createReadStream('./input'),
});

let main = () => {
  for (let i = 0; i < list.length; i+=2) {
    let itemA = list[i]
    let itemB = list[i+1]
    let next = 0;
    let j = 0;
    for (; ;) {
      if (itemA[j] == itemB[next] && next < itemB.length && j < itemA.length) {
        next++;
        j++;
      } else if (next > 0 && itemA[j - 1] == itemB[next]) {
        next++;
      } else {
        break
      }
    }
    console.log(next == itemB.length && j == itemA.length ? 'YES' : 'NO')
  }
}

let list = []
let n = 0, cnt = 0;
readline.on('line', (d) => {
  if (n == 0) {
    n = parseInt(d, 10)
  } else {
    list.push(d)
    if (++cnt >= n * 2) {
      readline.close();
    }
  }
});
readline.on('close', () => {
  main()
})

const DEBUG = false
let readline = require('readline').createInterface({
  input: !DEBUG ? process.stdin : require('fs').createReadStream('./input'),
});

let main = () => {
  for (let i = 0; i < list.length; i+=2) {
    let itemA = list[i]
    let itemB = list[i+1]

    if (itemA.length > itemB.length) {
      console.log('NO')
      continue
    }

    let next = 0;
    let j = 0;
    for (; ;) {
      if (itemA[j] == itemB[next] && next < itemB.length && j < itemA.length) {
        next++;
        j++;
      } else if (next > 0 && itemA[j - 1] == itemB[next]) {
        next++;
      } else {
        break
      }
    }
    console.log(next == itemB.length && j == itemA.length ? 'YES' : 'NO')
  }
}

let list = []
let n = 0, cnt = 0;
readline.on('line', (d) => {
  if (n == 0) {
    n = parseInt(d, 10)
  } else {
    list.push(d)
    if (++cnt >= n * 2) {
      readline.close();
    }
  }
});
readline.on('close', () => {
  main()
})

// Codeforces 1185/B
let lines = '';

process.stdin.resume();
process.stdin.setEncoding('utf-8');
process.stdin.on('data', input => lines += input);
process.stdin.on('end', () => {
  const { EOL } = require('os')
  lines = lines.split(EOL)

  main();
});

const main = () => {
  const npairs = parseInt(lines[0]);
  for (let i = 1; i < 2*npairs; i += 2) {
    console.log(solution(lines[i], lines[i+1]));
  }
};

const countChars = (s) => {
  let prevChar = s[0];
  let count = 1;
  let res = [];
  if (s.length === 1) return [`1${s[0]}`];
  for (let i = 1; i < s.length; i++) {
    if (i === s.length - 1) {
      if (s[i] !== prevChar) {
        res.push(`${count}${prevChar}`);
        res.push(`${1}${s[i]}`);
      } else {
        res.push(`${count+1}${s[i]}`);
      }
    } else if (s[i] !== prevChar) {
      res.push(`${count}${prevChar}`);
      count = 1;
    } else {
      count++;
    }
    prevChar = s[i];
  }
  return res;
};

const solution = (a, b) => {
  const a_arr = countChars(a);
  const b_arr = countChars(b);
  if (a_arr.length !== b_arr.length) return 'NO';
  for (let i = 0; i< a_arr.length; i++) {
    const aNum = parseInt(a_arr[i].substring(0, a_arr[i].length-1));
    const bNum = parseInt(b_arr[i].substring(0, b_arr[i].length-1));
    const aChar = a_arr[i][a_arr[i].length - 1];
    const bChar = b_arr[i][b_arr[i].length - 1];
    if (aNum > bNum) return 'NO';
    if (aChar !== bChar) return 'NO';
  }
  return 'YES';
};

// Codeforces 1185/B
let lines = '';

process.stdin.resume();
process.stdin.setEncoding('utf-8');
process.stdin.on('data', input => lines += input);
process.stdin.on('end', () => {
  const { EOL } = require('os')
  lines = lines.split(EOL)

  main();
});

const main = () => {
  const npairs = parseInt(lines[0]);
  for (let i = 1; i < 2*npairs; i += 2) {
    console.log(solution(lines[i], lines[i+1]));
  }
};

const countChars = (s) => {
  let prevChar = s[0];
  let count = 1;
  let res = [];
  for (let i = 1; i < s.length; i++) {
    if (i === s.length - 1) {
      if (s[i] !== prevChar) {
        res.push(`${count}${prevChar}`);
        res.push(`${1}${s[i]}`);
      } else {
        res.push(`${count+1}${s[i]}`);
      }
    } else if (s[i] !== prevChar) {
      res.push(`${count}${prevChar}`);
      count = 1;
    } else {
      count++;
    }
    prevChar = s[i];
  }
  return res;
};

const solution = (a, b) => {
  const a_arr = countChars(a);
  const b_arr = countChars(b);
  if (a_arr.length !== b_arr.length) return 'NO';
  for (let i = 0; i< a_arr.length; i++) {
    if (a_arr[i][0] > b_arr[i][0]) return 'NO';
    if (a_arr[i][1] !== b_arr[i][1]) return 'NO';
  }
  return 'YES';
};