"use strict";

function answer(wordLength, bigrams) {
    let lastBigram = null;
    let word = '';
    for (let i = 0; i < bigrams.length; i += 1) {
        const bigram = bigrams[i];
        if (lastBigram === null) {
            word += bigram;
            lastBigram = bigram;
            continue;
        }

        if (lastBigram[1] !== bigram[0]) {
            word += bigram;
        } else {
            word += bigram[1];
        }
        lastBigram = bigram;
    }

    if (word.length < wordLength) {
        word += 'a';
    }

    return word;
}

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

for (let i = 0; i < nQueues; i++) {
    const wordLength = this.readline();
    const bigrams = this.readline().split(" ");
    const result = answer(wordLength, bigrams);
    this.print(result)
}

    // your code goes here
    const fs = require('fs');
    const input = fs.readFileSync(0, 'utf8').trim().split('\n');
    let currentline = 0;
    function readline(){
        return input[currentline++];
    }
    var T = readline();
    for(var q =1;q<=T;q++) {
        var n = readline()
        var ar = readline().split(' ')
        var anc = ''
        anc += ar[0][0]
        if(2*ar.length < n) {
        	anc += ar[0][1]
        	for(var i=1;i<ar.length;i++) {
        		anc += ar[i][0]
        		anc += ar[i][1]
        	}
        	if(anc.length < n) {
        		while(anc.length < n) { anc += ar[i-1][1] }
        	}
        	console.log(anc)
        } else {
        	var i = 1, j = 1;
        	while(anc.length < n && i < ar.length) {
        		if(ar[i-1][j] == ar[i][j-1]) {
        			anc += ar[i][0]
        			i++;
        		} else {
        			anc += ar[i-1][j]
        			anc += ar[i][j-1]
        			i++;
        		}
        	}
        	if(anc.length < n) {
        		while(anc.length < n ) { anc += ar[i-1][1] }
        	}
        	console.log(anc)
        }
    }

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

  main(lines);
});

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

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

function solve(N, input) {
  let arr = [input[0]];
  let result = '';

  for (let i = 1; i < input.length; ++i) {
    if (input[i][0] !== input[i - 1][1]) {
      arr.push(input[i - 1][1] + input[i][0]);
    }

    arr.push(input[i]);
  }

  if (arr.length !== N - 1) {
    arr.push(arr[arr.length - 1][1] === 'a' ? 'ab' : 'ba');
  }

  result = arr[0];

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

  console.log(result);
}

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

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

function main () {
	let T = rn();
	while (T--) {
		const n = rn();
		const bgs = rl().split(' ');

		let ans = '';
		for (const bg of bgs) {
			if (ans.slice(-1) == bg[0])
				ans += bg[1];
			else
				ans += bg;
		}

		if (ans.length < n)
			ans += 'a';

		console.log(ans);
	}
}

let data = '';
process.stdin.on('data', c => data += c);

function* nextLine() {
	let lines = data.trim().split(/\n/g);
	for(let l of lines){
		yield l.trim();
	}
}

let nl = nextLine();

nl.elem = function(funParse) {
		return funParse(this.next().value);
	};

nl.array = function(funParse) {
		return this.next().value.split(/\s/g).map(funParse||(x => x));
	};

nl.num = function() {
		return nl.elem(Number);
	};

nl.nums = function() {
		return nl.array(Number);
	};

nl.line = function() {
		return this.next().value;
	};

const sol = () => {
	//your code this
	let t = nl.num();
	let ans = [];
	for(let i = 0; i < t; i++){
		let n = nl.num();
		let a = nl.array();
		let r = [];
		for(let j = 0; j < n - 2; j++){
			if (j == 0){
				r.push(a[j].charAt(0));
				r.push(a[j].charAt(1));
			} else {
				if (a[j-1].charAt(1) != a[j].charAt(0)){
					r.push(a[j].charAt(0));
				}
				r.push(a[j].charAt(1));
			}
		}
		if (r.length < n){
			r.push(r[r.length -1]);
		}
		ans.push(r.join(''));

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

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

// let s = ['ab', 'bb', 'ba', 'aa', 'ba'];
// let k = 7;
// let s = ['aa'];
// let k = 3;
let n = null, m = null, a=[], b=[];
const readline = require('readline').createInterface({
    input: process.stdin,
    output: process.stdout
});

readline.on('line', line => {
    if (n == null) {
        n = parseInt(line)
        m = n * 2
    } else if (m>0) {
        if (m%2==0)
        b.push(parseInt(line))
        else
        a.push(line.split(' '))
        m--;

    }
    if (m == 0) {
        readline.close();
        main();
    }
});

function main(){
    a.forEach((s,j)=> {
        let res = "";
        for (let i = 0 ; i < s.length-1; i++) {
            if (s[i][1] == s[i+1][0]) res+=s[i][0];
            else res += s[i];
        }
        res += s.pop();
        if (res.length < b[j]) res+='a';
        console.log(res)
    });
}
// main();

// 'ab' 'bb' 'ba' 'aa' 'ab' 'ba'
// 'ab' 'bb' 'ba' 'aa' 'ba'
// 'a' 'b' 'b' 'aa' 'ba'
// 'a' 'b' 'b' 'aa' 'ba'
// abbaaba

// bbabb

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 * 2
    } else if (count !== 0) {
        inputArr.push(data.trim())
        count--
    }
    // max number 2^(53) - 1 ~~ 10^(15)
    if (count === 0) {
        inputArr = inputArr.map(i => i.split(' '))
        main()
        process.exit(0)
    }
})

function solve([n], arr) {
    let res = '', flag = false
    res += arr[0][0]
    for (let i = 0; i < n - 3; i++) {
        if (arr[i][1] != arr[i + 1][0]) {
            res += arr[i][1];
            res += arr[i + 1][0];
            flag = true;
        } else {
            res += arr[i + 1][0];
        }
    }
    res += arr[n - 3][1]
    if (!flag) {
        res += arr[n - 3][1];
    }
    console.log(res)
}

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

//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 = nextStrArray(N - 2);
		var ok = false;
		var output = list[0][0];
		for(var i = 0; i < N - 3; i++){
			output += list[i][1];
			if(list[i][1] != list[i + 1][0]){
				output += list[i + 1][0];
				ok = true;
			}
		}
		output += list[N - 3][1];
		if(!ok){
			output += "a";
		}
		myout(output);
	}
}

    var len = readline();
    for(var i=0;i<+len;i++)
    {
     var lenth = readline();
     var inputData = readline().split(' ');
     var str ='';
     for(var j=0;j<inputData.length;j++)
     {
         if(str[str.length-1] != inputData[j][0])
         str+=inputData[j];
         else
         str+=inputData[j][1];
     }
     if(str.length < lenth)
           print(str+'a');
           else
           print(str);
    }

var len = readline();
for(var i=0;i<+len;i++)
{
 var lenth = readline();
 var inputData = readline().split(' ');
 var str ='';
 for(var j=0;j<inputData.length;j++)
 {
    // if(inputData[j].length ==1 && +lenth>2)
     //{
       //  str+=inputData[i]+'a';
     ////}
     //else{
     if(str[str.length-1] != inputData[j][0])
     str+=inputData[j];
     else
     str+=inputData[j][1];

  //   }
 }
 if(str.length < lenth)
       print(str+'a');
       else
       print(str);

}

var s = parseInt(readline());
  while (s--) {
    var n = parseInt(readline());
    var str = readline().split(" ");
    var string = str[0];
    for (var i = 1; i < str.length; i++) {
      var st = str[i];
      if (string[string.length - 1] === st[0]) {
        string += st[1];
      } else {
        string += st;
      }
    }
    if (string.length < n) {
      string += "a";
    }
    print(string);
  }

"use strict";

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

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

for (let i = 0; i < nQueues; i++) {
  const length = Number(this.readline());
  const bigrams = this.readline().split(' ');
  let word = ''
  let found = false
  for(let i= 0; i< bigrams.length-1; i++) {
    const a = bigrams[i]
    const b = bigrams[i+1]
    if(a[1] === b[0]){
      word+= a[0]
    } else {
      found = true
      word+= a
    }
  }
  word+= bigrams[bigrams.length-1]
  if(!found) word+='a'
  this.print(word)
}

// your code goes here
const fs = require('fs');
const input = fs.readFileSync(0, 'utf8').trim().split('\n');
let currentline = 0;
function readline(){
    return input[currentline++];
}
var T = readline();
for(var q =1;q<=T;q++) {
    var n = readline()
    var a = readline().split(' ')
    var ans = ''
    var anc = ''
    for(var i=0;i<a.length;i++) {
        anc += a[i]
    }
    for(var i=0;i<(anc.length-4);i++) {
        ans += anc[i]
    }
    console.log(ans)
}

var len = readline();
for(var i=0;i<+len;i++)
{
 var lenth = readline();
 var inputData = readline().split(' ');
 var str ='';
 for(var j=0;j<inputData.length;j++)
 {
     if(inputData[j].length ==1 && +lenth>2)
     {
         str+=inputData[i]+'a';
     }
     else{
     if(str[str.length-1] != inputData[j][0])
     str+=inputData[j];
     else
     str+=inputData[j][1];
     }
 }
       print(str);

}

var len = readline();
for(var i=0;i<+len;i++)
{
 var lenth = readline();
 var inputData = readline().split(' ');
 var str ='';
 for(var j=0;j<inputData.length;j++)
 {
     if(inputData[j].length ==1 && +lenth>2)
     {
         str+=inputData[i]+'a';
     }
     else{
     if(str[str.length-1] != inputData[j][0])
     str+=inputData[j];
     else
     str+inputData[j][1];
     }
 }
       print(str);

}

var len = readline();
for(var i=0;i<+len;i++)
{
 var lenth = readline();
 var inputData = readline().split(' ');
 var str ='';
 for(var j=0;j<inputData.length;j++)
 {
     if(str[str.length-1] != inputData[j][0])
     str+=inputData[j];
     else
     str+inputData[j][1];
 }
}
/*for(var j=1;j*j<=+inputData;j++)
{
   count.add(j*j);
}
for(var k=1;k*k*k<=+inputData;k++)
{
   count.add(k*k*k);
}
print(count.size);*/


var s = readline().split(' ');
n=s[0];
r=s[1];
var s = readline().split(' ');
var vec=[];
vec[0]=Number(r);
print(r);
for(i=1;i<n;i++){
	vec[i]=Number(r);
	for(j=i-1;j>=0;j--){
		if(Math.abs(s[i]-s[j])>r*2)continue;
		vec[i]=Math.max(vec[i],(Math.sqrt(Math.pow(r*2,2)-Math.pow(Math.abs(s[i]-s[j]),2))+Number(vec[j])));
	}
	print(vec[i]);
}

'use strict';

var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }();

{
    var kr = readline,
        chr = String.fromCodePoint,
        ord = function ord(v, i) {
        return v.charCodeAt(i);
    };
    var krr = function krr() {
        var sp = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : ' ';
        return kr().split(sp);
    };
    var S = String,
        N = Number,
        A = function A() {
        for (var _len = arguments.length, a = Array(_len), _key = 0; _key < _len; _key++) {
            a[_key] = arguments[_key];
        }

        return new (Function.prototype.bind.apply(Array, [null].concat(a)))();
    };
    var kt = function kt(m, d) {
        return d.map(function (v, i) {
            return m[i](v);
        });
    };
    //////////////////////////////////////////////////////////////////////////////
    var dist = function dist(x1, y1, x2, y2) {
        return Math.sqrt(Math.pow(x1 - x2, 2) + Math.pow(y1 - y2, 2));
    };
    var gp = function gp(x, y, r, x2) {
        var v = Math.pow(r, 2) - Math.pow(x - x2, 2);
        if (v < 0) return 0;
        return Math.sqrt(v) + y;
    };

    var _kt = kt([N, N], krr()),
        _kt2 = _slicedToArray(_kt, 2),
        n = _kt2[0],
        r = _kt2[1];

    var l = krr().map(N),
        SZ = 1000;
    var d = A(SZ),
        xx = A();
    for (var i = 0; i < 2000; i++) {
        xx[i] = A();
    }l.forEach(function (x, i) {
        var y = r;

        var _loop = function _loop(xi) {
            xx[xi].forEach(function (yi) {
                y = Math.max(y, gp(xi, yi, 2 * r, x));
            });
        };

        for (var xi = Math.max(1, x - r * 3); xi <= Math.min(1000, x + r * 3); xi++) {
            _loop(xi);
        }
        xx[x].push(y);
        d[i] = y;
    });
    print(d.slice(0, n).join(' '));
}

'use strict';

var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }();

{
    var kr = readline,
        chr = String.fromCodePoint,
        ord = function ord(v, i) {
        return v.charCodeAt(i);
    };
    var krr = function krr() {
        var sp = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : ' ';
        return kr().split(sp);
    };
    var S = String,
        N = Number,
        A = function A() {
        for (var _len = arguments.length, a = Array(_len), _key = 0; _key < _len; _key++) {
            a[_key] = arguments[_key];
        }

        return new (Function.prototype.bind.apply(Array, [null].concat(a)))();
    };
    var M = function M(l, f) {
        var r = A(l);for (var i = 0; i < l; i++) {
            r[i] = f(i);
        }return r;
    };
    var kt = function kt(m, d) {
        return d.map(function (v, i) {
            return m[i](v);
        });
    };
    //////////////////////////////////////////////////////////////////////////////
    var dist = function dist(x1, y1, x2, y2) {
        return Math.sqrt(Math.pow(x1 - x2, 2) + Math.pow(y1 - y2, 2));
    };
    var gp = function gp(x, y, r, x2) {
        var v = Math.pow(r, 2) - Math.pow(x - x2, 2);
        if (v < 0) return 0;
        return Math.sqrt(v) + y;
    };

    var _kt = kt([N, N], krr()),
        _kt2 = _slicedToArray(_kt, 2),
        n = _kt2[0],
        r = _kt2[1];

    var l = krr().map(N),
        SZ = 1100;
    var d = A(SZ),
        xx = M(SZ, function () {
        return A();
    });

    l.forEach(function (x, i) {
        var y = r;

        var _loop = function _loop(xi) {
            xx[xi].forEach(function (yi) {
                y = Math.max(y, gp(xi, yi, 2 * r, x));
            });
        };

        for (var xi = Math.max(1, x - r * 2); xi < Math.min(SZ, x + r * 2 + 1); xi++) {
            _loop(xi);
        }
        xx[x].push(y);
        d[i] = y;
    });
    print(d.slice(0, n).join(' '));
}

var s = readline().split(' ');
n=s[0];
r=s[1];
var s = readline().split(' ');
var ans=r+"";
var vec=[];
vec[0]=Number(r);
for(i=1;i<n;i++){
	hit = false;
	vec[i]=Number(-1);
	for(j=i-1;j>=0;j--){
		if(Math.abs(s[i]-s[j])>r*2)continue;
		hit=true;
		vec[i]=Math.max(vec[i],(Math.sqrt(Math.pow(r*2,2)-Math.pow(Math.abs(s[i]-s[j]),2))+Number(vec[j])));
	}
	if(hit===false){
		vec[i]=Number(r);
	}
	ans+=" "+vec[i];
}
print(ans);

'use strict';

var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }();

{
    var kr = readline,
        chr = String.fromCodePoint,
        ord = function ord(v, i) {
        return v.charCodeAt(i);
    };
    var krr = function krr() {
        var sp = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : ' ';
        return kr().split(sp);
    };
    var S = String,
        N = Number,
        A = function A() {
        for (var _len = arguments.length, a = Array(_len), _key = 0; _key < _len; _key++) {
            a[_key] = arguments[_key];
        }

        return new (Function.prototype.bind.apply(Array, [null].concat(a)))();
    };
    var M = function M(l, f) {
        var r = A(l);for (var i = 0; i < l; i++) {
            r[i] = f(i);
        }return r;
    };
    var kt = function kt(m, d) {
        return d.map(function (v, i) {
            return m[i](v);
        });
    };
    //////////////////////////////////////////////////////////////////////////////
    var dist = function dist(x1, y1, x2, y2) {
        return Math.sqrt(Math.pow(x1 - x2, 2) + Math.pow(y1 - y2, 2));
    };
    var gp = function gp(x, y, r, x2) {
        var v = Math.pow(r, 2) - Math.pow(x - x2, 2);
        if (v < 0) return 0;
        return Math.sqrt(v) + y;
    };

    var _kt = kt([N, N], krr()),
        _kt2 = _slicedToArray(_kt, 2),
        n = _kt2[0],
        r = _kt2[1];

    var l = krr().map(N),
        SZ = 1100;
    var d = A(SZ),
        xx = M(SZ, function () {
        return A();
    });

    l.forEach(function (x, i) {
        var y = r;

        var _loop = function _loop(xi) {
            xx[xi].forEach(function (yi) {
                y = Math.max(y, gp(xi, yi, 2 * r, x));
            });
        };

        for (var xi = Math.max(1, x - r * 2); xi < Math.min(SZ, x + r * 2); xi++) {
            _loop(xi);
        }
        xx[x].push(y);
        d[i] = y;
    });
    print(d.slice(0, n).join(' '));
}

'use strict';

var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }();

{
    var kr = readline,
        chr = String.fromCodePoint,
        ord = function ord(v, i) {
        return v.charCodeAt(i);
    };
    var krr = function krr() {
        var sp = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : ' ';
        return kr().split(sp);
    };
    var S = String,
        N = Number,
        A = function A() {
        for (var _len = arguments.length, a = Array(_len), _key = 0; _key < _len; _key++) {
            a[_key] = arguments[_key];
        }

        return new (Function.prototype.bind.apply(Array, [null].concat(a)))();
    };
    var kt = function kt(m, d) {
        return d.map(function (v, i) {
            return m[i](v);
        });
    };
    //////////////////////////////////////////////////////////////////////////////
    var dist = function dist(x1, y1, x2, y2) {
        return Math.sqrt(Math.pow(x1 - x2, 2) + Math.pow(y1 - y2, 2));
    };
    var gp = function gp(x, y, r, x2) {
        return Math.sqrt(Math.pow(r, 2) - Math.pow(x - x2, 2)) + y;
    };

    var _kt = kt([N, N], krr()),
        _kt2 = _slicedToArray(_kt, 2),
        n = _kt2[0],
        r = _kt2[1];

    var l = krr().map(N),
        SZ = 2000;
    var d = A(SZ),
        xx = A();
    for (var i = 0; i < SZ; i++) {
        xx[i] = A();
    }l.forEach(function (x, i) {
        var y = r;

        var _loop = function _loop(xi) {
            xx[xi].forEach(function (yi) {
                y = Math.max(y, gp(xi, yi, 2 * r, x));
            });
        };

        for (var xi = Math.max(0, x - r * 2); xi < Math.min(SZ, x + r * 2); xi++) {
            _loop(xi);
        }
        xx[x].push(y);
        d[i] = y;
    });
    print(d.slice(0, n).join(' '));
}

'use strict';

var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }();

{
    var kr = readline,
        chr = String.fromCodePoint,
        ord = function ord(v, i) {
        return v.charCodeAt(i);
    };
    var krr = function krr() {
        var sp = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : ' ';
        return kr().split(sp);
    };
    var S = String,
        N = Number,
        A = function A() {
        for (var _len = arguments.length, a = Array(_len), _key = 0; _key < _len; _key++) {
            a[_key] = arguments[_key];
        }

        return new (Function.prototype.bind.apply(Array, [null].concat(a)))();
    };
    var kt = function kt(m, d) {
        return d.map(function (v, i) {
            return m[i](v);
        });
    };
    //////////////////////////////////////////////////////////////////////////////
    var dist = function dist(x1, y1, x2, y2) {
        return Math.sqrt(Math.pow(x1 - x2, 2) + Math.pow(y1 - y2, 2));
    };
    var gp = function gp(x, y, r, x2) {
        return Math.sqrt(Math.pow(r, 2) - Math.pow(x - x2, 2)) + y;
    };

    var _kt = kt([N, N], krr()),
        _kt2 = _slicedToArray(_kt, 2),
        n = _kt2[0],
        r = _kt2[1];

    var l = krr().map(N),
        SZ = 2000;
    var d = A(SZ),
        xx = A();
    for (var i = 0; i < SZ; i++) {
        xx[i] = A();
    }l.forEach(function (x, i) {
        var y = r;

        var _loop = function _loop(xi) {
            xx[xi].forEach(function (yi) {
                y = Math.max(y, gp(xi, yi, 2 * r, x));
            });
        };

        for (var xi = Math.max(0, x - r * 3); xi < Math.min(SZ, x + r * 3); xi++) {
            _loop(xi);
        }
        xx[x].push(y);
        d[i] = y;
    });
    print(d.slice(0, n).join(' '));
}

var s = readline().split(' ');
n=s[0];
r=s[1];
var s = readline().split(' ');
var ans=r+"";
var vec=[];
print(r);
vec.push(r);
for(i=1;i<n;i++){
	hit = false;
	for(j=i-1;j>=0;j--){
		if(Math.abs(s[i]-s[j])>r*2)continue;
		hit=true;
		print((Math.sqrt(Math.pow(r*2,2)-Math.pow(Math.abs(s[i]-s[j]),2))+Number(vec[j])));
		ans+=" "+(Math.sqrt(Math.pow(r*2,2)-Math.pow(Math.abs(s[i]-s[j]),2))+Number(vec[j]));
		vec.push(Math.sqrt(Math.pow(r*2,2)-Math.pow(Math.abs(s[i]-s[j]),2))+Number(vec[j]));
	}
	if(hit===false){
		ans+=" "+Number(r);
		print(r);
		vec.push(r);
	}
}

var s = readline().split(' ');
n=s[0];
r=s[1];
var s = readline().split(' ');
var ans=r+"";
var vec=[];
vec.push(r);
for(i=1;i<n;i++){
	hit = false;
	for(j=i-1;j>=0;j--){
		if(Math.abs(s[i]-s[j])>r*2)continue;
		hit=true;
		ans+=" "+(Math.sqrt(Math.pow(r*2,2)-Math.pow(Math.abs(s[i]-s[j]),2))+vec[j]);
		vec.push(Math.sqrt(Math.pow(r*2,2)-Math.pow(Math.abs(s[i]-s[j]),2))+vec[j]);
	}
	if(hit==false){
		ans+=" "+r;
		vec.push(r);
	}
}
print(ans);

var s = readline().split(' ');
n=s[0];
r=s[1];
var s = readline().split(' ');
print(s);
var ans=r+"";
var vec=[];
vec.push(r);
for(i=1;i<n;i++){
	hit = false;
	for(j=i-1;j>=0;j--){
		if(Math.abs(s[i]-s[j])>r*2)continue;
		hit=true;
		ans+=" "+(Math.sqrt(Math.pow(r*2,2)-Math.pow(Math.abs(s[i]-s[j]),2))+vec[j]);
		vec.push(Math.sqrt(Math.pow(r*2,2)-Math.pow(Math.abs(s[i]-s[j]),2))+vec[j]);
	}
	if(hit==false){
		ans+=" "+r;
		vec.push(r);
	}
}
print(ans);

var s = readline().split(' ');
n=s[0];
r=s[1];
print(n+" "+r);

var s = readline().split(' ');
n=s[0];
r=s[1];
var s = readline().split(' ');
var ans=r+"";
var vec=[];
print(r);
vec.push(r);
for(i=1;i<n;i++){
	hit = false;
	for(j=i-1;j>=0;j--){
		if(Math.abs(s[i]-s[j])>r*2)continue;
		hit=true;
		print((Math.sqrt(Math.pow(r*2,2)-Math.pow(Math.abs(s[i]-s[j]),2))+ +vec[j]));
		ans+=" "+(Math.sqrt(Math.pow(r*2,2)-Math.pow(Math.abs(s[i]-s[j]),2))+ +vec[j]);
		vec.push(Math.sqrt(Math.pow(r*2,2)-Math.pow(Math.abs(s[i]-s[j]),2))+ +vec[j]);
	}
	if(hit===false){
		ans+=" "+ +r;
		print(r);
		vec.push(r);
	}
}

var s = readline().split(' ');
n=s[0];
r=s[1];
var s = readline().split(' ');
var ans=r+"";
var vec=[];
print(r);
vec[0]=r;
for(i=1;i<n;i++){
	hit = false;
	for(j=i-1;j>=0;j--){
		if(Math.abs(s[i]-s[j])>r*2)continue;
		hit=true;
		vec[i]=Math.max(vec[i],(Math.sqrt(Math.pow(r*2,2)-Math.pow(Math.abs(s[i]-s[j]),2))+Number(vec[j])));
	}
	if(hit===false){
		vec[i]=r;
	}
	ans+=" "+vec[i];
}
print(ans);

var s = readline().split(' ');
n=s[0];
r=s[1];
var s = readline().split(' ');
var ans=r+"";
var vec=[];
print(r);
vec.push(r);
for(i=1;i<n;i++){
	hit = false;
	for(j=i-1;j>=0;j--){
		if(Math.abs(s[i]-s[j])>=r*2)continue;
		hit=true;
		print((Math.sqrt(Math.pow(r*2,2)-Math.pow(Math.abs(s[i]-s[j]),2))+Number(vec[j])));
		ans+=" "+(Math.sqrt(Math.pow(r*2,2)-Math.pow(Math.abs(s[i]-s[j]),2))+Number(vec[j]));
		vec.push(Math.sqrt(Math.pow(r*2,2)-Math.pow(Math.abs(s[i]-s[j]),2))+Number(vec[j]));
		break;
	}
	if(hit===false){
		ans+=" "+Number(r);
		print(r);
		vec.push(r);
	}
}

var s = readline().split(' ');
n=s[0];
r=s[1];
var s = readline().split(' ');
var ans=r+"";
var vec=[];
vec[0]=Number(r);
for(i=1;i<n;i++){
	hit = false;
	for(j=i-1;j>=0;j--){
		if(Math.abs(s[i]-s[j])>r*2)continue;
		hit=true;
		vec[i]=Math.max(vec[i],(Math.sqrt(Math.pow(r*2,2)-Math.pow(Math.abs(s[i]-s[j]),2))+Number(vec[j])));
	}
	if(hit===false){
		vec[i]=Number(r);
	}
	ans+=" "+vec[i];
}
print(ans);

var s = readline().split(' ');
n=s[0];
r=s[1];
var s = readline().split(' ');
var ans=r+"";
var vec=[];
print(r);
vec.push(r);
for(i=1;i<n;i++){
	hit = false;
	for(j=i-1;j>=0;j--){
		if(Math.abs(s[i]-s[j])>r*2)continue;
		hit=true;
		print((Math.sqrt(Math.pow(r*2,2)-Math.pow(Math.abs(s[i]-s[j]),2))+vec[j]));
		ans+=" "+(Math.sqrt(Math.pow(r*2,2)-Math.pow(Math.abs(s[i]-s[j]),2))+vec[j]);
		vec.push(Math.sqrt(Math.pow(r*2,2)-Math.pow(Math.abs(s[i]-s[j]),2))+vec[j]);
	}
	if(hit===false){
		ans+=" "+r;
		print(r);
		vec.push(r);
	}
}

var s = readline().split(' ');
n=s[0];
r=s[1];
var s = readline().split(' ');
var ans=r+"";
var vec=[];
vec.push(r);
for(i=1;i<n;i++){
	hit = false;
	for(j=i-1;j>=0;j--){
		if(Math.abs(s[i]-s[j])>r*2)continue;
		hit=true;
		s+=" "+(Math.sqrt(Math.pow(r*2,2)-Math.pow(Math.abs(s[i]-s[j]),2))+vec[j]);
		vec.push(Math.sqrt(Math.pow(r*2,2)-Math.pow(Math.abs(s[i]-s[j]),2))+vec[j]);
	}
	if(hit==false){
		s+=" "+r;
		vec.push(r);
	}
}
print(s);

var s = readline().split(' ');
n=s[0];
r=s[1];
var s = readline().split(' ');
var ans=r+"";
var vec=[];
print(r);
vec.push(r);
for(i=1;i<n;i++){
	hit = false;
	for(j=i-1;j>=0;j--){
		if(Math.abs(s[i]-s[j])>r*2)continue;
		hit=true;
		print((Math.sqrt(Math.pow(r*2,2)-Math.pow(Math.abs(s[i]-s[j]),2))+Number(vec[j])));
		ans+=" "+(Math.sqrt(Math.pow(r*2,2)-Math.pow(Math.abs(s[i]-s[j]),2))+Number(vec[j]));
		vec.push(Math.sqrt(Math.pow(r*2,2)-Math.pow(Math.abs(s[i]-s[j]),2))+Number(vec[j]));
		break;
	}
	if(hit===false){
		ans+=" "+Number(r);
		print(r);
		vec.push(r);
	}
}


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

const MOD = 1e9 + 7;

function main () {
	let T = rn();
	while (T--) {
		const [N, K] = rna();

		/*
		   const dp = Array.from(Array(n+1), x => []);
		   function f (i, k) {
		   if (dp[i][k]) return dp[i][k];
		   console.log({i, k})
		   if (i == 0) return 1;
		   if (k > 1) return dp[i][k] = (f(i-1, k) + f(n-i, k-1)) % MOD;
		   else return dp[i][k] = f(i-1, k) % MOD;
		   }
		   */

		const dp = Array.from(Array(N+1), x => Array(K+1).fill(0));
		for (let k = 1; k <= K; k++) {
			dp[0][k] = 1;
		}
		for (let k = 1; k <= K; k++) {
			for (let n = 1; n <= N ; n++) {
				dp[n][k] = (dp[n-1][k] + dp[N-n][k-1]) % MOD;
			}
		}
		const ans = dp[N][K];

		console.log(ans);
	}
}

//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{
			ret[i] = next();
		}
	}
	return ret;
}
function nextIntArray(size){return nextArray(size, 'int');} function nextStrArray(size){return nextArray(size, 'str');}
function nextCharArray(){return myconv(next(),6);}
function next(){return obj.next();} function hasNext(){return obj.hasNext();} function nextInt(){return myconv(next(),1);}
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();
	var mod = 1000000007;
	for(var i = 0; i < t; i++){
		var N = nextInt();
		var K = nextInt();
		var output = 1;
		if(K == 1){
			myout(output);
			continue;
		}
		if(N == 1){
			myout(2);
			continue;
		}
		output++;
		N--;
		var list = new Array(N).fill(0);
		list[0] = 1;
		var isL = true;
		while(K > 1){
			if(!isL){
				for(var k = N - 2; k >= 0; k--){
					list[k] += list[k + 1];
					list[k] %= mod;
				}
			}else{
				for(var k = 1; k < N; k++){
					list[k] += list[k - 1];
					list[k] %= mod;
				}
			}
			for(var k = 0; k < N; k++){
				output += list[k];
				output %= mod;
			}
			K--;
			isL = !isL;
		}
		myout(output);
	}
}

'use strict';

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

let inputString = '';
let currentLine = 0;

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

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

  main();
});

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

var maxN = 1001
var mod = 1000000007

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

function main() {
  const x = readline();
  var toPrint = ''
  Array(Number(x)).fill(1).map((t, i) => {
    // const a = parseInt(readline());
    var [n, k] = readline().split(' ').map((x, iii) => {
      return parseInt(x)
    });
    if (k === 1) return toPrint += 1 + '\n'

    var dp = new Array(k)
    for (let j = 0; j < k; j++) {
      dp[j] = new Array(n).fill(0)
    }
    for (let j = 0; j < n; j++) {
      dp[0][j] = 1
    }
    for (let j = 0; j < k - 2; j++) {
      if (j % 2 === 0) {
        var sum = 0
        for (let i = 0; i < n; i++) {
          dp[j + 1][i] = sum
          sum += dp[j][i]
          sum = sum % mod
        }
      } else {
        sum = 0
        for (let i = n - 1; i >= 0; i--) {
          dp[j + 1][i] = sum
          sum += dp[j][i]
          sum = sum % mod
        }
      }
    }

    var ans = 1
    for (let j = 0; j < k - 1; j++) {
      for (let i = 0; i < n; i++) {
        // console.log(ans, dp[j][i])
        ans = (ans + dp[j][i]) % mod
      }
    }
    toPrint += ans.toString() + '\n'
    // console.log(dp)
  })
  console.log(toPrint)

}

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

const MOD = 1e9 + 7;

function main () {
	let T = rn();
	while (T--) {
		const [N, K] = rna();

		const dp = Array.from(Array(N+1), x => Array(K+1));
		for (let n = 0; n <= N; n++) {
			dp[n][0] = 0;
		}
		for (let k = 1; k <= K; k++) {
			dp[0][k] = 1;
		}
		for (let k = 1; k <= K; k++) {
			for (let n = 1; n <= N ; n++) {
				dp[n][k] = (dp[n-1][k] + dp[N-n][k-1]) % MOD;
			}
		}
		const ans = dp[N][K];

		console.log(ans);
	}
}

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

var maxN = 1001
var mod = 1000000007n

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

function main() {
  const x = readline();
var toPrint = ''
  Array(Number(x)).fill(1).map((t, i) => {
    // const a = parseInt(readline());
    var [n, k] = readline().split(' ').map((x, iii) => {
      return BigInt(x)
    });
    if (k === 1n) return console.log(1)
    var dp = new Array(k)
    for (let j = 0n; j < k; j++) {
      dp[j] = new Array(n).fill(0n)
    }
    for (let j = 0n; j < n; j++) {
      dp[0][j] = 1n
    }
    for (let j = 0n; j < k - 2n; j++) {
      if (j % 2n === 0n) {
        var sum = 0n
        for (let i = 0n; i < n; i++) {
          dp[j + 1n][i] = sum
          sum += dp[j][i]
          sum = sum % mod
        }
      } else {
        sum = 0n
        for (let i = n - 1n; i >= 0n; i--) {
          dp[j + 1n][i] = sum
          sum += dp[j][i]
          sum = sum % mod
        }
      }
    }

    var ans = 1n
    for (let j = 0n; j < k - 1n; j++) {
      for (let i = 0n; i < n; i++) {
        // console.log(ans, dp[j][i])
        ans = (ans + dp[j][i]) % mod
      }
    }
    toPrint += ans.toString() + '\n'
    // console.log(dp)
  })
  console.log(toPrint)

}


function main()
{

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

var n = parseInt( readline() );
var s = readline();

if ( n%4 > 0 )
{
	print( "===" );
	return;
}

var q = 0;
var a = [];
a['A'] = a['C'] = a['G'] = a['T'] = 0;

for ( var i = 0 ; i < n ; i++ )
{
	if ( s[i] == '?' )
		q++;
	else
		a[ s[i] ]++;
}

var e = n / 4;
if ( a['A'] > e || a['C'] > e || a['G'] > e || a['T'] > e )
{
	print( "===" );
	return;
}

var ans = "";
for ( var i=0 ; i<n ; i++ )
{
	if ( s[i] == '?' )
	{
		if ( a['A'] < e )
		{
			a['A']++;
			ans += 'A';
			continue;
		}

		if ( a['C'] < e )
		{
			a['C']++;
			ans += 'C';
			continue;
		}

		if ( a['G'] < e )
		{
			a['G']++;
			ans += 'G';
			continue;
		}

		if ( a['T'] < e )
		{
			a['T']++;
			ans += 'T';
			continue;
		}

	}
	else
	{
		ans += s[i];
	}
}

print( ans );

} main();

"use strict";

var NOT_FOUND = "===";
var letters = ["A", "C", "T", "G"];

function countLetters (genom) {
    var count = {};
    for (var i = 0; i < letters.length; i++) {
        count[letters[i]] = 0;
    }
    for (i = 0; i < genom.length; i++) {
        if (letters.indexOf(genom[i]) !== -1) {
            count[genom[i]]++;
        }
    }
    return count;
}

function reconstruct (genom) {
    if (genom.length % 4 !== 0) {
        return NOT_FOUND;
    }
    var count = countLetters(genom);
    var desiredCount = Math.round(genom.length / 4);
    for (var i = 0; i < letters.length; i++) {
        if (count[letters[i]] > desiredCount) {
            return NOT_FOUND;
        }
    }
    var result = "";
    for (i = 0; i < genom.length; i++) {
        if (letters.indexOf(genom[i]) === -1) {
            var curLetter = letters.filter(function (s) {
                return count[s] < desiredCount;
            })[0];
            result += curLetter;
            count[curLetter]++;
        } else {
            result += genom[i];
        }
    }
    return result;
}

var n = parseInt(readline());
var s = readline();
print(reconstruct(s));

"use strict";

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

let n = null;
let genome = [];
let map = {
    'A': 0,
    'C': 0,
    'G': 0,
    'T': 0,
    '?': 0
};

readline.on('line', line => {

    if (!n)
        n = line;
    else {
        genome = line.split('');
        readline.close();
    }
})

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

    genome.map(char => {
        map[char] = ++map[char];
    })

    let max = n / 4;

    let word = genome.join('');

    Object.keys(map).forEach(key => {
        if (key === '?') return;
        while (map['?'] > 0 && map[key] < max) {
            map[key] = ++map[key];
            map['?']--;
            word = word.replace('?', key);
        }
    })

    let cumple = true;
    Object.keys(map).forEach(key => {
        if (key !== '?' && map[key] < max) {
            cumple = false;
        }
    })
    if (word.includes('?') || !cumple)
        return console.log('===');
    console.log(word);
})

var memo = {
  A: 0,
  G: 0,
  C: 0,
  T: 0,
  '?': 0
};

var memo2 = {
  A: 0,
  G: 0,
  C: 0,
  T: 0
};

function max() {}

function resolve(s) {
  for (var i = 0; i < s.length; i++) {
    memo[s[i]]++;
  }
  var max = 0;
  for (var key in memo) {
    if (key !== '?' && memo[key] > max) {
      max = memo[key];
    }
  }
  var sum = 0;
  for (var key in memo) {
    if (key !== '?') {
      sum += max - memo[key];
      memo2[key] = max - memo[key];
    }
  }
  if (memo['?'] < sum) {
    return '===';
  }
  if ((memo['?'] - sum) % 4 !== 0) {
    return '===';
  } else {
    memo2.A += (memo['?'] - sum) / 4;
    memo2.G += (memo['?'] - sum) / 4;
    memo2.C += (memo['?'] - sum) / 4;
    memo2.T += (memo['?'] - sum) / 4;
  }
  var res = '';
  for (var i = 0; i < s.length; i++) {
    if (s[i] === '?') {
      if (memo2.A > 0) {
        res += 'A';
        memo2.A--;
      } else if (memo2.G > 0) {
        res += 'G';
        memo2.G--;
      } else if (memo2.C > 0) {
        res += 'C';
        memo2.C--;
      } else if (memo2.T > 0) {
        res += 'T';
        memo2.T--;
      }
    } else {
      res += s[i];
    }
  }
  return res;
}

//console.log(resolve('AA??'));

readline();
const s = readline();
print(resolve(s));

"use strict";

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

let n = null;
let genome = [];
let map = {
    'A': 0,
    'C': 0,
    'G': 0,
    'T': 0,
    '?': 0
};

readline.on('line', line => {

    if (!n)
        n = line;
    else {
        genome = line.split('');
        readline.close();
    }
})

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

    genome.map(char => {
        map[char] = ++map[char];
    })

    let max = 0;
    let maxKey = null;

    Object.keys(map).forEach(key => {
        if (key !== '?') {
            if (map[key] > max) {
                max = map[key]
                maxKey = key;
            }
        }
    })

    if (max === 0)
        max = map['?'] / 4;

    let word = genome.join('');

    Object.keys(map).forEach(key => {
        if (map['?'] >= 0) {
            if (key !== maxKey && map[key] < max) {
                map[key] = ++map[key];
                map['?']--;
                word = word.replace('?', key);
            }
        }
    })

    let cumple = true;
    Object.keys(map).forEach(key => {
        if (key != '?' && map[key] < max) {
            cumple = false;
        }
    })
    if (word.includes('?') || !cumple)
        return console.log('===');
    console.log(word);
})

"use strict";

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

let n = null;
let genome = [];
let map = {
    'A': 0,
    'C': 0,
    'G': 0,
    'T': 0,
    '?': 0
};

readline.on('line', line => {

    if (!n)
        n = line;
    else {
        genome = line.split('');
        readline.close();
    }
})

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

    genome.map(char => {
        map[char] = ++map[char];
    })

    let max = 0;
    let maxKey = null;

    Object.keys(map).forEach(key => {
        if (key !== '?') {
            if (map[key] > max) {
                max = map[key]
                maxKey = key;
            }
        }
    })

    if (max === 0)
        max = map['?'] / 4;

    let word = genome.join('');

    Object.keys(map).forEach(key => {
        if (map['?'] >= 0) {
            if (key !== maxKey && map[key] < max) {
                map[key] = ++map[key];
                map['?']--;
                word = word.replace('?', key);
            }
        }
    })
    if (word.includes('?'))
        return console.log('===');
    console.log(word);
})

"use strict";

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

let n = null;
let genome = [];
let map = {};

readline.on('line', line => {

    if (!n)
        n = line;
    else {
        genome = line.split('');
        readline.close();
    }
})

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

    genome.map(char => {
        map[char] = map[char] ? ++map[char] : 1;
    })

    if (Object.keys(map).length <= n / 2)
        return console.log('===');

    let max = 0;
    let maxKey = null;

    Object.keys(map).forEach(key => {
        if (key !== '?') {
            if (map[key] > max) {
                max = map[key]
                maxKey = key;
            }
        }
    })

    let word = genome.join('');

    Object.keys(map).forEach(key => {
        if (map['?'] >= 0) {
            if (key !== maxKey && map[key] < max) {
                map[key] = ++map[key];
                map['?']--;
                word = word.replace('?', key);
            }
        }
    })
    if (word.includes('?'))
        return console.log('===');
    console.log(word);
})

"use strict";

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

let n = null;
let genome = [];
let map = {
    'A': 0,
    'C': 0,
    'G': 0,
    'T': 0,
    '?': 0
};

readline.on('line', line => {

    if (!n)
        n = line;
    else {
        genome = line.split('');
        readline.close();
    }
})

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

    genome.map(char => {
        map[char] = ++map[char];
    })

    let max = 0;
    let maxKey = null;

    Object.keys(map).forEach(key => {
        if (key !== '?') {
            if (map[key] > max) {
                max = map[key]
                maxKey = key;
            }
        }
    })

    if (max === 0)
        max = map['?'] / 4;

    let word = genome.join('');

    Object.keys(map).forEach(key => {
        if (map['?'] >= 0) {
            if (key !== maxKey && map[key] < max) {
                map[key] = ++map[key];
                map['?']--;
                word = word.replace('?', key);
            }
        }
    })

    let cumple = true;
    Object.keys(map).forEach(key =>{
        if(map[key] < max){
            cumple = false;
        }
    })

    if (word.includes('?') || !cumple)
        return console.log('===');
    console.log(word);
})