// Generated by CoffeeScript 1.7.1
(function() {
  var buffer, console, process, readable, solve, source;

  solve = function(tasks) {
    var i, index, numWays, pass, sorted, value, virtualPass, x, _i, _j, _k, _l, _len, _len1, _len2, _m, _n, _ref;
    sorted = [];
    for (i = _i = 0; _i <= 2000; i = ++_i) {
      sorted[i] = [];
    }
    for (index = _j = 0, _len = tasks.length; _j < _len; index = ++_j) {
      value = tasks[index];
      sorted[value].push(index + 1);
    }
    numWays = 1;
    for (_k = 0, _len1 = sorted.length; _k < _len1; _k++) {
      x = sorted[_k];
      if (x.length >= 2) {
        numWays *= x.length;
      }
    }
    console.log((numWays >= 3 ? "YES" : "NO"));
    if (numWays >= 3) {
      for (pass = _l = 1; _l <= 3; pass = ++_l) {
        virtualPass = pass;
        for (_m = 0, _len2 = sorted.length; _m < _len2; _m++) {
          x = sorted[_m];
          if (x.length === 1) {
            process.stdout.write("" + x[0] + " ");
          }
          if (x.length === 2) {
            if (virtualPass === 1) {
              process.stdout.write("" + x[0] + " " + x[1] + " ");
            }
            if (virtualPass === 2) {
              process.stdout.write("" + x[1] + " " + x[0] + " ");
            }
            if (virtualPass === 3) {
              process.stdout.write("" + x[0] + " " + x[1] + " ");
              virtualPass = 2;
            }
          }
          if (x.length >= 3) {
            if (virtualPass === 1) {
              process.stdout.write("" + x[0] + " " + x[1] + " " + x[2] + " ");
            }
            if (virtualPass === 2) {
              process.stdout.write("" + x[1] + " " + x[2] + " " + x[0] + " ");
            }
            if (virtualPass === 3) {
              process.stdout.write("" + x[2] + " " + x[0] + " " + x[1] + " ");
            }
            if (x.length > 3) {
              for (i = _n = 3, _ref = x.length; 3 <= _ref ? _n < _ref : _n > _ref; i = 3 <= _ref ? ++_n : --_n) {
                process.stdout.write("" + x[i] + " ");
              }
            }
          }
        }
        console.log("");
      }
    }
    return console.log("");
  };

  if ((typeof process !== "undefined" && process !== null ? process.stdin : void 0) != null) {
    source = "";
    readable = process.stdin;
    readable.on('data', function(chunk) {
      return source += chunk;
    });
    readable.on('end', function() {
      var i, _i, _len, _results;
      source = source.split("\n\n");
      source = source.map(function(x) {
        return x.split("\n")[1];
      });
      source = source.map(function(x) {
        return x.split(/\s/g).map(function(z) {
          return parseInt(z, 10);
        });
      });
      _results = [];
      for (_i = 0, _len = source.length; _i < _len; _i++) {
        i = source[_i];
        _results.push(solve(i));
      }
      return _results;
    });
  } else {
    buffer = '';
    console = {};
    console.log = function(x) {
      print("" + buffer + x);
      return buffer = '';
    };
    process = {};
    process.stdout = {};
    process.stdout.write = function(x) {
      return buffer = "" + buffer + x;
    };
    source = readline();
    source = readline();
    source = source.split(/\s/g).map(function(z) {
      return parseInt(z, 10);
    });
    solve(source);
  }

}).call(this);

// Generated by CoffeeScript 1.7.1
(function() {
  var buffer, console, process, readable, solve, source;

  solve = function(tasks) {
    var i, index, numWays, pass, sorted, value, virtualPass, x, _i, _j, _k, _l, _len, _len1, _len2, _m;
    sorted = [];
    for (i = _i = 0; _i <= 2000; i = ++_i) {
      sorted[i] = [];
    }
    for (index = _j = 0, _len = tasks.length; _j < _len; index = ++_j) {
      value = tasks[index];
      sorted[value].push(index + 1);
    }
    numWays = 1;
    for (_k = 0, _len1 = sorted.length; _k < _len1; _k++) {
      x = sorted[_k];
      if (x.length >= 2) {
        numWays *= x.length;
      }
    }
    console.log((numWays >= 3 ? "YES" : "NO"));
    if (numWays >= 3) {
      for (pass = _l = 1; _l <= 3; pass = ++_l) {
        virtualPass = pass;
        for (_m = 0, _len2 = sorted.length; _m < _len2; _m++) {
          x = sorted[_m];
          if (x.length === 1) {
            process.stdout.write("" + x[0] + " ");
          }
          if (x.length === 2) {
            if (virtualPass === 1) {
              process.stdout.write("" + x[0] + " " + x[1] + " ");
            }
            if (virtualPass === 2) {
              process.stdout.write("" + x[1] + " " + x[0] + " ");
            }
            if (virtualPass === 3) {
              process.stdout.write("" + x[0] + " " + x[1] + " ");
              virtualPass = 2;
            }
          }
          if (x.length >= 3) {
            if (virtualPass === 1) {
              process.stdout.write("" + x[0] + " " + x[1] + " " + x[2] + " ");
            }
            if (virtualPass === 2) {
              process.stdout.write("" + x[1] + " " + x[2] + " " + x[0] + " ");
            }
            if (virtualPass === 3) {
              process.stdout.write("" + x[2] + " " + x[0] + " " + x[1] + " ");
            }
          }
        }
        console.log("");
      }
    }
    return console.log("");
  };

  if ((typeof process !== "undefined" && process !== null ? process.stdin : void 0) != null) {
    source = "";
    readable = process.stdin;
    readable.on('data', function(chunk) {
      return source += chunk;
    });
    readable.on('end', function() {
      var i, _i, _len, _results;
      source = source.split("\n\n");
      source = source.map(function(x) {
        return x.split("\n")[1];
      });
      source = source.map(function(x) {
        return x.split(/\s/g).map(function(z) {
          return parseInt(z, 10);
        });
      });
      _results = [];
      for (_i = 0, _len = source.length; _i < _len; _i++) {
        i = source[_i];
        _results.push(solve(i));
      }
      return _results;
    });
  } else {
    buffer = '';
    console = {};
    console.log = function(x) {
      print("" + buffer + x);
      return buffer = '';
    };
    process = {};
    process.stdout = {};
    process.stdout.write = function(x) {
      return buffer = "" + buffer + x;
    };
    source = readline();
    source = readline();
    source = source.split(/\s/g).map(function(z) {
      return parseInt(z, 10);
    });
    solve(source);
  }

}).call(this);

// Generated by CoffeeScript 1.7.1
(function() {
  var buffer, console, process, readable, solve, source;

  solve = function(tasks) {
    var i, index, numWays, pass, sorted, value, virtualPass, x, _i, _j, _k, _l, _len, _len1, _len2, _m;
    sorted = [];
    for (i = _i = 0; _i <= 2000; i = ++_i) {
      sorted[i] = [];
    }
    for (index = _j = 0, _len = tasks.length; _j < _len; index = ++_j) {
      value = tasks[index];
      sorted[value].push(index + 1);
    }
    numWays = 1;
    for (_k = 0, _len1 = sorted.length; _k < _len1; _k++) {
      x = sorted[_k];
      if (x.length >= 2) {
        numWays *= x.length;
      }
    }
    console.log((numWays >= 3 ? "YES" : "NO"));
    if (numWays >= 3) {
      for (pass = _l = 1; _l <= 3; pass = ++_l) {
        virtualPass = pass;
        for (_m = 0, _len2 = sorted.length; _m < _len2; _m++) {
          x = sorted[_m];
          if (x.length === 1) {
            process.stdout.write("" + x[0] + " ");
          }
          if (x.length === 2) {
            if (virtualPass === 1) {
              process.stdout.write("" + x[0] + " " + x[1] + " ");
            }
            if (virtualPass === 2) {
              process.stdout.write("" + x[1] + " " + x[0] + " ");
            }
            if (virtualPass === 3) {
              process.stdout.write("" + x[0] + " " + x[1] + " ");
              virtualPass = 2;
            }
          }
          if (x.length === 3) {
            if (virtualPass === 1) {
              process.stdout.write("" + x[0] + " " + x[1] + " " + x[2] + " ");
            }
            if (virtualPass === 2) {
              process.stdout.write("" + x[1] + " " + x[2] + " " + x[0] + " ");
            }
            if (virtualPass === 3) {
              process.stdout.write("" + x[2] + " " + x[0] + " " + x[1] + " ");
            }
          }
        }
        console.log("");
      }
    }
    return console.log("");
  };

  if (typeof process !== "undefined" && process !== null) {
    source = "";
    readable = process.stdin;
    readable.on('data', function(chunk) {
      return source += chunk;
    });
    readable.on('end', function() {
      var i, _i, _len, _results;
      source = source.split("\n\n");
      source = source.map(function(x) {
        return x.split("\n")[1];
      });
      source = source.map(function(x) {
        return x.split(/\s/g).map(function(z) {
          return parseInt(z, 10);
        });
      });
      _results = [];
      for (_i = 0, _len = source.length; _i < _len; _i++) {
        i = source[_i];
        _results.push(solve(i));
      }
      return _results;
    });
  } else {
    buffer = '';
    console = {};
    console.log = function(x) {
      print("" + buffer + x);
      return buffer = '';
    };
    process = {};
    process.stdout = {};
    process.stdout.write = function(x) {
      return buffer = "" + buffer + x;
    };
    source = readline();
    source = readline();
    source = source.split(/\s/g).map(function(z) {
      return parseInt(z, 10);
    });
    solve(source);
  }

}).call(this);

;(function () {

	print(function () {

		var qw = true;

		var n = +readline(),
			m = {}, lib = [],
			h = readline().split(' ').map(function (e, i) {
				e = +e;
				m[e] = m[e] ? m[e] + 1 : 1;
				if (lib.indexOf(e) === -1) lib.push(e);
				return [e, i+1];
			});

		h = h.sort(function (a, b) { return a[0] - b[0]; });

		var flag = false;
		lib.forEach(function (e) {
			if (m[e] === 1) flag = true;
		});

		if (flag) return 'NO';

		var ret = [[], [], []];

		lib = [];
		h.forEach(function (e) {
			if (lib.indexOf(e[0]) === -1) lib.push(e[0]);
		});

		lib.forEach(function (e) {
			var a = [];
			h.forEach(function (j) {
				if (j[0] === e) a.push(j[1]);
			});

			if (a.length === 2) {
				qw = !qw;
				if (qw) {
					ret[0].push(a[0], a[1]);
					ret[1].push(a[0], a[1]);
					ret[2].push(a[1], a[0]);
				} else {
					ret[0].push(a[0], a[1]);
					ret[1].push(a[1], a[0]);
					ret[2].push(a[1], a[0]);
				}
			} else {
				for (var j = 0; j < 3; j++)
					for (var i = j; i < a.length; i++) ret[j].push(a[i]);
				ret[1].push(a[0]);
				ret[2].push(a[0], a[1]);
			}
		});

		var n = 3;
		while (n--) {
			ret[n] = ret[n].join(' ');
		}

		ret.unshift('YES');

		return ret.join('\n');

	}());

}.call(this));

;(function () {

	print(function () {

		var qw = -1;

		var n = +readline(),
			m = {}, lib = [],
			h = readline().split(' ').map(function (e, i) {
				e = +e;
				m[e] = m[e] ? m[e] + 1 : 1;
				if (lib.indexOf(e) === -1) lib.push(e);
				return [e, i+1];
			});

		h = h.sort(function (a, b) { return a[0] - b[0]; });

		var flag = 0;
		lib.forEach(function (e) {
			if (m[e] == 2) flag++;
			if (m[e] == 3) flag+=3;
		});

		if (flag < 2 ) return 'NO';

		var ret = [[], [], []];

		lib = [];
		h.forEach(function (e) {
			if (lib.indexOf(e[0]) === -1) lib.push(e[0]);
		});

		lib.forEach(function (e) {
			var a = [];
			h.forEach(function (j) {
				if (j[0] === e) a.push(j[1]);
			});

			if (a.length === 2) {
				qw++;

				switch (qw % 3) {
					case 0:
						ret[0].push(a[0], a[1]);
						ret[1].push(a[0], a[1]);
						ret[2].push(a[1], a[0]);
						break;
					case 1:
						ret[0].push(a[0], a[1]);
						ret[1].push(a[1], a[0]);
						ret[2].push(a[0], a[1]);
						break;
					case 2:
						ret[0].push(a[1], a[0]);
						ret[1].push(a[0], a[1]);
						ret[2].push(a[0], a[1]);
						break;
				}
			} else {
				for (var j = 0; j < 3; j++)
					for (var i = j; i < a.length; i++) ret[j].push(a[i]);
				ret[1].push(a[0]);
				ret[2].push(a[0], a[1]);
			}
		});

		var n = 3;
		while (n--) {
			ret[n] = ret[n].join(' ');
		}

		ret.unshift('YES');

		return ret.join('\n');

	}());

}.call(this));

;(function () {

	print(function () {

		var qw = -1;

		var n = +readline(),
			m = {}, lib = [],
			h = readline().split(' ').map(function (e, i) {
				e = +e;
				m[e] = m[e] ? m[e] + 1 : 1;
				if (lib.indexOf(e) === -1) lib.push(e);
				return [e, i+1];
			});

		h = h.sort(function (a, b) { return a[0] - b[0]; });

		var flag = false;
		lib.forEach(function (e) {
			if (m[e] === 1) flag = true;
		});

		if (flag) return 'NO';

		var ret = [[], [], []];

		lib = [];
		h.forEach(function (e) {
			if (lib.indexOf(e[0]) === -1) lib.push(e[0]);
		});

		lib.forEach(function (e) {
			var a = [];
			h.forEach(function (j) {
				if (j[0] === e) a.push(j[1]);
			});

			if (a.length === 2) {
				qw++;

				switch (qw % 3) {
					case 0:
						ret[0].push(a[0], a[1]);
						ret[1].push(a[0], a[1]);
						ret[2].push(a[1], a[0]);
						break;
					case 1:
						ret[0].push(a[0], a[1]);
						ret[1].push(a[1], a[0]);
						ret[2].push(a[0], a[1]);
						break;
					case 2:
						ret[0].push(a[1], a[0]);
						ret[1].push(a[0], a[1]);
						ret[2].push(a[0], a[1]);
						break;
				}
			} else {
				for (var j = 0; j < 3; j++)
					for (var i = j; i < a.length; i++) ret[j].push(a[i]);
				ret[1].push(a[0]);
				ret[2].push(a[0], a[1]);
			}
		});

		var n = 3;
		while (n--) {
			ret[n] = ret[n].join(' ');
		}

		ret.unshift('YES');

		return ret.join('\n');

	}());

}.call(this));

;(function () {

	print(function () {

		var n = +readline(),
			m = {}, lib = [],
			h = readline().split(' ').map(function (e, i) {
				e = +e;
				m[e] = m[e] ? m[e] + 1 : 1;
				if (lib.indexOf(e) === -1) lib.push(e);
				return [e, i+1];
			});

		h = h.sort(function (a, b) { return a[0] - b[0]; });

		var flag = false;
		lib.forEach(function (e) {
			if (m[e] === 1) flag = true;
		});

		if (flag) return 'NO';

		var ret = [[], [], []];

		lib = [];
		h.forEach(function (e) {
			if (lib.indexOf(e[0]) === -1) lib.push(e[0]);
		});

		lib.forEach(function (e) {
			var a = [];
			h.forEach(function (j) {
				if (j[0] === e) a.push(j[1]);
			});

			if (a.length === 2) {
				ret[0].push(a[0], a[1]);
				ret[1].push(a[0], a[1]);
				ret[2].push(a[1], a[0]);
			} else {
				for (var i = 0; i < a.length; i++) ret[0].push(a[i]);
				for (var i = 1; i < a.length; i++) ret[1].push(a[i]); ret[1].push(a[0]);
				for (var i = 2; i < a.length; i++) ret[2].push(a[i]); ret[2].push(a[0], a[1]);
			}
		});

		var n = 3;
		while (n--) {
			ret[n] = ret[n].join(' ');
		}

		ret.unshift('YES');

		return ret.join('\n');

	}());

}.call(this));


//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 list = [];
		for(var i = 1; i <= N; i++){
			list.push(i);
		}
		for(var i = N - 1; i > 0; i -= 2){
			var tmp = list[i - 1];
			list[i - 1] = list[i];
			list[i] = tmp;
		}
		myout(myconv(list, 8));
	}
}

var limit = parseInt(readline());
for (var i = 0; i < limit; i++)
{
    var value = parseInt(readline());
    var result = "";
    if (value % 2 === 0)
    {
        for (var j = 1; j <= value; j+=2)
        {
            result += `${j+1} ${j} `;
        }
    }
    else
    {
        result += "1 ";
        for (var j = 2; j <= value; j+=2)
        {
            result += `${j+1} ${j} `;
        }
    }
    print(result);
}

var tests = parseInt(readline());
    var n;
    for (var t=0; t < tests; t++) {
        n = parseInt(readline());
        var ans = [];
        var start = 1;
        if (n & 1) {
            start = 2;
            ans.push(1);
        }
        for (var i = start; i < n; i+=2) {
            ans.push(i+1);
            ans.push(i);
        }
        print(ans.join(' '));
    }

let ryan = '';//.map(Number).sort(function(a, b){return a - b})
process.stdin.on('data', c => ryan += c);
process.stdin.on('end', () => {
    const {EOL} = require('os');
    const lines = ryan.split(EOL);
    var n = lines[0], e = 0, g = 0
    for(j = 1; j <= n; j++){
        var k = Number(lines[j])
        e = '', g = ''
        if(k % 2 == 1){
            e = '1' + ' '
            for(l = 1; l < k; l+=2){
                e += (l + 2) + ' ' + (l + 1) + ' '
            }
            console.log(e)
        }else{
            for(l = 2; l <= k; l+=2){
                e += (l) + ' ' + (l - 1) + ' '
            }
            console.log(e)
        }
    }
});

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

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

var input_stdin = "";
var input_stdin_array = "";
var input_currentline = 0;

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

process.stdin.on("end", function () {
  input_stdin_array = input_stdin.split("\n");
  // console.log(input_stdin_array);
  main();
});

function readLine() {
  return input_stdin_array[input_currentline++];
}

function main() {
  var a = readLine();
  while (a--) {
    var b = readLine();
    var res = solveMeFirst(b);
    let out = "";
    if (res) {
      for (let i = 0; i < res.length; i++) {
        out += res[i] + " ";
      }
      console.log(out);
    }
  }
}
function solveMeFirst(p) {
  let arr = [];
  if (p % 2 === 0) {
    arr.push(2);
  } else if (p > 1) {
    arr.push(1);
    arr.push(3);
  } else {
    arr.push(1);
  }
  let isMinus = true;
  for (let i = p % 2 === 0 ? 1 : 2; i < p; i++) {
    if (isMinus) {
      arr[i] = arr[i - 1] - 1;
      isMinus = false;
    } else {
      arr[i] = arr[i - 1] + 3;
      isMinus = true;
    }
  }
  return arr;
}

// console.log(solveMeFirst(2, [2, 3, 2, 4, 1, 3, 4, 1]));
// console.log(timeConversion([100, 90, 90, 80], [70, 80, 105]));

'use strict';

const fs = require('fs');

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

let inputString = '';
let currentLine = 0;

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

process.stdin.on('end', function() {
    inputString = inputString.split('\n');

    main();
});

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

function isPossible(n, x, heights) {
    heights.sort();
    heights.sort(function(a, b) {
        return a - b;
      });
    // //console.log(heights)

    let front = []
    let back = []

    for (let i = 0; i < heights.length; i++) {
        if (i < n) {
            front.push(heights[i])
        } else {
            back.push(heights[i])
        }
    }

    // //console.log(front)
    // //console.log(back)
    for (let j = 0; j < front.length; j++) {
        if (back[j] - front[j] < x) {
            // //console.log(back[j] + " " + front[j])
            return "NO";
        }
    }

    return "YES";
}

function calc(a, m) {
    let s = "";
    for (let index = 0; index < m; index++) {
        s += "B"
    }

   for (let index = 0; index < a.length; index++) {
        let ai = a[index];

        if (ai < (m + 1 - ai)) {
            let _s = s.replaceAt(ai - 1, "A");
            if (compare(_s, s) < 0) {
                s = _s;
                continue;
            } else if (compare(_s, s) >= 0) {
                    let __ss = s.replaceAt(m + 1 - ai - 1, "A");
                    if (compare(__ss, s) < 0) {
                        s = __ss;
                        continue;
                    }
            }
         }  else {
            let _s = s.replaceAt(m + 1 - ai - 1, "A");
            if (compare(_s, s) < 0) {
                s = _s;
                continue;
            }  if (compare(_s, s) >= 0) {
                    let __ss = s.replaceAt(ai - 1, "A");
                    if (compare(__ss, s) < 0) {
                        s = __ss;
                        continue;
                    }
            }
    }
}

   return s;
}

function compare(s1, s2) {
    return s1.localeCompare(s2)
}

String.prototype.replaceAt = function(index, replacement) {
    return this.substring(0, index) + replacement + this.substring(index + replacement.length);
}

function main() {
    // const ws = fs.createWriteStream(process.env.OUTPUT_PATH);

    const test_cases = parseInt(readLine().trim(), 10);

    for (let gItr = 0; gItr < test_cases; gItr++) {
        // const nk = readLine().replace(/\s+$/g, '').split(' ').map(arrTemp => parseInt(arrTemp, 10));
        // const n = nk[0];
        // const k = nk[1];

        const n = parseInt(readLine().trim(), 10);
        let a = []

        if (n%2 == 0) {
            for (let i = n; i > 0; i-=2) {
                a.push(i - 1)
                a.push(i)
            }
        } else {
            for (let i = n; i > 1; i-=2) {
                a.push(i - 1)
                a.push(i)
            }
            a.push(1)
        }

        a = a.reverse()
        // console.log(a)
        let s = ""
        for (let i = 0; i < a.length; i++) {
            // console.log(a[i])
            s += a[i] + " "
        }

        s.slice(0, -1);
        console.log(s)

        // const p = readLine().replace(/\s+$/g, '').split(' ').map(arrTemp => parseInt(arrTemp, 10));
        // const q = p
        // if (k == n || k == 0) {
        //     console.log("0");
        // } else {
        //     const p1 = p.slice(0, k)
        //     q.sort(function(a, b){return a-b});

        //     let count = 0
        //     for (let i = 0; i < k; i++) {
        //         if (!p1.includes(q[i])) count++
        //     }

        //     console.log(count)
        // }

        // if ((n >= 1 && n <= 50) && (m >= 1 && m <= 50)) {
        // const val = readLine().replace(/\s+$/g, '').split(' ').map(arrTemp => parseInt(arrTemp, 10));
        // const val = readLine().trim()
        // if (val.toUpperCase() == "YES") console.log("YES")
        // else console.log("NO")
        // let output = calc(val, m);
        // console.log(output)
        // }
        // ws.write(result + '\n');
    }

    // ws.end();
}

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 [n, k] = readline().split(' ').map((x) => parseInt(x));
  // var a = readline().split(' ').map((x) => parseInt(x));
  var n = readline();
  var a = [];
  if(n % 2 == 0) {
    for(var i=0;i<n;i+=2) {
      a[i] = i+2;
      a[i+1] = i+1
    }
  } else {
    a[0] = 1;
    for(var i=1;i+1<n;i+=2) {
      a[i] = i+2;
      a[i+1] = i+1
    }
  }

  console.log(a.join(" "))
}

'use strict';

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

let inputString = '';
let currentLine = 0;

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

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

    main();
});

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

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

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

    for (let i = 0; i < N; i++) {
        const n = parseInt(readline(), 10);

        let result = [];
        let i = 0;
        if (n % 2 === 0) {
            result.push(2);
            result.push(1);
            i = 3;
            for (; i <= n; i++) {
                i % 2 === 0 ? result.push(i - 1) : result.push(i + 1);
            }
        } else {
            result.push(1);
            i = 2;
            for (; i <= n; i++) {
                i % 2 === 0 ? result.push(i + 1) : result.push(i - 1);
            }
        }

        output(result.join(' '));
    }
}

'use strict';

function solve(n) {
  const res = new Array(n);
  for (let i = n - 1; i >= 0; i -= 2) {
    if (i === 0) {
      res[i] = 1;
    } else {
      res[i] = i;
      res[i - 1] = i + 1;
    }
  }
  return res.join(' ');
}

async function main(r) {
  const rn = async () => Number(await r());
  try {
    let t = Number(await r());
    let res = new Array(t);
    for (let i = 0; i < t; i++) {
      const n = await rn();
      res[i] = solve(n);
    }
    return 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', async () => {
  inputs = str.split('\n').values();
  const output = await main(read);
  process.stdout.write(output);
});

let i = '';
process.stdin.on('data', c => i += c);
process.stdin.on('end', () => {
    const {EOL} = require('os');
    const lines = i.split(EOL);
    var n = lines[0]
    var a = 0
    for(j = 1; j <= n ;j ++){
    var k = lines[j]
        a = k + ' '
        for(l = 1; l < k; l++){
            a += l + ' '
        }
            console.log(a)

    }

});

let i = '';
process.stdin.on('data', c => i += c);
process.stdin.on('end', () => {
    const {EOL} = require('os');
    const lines = i.split(EOL);
    var n = lines[0]
    for(j = 1; j <= n; j++){
        var f = false
        var h = lines[j].split('')
        var r = lines[j].split('')
        h.reverse()
        console.log(h, r)
        if(h == r){
            for(l = 0 ; l < h.length; l++){
                if(h[l] == h[l + 1]){
                    f = true
                }else{
                    f = false
                    h.splice(0, 0,  h[1], h[0])
                    h.splice(2, 2)
                    break;
                }
            }
            if(f === true){
                console.log(-1)
            }else{
                console.log(h)
            }
        }else{
            console.log(lines[j], 'dasd')
        }

    }
});

let stop = '';
process.stdin.on('data', c => stop += c);
process.stdin.on('end', () => {
    const {EOL} = require('os');
    const lines = stop.split(EOL);
    var n = lines[0];
    for(i = 1; i <= n; i++){
        var t = lines[i];

    }
    console.log(1);
    console.log(2, 1);
});

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

var input_stdin = "";
var input_stdin_array = "";
var input_currentline = 0;

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

process.stdin.on("end", function () {
  input_stdin_array = input_stdin.split("\n");
  // console.log(input_stdin_array);
  main();
});

function readLine() {
  return input_stdin_array[input_currentline++];
}

function main() {
  var a = readLine();
  while (a--) {
    var b = readLine();
    var res = solveMeFirst(b);
    let out = "";
    if (res) {
      for (let i = 0; i < res.length; i++) {
        out += res[i] + " ";
      }
      console.log(out);
    }
  }
}
function solveMeFirst(p) {
  let arr = [];
  for (let i = +p; i >= 1; i--) {
    arr.push(i);
  }
  return arr;
}

// console.log(solveMeFirst(2, [2, 3, 2, 4, 1, 3, 4, 1]));
// console.log(timeConversion([100, 90, 90, 80], [70, 80, 105]));

'use strict';

const fs = require('fs');

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

let inputString = '';
let currentLine = 0;

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

process.stdin.on('end', function() {
    inputString = inputString.split('\n');

    main();
});

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

function isPossible(n, x, heights) {
    heights.sort();
    heights.sort(function(a, b) {
        return a - b;
      });
    // //console.log(heights)

    let front = []
    let back = []

    for (let i = 0; i < heights.length; i++) {
        if (i < n) {
            front.push(heights[i])
        } else {
            back.push(heights[i])
        }
    }

    // //console.log(front)
    // //console.log(back)
    for (let j = 0; j < front.length; j++) {
        if (back[j] - front[j] < x) {
            // //console.log(back[j] + " " + front[j])
            return "NO";
        }
    }

    return "YES";
}

function calc(a, m) {
    let s = "";
    for (let index = 0; index < m; index++) {
        s += "B"
    }

   for (let index = 0; index < a.length; index++) {
        let ai = a[index];

        if (ai < (m + 1 - ai)) {
            let _s = s.replaceAt(ai - 1, "A");
            if (compare(_s, s) < 0) {
                s = _s;
                continue;
            } else if (compare(_s, s) >= 0) {
                    let __ss = s.replaceAt(m + 1 - ai - 1, "A");
                    if (compare(__ss, s) < 0) {
                        s = __ss;
                        continue;
                    }
            }
         }  else {
            let _s = s.replaceAt(m + 1 - ai - 1, "A");
            if (compare(_s, s) < 0) {
                s = _s;
                continue;
            }  if (compare(_s, s) >= 0) {
                    let __ss = s.replaceAt(ai - 1, "A");
                    if (compare(__ss, s) < 0) {
                        s = __ss;
                        continue;
                    }
            }
    }
}

   return s;
}

function compare(s1, s2) {
    return s1.localeCompare(s2)
}

String.prototype.replaceAt = function(index, replacement) {
    return this.substring(0, index) + replacement + this.substring(index + replacement.length);
}

function main() {
    // const ws = fs.createWriteStream(process.env.OUTPUT_PATH);

    const test_cases = parseInt(readLine().trim(), 10);

    for (let gItr = 0; gItr < test_cases; gItr++) {
        // const nk = readLine().replace(/\s+$/g, '').split(' ').map(arrTemp => parseInt(arrTemp, 10));
        // const n = nk[0];
        // const k = nk[1];

        const n = parseInt(readLine().trim(), 10);
        let a = []

        for (let i = n; i > 0; i --) {
            a.push(i)
        }

        let s = ""
        for (let i = 0; i < a.length; i++) {
            // console.log(a[i])
            s += a[i] + " "
        }

        s.slice(0, -1);
        console.log(s)

        // const p = readLine().replace(/\s+$/g, '').split(' ').map(arrTemp => parseInt(arrTemp, 10));
        // const q = p
        // if (k == n || k == 0) {
        //     console.log("0");
        // } else {
        //     const p1 = p.slice(0, k)
        //     q.sort(function(a, b){return a-b});

        //     let count = 0
        //     for (let i = 0; i < k; i++) {
        //         if (!p1.includes(q[i])) count++
        //     }

        //     console.log(count)
        // }

        // if ((n >= 1 && n <= 50) && (m >= 1 && m <= 50)) {
        // const val = readLine().replace(/\s+$/g, '').split(' ').map(arrTemp => parseInt(arrTemp, 10));
        // const val = readLine().trim()
        // if (val.toUpperCase() == "YES") console.log("YES")
        // else console.log("NO")
        // let output = calc(val, m);
        // console.log(output)
        // }
        // ws.write(result + '\n');
    }

    // ws.end();
}


readline();
var a = readline().split( " " ).map( ai => parseInt( ai, 10 ) );
var values = [...new Set( a )];
var answer = "NO";
// min + x = mid = max - x can't be equal to some other number.
if ( values.length == 3 ) {
  values.sort( ( a, b ) => a - b );
  var min = values[ 0 ];
  var mid = values[ 1 ];
  var max = values[ 2 ];
  var x = ( max - min ) / 2;
  if ( Math.floor( x ) == x && min + x == mid && mid == max - x ) {
    answer = "YES";
  }
} else if ( values.length < 3 ) {
  answer = "YES";
}
print( answer );

function readIntTabLine(n) {
  var l = readline().split(' ')
  for (var i = 0 ; i < n ; i++) {
    l[i] = parseInt(l[i])
  }
  return l
}

var n = parseInt(readline())
var tab = readIntTabLine(n)
var possible = true
var set = []

for (var i = 0 ; i < n && possible; i++) {
  if (set.indexOf(tab[i]) == -1)
    possible = set.push(tab[i]) <= 3
}

if (!possible) print('NO')
else if (set.length < 3) print('YES')
else {
  var tri = []
  tri.push(Math.min.apply(null, set))
  set.splice(set.indexOf(tri[0]),1)
  tri.push(Math.min(set[0],set[1]))
  tri.push(Math.max(set[0],set[1]))
  if (tri[1]-tri[0] == tri[2]-tri[1]) print('YES')
  else print('NO')
}

readline();
var a = readline().split( " " ).map( ai => parseInt( ai, 10 ) );
var values = [...new Set( a )];
var answer = "NO";
// min + x = mid = max - x are only possible combinations of x and some number.
if ( values.length == 3 ) {
  values.sort( ( a, b ) => a - b );
  var min = values[ 0 ];
  var mid = values[ 1 ];
  var max = values[ 2 ];
  // Derived from equation above.
  if ( 2 * mid == max + min ) {
    answer = "YES";
  }
} else if ( values.length < 3 ) {
  answer = "YES";
}
print( answer );


'use strict';

let line = readline().split(' ');
let n = parseInt(line[0]);
let m = parseInt(line[1]);
const container = {};
let command, ip;
while (n--) {
  line = readline().split(' ');
  command = line[0];
  ip = line[1];
  container[ip] = command;
}

while (m--) {
  line = readline().split(' ');
  command = line[0];
  ip = line[1].substr(0, line[1].length - 1);
  print (`${command} ${ip}; #${container[ip]}`);
}

var dim = readline().split(' ');
var n = parseInt(dim[0]);
var m = parseInt(dim[1]);
var k, mydns = {};
for(k = 1; k <= n; k++){
	var server = readline().split(' ');
	mydns[server[1]] = server[0];
}

for(k = 0; k < m; k++){
	var command = readline().split(/[; ]/);
	print(command[0] + ' ' + command[1] + '; #' + mydns[command[1]]);
}

"use strict";

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

let [namesLength, commandsLenght] = [null];
let ips = [], names = [], commands = [];

readline.on('line', line => {
    if (!namesLength) {
        [namesLength, commandsLenght] = line.split(' ');
    } else if (names.length < namesLength) {
        let [a, b] = line.split(' ');
        names.push(a);
        ips.push(b);
    } else {
        commands.push(line.split(' '));
        if (commands.length == commandsLenght)
            readline.close();
    }
});

readline.on('close', () => {
    writeFile();
});

const writeFile = () => {
    commands.map(input => {
        let [name, target] = input;
        let origin = names[ips.indexOf(target.split(';')[0])];
        console.log(`${name} ${target} #${origin}`);
    })
};

nm = readline().split(' ').map(Number);

var n = nm[0], m = nm[1], nameArr = [];

for (var i = 0; i < n; i++) {
	str = readline().split(' ');

	for (var j = 0; j < str.length; j++) {
		nameArr.push(str[j]);
	};
};

for (var j = 0; j < m; j++) {
	str = readline().split(' ');

	for (var k = 0; k < nameArr.length; k++) {
		if (nameArr[k] + ';' == str[1]) {
			print(str.join(' ') + ' #' + nameArr[k - 1]);
		};
	};
};

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

rl.on('line', (d) => {
  if (c === 0) {
    [n, m] = d.split(' ').map(Number);

    c++;
    return;
  }

  if (c <= n) {
    const [name, ip] = d.split(' ');
    obj[`${ip};`] = `#${name}`;

    c++;
    return;
  }

  const [command, ip] = d.split(' ');
  console.log(`${command} ${ip} ${obj[ip]}`);

  c++;
});

rl.on('close', () => {

});

'use strict';

let line = readline().split(' ');
let n = parseInt(line[0]);
let m = parseInt(line[1]);
const container = {};
let command, ip;
while (n--) {
  line = readline().split(' ');
  command = line[0];
  ip = line[1];
  container[ip] = command;
}

while (m--) {
  line = readline().split(' ');
  command = line[0];
  ip = line[1].substr(0, line[1].length - 1);
  print (command + ' ' + ip + '; #' + container[ip]);
}

var l=readline().split(" ");
var n=parseInt(l[0]);
var m=parseInt(l[1]);
var an=new Array(n);
var am=new Array(m);
for(var i=0;i<n;i++){
	an[i]=readline();
}
for(var i=0;i<m;i++){
	am[i]=readline();
}
var f1="",f2="";
for(var i=0;i<m;i++){
	f1=am[i].split(" ");
	for(var y=0;y<n;y++){
		f2=(an[y].concat(";")).split(" ");
		if(f1[1]===f2[1]){print(f1[0].concat(" ",f1[1]," #",f2[0]));}
	}
}

var line = readline();
var n = line.split(" ")[0];
var m = line.split(" ")[1];
var domains = {};
var ip, server;

for(var i = 0; i < n; i++){
    line = readline();
    ip = line.split(" ")[1];
    server = line.split(" ")[0];
    domains[ip] = server;
}

for(var i = 0; i < m; i++){
    line = readline();
    ip = line.split(" ")[1].slice(0, -1);
    print(line + " #" + domains[ip]);
}

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

var s = serversAndCommandsAmount[0],
    c = serversAndCommandsAmount[1];

var servers = {}

for (var i = 0; i < s; i++) {
  var server = readline().split(' ');
  servers[ server[1] ] = server[0];
}

for (var i = 0; i < c; i++) {
  var command = readline();
  print(command + ' #' + servers[ command.split(' ')[1].slice(0, -1)]);
}

var operations = readline().split(" ");
var servers=[], options=[];
for (var i = 0; i < operations[0]; i++) {
    servers.push(readline());
}
for (var j = 0; j < operations[1]; j++) {
    options.push(readline());
}
for (var option = 0; option < options.length; option++) {
    var strWithIp = options[option].split(" ")[1];
    var ip = strWithIp.substring(0,strWithIp.length-1);
    for (var server = 0; server < servers.length; server++) {
        var strWithServerIp = servers[server].split(" ")[1];
        if (strWithServerIp == ip) {
            write(options[option] + " #" + servers[server].split(" ")[0] + "\n");
            break;
        }
    }
}

function main() {
  var nm = readline().split(' ');
  var n = nm[0];
  var m = nm[1];
  var ipNames = [];
  var result = [];

  for (var i = 0; i < n; i++) {
    var nameIp = readline().split(' ');
    var name = nameIp[0];
    var ip = nameIp[1];
    ipNames.push({ name: name, ip: ip });
  }

  for (var i = 0; i < m; i++) {
    var line = readline();
    var ip = line.split(' ')[1].slice(0, -1);
    var item = ipNames.find(item => item.ip === ip);
    result.push(line + ' #' + item.name);
  }

  for (var i = 0; i < m; i++) {
    print(result[i]);
  }
}

main();

var a = readline().split(" ");
var n = parseInt(a[0]);
var m = parseInt(a[1]);

var nameArr = [];
var ipArr = [];
var funcArr = [];

for(var i = 0; i < n; i++)
{
    var nInput = readline().split(" ");
    var name = nInput[0];
    var ip = nInput[1] + ";";

    nameArr.push(name);
    ipArr.push(ip);
}

for(var i = 0; i < m; i++)
{
    var mInput = readline().split(" ");
    var func = mInput[0];
    var ip = mInput[1];

    funcArr.push(ip);
    funcArr.push(func);
}

for(var i = 0; i < (2 * m); i += 2)
{
    var ip = funcArr[i];
    var func = funcArr[i + 1];

    for(var j = 0; j < n; j++)
    {
        if(ip == ipArr[j])
        {
            var name = nameArr[j];
            break;
        }
    }

    print(func + " " + ip + " #" + name);
}

'use strict';

let line = readline().split(' ');
let n = parseInt(line[0]);
let m = parseInt(line[1]);
const container = {};
let command, ip;
while (n--) {
  line = readline().split(' ');
  command = line[0];
  ip = line[1];
  container[ip] = command;
}

while (m--) {
  line = readline().split(' ');
  command = line[0];
  ip = line[1].substr(0, ip.length - 1);
  print (command + ' ' + ip + '; #' + container[ip]);
}

var l=readline().split(" ");
var n=parseInt(l[0]);
var m=parseInt(l[1]);
var ar=new Array(n);
var i2=0;
var full1="",full2="";
var ar2=new Array(m);
for(var i=0;i<n;i++){
	ar[i]=readline();
}
for(var i=0;i<n;i++){

	full1=ar[i].concat(";").split(" ");

for(var y=0;y<n;y++){

	full2=ar[y].split(" ");
	if(full1[1]==full2[1]&&full1[0]!=full2[0]){ar2[i2]=(full2.concat(" #",full1[0]));i2++;}
}
}for(var i=0;i<m;i++){
	print(ar2[i]);
}

var l=readline().split(" ");
var n=parseInt(l[0]);
var m=parseInt(l[1]);
var an=new Array(n);
var am=new Array(m);
for(var i=0;i<n;i++){
	an[i]=readline();
}
for(var i=0;i<m;i++){
	am[i]=readline();
}
var f1="",f2="";
for(var i=0;i<m;i++){
	f1=am[i].split(" ");
	for(var y=0;y<n;y++){
		f2=(an[y].concat(";")).split(" ");
		if(f1[1]===f2[1]){print(f1[0].concat(f1[1]," #",f2[0]));}
	}
}

var l=readline().split(" ");
var n=parseInt(l[0]);
var m=parseInt(l[1]);
var ar=new Array(n);
var full1,full2;
var ar2=new Array(m);
for(var i=0;i<n;i++){
	ar[i]=readline();
}
for(var i=0;i<n;i++){
	full1=ar[i];
	full1=full1.concat(";");
	full1=full1.split(" ");

for(var y=i+1;y<n;y++){

	full2=ar[y].split(" ");
	if(full1[1]===full2[1]){print(full2.concat(" #",full1[0]));}
}
}

var l=readline().split(" ");
var n=parseInt(l[0]);
var m=parseInt(l[1]);
var ar=new Array(n);
var i2=0;
var full1="",full2="";
var ar2=new Array(m);
for(var i=0;i<n;i++){
	ar[i]=readline();
}
for(var i=0;i<n;i++){
for(var y=i+1;y<n;y++){
		full1=ar[i].split(" ");

	full2=ar[y].split(" ");
	if(full1[1].concat(";")===full2[1]){ar2[i2]=full2.concat(" #",full1[0]);i2++;}
}
}for(var i=0;i<m;i++){
	print(ar2[i]);
}

var l=readline().split(" ");
var n=parseInt(l[0]);
var m=parseInt(l[1]);
var ar=new Array(n);
var i2=0;
var full1="",full2="";
var ar2=new Array(m);
for(var i=0;i<n;i++){
	ar[i]=readline();
}
for(var i=0;i<n;i++){
	full1=ar[i].split(" ");
for(var y=i+1;y<n;y++){

	full2=ar[y].split(" ");
	if(full1[1]===full2[1]){ar2[i2]=full2.concat(" #",full1[0]);i2++;}
}
}for(var i=0;i<m;i++){
	print(ar2[i]);
}

var l=readline().split(" ");
var n=parseInt(l[0]);
var m=parseInt(l[1]);
var ar=new Array(n);
var i2=0;
var full1="",full2="";
var ar2=new Array(m);
for(var i=0;i<n;i++){
	ar[i]=readline();
}
for(var i=0;i<n;i++){
for(var y=i+1;y<n;y++){
		full1=ar[i].split(" ");

	full2=ar[y].split(" ");
	if(full1[1]===full2[1]){ar2[i2]=full2.concat(" #",full1[0]);i2++;}
}
}for(var i=0;i<m;i++){
	print(ar2[i]);
}

var l=readline().split(" ");
var n=parseInt(l[0]);
var m=parseInt(l[1]);
var ar=new Array(n);
var i2=0;
var full1,full2;
var ar2=new Array(m);
for(var i=0;i<n;i++){
	ar[i]=readline();
}
for(var i=0;i<n;i++){
	full1=ar[i];
	full1=full1.concat(";");
	full1=full1.split(" ");

for(var y=i+1;y<n;y++){

	full2=ar[y].split(" ");
	if(full1[1]===full2[1]){ar2[i2]=(full2.concat(" #",full1[0]));i2++;}
}
}for(var i=0;i<m;i++){
	print(ar2[i]);
}

var l=readline().split(" ");
var n=parseInt(l[0]);
var m=parseInt(l[1]);
var ar=new Array(n);
var i2=0;
var full1,full2;
var ar2=new Array(m);
for(var i=0;i<n;i++){
	ar[i]=readline();
}
for(var i=0;i<n;i++){
	full1=ar[i].split(" ");
for(var y=i+1;y<n;y++){

	full2=ar[y].split(" ");
	if(full1[1]===full2[1]){ar2[i2]=full2+" #"+full1[0];i2++;}
}
}for(var i=0;i<m;i++){
	print(ar2[i]);
}

function main() {
  var nm = readline().split(' ');
  var n = nm[0];
  var m = nm[1];
  var ipNames = [];
  var result = [];

  for (var i = 0; i < n; i++) {
    var nameIp = readline().split(' ');
    var name = nameIp[0];
    var ip = nameIp[1];
    ipNames.push({ name: name, ip: ip });
  }

  for (var i = 0; i < m; i++) {
    var line = readline().split(' ');
    var ip = line[1].slice(0, -1);
    var item = ipNames.find(item => item.ip === ip);
    result.push(line + ' ' + item.name);
  }

  for (var i = 0; i < m; i++) {
    print(result[i]);
  }
}

main();

var dim = readline().split(' ');
(function(n,m){
	write(n+'***'+m);
	return print();
})(dim[0],dim[1]);


///////////////////////////////// pre-define /////////////////////////////////////
const pr = console.log;
///////////////////////////////////////////////////////////////////////////////////

const solve = (n) => {
    while (1) {
        let s = n.toString();
        let sum = 0n;
        for (const c of s) sum += BigInt(c);
        let res = gcd(n, sum);
        if (res > 1) return pr(s);
        n++;
    }
};

const gcd = (a, b) => b == 0 ? a : gcd(b, a % b);

const main = () => {
    const readline = require('readline');
    const rl = readline.createInterface({
        input: process.stdin,
        output: process.stdout
    });
    let input = [];
    rl.on('line', (line) => {
        input.push(BigInt(line));
    });
    rl.on('close', () => {
        let t = input[0];
        let i = 1;
        while (t--) {
            solve(input[i]);
            i++;
        }
    });
};

main()

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

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

let count = -1
let inputArr = []

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

function solve(n) {
    // if (n.length <= 2) return 0
    for (let i = BigInt(n); ; i++) {
        let len = i.toString().length
        let sum = i.toString().split('').map(i => +i).reduce((acc, i) => acc + i, 0)
        sum = BigInt(sum)
        for (let j = 2n; j <= sum; j++) {
            if (BigInt(i) % j === 0n && sum % j === 0n) return i.toString()
        }

    }

}

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

'use strict';

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

let inputString = '';
let currentLine = 0;

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

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

  main()
});

function readline() {
  return inputString[currentLine++]
}
// Make a Snippet for the code above this and then write your logic in main();

function main() {
  let testCases = readline()
  while(testCases--)
    solve()
  // let testCases = readline()
  // let testNum = 1,
  //   ans = null
  // while(testCases--) {
  //   ans = solve()
  //   console.log('Case #' + (testNum++) + ': ' + ans)
  // }
}

// function to solve problems
function solve (){
  let n = BigInt(readline())
  let sum = 0,
  gcdSum = 0n,
  count = 2,
  tempGcdSum = 0,
  ans = n

  // find smallest of n, n+1 and n+2
  sum = sumOfDigits(n)
  gcdSum = findGcdSum(n, sum)
  while (count-- && gcdSum == 1) {
    n++
    if (n % 10n == 0) {
      sum = sumOfDigits(n)
    } else {
      sum++
    }
    tempGcdSum = findGcdSum(n, sum)
    // console.log('tempGcdSum:', tempGcdSum)
    if (tempGcdSum != 1) {
      ans = n
      break
    }
  }
  console.log(ans.toString())
}

function sumOfDigits (n) {
  let ans = 0n
  while (n > 0) {
    ans += n % 10n
    n = BigInt(n/10n)
  }
  return ans
}

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

'use strict';

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

let inputString = '';
let currentLine = 0;

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

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

  main();
});

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

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

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

  Array(Number(x)).fill(1).map((t, i) => {
    var a = BigInt(readline());

    // var a = read
    while (gcd(a,SUMnUMBER(a))<=1) a++
    console.log(a.toString())
    var values
  })
  // var b = a.sort((a, b) => Math.abs(a) - Math.abs(b))

}

function SUMnUMBER(x) {
  var sum = 0n
  while (x>0n){
    sum+=x% 10n
    x = x/10n
  }
  return sum
}
function gcd(a, b) {
  if (!b) {
    return a;
  }

  return gcd(b, a % b);
}

'use strict';

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

let inputString = '';
let currentLine = 0;

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

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

  main()
});

function readline() {
  return inputString[currentLine++]
}
// Make a Snippet for the code above this and then write your logic in main();

function main() {
  let testCases = readline()
  while(testCases--)
    solve()
  // let testCases = readline()
  // let testNum = 1,
  //   ans = null
  // while(testCases--) {
  //   ans = solve()
  //   console.log('Case #' + (testNum++) + ': ' + ans)
  // }
}

// function to solve problems
function solve (){
  let n = readline().split(' ').map(x => +x)
  let sum = 0,
  gcdSum = 0,
  count = 2,
  tempGcdSum = 0,
  ans = 0

  // find smallest of n, n+1 and n+2
  sum = sumOfDigits(n)
  gcdSum = findGcdSum(n, sum)
  ans = +n
  while (count-- && gcdSum == 1) {
    n++
    if (n % 10 == 0) {
      sum = sumOfDigits(n)
    } else {
      sum ++
    }
    tempGcdSum = findGcdSum(n, sum)
    // console.log('tempGcdSum:', tempGcdSum)
    if (tempGcdSum != 1) {
      gcdSum = tempGcdSum
      ans = n
      break
    }
  }
  console.log(ans)
}

function sumOfDigits (n) {
  let ans = 0
  while (n > 0) {
    ans += n % 10
    n = parseInt(n/10)
  }
  return ans
}

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


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

function solve(n, m, arr) {
    return binarySearch(1, 1e9, x => check(n, m, arr, x))
}
function binarySearch(l, r, fn) {
    while (l <= r) {
        const m = Math.floor((l + r) / 2)
        if (fn(m)) {
            l = m + 1
        } else {
            r = m - 1
        }
    }
    return r
}
function check(n, m, arr, min) {
    const map = {}
    let has2 = 0
    for (let i = 0; i < n; i++) {
        let has = 0
        for (let j = 0; j < m; j++) {
            if (arr[j][i] >= min) {
                map[j] = (map[j] || 0) + 1
                has = 1
                if (map[j] > 1) has2 = 1
            }
        }
        if (!has) return false
    }
    return has2
}

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

let inputString = '';

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

process.stdin.on("end", (_) => {
    const lines = inputString.trim().split("\n").map(string => string.trim()).filter(Boolean);

    main(lines);
});

function main(lines) {
  let index = 0;
  let T = Number(lines[index++]);
  let shops, friends;
  let arr;

  while (T--) {
    [shops, friends] = lines[index++].split(' ').map(Number);
    arr = new Array(shops);

    for (let i = 0; i < shops; ++i) {
      arr[i] = lines[index++].split(' ').map(Number);
    }

    solve(shops, friends, arr);
  }
}

function solve(shops, friends, arr) {
  let [basicFriendMaxKey, basicFriendMinKey] = [0, 1];
  let [basicFriendMaxValue, basicFriendMinValue] = [
    Math.max(arr[0][0], arr[0][1]),
    Math.min(arr[0][0], arr[0][1]),
  ];
  let curMaxKey, prevMaxKey;
  let curMaxValue, prevMaxValue;

  let friendsMap = new Array(friends).fill(0);

  for (let i = 0; i < shops; ++i) {
    [curMaxKey, prevMaxKey] = [0, 1];
    [curMaxValue, prevMaxValue] = [0, 0];

    for (let j = 0; j < friends; ++j) {
      if (arr[i][j] >= curMaxValue) {
        prevMaxValue = curMaxValue;
        prevMaxKey = curMaxKey;

        curMaxValue = arr[i][j];
        curMaxKey = j;
      } else if (arr[i][j] >= prevMaxValue) {
        prevMaxValue = arr[i][j];
        prevMaxKey = j;
      }
    }

    if (prevMaxValue > basicFriendMinValue) {
      basicFriendMinValue = prevMaxValue;
      basicFriendMinKey = prevMaxKey;

      basicFriendMaxValue = curMaxValue;
      basicFriendMaxKey = curMaxKey;
    }
  }

  friendsMap[basicFriendMinKey] = basicFriendMinValue;
  friendsMap[basicFriendMaxKey] = basicFriendMaxValue;

  for (let i = 0; i < shops; ++i) {
    for (let j = 0; j < friends; ++j) {
      if (j === basicFriendMinKey || j === basicFriendMaxKey) {
        continue;
      }

      friendsMap[j] = Math.max(friendsMap[j], arr[i][j]);
    }
  }

  console.log(Math.min(...friendsMap));
}

'use strict';
const readline = require('readline');
const util = require('util');
const rl = readline.createInterface({
    input: process.stdin,
});
let pos = 0;
const words = [];
rl.on('line', (line) => {
    words.push.apply(words, line.split(' ').filter(s => s != ''));
});
rl.on('close', main);
function check(b) {
    if (!b) {
        process.stderr.write(`${new Error().stack}\n`);
        process.exit(-1);
    }
}
function printf(...args) {
    process.stdout.write(util.format(...args));
}
function nextInt() {
    return Math.trunc(Number(words[pos++]));
}
function nextStr() {
    return words[pos++];
}
function af(l) {
    return Array.from({ length: l });
}
const INIT = -1;
let m;
let n;
let p;
function can(mid) {
    const friends = af(n).fill(0);
    const shops = af(m).fill(0);
    for (let i = 0; i < m; i++) {
        for (let j = 0; j < n; j++) {
            if (p[i][j] >= mid) {
                friends[j]++;
                shops[i]++;
            }
        }
    }
    for (let i = 0; i < n; i++) {
        if (friends[i] == 0) {
            return false;
        }
    }
    for (let i = 0; i < m; i++) {
        if (shops[i] > 1) {
            return true;
        }
    }
    return false;
}
function main() {
    let tc = nextInt();
    while (tc-- > 0) {
        m = nextInt();
        n = nextInt();
        p = Array.from({ length: m });
        let mx = 0;
        for (let i = 0; i < m; i++) {
            p[i] = af(n);
            for (let j = 0; j < n; j++) {
                p[i][j] = nextInt();
                mx = Math.max(mx, p[i][j]);
            }
        }
        let lo = 0;
        let hi = mx + 1;
        let ans = 0;
        while (lo < hi) {
            let mid = lo + Math.trunc((hi - lo) / 2);
            if (!can(mid)) {
                hi = mid;
            }
            else {
                lo = mid + 1;
                ans = mid;
            }
        }
        printf("%d\n", ans);
    }
}

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

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

function main () {
	let T = rn();
	while (T--) {
		rl();
		const [m, n] = rna();
		const p = [];
		for (let i = 0; i < m; i++)
			p[i] = rna();

		const mxjoy = Array(n).fill(0);
		let mxsmx = 0;
		for (let i = 0; i < m; i++) {
			let fmx = 0, smx = 0;
			for (let j = 0; j < n; j++) {
				mxjoy[j] = Math.max(mxjoy[j], p[i][j]);
				if (p[i][j] > fmx) {
					[fmx, smx] = [p[i][j], fmx]
				} else if (p[i][j] > smx)
					smx = p[i][j];
			}
			mxsmx = Math.max(mxsmx, smx);
			//console.log({mxsmx})
		}

		const ans = Math.min(mxsmx, ...mxjoy);

		console.log(ans);
	}
}

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

let inputString = '';

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

process.stdin.on("end", (_) => {
    const lines = inputString.trim().split("\n").map(string => string.trim()).filter(Boolean);

    console.log(lines);
});

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

    console.log(inputString);
});


'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++];
}
/**
7
4
11 14 16 12
2
1 8
4
1 1 1 1
4
1 2 5 6
2
12 13
6
1 6 3 10 5 8
6
1 12 3 10 5 8

**/

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

    return gcd(b, a % b);
};

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

    for(let r=0;r<range;r++) {
        let n = parseInt(readline());
        let a = readline().split(" ").map(Number);

        let even = [];
        let odd = [];

        for(let i=0;i<n;i++) {
            if(a[i] % 2 === 0) {
                even.push(a[i]);
            } else {
                odd.push(a[i]);
            }
        }

        if(even.length % 2 === 0 && odd.length % 2 === 0) {
            console.log('YES');
        } else {
            let find = false;
            for(let i=0;i<odd.length;i++) {
                for(let j=0;j<even.length;j++) {
                    if(Math.abs(odd[i] - even[j]) === 1) {
                        find = true;
                    }
                }
            }

            if(find) {
                console.log('YES');
            } else {
                console.log('NO');
            }
        }
    }
}

var t = parseInt(readline());
for (var tc = 0; tc < t; tc++) {
  var n = parseInt(readline());
  var arr = readline()
    .split(" ")
    .map((val) => parseInt(val));

  var flag = false;
  arr = arr.sort((a, b) => a - b);
  for (var i = 1; i < arr.length; i++) {
    if (Math.abs(arr[i] - arr[i - 1] == 1) == 1) {
      arr = arr.slice(0, i - 1).concat(arr.slice(i + 1));
      i -= 2;
      flag = true;
    }
  }
  if (arr.length == 0) print("Yes");
  else {
    var odd = arr.filter((val) => val % 2 != 0);
    var even = arr.filter((val) => val % 2 == 0);

    if (odd.length % 2 == 0 && even.length % 2 == 0) print("Yes");
    else if (flag) {
      print("Yes");
    } else print("NO");
  }
}

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

function main() {
  var testCasesNum = +readline();
  for (var i = 0; i < testCasesNum; i++) {
    var n = +readline();
    var arr = readNumArray().sort((a, b) => a - b);
    var evens = 0;
    var odds = 0;
    var curr = arr[0];
    var has1diff = false;
    for (var j = 0; j < n; j++) {
      if (arr[j] - curr === 1) {
        has1diff = true;
      }
      curr = arr[j];
      if (arr[j] % 2) {
        odds++;
      } else {
        evens++;
      }
    }
    if (has1diff || odds % 2 === 0) {
      print("YES");
    } else {
      print("NO");
    }
  }

}

main();

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);
  myerr("-----start-----");
  var start = new Date();
  Main();
  var end = new Date() - start;
  myerr("----- end -----");
  myerr("time : " + (end) + "ms");
  myerr("memory : " + Math.round(process.memoryUsage().heapTotal / 1024) + "KB");
});
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){
  var returnObj = {
    list : input, index : 0, max : input.length,
    hasNext : function(){return (this.index < this.max);},
    next : function(){if(!this.hasNext()){throw "ArrayIndexOutOfBoundsException これ以上ないよ";}else{var returnInput = this.list[this.index];this.index++;return returnInput;}}
  };
  return returnObj;
}
function myout(s){console.log(s);}
function myerr(s){console.error("debug:" + require("util").inspect(s,false,null));}
//[no]要素の扱い。数値型
//不明値、異常時:引数そのまま返す 1:数値へ変換
//2:半角SPで分割 4:半角SPで分割し、数値配列へ
//6:1文字で分割  7:1文字で分割し、数値配列へ
//8:半角SPで結合 9:改行で結合 0:文字なしで結合
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;}}
function Main(){
	var t = nextInt();
	var output = new Array(t);
	for(var k = 0; k < t; k++){
		var N = nextInt();
		var list = nextIntArray();
		var odd = [];
		var even = [];
		for(var i = 0; i < N; i++){
			if(list[i] % 2 == 1){
				odd.push(list[i]);
			}else{
				even.push(list[i]);
			}
		}
		if(odd.length % 2 == 0 && even.length % 2 == 0){
			output[k] = "YES";
		}else{
			var isOK = false;
			for(var i = 0; i < odd.length; i++){
				for(var j = 0; j < even.length; j++){
					if(Math.abs(odd[i] - even[j]) == 1){
						isOK = true;
					}
				}
			}
			if(isOK){
				output[k] = "YES";
			}else{
				output[k] = "NO";
			}
		}

	}
	myout(myconv(output,9));
}

const processData = (lines) => {
  const n = +lines[0]
  for (let i=0; i<n; i++) {
    const arr = lines[i*2+2].split(' ').map(x => +x)
    const p = [0, 0]
    for (const t of arr) {
      p[t%2]++
    }
    if (p[0]%2 !==0) {
      arr.sort((a, b) => a-b)
      let prev = arr[0]
      for (let i=1;i<arr.length; i++) {
        if (Math.abs(prev - arr[i]) === 1) {
          p[0]--
          p[1]--
          break
        }
        prev = arr[i]
      }
    }
    console.log(p[0]%2 === 0 ? 'YES' : 'NO')
  }
}

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

'use strict';

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

let inputString = '';
let currentLine = 0;

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

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

    main();
});

function readline() {
    return inputString[currentLine++];
}
// Make a Snippet for the code above this and then write your logic in main();

function main() {

    let cases = parseInt(readline(), 10);
    for (var X = 0; X < cases; X++) {
      readline();
      let force = readline().split(" ").map(e => parseInt(e));
      const {pow, max, min} = Math;

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

      const odds = force.filter(f => f % 2 === 0);
      const even = force.filter(f => f % 2 === 1);

      if (odds.length % 2 === 0 && even.length % 2 === 0) {
        console.log('YES');
      } else {
        let follow = false;
        for (let i = 0; i < force.length - 1; i++) {
          const c1 = force[i];
          const c2 = force[i+1];
          if (Math.abs(c1 - c2) === 1) {
            follow = true;
            break;
          }
        }
        if (follow) {
          console.log('YES');
        } else {
          console.log('NO');
        }
      }

      //break;
      //console.log(Math.pow(Math.max(a,b) + Math.max(a,b) , 2))
    }

}

var t = parseInt(readline());
for (var tc = 0; tc < t; tc++) {
  var n = parseInt(readline());
  var arr = readline()
    .split(" ")
    .map((val) => parseInt(val));

  var differs = [];
  var reminders = [];
  reminders.push(arr[0] % 2);
  for (var i = 1; i < arr.length; i++) {
    differs.push(Math.abs(arr[i] - arr[i - 1]));
    reminders.push(arr[i] % 2);
  }
  if (differs.includes(1)) print("Yes");
  else {
    var found = false;
    for (var i = 1; i < reminders.length; i++) {
      if (reminders[i] == reminders[i - 1]) {
        print("Yes");
        found = true;
        break;
      }
    }
    if (!found) print("No");
  }

  differs = differs.sort((a, b) => a - b);
  print(differs[0]);
}

var t = parseInt(readline());
for (var tc = 0; tc < t; tc++) {
  var n = parseInt(readline());
  var arr = readline()
    .split(" ")
    .map((val) => parseInt(val));

  var differs = [];
  var reminders = [];
  reminders.push(arr[0] % 2);
  for (var i = 1; i < arr.length; i++) {
    differs.push(Math.abs(arr[i] - arr[i - 1]));
    reminders.push(arr[i] % 2);
  }
  if (differs.includes(1)) print("Yes");
  else {
    var found = false;
    for (var i = 1; i < reminders.length; i++) {
      if (reminders[i] == reminders[i - 1]) {
        print("Yes");
        found = true;
        break;
      }
    }
    if (!found) print("No");
  }
}

var t = parseInt(readline());
for (var tc = 0; tc < t; tc++) {
  var n = parseInt(readline());
  var arr = readline()
    .split(" ")
    .map((val) => parseInt(val));

  var differs = [];
  var reminders = [];
  reminders.push(arr[0] % 2);
  for (var i = 1; i < arr.length; i++) {
    differs.push(Math.abs(arr[i] - arr[i - 1]));
    reminders.push(arr[i] % 2);
  }
  reminders = reminders.sort((a, b) => a - b);
  if (differs.includes(1)) print("Yes");
  else {
    var found = false;
    for (var i = 1; i < reminders.length; i++) {
      if (reminders[i] == reminders[i - 1]) {
        print("Yes");
        found = true;
        break;
      }
    }
    if (!found) print("No");
  }
}

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);
  myerr("-----start-----");
  var start = new Date();
  Main();
  var end = new Date() - start;
  myerr("----- end -----");
  myerr("time : " + (end) + "ms");
  myerr("memory : " + Math.round(process.memoryUsage().heapTotal / 1024) + "KB");
});
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){
  var returnObj = {
    list : input, index : 0, max : input.length,
    hasNext : function(){return (this.index < this.max);},
    next : function(){if(!this.hasNext()){throw "ArrayIndexOutOfBoundsException これ以上ないよ";}else{var returnInput = this.list[this.index];this.index++;return returnInput;}}
  };
  return returnObj;
}
function myout(s){console.log(s);}
function myerr(s){console.error("debug:" + require("util").inspect(s,false,null));}
//[no]要素の扱い。数値型
//不明値、異常時:引数そのまま返す 1:数値へ変換
//2:半角SPで分割 4:半角SPで分割し、数値配列へ
//6:1文字で分割  7:1文字で分割し、数値配列へ
//8:半角SPで結合 9:改行で結合 0:文字なしで結合
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;}}
function Main(){
	var t = nextInt();
	var output = new Array(t);
	for(var k = 0; k < t; k++){
		var N = nextInt();
		var list = nextIntArray();
		for(var i = 0; i < list.length; i++){
			if(list[i] == -1){
				continue;
			}
			var ato = list[i] + 1;
			var mae = list[i] - 1;
			if(list.indexOf(ato) != -1){
				list[i] = -1;
				list[list.indexOf(ato)] = -1;
			}else if(list.indexOf(mae) != -1){
				list[i] = -1;
				list[list.indexOf(mae)] = -1;
			}
		}
		for(var i = 0; i < list.length; i++){
			if(list[i] == -1){
				continue;
			}
			for(var j = 0; j < list.length; j++){
				if(list[j] == -1){
					continue;
				}
				if(i != j && (list[i] % 2 == list[j] % 2)){
					list[i] = -1;
					list[j] = -1;
				}
			}
		}
		var isOK = true;
		for(var i = 0; i < N; i++){
			if(list[i] != -1){
				isOK = false;
				break;
			}
		}
		if(isOK){
			output[k] = "YES";
		}else{
			output[k] = "NO";
		}
	}
	myout(myconv(output,9));
}

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);
  myerr("-----start-----");
  var start = new Date();
  Main();
  var end = new Date() - start;
  myerr("----- end -----");
  myerr("time : " + (end) + "ms");
  myerr("memory : " + Math.round(process.memoryUsage().heapTotal / 1024) + "KB");
});
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){
  var returnObj = {
    list : input, index : 0, max : input.length,
    hasNext : function(){return (this.index < this.max);},
    next : function(){if(!this.hasNext()){throw "ArrayIndexOutOfBoundsException これ以上ないよ";}else{var returnInput = this.list[this.index];this.index++;return returnInput;}}
  };
  return returnObj;
}
function myout(s){console.log(s);}
function myerr(s){console.error("debug:" + require("util").inspect(s,false,null));}
//[no]要素の扱い。数値型
//不明値、異常時:引数そのまま返す 1:数値へ変換
//2:半角SPで分割 4:半角SPで分割し、数値配列へ
//6:1文字で分割  7:1文字で分割し、数値配列へ
//8:半角SPで結合 9:改行で結合 0:文字なしで結合
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;}}
function Main(){
	var t = nextInt();
	var output = new Array(t);
	for(var k = 0; k < t; k++){
		var N = nextInt();
		var list = nextIntArray();
		if(N % 4 == 2){
			for(var i = 0; i < list.length; i++){
				if(list[i] == -1){
					continue;
				}
				var ato = list[i] + 1;
				var mae = list[i] - 1;
				if(list.indexOf(ato) != -1){
					list[i] = -1;
					list[list.indexOf(ato)] = -1;
					break;
				}else if(list.indexOf(mae) != -1){
					list[i] = -1;
					list[list.indexOf(mae)] = -1;
					break;
				}
			}
			for(var i = 0; i < list.length; i++){
				if(list[i] == -1){
					continue;
				}
				for(var j = 0; j < list.length; j++){
					if(list[j] == -1){
						continue;
					}
					if(i != j && (list[i] % 2 == list[j] % 2)){
						list[i] = -1;
						list[j] = -1;
					}
				}
			}
		}else{
			for(var i = 0; i < list.length; i++){
				if(list[i] == -1){
					continue;
				}
				for(var j = 0; j < list.length; j++){
					if(list[j] == -1){
						continue;
					}
					if(i != j && (list[i] % 2 == list[j] % 2)){
						list[i] = -1;
						list[j] = -1;
					}
				}
			}
			for(var i = 0; i < list.length; i++){
				if(list[i] == -1){
					continue;
				}
				var ato = list[i] + 1;
				var mae = list[i] - 1;
				if(list.indexOf(ato) != -1){
					list[i] = -1;
					list[list.indexOf(ato)] = -1;
				}else if(list.indexOf(mae) != -1){
					list[i] = -1;
					list[list.indexOf(mae)] = -1;
				}
			}
		}
		var isOK = true;
		for(var i = 0; i < N; i++){
			if(list[i] != -1){
				isOK = false;
				break;
			}
		}
		if(isOK){
			output[k] = "YES";
		}else{
			output[k] = "NO";
		}
	}
	myout(myconv(output,9));
}

'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++];
}
/**
7
4
11 14 16 12
2
1 8
4
1 1 1 1
4
1 2 5 6
2
12 13
6
1 6 3 10 5 8
6
1 12 3 10 5 8

**/

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

    return gcd(b, a % b);
};

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

    for(let r=0;r<range;r++) {
        let n = parseInt(readline());
        let a = readline().split(" ").map(Number);

        a.sort((x, y) => x - y);

        for(let i=0;i<a.length;i++) {
            if(!a[i]) {
                continue;
            }
            for(let j=1;j<a.length;j++) {
                if(i === j) {
                    continue;
                }
                if(!a[j]) {
                    continue;
                }

                if(Math.abs(a[i] - a[j]) === 1) {
                    a[i] = undefined;
                    a[j] = undefined;
                    continue;
                }

                if(a[i] % 2 === a[j] % 2) {
                    a[i] = undefined;
                    a[j] = undefined;
                    continue;
                }
            }
        }

        let nums = a.filter((x) => x !== undefined);
        if(!nums.length) {
            console.log('YES');
        } else {
            console.log('NO');
        }
    }
}


'use strict';

function createReadLine() {
  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++];
  }

  return readline;
}

const readline = createReadLine();

function readInts(){
  return readline().split(' ').map((value => Number.parseInt(value)));
}

function readFloats(){
  return readline().split(' ').map((value => Number.parseFloat(value)));
}

function readStr() {
  return readline();
}

function readInt(){
  return Number.parseInt(readline());
}

function readFloat(){
  return Number.parseFloat(readline());
}

function main() {
  const n = readInt();
  const strs = []
  for (let i = 0; i < n; i ++){
    strs.push(readStr())
  }
  const result = solve(strs);
  console.log(result);
}

function makeStep(str, steps) {
  return str.slice(steps) + str.slice(0, steps);
}

function solve(strs){
  let set =  strs.map(() => new Map());
  const firstLine = new Array(strs[0].length);
  firstLine[0] = strs[0]
  for (let j = 1; j < firstLine.length; j++){
    firstLine[j] = makeStep(strs[0], j)
  }
  set[0] = new Map([...new Set(firstLine)].map(((value, index) => [value, index])));
  for (let i = 1; i < set.length; i ++){
    for (let j = 0; j < strs[0].length; j ++){
      const current = makeStep(strs[i], j)
      let value = set[i  -1].get(current);
      if(value === undefined) {
        value = -1;
      } else {
        const prev = makeStep(strs[i], j -1);
        const currentValue = set[i].get(current);
        if(currentValue) {
          continue;
        }
        if(prev !== current){
          value += j;
        }
      }
      set[i].set(current, value);
    }
  }
  return Math.min(...set[strs.length - 1].values())
}

module.exports.solve = solve;

'use strict';

function createReadLine() {
  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++];
  }

  return readline;
}

const readline = createReadLine();

function readInts(){
  return readline().split(' ').map((value => Number.parseInt(value)));
}

function readFloats(){
  return readline().split(' ').map((value => Number.parseFloat(value)));
}

function readStr() {
  return readline();
}

function readInt(){
  return Number.parseInt(readline());
}

function readFloat(){
  return Number.parseFloat(readline());
}

function main() {
  const n = readInt();
  const strs = []
  for (let i = 0; i < n; i ++){
    strs.push(readStr())
  }
  const result = solve(strs);
  console.log(result);
}

function makeStep(str, steps) {
  return str.slice(steps) + str.slice(0, steps);
}

function solve(strs){
  let set =  strs.map(() => new Map());
  const firstLine = new Array(strs[0].length);
  firstLine[0] = strs[0]
  for (let j = 1; j < firstLine.length; j++){
    firstLine[j] = makeStep(strs[0], j)
  }
  set[0] = new Map([...new Set(firstLine)].map(((value, index) => [value, index])));
  for (let i = 1; i < set.length; i ++){
    for (let j = 0; j < strs[0].length; j ++){
      const current = makeStep(strs[i], j)
      let value = set[i  -1].get(current);
      if(value === undefined) {
        return -1;
      } else {
        const prev = makeStep(strs[i], j -1);
        const currentValue = set[i].get(current);
        if(currentValue) {
          continue;
        }
        if(prev !== current){
          value += j;
        }
      }
      set[i].set(current, value);
    }
  }
  return Math.min(...set[strs.length - 1].values())
}

module.exports.solve = solve;

var N = readline() | 0;
var lines = [];
for(var i = 0; i < N; ++i) {
    lines.push(readline());
}

var results = lines.map(function (line) {
    return lines.map(function (x) {
        return (x+x).indexOf(line);
    });
});

if (results[0].indexOf(-1) >= 0) {
    print(-1);
} else {
    print(results
        .map(function (x) { return x.reduce(function (a, x) { return a + x }, 0); })
        .reduce(function (a, x) { return Math.min(a,x); }, 10000000));
}

var l = [], res = 9999;
for (var i = Number(readline()); i > 0; i--) {
    var s = readline(), d = {};
    for (var j = s.length - 1; j >= 0; j--) d[s.substr(j) + s.substr(0, j)] = j;
    l.push(d)
}
for (s in d) {
    var x = 0;
    for (var t of l) x += t.hasOwnProperty(s) ? t[s] : 9999;
    if (x >= 9999) res = -1;
    else if (res > x) res = x;
}
print(res);

 var n = parseInt(readline());
  var s = [];
  String.prototype.rotate = function(x) {
    var a = x % this.length;
    var b;
    if(a > 0){
      b = this.length - a;
    } else {
      b = -a;
    }
    var c = this.substr(b, this.length);
    var d = this.substr(0, b);
    return c + d;
  };
  for(var i = 0; i < n; i += 1) {
    s[i] = readline();
  }
  var r = [];
  var t = [];
  var flag = true;
  var len = s[0].length;
  for(var i = 0; flag && i < n; i += 1) {
    var ok0 = false;
    var ok1 = false;
    for(var j = 0; j <= len; j += 1) {
      if(s[i].rotate(-j) == s[i] && j !== 0) {
        if(ok1 === false) {
          t[i] = j;
          ok1 = true;
        }
      }
      if(s[i].rotate(-j) == s[0]) {
        if(ok0 === false) {
          r[i] = j;
          ok0 = true;
        }
      }
    }
    if(ok0 == false) {
      flag = false;
    }
  }
  if(flag === false) {
    print(-1);
  } else {
    var res = Infinity;
    for(var i = 0; i < len; i += 1) {
      var tmp = 0;
      for(var j = 0; j < n; j += 1) {
        tmp += (r[j] + i) % t[j];
      }
      res = Math.min(res, tmp);
    }
    print(res);
  }

//@ts-check

/**
 * @param {string} str
 * @param {number} steps
 */
function makeSteps(str, steps) {
  return str.slice(steps) + str.slice(0, steps);
}

/**
 * @param {string[]} arr
 */
function solve(arr) {
  const len = arr[0].length;
  const $ = arr.map(() => new Map());
  for (let j = 0; j < len; j++) {
    const target = makeSteps(arr[0], j);
    if (!$[0].has(target)) {
      $[0].set(makeSteps(arr[0], j), j);
    }
  }
  for (let i = 1; i < $.length; i++) {
    for (let j = 0; j < len; j++) {
      const target = makeSteps(arr[i], j);
      const currentSteps = $[i].has(target)
        ? $[i].get(target)
        : Number.POSITIVE_INFINITY;
      if ($[i - 1].has(target) || $[i - 1].get(target) === -1) {
        const prevLineSteps = $[i - 1].get(target);
        $[i].set(target, Math.min(currentSteps, prevLineSteps + j));
      } else {
        $[i].set(target, -1);
      }
    }
  }
  return Math.min(...$.pop().values());
}

function* main() {
  const n = parseInt(yield);
  const s = [];
  for (let index = 0; index < n; index++) {
    s.push(yield);
  }
  const r = solve(s);
  console.log(r);
  process.exit(0);
}

if (!module.parent) {
  (() => {
    const q = main();
    q.next();
    require("readline")
      .createInterface({
        input: process.stdin,
        output: null,
      })
      .on("line", (line) => q.next(line));
  })();
}

exports.solve = solve;

'use strict';

function createReadLine() {
  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++];
  }

  return readline;
}

const readline = createReadLine();

function readInts(){
  return readline().split(' ').map((value => Number.parseInt(value)));
}

function readFloats(){
  return readline().split(' ').map((value => Number.parseFloat(value)));
}

function readStr() {
  return readline();
}

function readInt(){
  return Number.parseInt(readline());
}

function readFloat(){
  return Number.parseFloat(readline());
}

function main() {
  const n = readInt();
  const strs = []
  for (let i = 0; i < n; i ++){
    strs.push(readStr())
  }
  const result = solve(strs);
  console.log(result);
}

function makeStep(str, steps) {
  return str.slice(steps) + str.slice(0, steps);
}

function solve(strs){
  let set =  strs.map(() => new Map());
  const firstLine = new Array(strs[0].length);
  firstLine[0] = strs[0]
  for (let j = 1; j < firstLine.length; j++){
    firstLine[j] = makeStep(strs[0], j)
  }
  set[0] = new Map([...new Set(firstLine)].map(((value, index) => [value, index])));
  const resultArr =  new Array(strs.length).fill(0).map(() => new Array(strs[0].length).fill(0));
  const values = [...set[0].values()];
  resultArr[0] = [...strs[0]].map((val, index) => {
    if(values[index] !== undefined){
      return index;
    }
    return 0
  })
  for (let i = 1; i < set.length; i ++){
    for (let j = 0; j < strs[0].length; j ++){
      const current = makeStep(strs[i], j)
      let value = set[i  -1].get(current);
      if(value === undefined) {
        value = -1;
      } else {
        const prev = makeStep(strs[i], j -1);
        const currentValue = set[i].get(current);
        if(currentValue) {
          resultArr[i][j] = currentValue;
          continue;
        }
        if(prev !== current){
          value += j;
        }
      }
      set[i].set(current, value);
      resultArr[i][j] = value;
    }
  }
  return Math.min(...resultArr[strs.length - 1])
}

module.exports.solve = solve;

//@ts-check

/**
 * @param {string} str
 * @param {number} steps
 */
function makeSteps(str, steps) {
  return str.slice(steps) + str.slice(0, steps);
}

/**
 * @param {string[]} arr
 */
function solve(arr) {
  const len = arr[0].length;
  const $ = arr.map(() => new Map());
  for (let j = 0; j < len; j++) {
    $[0].set(makeSteps(arr[0], j), j);
  }
  for (let i = 1; i < $.length; i++) {
    for (let j = 0; j < len; j++) {
      const target = makeSteps(arr[i], j);
      if ($[i - 1].has(target) || $[i - 1].get(target) === -1) {
        const prevLineSteps = $[i - 1].get(target);
        $[i].set(target, prevLineSteps + j);
      } else {
        $[i].set(target, -1);
      }
    }
  }
  return Math.min(...$.pop().values());
}

function* main() {
  const n = parseInt(yield);
  const s = [];
  for (let index = 0; index < n; index++) {
    s.push(yield);
  }
  const r = solve(s);
  console.log(r);
  process.exit(0);
}

if (!module.parent) {
  (() => {
    const q = main();
    q.next();
    require("readline")
      .createInterface({
        input: process.stdin,
        output: null,
      })
      .on("line", (line) => q.next(line));
  })();
}

exports.solve = solve;

'use strict';

function createReadLine() {
  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++];
  }

  return readline;
}

const readline = createReadLine();

function readInts(){
  return readline().split(' ').map((value => Number.parseInt(value)));
}

function readFloats(){
  return readline().split(' ').map((value => Number.parseFloat(value)));
}

function readStr() {
  return readline();
}

function readInt(){
  return Number.parseInt(readline());
}

function readFloat(){
  return Number.parseFloat(readline());
}

function main() {
  const n = readInt();
  const strs = []
  for (let i = 0; i < n; i ++){
    strs.push(readStr())
  }
  const result = solve(strs);
  console.log(result);
}

function makeStep(str, steps) {
  return str.slice(steps) + str.slice(0, steps);
}

function solve(strs){
  let set =  strs.map(() => new Map());
  const firstLine = new Array(strs[0].length);
  firstLine[0] = strs[0]
  for (let j = 1; j < firstLine.length; j++){
    firstLine[j] = makeStep(strs[0], j)
  }
  set[0] = new Map([...new Set(firstLine)].map(((value, index) => [value, index])));
  const resultArr =  new Array(strs.length).fill(0).map(() => new Array(strs[0].length).fill(0));
  const values = [...set[0].values()];
  resultArr[0] = [...strs[0]].map((_, index) => {
    if(values[index] !== undefined){
      return index;
    }
    return Math.max(...values)
  })
  for (let i = 1; i < set.length; i ++){
    for (let j = 0; j < strs[0].length; j ++){
     const current = makeStep(strs[i], j)
     let value = set[i  -1].get(current);
     if(value === undefined) {
       value = -1;
     } else {
       const prev = makeStep(strs[i], j -1);
       if(prev !== current){
         value += j;
       }
     }
     set[i].set(current, value);
     resultArr[i][j] = value;
    }
  }
  return Math.min(...resultArr[strs.length - 1])
}

module.exports.solve = solve;

  var n = parseInt(readline());
  var s = [];
  String.prototype.rotate = function(x) {
    var a = x % this.length;
    var b;
    if(a > 0){
      b = this.length - a;
    } else {
      b = -a;
    }
    var c = this.substr(b, this.length);
    var d = this.substr(0, b);
    return c + d;
  };
  for(var i = 0; i < n; i += 1) {
    s[i] = readline();
  }
  var r = [];
  r[0] = 0;
  var flag = true;
  var len = s[0].length;
  for(var i = 1; flag && i < n; i += 1) {
    var ok = false;
    for(var j = 0; j < len; j += 1) {
      if(s[i].rotate(-j) == s[0]) {
        r[i] = j;
        ok = true;
      }
    }
    if(ok == false) {
      flag = false;
    }
  }
  if(flag === false) {
    print(-1);
  } else {
    var res = Infinity;
    for(var i = 0; i < len; i += 1) {
      var tmp = 0;
      for(var j = 0; j < n; j += 1) {
        tmp += (r[j] + i) % len;
      }
      res = Math.min(res, tmp);
    }
    print(res);
  }

  var n = parseInt(readline());
  var s = [];
  String.prototype.rotate = function(x) {
    var a = x % this.length;
    var b;
    if(a > 0){
      b = this.length - a;
    } else {
      b = -a;
    }
    var c = this.substr(b, this.length);
    var d = this.substr(0, b);
    return c + d;
  };
  for(var i = 0; i < n; i += 1) {
    s[i] = readline();
  }
  var r = [];
  r[0] = 0;
  var flag = true;
  var len = s[0].length;
  for(var i = 1; flag && i < n; i += 1) {
    var ok = false;
    for(var j = 0; j < len; j += 1) {
      if(s[i].rotate(-j) == s[0]) {
        r[i] = j;
        ok = true;
        break;
      }
    }
    if(ok == false) {
      flag = false;
    }
  }
  if(flag === false) {
    print(-1);
  } else {
    var res = Infinity;
    for(var i = 0; i < len; i += 1) {
      var tmp = 0;
      for(var j = 0; j < n; j += 1) {
        tmp += (r[j] + i) % len;
      }
      res = Math.min(res, tmp);
    }
    print(res);
  }


"use strict";

var foo = function(s1, s2) {
    var f = [];
    for (var i = 0, j = 0; j < s2.length; ++j) {
        if (i < s1.length && s1[i] === s2[j]) {
            ++i;
        } else {
            f.push(s2[j]);
        }
    }

    return [i === s1.length, f];
};

var main = function() {
    var q = +rd();
    loop:while (q-->0) {
        var s = rd().split('');
        var t = rd().split('');
        var p = rd().split('');

        var f1 = foo(s, t);
        if (f1[0]) {
            var f2 = foo(f1[1].sort(), p.sort());
            if (f2[0]) {
                pr('YES');
                continue loop;
            }
        }

        pr('NO');
    }
};

var rd = readline;
var wr = write;
var pr = print;
var rdAr = () => rd().split(' ').map(v => +v);
var prAr = (a) => pr(a.join(' '));
var cmpLt = (a, b) => a - b;
var cmpGt = (a, b) => b - a;

main();

const readline = require('readline');

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

var q, s, t, p;

rl.on("line", (line) => {
	if (q == null) q = parseInt(line);
	else if (s == null) s = line;
	else if (t == null) t = line;
	else if (p == null) {
		p = line;
		// begin to solve
		var mp = {};
		var len1 = s.length;
		var len2 = t.length;
		var len3 = p.length;
		for (var i = 0; i < len3; i ++) {
			if (! mp[ p[i] ]) mp[ p[i] ] = 1;
			else mp[ p[i] ] ++;
		}
		var flag = true;
		var j = 0;
		for (var i = 0; i < len2; i ++) {
			if (j < len1 && s[j] == t[i]) j ++;
			else if (mp[ t[i] ]) mp[ t[i] ] --;
			else {
				flag = false;
				break;
			}
		}
		if (j < len1) flag = false;
		console.log( flag ? "YES" : "NO" );
		// end of solve
		s = t = p = null;
		q --;
		if (q == 0)
			rl.close();
	}
});

const y = "YES";
const n = "NO";
function solve(){
    var s = readline();
    var t = readline();
    var p = readline();
    if(s.length > t.length){
        print(n);
        return;
    }
    var jt = 0;
    var was = new Array(t.length);
    was.fill(0, 0, t.length);
    var buff = new Array(p.length);
    buff.fill(0, 0, p.length);
    for(var i = 0;i < t.length;i++){
        if(s[jt] == t[i]){
            was[i] = 1;
            jt++;
            if(jt == s.length){
                break;
            }
        }
    }
    if(jt != s.length){
        print(n);
        return;
    }
    for(var i = 0;i < t.length;i++){
        if(!was[i]){
            var can = 0;
            for(var j = 0;j < p.length;j++){
                if(!buff[j] && p[j] == t[i]){
                    buff[j] = 1;
                    can = 1;
                    break;
                }
            }
            if(!can){
                print(n);
                return;
            }
        }
    }
    print(y);
    return;
}

var t = Number(readline());
while(t--){
    solve();
}

"use strict";

var foo = function(s1, s2) {
    var f = [];
    for (var i = 0, j = 0; j < s2.length; ++j) {
        if (i < s1.length && s1[i] === s2[j]) {
            ++i;
        } else {
            f.push(s2[j]);
        }
    }

    return [i === s1.length, f];
};

var main = function() {
    var q = +rd();
    loop:while (q-->0) {
        var s = rd().split('');
        var t = rd().split('');
        var p = rd().split('');

        var f1 = foo(s, t);
        if (f1[0]) {
            //pr(f1[1]);
            var f2 = foo(f1[1], p);
            if (f2[0]) {
                pr('YES');
                continue loop;
            }
        }

        pr('NO');
    }
};

var rd = readline;
var wr = write;
var pr = print;
var rdAr = () => rd().split(' ').map(v => +v);
var prAr = (a) => pr(a.join(' '));
var cmpLt = (a, b) => a - b;
var cmpGt = (a, b) => b - a;

main();

const readline = require('readline');

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

var q, s, t, p;

rl.on("line", (line) => {
	if (q == null) q = parseInt(line);
	else if (s == null) s = line;
	else if (t == null) t = line;
	else if (p == null) {
		p = line;
		// begin to solve
		var mp = {};
		var len1 = s.length;
		var len2 = t.length;
		var len3 = p.length;
		for (var i = 0; i < len3; i ++) {
			if (! mp[ p[i] ]) mp[ p[i] ] = 1;
			else mp[ p[i] ] ++;
		}
		var flag = true;
		var j = 0;
		for (var i = 0; i < len2; i ++) {
			if (j < len1 && s[j] == t[i]) j ++;
			else if (mp[ t[i] ]) mp[ t[i] ] --;
			else {
				flag = false;
				break;
			}
		}
		console.log( flag ? "YES" : "NO" );
		// end of solve
		s = t = p = null;
		q --;
		if (q == 0)
			rl.close();
	}
});