Devu is a dumb guy, his learning curve is very slow. You are supposed to teach him n subjects, the ith subject has ci chapters. When you teach him, you are supposed to teach all the chapters of a subject continuously.Let us say that his initial per chapter learning power of a subject is x hours. In other words he can learn a chapter of a particular subject in x hours.Well Devu is not complete dumb, there is a good thing about him too. If you teach him a subject, then time required to teach any chapter of the next subject will require exactly 1 hour less than previously required (see the examples to understand it more clearly). Note that his per chapter learning power can not be less than 1 hour.You can teach him the n subjects in any possible order. Find out minimum amount of time (in hours) Devu will take to understand all the subjects and you will be free to do some enjoying task rather than teaching a dumb guy.Please be careful that answer might not fit in 32 bit data type.

The first line will contain two space separated integers n, x (1 ≤ n, x ≤ 105). The next line will contain n space separated integers: c1, c2, ..., cn (1 ≤ ci ≤ 105).

Output a single integer representing the answer to the problem.

NoteLook at the first example. Consider the order of subjects: 1, 2. When you teach Devu the first subject, it will take him 3 hours per chapter, so it will take 12 hours to teach first subject. After teaching first subject, his per chapter learning time will be 2 hours. Now teaching him second subject will take 2 × 1 = 2 hours. Hence you will need to spend 12 + 2 = 14 hours.Consider the order of subjects: 2, 1. When you teach Devu the second subject, then it will take him 3 hours per chapter, so it will take 3 × 1 = 3 hours to teach the second subject. After teaching the second subject, his per chapter learning time will be 2 hours. Now teaching him the first subject will take 2 × 4 = 8 hours. Hence you will need to spend 11 hours.So overall, minimum of both the cases is 11 hours.Look at the third example. The order in this example doesn't matter. When you teach Devu the first subject, it will take him 3 hours per chapter. When you teach Devu the second subject, it will take him 2 hours per chapter. When you teach Devu the third subject, it will take him 1 hours per chapter. In total it takes 6 hours.

if (!this.readline) print = console.log, readline = require('./readline');

print(function(n, x) {
	var c = readline().split(' ').map(Number);
	c.sort(function(a, b) {
		return a - b;
	});

	var ans = 0;
	for (var i = 0; i < n; i++) {
		ans += c[i] * x;
		if (x > 1)
			x--;
	}
	return ans;

}.apply(0, readline().split(' ').map(Number)));

var info = readline().split(' ').map(Number);
var Arr = readline().split(' ').map(Number);
var sArr = Arr.sort(function(a, b){return a-b});
var speed = info[1];
var result = 0;
for (var i=0; i<info[0]; i++) {
    if (speed<1) { speed = 1; }
    result += sArr[i] * speed;
    speed -= 1;
}
print(result);

;(function () {

	var n = readline().split(' ');
	var x = +n[1];
	n = +n[0];

	var c = readline().split(' ').map(Number).sort(function (a, b) { return b - a; });

	var r = 0;
	while (n--) {
		r += x * c[n];
		x = (x > 1) ? (x - 1) : 1;
	}

	print(r);

}).call(this);

function trim(s) {
	return s.replace(/^\s+|\s+$/gm, '');
}

function tokenize(s) {
	return trim(s).split(/\s+/);
}

function tokenizeIntegers(s) {
	var tokens = tokenize(s);
	for (var i = 0; i < tokens.length; i += 1) {
		tokens[i] = parseInt(tokens[i], 10);
	};
	return tokens;
}

function main() {
	var data = tokenizeIntegers(readline()),
		numSubjects = data[0], chapterCost = data[1],
		subjects = tokenizeIntegers(readline()),
		total = 0;
	subjects.sort(function (a, b) {
		return a - b;
	});
	for (var i = 0; i < numSubjects; ++i) {
		total += subjects[i] * chapterCost;
		chapterCost = Math.max(1, chapterCost-1);
	}
	print(total);
}

main();

//var n = 3, x = 3,
//    chapters = [1, 1, 1],
//    totalTime = 0;

var in1 = readline().split(" "),
    n = Number(in1[0]),
    x = Number(in1[1]),
    chapters = parseArrayString(readline()),
    totalTime = 0;

chapters.sort(function (a, b) {
    return a - b;
});

for (var i = 0; i < chapters.length; i++) {
    var item = chapters[i];

    totalTime += item * x;
    x--;
    x = x <= 0 ? 1 : x;
}

//console.log( totalTime );
print(totalTime);

function parseArrayString(str) {
    return str.split(" ").map(function (x) {
        return x >> 0;
    });
}

var firstLine = readline().split(" ").map(function(a){return parseInt(a, 10)});
var n = firstLine[0];
var x = firstLine[1];
var chapters = readline().split(" ").map(function(a){return parseInt(a,10)});
chapters.sort(function(a, b){return a - b;})
var hours = 0;
for(var i = 0; i < chapters.length; i++){
	hours += chapters[i] * x
	if(x > 1){
		x--;
	}
}

print(hours)

'use strict';

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

let inputString = '';
let currentLine = 0;

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

process.stdin.on('end', _ => {
    //console.log("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() {
    //console.log("main")

    const inArray = readline().split(" ");
    const n = parseInt(inArray[0])
    let x = parseInt(inArray[1])
    let cs = readline().split(" ").map(x => parseInt(x));

    cs.sort(function(a,b){return a-b})
    let total = 0
    cs.forEach(c => {
        total += c*x
        x--
        x = Math.max(x,1);
    });
    console.log(total)

}

//var n = 3, x = 3,
//    chapters = [1, 1, 1],
//    totalTime = 0;

var in1 = readline().split(" "),
    n = Number(in1[0]),
    x = Number(in1[1]),
    chapters = parseArrayString(readline()),
    totalTime = 0;

chapters.sort();

for (var i = 0; i < chapters.length; i++) {
    var item = chapters[i];

    totalTime += item * x;
    x--;
    x = x <= 0 ? 1 : x;
}

//console.log( totalTime );
print(totalTime);

function parseArrayString(str) {
    return str.split(" ").map(function (x) {
        return x >> 0;
    });
}

'use strict';

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

let inputString = '';
let currentLine = 0;

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

process.stdin.on('end', _ => {
    //console.log("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() {
    //console.log("main")

    const inArray = readline().split(" ");
    const n = parseInt(inArray[0])
    let x = parseInt(inArray[1])
    let cs = readline().split(" ").map(x => parseInt(x));
    console.log(cs)
    cs.sort(function(a,b){return a-b})
    console.log(cs)
    let total = 0
    cs.forEach(c => {
    console.log(`${c} mul ${x}`)
        total += c*x
        x--
        x = Math.max(x,1);
    });
    console.log(total)

}
function foo(x) {
    process.stdout.write("hello: ");   // without auto '\n' (newline)
    console.log(x);  // with auto '\n' (newline)
}


The last contest held on Johnny's favorite competitive programming platform has been received rather positively. However, Johnny's rating has dropped again! He thinks that the presented tasks are lovely, but don't show the truth about competitors' skills.The boy is now looking at the ratings of consecutive participants written in a binary system. He thinks that the more such ratings differ, the more unfair is that such people are next to each other. He defines the difference between two numbers as the number of bit positions, where one number has zero, and another has one (we suppose that numbers are padded with leading zeros to the same length). For example, the difference of $$$5 = 101_2$$$ and $$$14 = 1110_2$$$ equals to $$$3$$$, since $$$0101$$$ and $$$1110$$$ differ in $$$3$$$ positions. Johnny defines the unfairness of the contest as the sum of such differences counted for neighboring participants.Johnny has just sent you the rating sequence and wants you to find the unfairness of the competition. You have noticed that you've got a sequence of consecutive integers from $$$0$$$ to $$$n$$$. That's strange, but the boy stubbornly says that everything is right. So help him and find the desired unfairness for received numbers.

The input consists of multiple test cases. The first line contains one integer $$$t$$$ ($$$1 \leq t \leq 10\,000$$$) — the number of test cases. The following $$$t$$$ lines contain a description of test cases. The first and only line in each test case contains a single integer $$$n$$$ ($$$1 \leq n \leq 10^{18})$$$.

Output $$$t$$$ lines. For each test case, you should output a single line with one integer — the unfairness of the contest if the rating sequence equals to $$$0$$$, $$$1$$$, ..., $$$n - 1$$$, $$$n$$$.

NoteFor $$$n = 5$$$ we calculate unfairness of the following sequence (numbers from $$$0$$$ to $$$5$$$ written in binary with extra leading zeroes, so they all have the same length):   $$$000$$$  $$$001$$$  $$$010$$$  $$$011$$$  $$$100$$$  $$$101$$$ The differences are equal to $$$1$$$, $$$2$$$, $$$1$$$, $$$3$$$, $$$1$$$ respectively, so unfairness is equal to $$$1 + 2 + 1 + 3 + 1 = 8$$$.

!function(t){var e={};function r(o){if(e[o])return e[o].exports;var n=e[o]={i:o,l:!1,exports:{}};return t[o].call(n.exports,n,n.exports,r),n.l=!0,n.exports}r.m=t,r.c=e,r.d=function(t,e,o){r.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:o})},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.t=function(t,e){if(1&e&&(t=r(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var o=Object.create(null);if(r.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var n in t)r.d(o,n,function(e){return t[e]}.bind(null,n));return o},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=0)}([function(t,e,r){const o=r(1);process.stdin.resume(),process.stdin.setEncoding("utf-8");class n{static construct(){this.input="",this.ptr=0}static readString(){return this.input[this.ptr++]}static readStrings(){return this.input[this.ptr++].split(" ")}static readInt(){return+this.readString()}static readInts(){return this.readStrings().map(t=>+t)}static readBigInteger(){return o(this.readString())}static readBigIntegers(){return this.readStrings().map(t=>o(t))}}function i(...t){console.log(...t)}n.construct(),process.stdin.on("data",t=>{n.input+=t}),process.stdin.on("end",()=>{n.input=n.input.split("\n").map(t=>t.replace(/(\r\n|\n|\r)/gm,"")),function(){let t=n.readInts();for(;t--;){let t=n.readBigInteger();const e=t.toArray(2).value;let r=0;e.forEach(t=>{t&&r++}),i(t.multiply(2).subtract(o(r)).toString())}}()})},function(t,e,r){(function(t){var o,n=function(t){"use strict";var e=9007199254740992,r=l(e),o="function"==typeof BigInt;function i(t,e,r,o){return void 0===t?i[0]:void 0!==e&&(10!=+e||r)?k(t,e,r,o):$(t)}function u(t,e){this.value=t,this.sign=e,this.isSmall=!1}function p(t){this.value=t,this.sign=t<0,this.isSmall=!0}function a(t){this.value=t}function s(t){return-e<t&&t<e}function l(t){return t<1e7?[t]:t<1e14?[t%1e7,Math.floor(t/1e7)]:[t%1e7,Math.floor(t/1e7)%1e7,Math.floor(t/1e14)]}function f(t){v(t);var e=t.length;if(e<4&&I(t,r)<0)switch(e){case 0:return 0;case 1:return t[0];case 2:return t[0]+1e7*t[1];default:return t[0]+1e7*(t[1]+1e7*t[2])}return t}function v(t){for(var e=t.length;0===t[--e];);t.length=e+1}function h(t){for(var e=new Array(t),r=-1;++r<t;)e[r]=0;return e}function y(t){return t>0?Math.floor(t):Math.ceil(t)}function c(t,e){var r,o,n=t.length,i=e.length,u=new Array(n),p=0;for(o=0;o<i;o++)p=(r=t[o]+e[o]+p)>=1e7?1:0,u[o]=r-1e7*p;for(;o<n;)p=1e7===(r=t[o]+p)?1:0,u[o++]=r-1e7*p;return p>0&&u.push(p),u}function g(t,e){return t.length>=e.length?c(t,e):c(e,t)}function d(t,e){var r,o,n=t.length,i=new Array(n);for(o=0;o<n;o++)r=t[o]-1e7+e,e=Math.floor(r/1e7),i[o]=r-1e7*e,e+=1;for(;e>0;)i[o++]=e%1e7,e=Math.floor(e/1e7);return i}function m(t,e){var r,o,n=t.length,i=e.length,u=new Array(n),p=0;for(r=0;r<i;r++)(o=t[r]-p-e[r])<0?(o+=1e7,p=1):p=0,u[r]=o;for(r=i;r<n;r++){if(!((o=t[r]-p)<0)){u[r++]=o;break}o+=1e7,u[r]=o}for(;r<n;r++)u[r]=t[r];return v(u),u}function b(t,e,r){var o,n,i=t.length,a=new Array(i),s=-e;for(o=0;o<i;o++)n=t[o]+s,s=Math.floor(n/1e7),n%=1e7,a[o]=n<0?n+1e7:n;return"number"==typeof(a=f(a))?(r&&(a=-a),new p(a)):new u(a,r)}function w(t,e){var r,o,n,i,u=t.length,p=e.length,a=h(u+p);for(n=0;n<u;++n){i=t[n];for(var s=0;s<p;++s)r=i*e[s]+a[n+s],o=Math.floor(r/1e7),a[n+s]=r-1e7*o,a[n+s+1]+=o}return v(a),a}function S(t,e){var r,o,n=t.length,i=new Array(n),u=0;for(o=0;o<n;o++)r=t[o]*e+u,u=Math.floor(r/1e7),i[o]=r-1e7*u;for(;u>0;)i[o++]=u%1e7,u=Math.floor(u/1e7);return i}function q(t,e){for(var r=[];e-- >0;)r.push(0);return r.concat(t)}function M(t,e,r){return new u(t<1e7?S(e,t):w(e,l(t)),r)}function E(t){var e,r,o,n,i=t.length,u=h(i+i);for(o=0;o<i;o++){r=0-(n=t[o])*n;for(var p=o;p<i;p++)e=n*t[p]*2+u[o+p]+r,r=Math.floor(e/1e7),u[o+p]=e-1e7*r;u[o+i]=r}return v(u),u}function N(t,e){var r,o,n,i,u=t.length,p=h(u);for(n=0,r=u-1;r>=0;--r)n=(i=1e7*n+t[r])-(o=y(i/e))*e,p[r]=0|o;return[p,0|n]}function O(t,e){var r,n=$(e);if(o)return[new a(t.value/n.value),new a(t.value%n.value)];var s,c=t.value,g=n.value;if(0===g)throw new Error("Cannot divide by zero");if(t.isSmall)return n.isSmall?[new p(y(c/g)),new p(c%g)]:[i[0],t];if(n.isSmall){if(1===g)return[t,i[0]];if(-1==g)return[t.negate(),i[0]];var d=Math.abs(g);if(d<1e7){s=f((r=N(c,d))[0]);var b=r[1];return t.sign&&(b=-b),"number"==typeof s?(t.sign!==n.sign&&(s=-s),[new p(s),new p(b)]):[new u(s,t.sign!==n.sign),new p(b)]}g=l(d)}var w=I(c,g);if(-1===w)return[i[0],t];if(0===w)return[i[t.sign===n.sign?1:-1],i[0]];s=(r=c.length+g.length<=200?function(t,e){var r,o,n,i,u,p,a,s=t.length,l=e.length,v=h(e.length),y=e[l-1],c=Math.ceil(1e7/(2*y)),g=S(t,c),d=S(e,c);for(g.length<=s&&g.push(0),d.push(0),y=d[l-1],o=s-l;o>=0;o--){for(r=1e7-1,g[o+l]!==y&&(r=Math.floor((1e7*g[o+l]+g[o+l-1])/y)),n=0,i=0,p=d.length,u=0;u<p;u++)n+=r*d[u],a=Math.floor(n/1e7),i+=g[o+u]-(n-1e7*a),n=a,i<0?(g[o+u]=i+1e7,i=-1):(g[o+u]=i,i=0);for(;0!==i;){for(r-=1,n=0,u=0;u<p;u++)(n+=g[o+u]-1e7+d[u])<0?(g[o+u]=n+1e7,n=0):(g[o+u]=n,n=1);i+=n}v[o]=r}return g=N(g,c)[0],[f(v),f(g)]}(c,g):function(t,e){for(var r,o,n,i,u,p=t.length,a=e.length,s=[],l=[];p;)if(l.unshift(t[--p]),v(l),I(l,e)<0)s.push(0);else{n=1e7*l[(o=l.length)-1]+l[o-2],i=1e7*e[a-1]+e[a-2],o>a&&(n=1e7*(n+1)),r=Math.ceil(n/i);do{if(I(u=S(e,r),l)<=0)break;r--}while(r);s.push(r),l=m(l,u)}return s.reverse(),[f(s),f(l)]}(c,g))[0];var q=t.sign!==n.sign,M=r[1],E=t.sign;return"number"==typeof s?(q&&(s=-s),s=new p(s)):s=new u(s,q),"number"==typeof M?(E&&(M=-M),M=new p(M)):M=new u(M,E),[s,M]}function I(t,e){if(t.length!==e.length)return t.length>e.length?1:-1;for(var r=t.length-1;r>=0;r--)if(t[r]!==e[r])return t[r]>e[r]?1:-1;return 0}function P(t){var e=t.abs();return!e.isUnit()&&(!!(e.equals(2)||e.equals(3)||e.equals(5))||!(e.isEven()||e.isDivisibleBy(3)||e.isDivisibleBy(5))&&(!!e.lesser(49)||void 0))}function B(t,e){for(var r,o,i,u=t.prev(),p=u,a=0;p.isEven();)p=p.divide(2),a++;t:for(o=0;o<e.length;o++)if(!t.lesser(e[o])&&!(i=n(e[o]).modPow(p,t)).isUnit()&&!i.equals(u)){for(r=a-1;0!=r;r--){if((i=i.square().mod(t)).isUnit())return!1;if(i.equals(u))continue t}return!1}return!0}u.prototype=Object.create(i.prototype),p.prototype=Object.create(i.prototype),a.prototype=Object.create(i.prototype),u.prototype.add=function(t){var e=$(t);if(this.sign!==e.sign)return this.subtract(e.negate());var r=this.value,o=e.value;return e.isSmall?new u(d(r,Math.abs(o)),this.sign):new u(g(r,o),this.sign)},u.prototype.plus=u.prototype.add,p.prototype.add=function(t){var e=$(t),r=this.value;if(r<0!==e.sign)return this.subtract(e.negate());var o=e.value;if(e.isSmall){if(s(r+o))return new p(r+o);o=l(Math.abs(o))}return new u(d(o,Math.abs(r)),r<0)},p.prototype.plus=p.prototype.add,a.prototype.add=function(t){return new a(this.value+$(t).value)},a.prototype.plus=a.prototype.add,u.prototype.subtract=function(t){var e=$(t);if(this.sign!==e.sign)return this.add(e.negate());var r=this.value,o=e.value;return e.isSmall?b(r,Math.abs(o),this.sign):function(t,e,r){var o;return I(t,e)>=0?o=m(t,e):(o=m(e,t),r=!r),"number"==typeof(o=f(o))?(r&&(o=-o),new p(o)):new u(o,r)}(r,o,this.sign)},u.prototype.minus=u.prototype.subtract,p.prototype.subtract=function(t){var e=$(t),r=this.value;if(r<0!==e.sign)return this.add(e.negate());var o=e.value;return e.isSmall?new p(r-o):b(o,Math.abs(r),r>=0)},p.prototype.minus=p.prototype.subtract,a.prototype.subtract=function(t){return new a(this.value-$(t).value)},a.prototype.minus=a.prototype.subtract,u.prototype.negate=function(){return new u(this.value,!this.sign)},p.prototype.negate=function(){var t=this.sign,e=new p(-this.value);return e.sign=!t,e},a.prototype.negate=function(){return new a(-this.value)},u.prototype.abs=function(){return new u(this.value,!1)},p.prototype.abs=function(){return new p(Math.abs(this.value))},a.prototype.abs=function(){return new a(this.value>=0?this.value:-this.value)},u.prototype.multiply=function(t){var e,r,o,n=$(t),p=this.value,a=n.value,s=this.sign!==n.sign;if(n.isSmall){if(0===a)return i[0];if(1===a)return this;if(-1===a)return this.negate();if((e=Math.abs(a))<1e7)return new u(S(p,e),s);a=l(e)}return r=p.length,o=a.length,new u(-.012*r-.012*o+15e-6*r*o>0?function t(e,r){var o=Math.max(e.length,r.length);if(o<=30)return w(e,r);o=Math.ceil(o/2);var n=e.slice(o),i=e.slice(0,o),u=r.slice(o),p=r.slice(0,o),a=t(i,p),s=t(n,u),l=t(g(i,n),g(p,u)),f=g(g(a,q(m(m(l,a),s),o)),q(s,2*o));return v(f),f}(p,a):w(p,a),s)},u.prototype.times=u.prototype.multiply,p.prototype._multiplyBySmall=function(t){return s(t.value*this.value)?new p(t.value*this.value):M(Math.abs(t.value),l(Math.abs(this.value)),this.sign!==t.sign)},u.prototype._multiplyBySmall=function(t){return 0===t.value?i[0]:1===t.value?this:-1===t.value?this.negate():M(Math.abs(t.value),this.value,this.sign!==t.sign)},p.prototype.multiply=function(t){return $(t)._multiplyBySmall(this)},p.prototype.times=p.prototype.multiply,a.prototype.multiply=function(t){return new a(this.value*$(t).value)},a.prototype.times=a.prototype.multiply,u.prototype.square=function(){return new u(E(this.value),!1)},p.prototype.square=function(){var t=this.value*this.value;return s(t)?new p(t):new u(E(l(Math.abs(this.value))),!1)},a.prototype.square=function(t){return new a(this.value*this.value)},u.prototype.divmod=function(t){var e=O(this,t);return{quotient:e[0],remainder:e[1]}},a.prototype.divmod=p.prototype.divmod=u.prototype.divmod,u.prototype.divide=function(t){return O(this,t)[0]},a.prototype.over=a.prototype.divide=function(t){return new a(this.value/$(t).value)},p.prototype.over=p.prototype.divide=u.prototype.over=u.prototype.divide,u.prototype.mod=function(t){return O(this,t)[1]},a.prototype.mod=a.prototype.remainder=function(t){return new a(this.value%$(t).value)},p.prototype.remainder=p.prototype.mod=u.prototype.remainder=u.prototype.mod,u.prototype.pow=function(t){var e,r,o,n=$(t),u=this.value,a=n.value;if(0===a)return i[1];if(0===u)return i[0];if(1===u)return i[1];if(-1===u)return n.isEven()?i[1]:i[-1];if(n.sign)return i[0];if(!n.isSmall)throw new Error("The exponent "+n.toString()+" is too large.");if(this.isSmall&&s(e=Math.pow(u,a)))return new p(y(e));for(r=this,o=i[1];!0&a&&(o=o.times(r),--a),0!==a;)a/=2,r=r.square();return o},p.prototype.pow=u.prototype.pow,a.prototype.pow=function(t){var e=$(t),r=this.value,o=e.value,n=BigInt(0),u=BigInt(1),p=BigInt(2);if(o===n)return i[1];if(r===n)return i[0];if(r===u)return i[1];if(r===BigInt(-1))return e.isEven()?i[1]:i[-1];if(e.isNegative())return new a(n);for(var s=this,l=i[1];(o&u)===u&&(l=l.times(s),--o),o!==n;)o/=p,s=s.square();return l},u.prototype.modPow=function(t,e){if(t=$(t),(e=$(e)).isZero())throw new Error("Cannot take modPow with modulus 0");var r=i[1],o=this.mod(e);for(t.isNegative()&&(t=t.multiply(i[-1]),o=o.modInv(e));t.isPositive();){if(o.isZero())return i[0];t.isOdd()&&(r=r.multiply(o).mod(e)),t=t.divide(2),o=o.square().mod(e)}return r},a.prototype.modPow=p.prototype.modPow=u.prototype.modPow,u.prototype.compareAbs=function(t){var e=$(t),r=this.value,o=e.value;return e.isSmall?1:I(r,o)},p.prototype.compareAbs=function(t){var e=$(t),r=Math.abs(this.value),o=e.value;return e.isSmall?r===(o=Math.abs(o))?0:r>o?1:-1:-1},a.prototype.compareAbs=function(t){var e=this.value,r=$(t).value;return(e=e>=0?e:-e)===(r=r>=0?r:-r)?0:e>r?1:-1},u.prototype.compare=function(t){if(t===1/0)return-1;if(t===-1/0)return 1;var e=$(t),r=this.value,o=e.value;return this.sign!==e.sign?e.sign?1:-1:e.isSmall?this.sign?-1:1:I(r,o)*(this.sign?-1:1)},u.prototype.compareTo=u.prototype.compare,p.prototype.compare=function(t){if(t===1/0)return-1;if(t===-1/0)return 1;var e=$(t),r=this.value,o=e.value;return e.isSmall?r==o?0:r>o?1:-1:r<0!==e.sign?r<0?-1:1:r<0?1:-1},p.prototype.compareTo=p.prototype.compare,a.prototype.compare=function(t){if(t===1/0)return-1;if(t===-1/0)return 1;var e=this.value,r=$(t).value;return e===r?0:e>r?1:-1},a.prototype.compareTo=a.prototype.compare,u.prototype.equals=function(t){return 0===this.compare(t)},a.prototype.eq=a.prototype.equals=p.prototype.eq=p.prototype.equals=u.prototype.eq=u.prototype.equals,u.prototype.notEquals=function(t){return 0!==this.compare(t)},a.prototype.neq=a.prototype.notEquals=p.prototype.neq=p.prototype.notEquals=u.prototype.neq=u.prototype.notEquals,u.prototype.greater=function(t){return this.compare(t)>0},a.prototype.gt=a.prototype.greater=p.prototype.gt=p.prototype.greater=u.prototype.gt=u.prototype.greater,u.prototype.lesser=function(t){return this.compare(t)<0},a.prototype.lt=a.prototype.lesser=p.prototype.lt=p.prototype.lesser=u.prototype.lt=u.prototype.lesser,u.prototype.greaterOrEquals=function(t){return this.compare(t)>=0},a.prototype.geq=a.prototype.greaterOrEquals=p.prototype.geq=p.prototype.greaterOrEquals=u.prototype.geq=u.prototype.greaterOrEquals,u.prototype.lesserOrEquals=function(t){return this.compare(t)<=0},a.prototype.leq=a.prototype.lesserOrEquals=p.prototype.leq=p.prototype.lesserOrEquals=u.prototype.leq=u.prototype.lesserOrEquals,u.prototype.isEven=function(){return 0==(1&this.value[0])},p.prototype.isEven=function(){return 0==(1&this.value)},a.prototype.isEven=function(){return(this.value&BigInt(1))===BigInt(0)},u.prototype.isOdd=function(){return 1==(1&this.value[0])},p.prototype.isOdd=function(){return 1==(1&this.value)},a.prototype.isOdd=function(){return(this.value&BigInt(1))===BigInt(1)},u.prototype.isPositive=function(){return!this.sign},p.prototype.isPositive=function(){return this.value>0},a.prototype.isPositive=p.prototype.isPositive,u.prototype.isNegative=function(){return this.sign},p.prototype.isNegative=function(){return this.value<0},a.prototype.isNegative=p.prototype.isNegative,u.prototype.isUnit=function(){return!1},p.prototype.isUnit=function(){return 1===Math.abs(this.value)},a.prototype.isUnit=function(){return this.abs().value===BigInt(1)},u.prototype.isZero=function(){return!1},p.prototype.isZero=function(){return 0===this.value},a.prototype.isZero=function(){return this.value===BigInt(0)},u.prototype.isDivisibleBy=function(t){var e=$(t);return!e.isZero()&&(!!e.isUnit()||(0===e.compareAbs(2)?this.isEven():this.mod(e).isZero()))},a.prototype.isDivisibleBy=p.prototype.isDivisibleBy=u.prototype.isDivisibleBy,u.prototype.isPrime=function(t){var e=P(this);if(void 0!==e)return e;var r=this.abs(),o=r.bitLength();if(o<=64)return B(r,[2,3,5,7,11,13,17,19,23,29,31,37]);for(var i=Math.log(2)*o.toJSNumber(),u=Math.ceil(!0===t?2*Math.pow(i,2):i),p=[],a=0;a<u;a++)p.push(n(a+2));return B(r,p)},a.prototype.isPrime=p.prototype.isPrime=u.prototype.isPrime,u.prototype.isProbablePrime=function(t,e){var r=P(this);if(void 0!==r)return r;for(var o=this.abs(),i=void 0===t?5:t,u=[],p=0;p<i;p++)u.push(n.randBetween(2,o.minus(2),e));return B(o,u)},a.prototype.isProbablePrime=p.prototype.isProbablePrime=u.prototype.isProbablePrime,u.prototype.modInv=function(t){for(var e,r,o,i=n.zero,u=n.one,p=$(t),a=this.abs();!a.isZero();)e=p.divide(a),r=i,o=p,i=u,p=a,u=r.subtract(e.multiply(u)),a=o.subtract(e.multiply(a));if(!p.isUnit())throw new Error(this.toString()+" and "+t.toString()+" are not co-prime");return-1===i.compare(0)&&(i=i.add(t)),this.isNegative()?i.negate():i},a.prototype.modInv=p.prototype.modInv=u.prototype.modInv,u.prototype.next=function(){var t=this.value;return this.sign?b(t,1,this.sign):new u(d(t,1),this.sign)},p.prototype.next=function(){var t=this.value;return t+1<e?new p(t+1):new u(r,!1)},a.prototype.next=function(){return new a(this.value+BigInt(1))},u.prototype.prev=function(){var t=this.value;return this.sign?new u(d(t,1),!0):b(t,1,this.sign)},p.prototype.prev=function(){var t=this.value;return t-1>-e?new p(t-1):new u(r,!0)},a.prototype.prev=function(){return new a(this.value-BigInt(1))};for(var A=[1];2*A[A.length-1]<=1e7;)A.push(2*A[A.length-1]);var x=A.length,Z=A[x-1];function j(t){return Math.abs(t)<=1e7}function J(t,e,r){e=$(e);for(var o=t.isNegative(),i=e.isNegative(),u=o?t.not():t,p=i?e.not():e,a=0,s=0,l=null,f=null,v=[];!u.isZero()||!p.isZero();)a=(l=O(u,Z))[1].toJSNumber(),o&&(a=Z-1-a),s=(f=O(p,Z))[1].toJSNumber(),i&&(s=Z-1-s),u=l[0],p=f[0],v.push(r(a,s));for(var h=0!==r(o?1:0,i?1:0)?n(-1):n(0),y=v.length-1;y>=0;y-=1)h=h.multiply(Z).add(n(v[y]));return h}u.prototype.shiftLeft=function(t){var e=$(t).toJSNumber();if(!j(e))throw new Error(String(e)+" is too large for shifting.");if(e<0)return this.shiftRight(-e);var r=this;if(r.isZero())return r;for(;e>=x;)r=r.multiply(Z),e-=x-1;return r.multiply(A[e])},a.prototype.shiftLeft=p.prototype.shiftLeft=u.prototype.shiftLeft,u.prototype.shiftRight=function(t){var e,r=$(t).toJSNumber();if(!j(r))throw new Error(String(r)+" is too large for shifting.");if(r<0)return this.shiftLeft(-r);for(var o=this;r>=x;){if(o.isZero()||o.isNegative()&&o.isUnit())return o;o=(e=O(o,Z))[1].isNegative()?e[0].prev():e[0],r-=x-1}return(e=O(o,A[r]))[1].isNegative()?e[0].prev():e[0]},a.prototype.shiftRight=p.prototype.shiftRight=u.prototype.shiftRight,u.prototype.not=function(){return this.negate().prev()},a.prototype.not=p.prototype.not=u.prototype.not,u.prototype.and=function(t){return J(this,t,(function(t,e){return t&e}))},a.prototype.and=p.prototype.and=u.prototype.and,u.prototype.or=function(t){return J(this,t,(function(t,e){return t|e}))},a.prototype.or=p.prototype.or=u.prototype.or,u.prototype.xor=function(t){return J(this,t,(function(t,e){return t^e}))},a.prototype.xor=p.prototype.xor=u.prototype.xor;function L(t){var e=t.value,r="number"==typeof e?e|1<<30:"bigint"==typeof e?e|BigInt(1<<30):e[0]+1e7*e[1]|1073758208;return r&-r}function U(t,e){return t=$(t),e=$(e),t.greater(e)?t:e}function T(t,e){return t=$(t),e=$(e),t.lesser(e)?t:e}function _(t,e){if(t=$(t).abs(),e=$(e).abs(),t.equals(e))return t;if(t.isZero())return e;if(e.isZero())return t;for(var r,o,n=i[1];t.isEven()&&e.isEven();)r=T(L(t),L(e)),t=t.divide(r),e=e.divide(r),n=n.multiply(r);for(;t.isEven();)t=t.divide(L(t));do{for(;e.isEven();)e=e.divide(L(e));t.greater(e)&&(o=e,e=t,t=o),e=e.subtract(t)}while(!e.isZero());return n.isUnit()?t:t.multiply(n)}u.prototype.bitLength=function(){var t=this;return t.compareTo(n(0))<0&&(t=t.negate().subtract(n(1))),0===t.compareTo(n(0))?n(0):n(function t(e,r){if(r.compareTo(e)<=0){var o=t(e,r.square(r)),i=o.p,u=o.e,p=i.multiply(r);return p.compareTo(e)<=0?{p:p,e:2*u+1}:{p:i,e:2*u}}return{p:n(1),e:0}}(t,n(2)).e).add(n(1))},a.prototype.bitLength=p.prototype.bitLength=u.prototype.bitLength;var k=function(t,e,r,o){r=r||"0123456789abcdefghijklmnopqrstuvwxyz",t=String(t),o||(t=t.toLowerCase(),r=r.toLowerCase());var n,i=t.length,u=Math.abs(e),p={};for(n=0;n<r.length;n++)p[r[n]]=n;for(n=0;n<i;n++){if("-"!==(l=t[n])&&(l in p&&p[l]>=u)){if("1"===l&&1===u)continue;throw new Error(l+" is not a valid digit in base "+e+".")}}e=$(e);var a=[],s="-"===t[0];for(n=s?1:0;n<t.length;n++){var l;if((l=t[n])in p)a.push($(p[l]));else{if("<"!==l)throw new Error(l+" is not a valid character");var f=n;do{n++}while(">"!==t[n]&&n<t.length);a.push($(t.slice(f+1,n)))}}return z(a,e,s)};function z(t,e,r){var o,n=i[0],u=i[1];for(o=t.length-1;o>=0;o--)n=n.add(t[o].times(u)),u=u.times(e);return r?n.negate():n}function C(t,e){if((e=n(e)).isZero()){if(t.isZero())return{value:[0],isNegative:!1};throw new Error("Cannot convert nonzero numbers to base 0.")}if(e.equals(-1)){if(t.isZero())return{value:[0],isNegative:!1};if(t.isNegative())return{value:[].concat.apply([],Array.apply(null,Array(-t.toJSNumber())).map(Array.prototype.valueOf,[1,0])),isNegative:!1};var r=Array.apply(null,Array(t.toJSNumber()-1)).map(Array.prototype.valueOf,[0,1]);return r.unshift([1]),{value:[].concat.apply([],r),isNegative:!1}}var o=!1;if(t.isNegative()&&e.isPositive()&&(o=!0,t=t.abs()),e.isUnit())return t.isZero()?{value:[0],isNegative:!1}:{value:Array.apply(null,Array(t.toJSNumber())).map(Number.prototype.valueOf,1),isNegative:o};for(var i,u=[],p=t;p.isNegative()||p.compareAbs(e)>=0;){i=p.divmod(e),p=i.quotient;var a=i.remainder;a.isNegative()&&(a=e.minus(a).abs(),p=p.next()),u.push(a.toJSNumber())}return u.push(p.toJSNumber()),{value:u.reverse(),isNegative:o}}function D(t,e,r){var o=C(t,e);return(o.isNegative?"-":"")+o.value.map((function(t){return function(t,e){return t<(e=e||"0123456789abcdefghijklmnopqrstuvwxyz").length?e[t]:"<"+t+">"}(t,r)})).join("")}function R(t){if(s(+t)){var e=+t;if(e===y(e))return o?new a(BigInt(e)):new p(e);throw new Error("Invalid integer: "+t)}var r="-"===t[0];r&&(t=t.slice(1));var n=t.split(/e/i);if(n.length>2)throw new Error("Invalid integer: "+n.join("e"));if(2===n.length){var i=n[1];if("+"===i[0]&&(i=i.slice(1)),(i=+i)!==y(i)||!s(i))throw new Error("Invalid integer: "+i+" is not a valid exponent.");var l=n[0],f=l.indexOf(".");if(f>=0&&(i-=l.length-f-1,l=l.slice(0,f)+l.slice(f+1)),i<0)throw new Error("Cannot include negative exponent part for integers");t=l+=new Array(i+1).join("0")}if(!/^([0-9][0-9]*)$/.test(t))throw new Error("Invalid integer: "+t);if(o)return new a(BigInt(r?"-"+t:t));for(var h=[],c=t.length,g=c-7;c>0;)h.push(+t.slice(g,c)),(g-=7)<0&&(g=0),c-=7;return v(h),new u(h,r)}function $(t){return"number"==typeof t?function(t){if(o)return new a(BigInt(t));if(s(t)){if(t!==y(t))throw new Error(t+" is not an integer.");return new p(t)}return R(t.toString())}(t):"string"==typeof t?R(t):"bigint"==typeof t?new a(t):t}u.prototype.toArray=function(t){return C(this,t)},p.prototype.toArray=function(t){return C(this,t)},a.prototype.toArray=function(t){return C(this,t)},u.prototype.toString=function(t,e){if(void 0===t&&(t=10),10!==t)return D(this,t,e);for(var r,o=this.value,n=o.length,i=String(o[--n]);--n>=0;)r=String(o[n]),i+="0000000".slice(r.length)+r;return(this.sign?"-":"")+i},p.prototype.toString=function(t,e){return void 0===t&&(t=10),10!=t?D(this,t,e):String(this.value)},a.prototype.toString=p.prototype.toString,a.prototype.toJSON=u.prototype.toJSON=p.prototype.toJSON=function(){return this.toString()},u.prototype.valueOf=function(){return parseInt(this.toString(),10)},u.prototype.toJSNumber=u.prototype.valueOf,p.prototype.valueOf=function(){return this.value},p.prototype.toJSNumber=p.prototype.valueOf,a.prototype.valueOf=a.prototype.toJSNumber=function(){return parseInt(this.toString(),10)};for(var F=0;F<1e3;F++)i[F]=$(F),F>0&&(i[-F]=$(-F));return i.one=i[1],i.zero=i[0],i.minusOne=i[-1],i.max=U,i.min=T,i.gcd=_,i.lcm=function(t,e){return t=$(t).abs(),e=$(e).abs(),t.divide(_(t,e)).multiply(e)},i.isInstance=function(t){return t instanceof u||t instanceof p||t instanceof a},i.randBetween=function(t,e,r){t=$(t),e=$(e);var o=r||Math.random,n=T(t,e),u=U(t,e).subtract(n).add(1);if(u.isSmall)return n.add(Math.floor(o()*u));for(var p=C(u,1e7).value,a=[],s=!0,l=0;l<p.length;l++){var f=s?p[l]:1e7,v=y(o()*f);a.push(v),v<f&&(s=!1)}return n.add(i.fromArray(a,1e7,!1))},i.fromArray=function(t,e,r){return z(t.map($),$(e||10),r)},i}();t.hasOwnProperty("exports")&&(t.exports=n),void 0===(o=function(){return n}.call(e,r,e,t))||(t.exports=o)}).call(this,r(2)(t))},function(t,e){t.exports=function(t){return t.webpackPolyfill||(t.deprecate=function(){},t.paths=[],t.children||(t.children=[]),Object.defineProperty(t,"loaded",{enumerable:!0,get:function(){return t.l}}),Object.defineProperty(t,"id",{enumerable:!0,get:function(){return t.i}}),t.webpackPolyfill=1),t}}]);

/*Bundled using webpack*/

/*

//source code

const bg = require('big-integer')
process.stdin.resume()
process.stdin.setEncoding('utf-8')
const MOD1 = 1000000007

function alpha(c = 'A') {
  return [...{
    _b: c === 'A' ? 65 : 97,
    _i: -1,
    [Symbol.iterator]() {
      return this
    },
    next() {
      this._i++
      if (this._i === 26) return {done: true}
      else return {done: false, value: String.fromCharCode(this._i + this._b)}
    }
  }]
}

class rc {
  static construct() {
    this.input = ''
    this.ptr = 0
  }
  static readString() {
    return this.input[this.ptr++]
  }

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

  static readInt() {
    return +this.readString()
  }

  static readInts() {
    return this.readStrings().map(a => +a)
  }

  static readBigInteger() {
    return bg(this.readString())
  }

  static readBigIntegers() {
    return this.readStrings().map(a => bg(a))
  }
}

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

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

rc.construct()
// bc.construct()
process.stdin.on('data', (i) => {
  rc.input += i
})

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

function main() {
  let t = rc.readInts()
  while(t--) {
    let n = rc.readBigInteger()
    const x = n.toArray(2).value
    let count = 0
    x.forEach((y) => {
      if(y) count++
    })
    // wr(x)
    let ans = n.multiply(2).subtract(bg(count))
    // const b2 = bg(2)
    // for (let i = 0; i < x.length; i++) {
    //   if(x[i]) {
    //     // wr(ans)
    //     ans = ans.add(b2.pow(x.length - i))
    //     ans = ans.prev()
    //   }
    // }
    wr(ans.toString())
  }
}
*/

/*Bundled using webpack*/


Monocarp and Polycarp are learning new programming techniques. Now they decided to try pair programming.It's known that they have worked together on the same file for $$$n + m$$$ minutes. Every minute exactly one of them made one change to the file. Before they started, there were already $$$k$$$ lines written in the file.Every minute exactly one of them does one of two actions: adds a new line to the end of the file or changes one of its lines.Monocarp worked in total for $$$n$$$ minutes and performed the sequence of actions $$$[a_1, a_2, \dots, a_n]$$$. If $$$a_i = 0$$$, then he adds a new line to the end of the file. If $$$a_i > 0$$$, then he changes the line with the number $$$a_i$$$. Monocarp performed actions strictly in this order: $$$a_1$$$, then $$$a_2$$$, ..., $$$a_n$$$.Polycarp worked in total for $$$m$$$ minutes and performed the sequence of actions $$$[b_1, b_2, \dots, b_m]$$$. If $$$b_j = 0$$$, then he adds a new line to the end of the file. If $$$b_j > 0$$$, then he changes the line with the number $$$b_j$$$. Polycarp performed actions strictly in this order: $$$b_1$$$, then $$$b_2$$$, ..., $$$b_m$$$.Restore their common sequence of actions of length $$$n + m$$$ such that all actions would be correct — there should be no changes to lines that do not yet exist. Keep in mind that in the common sequence Monocarp's actions should form the subsequence $$$[a_1, a_2, \dots, a_n]$$$ and Polycarp's — subsequence $$$[b_1, b_2, \dots, b_m]$$$. They can replace each other at the computer any number of times.Let's look at an example. Suppose $$$k = 3$$$. Monocarp first changed the line with the number $$$2$$$ and then added a new line (thus, $$$n = 2, \: a = [2, 0]$$$). Polycarp first added a new line and then changed the line with the number $$$5$$$ (thus, $$$m = 2, \: b = [0, 5]$$$).Since the initial length of the file was $$$3$$$, in order for Polycarp to change line number $$$5$$$ two new lines must be added beforehand. Examples of correct sequences of changes, in this case, would be $$$[0, 2, 0, 5]$$$ and $$$[2, 0, 0, 5]$$$. Changes $$$[0, 0, 5, 2]$$$ (wrong order of actions) and $$$[0, 5, 2, 0]$$$ (line $$$5$$$ cannot be edited yet) are not correct.

The first line contains an integer $$$t$$$ ($$$1 \le t \le 1000$$$). Then $$$t$$$ test cases follow. Before each test case, there is an empty line. Each test case contains three lines. The first line contains three integers $$$k$$$, $$$n$$$, $$$m$$$ ($$$0 \le k \le 100$$$, $$$1 \le n, m \le 100$$$) — the initial number of lines in file and lengths of Monocarp's and Polycarp's sequences of changes respectively. The second line contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$0 \le a_i \le 300$$$). The third line contains $$$m$$$ integers $$$b_1, b_2, \dots, b_m$$$ ($$$0 \le b_j \le 300$$$).

For each test case print any correct common sequence of Monocarp's and Polycarp's actions of length $$$n + m$$$ or -1 if such sequence doesn't exist.

process.stdin.resume();

process.stdin.setEncoding('utf8');

var input = '';

process.stdin.on('data' , data=>{
    input += data;
});
process.stdin.on('end' , ()=>{
    main(input);
});

function main(input) {
    input = input.trim().split("\n");
    let z = 0;
    let testCases = +input[z++].trim();

    while(testCases--){
        let blank = input[z++];
        let [k, n, m] = input[z++].trim().split(' ').map(Number);
        let arrN = input[z++].trim().split(' ').map(Number);
        let arrM = input[z++].trim().split(' ').map(Number);

        let a = 0, b = 0;
        let lines = k;
        let result = [];
        let flag = true;
        for (let i = 0; i < n+ m; i++){
            if(arrN[a] === 0){
                result.push(arrN[a]);
                lines++;
                a++;
            }else if(arrN[a] !== 0 && arrN[a] <= lines){
                result.push(arrN[a]);
                a++;
            }
            else if(arrM[b] === 0){
                result.push(arrM[b]);
                lines++;
                b++;
            }else if(arrM[b] !== 0 && arrM[b] <= lines){
                result.push(arrM[b]);
                b++;
            }
            else{
                flag = false;
            }
        }
        let ans = flag ? result : [-1];
        console.log(...ans);
    }
}

var readline = require('readline');

var rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
});
var lines = [];
rl.on('line', function(input) {
    lines.push(input);
});
rl.on('close', function() {
    var l = 0;
    var t = +lines[l++]
    for (var i = 0; i < t; i++) {
        l++
        var [k, n, m] = lines[l++].trim().split(' ').map(Number)
        var a1 = lines[l++].trim().split(' ').map(Number)
        var a2 = lines[l++].trim().split(' ').map(Number)
        console.log(solve(k, n, m, a1, a2))
    }
});

function solve(k, n, m, a1, a2) {
    // console.log(a1, a2)
    let i = 0
    let j = 0
    const r = []
    while (i < n && j < m) {
        const b1 = a1[i] && a1[i] > k
        const b2 = a2[j] && a2[j] > k
        if (b1 && b2) {
            return -1
        } else if (b1) {
            if (!a2[j]) k++
            r.push(a2[j++])
        } else if (b2) {
            if (!a1[i]) k++
            r.push(a1[i++])
        } else {
            if (!a1[i]) k++
            if (!a2[j]) k++
            r.push(a1[i++])
            r.push(a2[j++])
        }
    }
    while (i < n) {
        if (a1[i] > k) return -1
        if (!a1[i]) k++
        r.push(a1[i++])
    }
    while (j < m) {
        if (a2[j] > k) return -1
        if (!a2[j]) k++
        r.push(a2[j++])
    }
    return r.join(' ')
}

const fs = require('fs');
const input = fs.readFileSync(0, 'utf8').trim().split('\n');

let currentline = 0;
function readline(){
    return input[currentline++];
}

let t = +readline()
while(t--){
    readline()
    let [k,n,m] = readline().split(' ').map(x=>+x);
    let a = readline().split(' ').map(x=>+x)
    let b = readline().split(' ').map(x=>+x)
    console.log(`${solve(a, b, n, m, k)}`);
}

function solve(a, b, n, m, k){
    let idx_a = 0;
    let idx_b = 0;
    let result = '';

    while(idx_a < n || idx_b < m){
        if(a[idx_a] === 0){
            result += ` ${0}`;
            idx_a++;
            k++
        }else if(b[idx_b] === 0){
            result += ` ${0}`;
            idx_b++;
            k++;
        }else if(a[idx_a] <= k){
            result += ` ${a[idx_a]}`;
            idx_a++;
        }else if(b[idx_b] <= k){
            result += ` ${b[idx_b]}`;
            idx_b++;
        }else return -1;
    }
    return result.trim();
}

const fs = require('fs');
const input = fs.readFileSync(0, 'utf8').trim().split('\n');

let currentline = 0;
function readline(){
    return input[currentline++];
}

let t = +readline()
while(t--){
    readline()
    let [k,n,m] = readline().split(' ').map(x=>+x);
    let a = readline().split(' ').map(x=>+x)
    let b = readline().split(' ').map(x=>+x)
    console.log(`${solve(a, b, n, m, k)}`);
}

function solve(a, b, n, m, k){
    let idx_a = 0;
    let idx_b = 0;
    let result = [];

    while(idx_a < n || idx_b < m){
        if(a[idx_a] === 0){
            result.push(0);
            idx_a++;
            k++
        }else if(b[idx_b] === 0){
            result.push(0);
            idx_b++;
            k++;
        }else if(a[idx_a] <= k){
            result.push(a[idx_a]);
            idx_a++;
        }else if(b[idx_b] <= k){
            result.push(b[idx_b]);
            idx_b++;
        }else return -1;
    }
    return result.join(' ');
}

"use strict";

const fs = require("fs");
//let filename = "0.txt";
let filename = 0;
const input = fs.readFileSync(filename, "utf8").trim().split("\n");
let line = 0;
function readline() {
  return input[line++];
}

const solve = () => {
  let t = parseInt(readline());
  while (t--) {
    readline();
    let [k, n, m] = readline()
      .trim()
      .split(" ")
      .map((cur) => parseInt(cur));
    let arr1 = readline()
      .trim()
      .split(" ")
      .map((cur) => parseInt(cur));
    let arr2 = readline()
      .trim()
      .split(" ")
      .map((cur) => parseInt(cur));
    let i = 0,
      j = 0,
      res = [];
    while (i < n || j < m) {
      if (i < n && arr1[i] === 0) {
        res.push(arr1[i++]);
        k++;
      } else if (j < m && arr2[j] === 0) {
        res.push(arr2[j++]);
        k++;
      } else if (i < n && arr1[i] <= k) res.push(arr1[i++]);
      else if (j < m && arr2[j] <= k) res.push(arr2[j++]);
      else break;
    }
    if (res.length === n + m) console.log(res.join(" "));
    else console.log(-1);
  }
};
solve();

//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] = BigInt(next());
		}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 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 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 s = next();
		var K = nextInt();
		var N = nextInt();
		var M = nextInt();
		var alist = nextIntArray(N);
		var blist = nextIntArray(M);
		var output = [];
		while(alist.length + blist.length > 0){
			if(alist.length > 0){
				if(alist[0] == 0){
					output.push(alist.shift());
					K++;
					continue;
				}else if(alist[0] <= K){
					output.push(alist.shift());
					continue;
				}
			}
			if(blist.length > 0){
				if(blist[0] == 0){
					output.push(blist.shift());
					K++;
					continue;
				}else if(blist[0] <= K){
					output.push(blist.shift());
					continue;
				}
			}
			output = -1;
			break;
		}
		if(output == -1){
			myout(output);
		}else{
			myout(myconv(output, 8));
		}
	}
}

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

let chng;

function main () {
	let T = rn();
	while (T--) {
		rl();
		let [k, n, m] = rna();
		const a = rna();
		const b = rna();

		function go (ar) {
			while (ar.length && ar[0] <= k) {
				if (ar[0] == 0) k++;
				ans.push(ar[0]);
				ar.shift();
				chng = true;
			}
		}

		let ans = [];
		let i = 0, j = 0;
		while (a.length || b.length) {
			chng = false;
			go(a);
			go(b);

			if (!chng) {
				ans = false;
				break;
			}
		}

		console.log(ans ? ans.join(' ') : -1);
	}
}

function isZero(num) {
   if (typeof num === 'bigint') {
      return num === 0n;
   }
   return num === 0;
}
function div(a, b) {
   if (typeof a !== typeof b) {
      throw new Error('Different types on division');
   }
   if (typeof a === 'bigint') {
      return a / b;
   }
   return Math.floor(a / b);
}

function gcd(x, y) {
   if (isZero(y)) {
      return x;
   }
   return gcd(y, x % y);
}

function lcm(x, y) {
   return div(x * y, gcd(x, y));
}

function allIndexOf(arr, value) {
   var index = arr.indexOf(value)
   var ans = [];
   while (index !== -1) {
      ans.push(index);
      index = arr.indexOf(value, index + 1);
   }
   return ans;
}

function xor(a, b, k) {
   if (k === 2) {
      return a ^ b;
   }
}

const acode = 'a'.charCodeAt(0);
const zcode = 'z'.charCodeAt(0);
const arr = [];
for (let i = acode; i <= zcode; i++) {
   arr.push(String.fromCharCode(i));
}

function solve() {
   read();
   const [k, n, m] = readArray(Number);
   const a = readArray(Number);
   const b = readArray(Number);
   const ans = [];
   let curn = k;
   let ia = 0;
   let ib = 0;
   for (let i = 0; i < n + m; i++) {
      if (a[ia] === 0) {
         ans.push(0);
         ia++;
         curn++;
         continue;
      }
      if (b[ib] === 0) {
         ans.push(0);
         ib++;
         curn++;
         continue;
      }
      if (a[ia] <= curn) {
         ans.push(a[ia]);
         ia++;
         continue;
      }
      if (b[ib] <= curn) {
         ans.push(b[ib]);
         ib++;
         continue;
      }
      write(-1);
      return;
   }
   write(ans.join(' '));
}

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

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

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

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

   var inTextName;
   var outTextName;

   var needWriteFile = false;

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

   if (inTextName) {
      fs.readFile(path.join(__dirname, inTextName), 'utf8', (err, data) => {
         MEMORY = data.split('\r\n');
         init();
         if (needWriteFile) {
            fs.writeFile(path.join(__dirname, outTextName), writeResult, (err) => {
               err ? console.error(err) : console.log('good')
            });
         }
      });
   } else {
      MEMORY = fs.readFileSync(0, 'utf-8').split('\r\n');
      init();
   }
} else {
   init();
}

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

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(str => str.trim());

    main();
});

function readLine() {
    return inputString[currentLine++];
}
function main()
{
    //const name=readLine();
    //console.log(name);

    let test=readLine();
    while(test--)
    {
       // let p1x,p1y,p2x,p2y,p3x,p3y;

        readLine();
        p1=readLine();
        p2=readLine();
        p3=readLine();
        p1=p1.split(" ");
        p2=p2.split(" ");
        p3=p3.split(" ");
        k=parseInt(p1[0]);
        n=parseInt(p1[1]);
        m=parseInt(p1[2]);
        //console.log(n,m,k);
        vec1=[],vec2=[],vec=[];
        for(i=0;i<n;i++)
        {
            //console.log("hh ",i);
            vec1.push(parseInt(p2[i]));
        }
        for(i=0;i<m;i++)
        {
            vec2.push(parseInt(p3[i]));
        }
        //console.log(vec1);
        //console.log(vec2);
        for( i=0,pos1=0,pos2=0;i<n+m;i++)
        {
            if(pos1===n)
            {
                for( j=pos2;j<m;j++)
                {
                    vec.push(vec2[pos2++]);
                }
                break;
            }
            if(pos2===m)
            {
                for(j=pos1;j<n;j++)
                {
                    vec.push(vec1[pos1++]);
                }
                break;
            }

            if(vec1[pos1]<=vec2[pos2])
            {
                vec.push(vec1[pos1]);
                pos1++;
            }
            else
            {
                vec.push(vec2[pos2]);
                pos2++;
            }
        }
        cnt=k;
        chk=true;
        for(i=0;i<n+m;i++)
        {
            if(vec[i]==0)
            {
                cnt++;
                continue;
            }
            val=vec[i];
            if(val>cnt)
            {
                chk=false;
                break;
            }

        }
        //console.log("hello ",chk);
        if(chk===false)
        {
            console.log(-1);
            //cout<<-1<<endl;
        }
        else
        {
            out="";
            for(i=0;i<n+m;i++)
                out+=vec[i]+" ";
            console.log(out);
                //console.log(vec[i]," ");
        }

    }
}

var readline = require('readline');

var rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
});
var lines = [];
rl.on('line', function(input) {
    lines.push(input);
});
rl.on('close', function() {
    var l = 0;
    var t = +lines[l++]
    for (var i = 0; i < t; i++) {
        l++
        var [k, n, m] = lines[l++].trim().split(' ').map(Number)
        var a1 = lines[l++].trim().split(' ').map(Number)
        var a2 = lines[l++].trim().split(' ').map(Number)
        console.log(solve(a1, a2, k, []));
    }
});

const solve = (d1, d2, k, res) => {
    try{
        if(d1.length >0 || d2.length > 0){
            if(d1.length && d1[0] === 0){
                res.push(d1[0])
                return solve(d1.slice(1), d2, k+1, res)
            }else if(d2.length && d2[0] === 0){
                res.push(d2[0])
                return solve(d1, d2.slice(1), k+1, res)
            }else if(d1.length && d1[0] <= k){
                res.push(d1[0])
                return solve(d1.slice(1), d2, k, res)
            }else if(d2.length && d2[0] <= k){
                res.push(d2[0])
                return solve(d1, d2.slice(1), k, res)
            }else{
                return -1
            }

        }else{
            return res.join(' ');
        }
    }catch (ex){
        console.log('ex:', ex)
    }
}

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
    Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
    o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
    if (mod && mod.__esModule) return mod;
    var result = {};
    if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
    __setModuleDefault(result, mod);
    return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
const fs = __importStar(require("fs"));
// import * as readline from 'readline'
// const rl = readline.createInterface({ input: process.stdin, output: process.stdout })
// const ask = (query: string) => new Promise<string>((resolve) => rl.question(query, resolve))
// // Don't forget `rl.close()`.
const INT = Math.floor;
Array.prototype.last = function () {
    return this.length === 0 ? undefined : this[this.length - 1];
};
Array.prototype.isEmpty = function () {
    return this.length === 0;
};
const less = (a, b) => (a == b ? 0 : a < b ? -1 : 1);
const greater = (a, b) => (a == b ? 0 : a < b ? 1 : -1);
const bigIntMax = (...args) => args.reduce((m, e) => (e > m ? e : m));
const bigIntMin = (...args) => args.reduce((m, e) => (e < m ? e : m));
const bigIntAbs = (arg) => (arg < 0 ? -arg : arg);
function read_stdin() {
    return fs.readFileSync(process.env.NODE_ENV === 'debug' ? stdin : process.stdin.fd, 'utf8');
}
class Input {
    constructor(str) {
        this.index = 0;
        this.inputs = (str ? str : read_stdin()).split(/\s+/);
    }
    number() {
        return Number(this.inputs[this.index++]);
    }
    numbers(n) {
        return this.inputs.slice(this.index, (this.index += n)).map(Number);
    }
    bigint() {
        return BigInt(this.inputs[this.index++]);
    }
    bigints(n) {
        return this.inputs.slice(this.index, (this.index += n)).map(BigInt);
    }
    word() {
        return this.inputs[this.index++];
    }
    words(n) {
        return this.inputs.slice(this.index, (this.index += n));
    }
}
function array(len, init) {
    return Array(len).fill(init);
}
function array2(h, w, init) {
    return array(h, 0).map(() => array(w, init));
}
function main() {
    const input = new Input();
    const t = input.number();
    const ans = Array(t);
    loop: for (let i = 0; i < t; i++) {
        let [k, n, m] = input.numbers(3);
        const A = input.numbers(n);
        const B = input.numbers(m);
        A.reverse();
        B.reverse();
        const seq = [];
        for (let j = 0; j < n + m; j++) {
            if (!A.isEmpty() && A.last() === 0) {
                k++;
                seq.push(A.pop());
            }
            else if (!B.isEmpty() && B.last() === 0) {
                k++;
                seq.push(B.pop());
            }
            else {
                if (!A.isEmpty() && !B.isEmpty()) {
                    if (A.last() < B.last()) {
                        const line = A.pop();
                        if (line > k) {
                            ans[i] = [-1];
                            continue loop;
                        }
                        seq.push(line);
                    }
                    else {
                        const line = B.pop();
                        if (line > k) {
                            ans[i] = [-1];
                            continue loop;
                        }
                        seq.push(line);
                    }
                }
                else if (!A.isEmpty()) {
                    const line = A.pop();
                    if (line > k) {
                        ans[i] = [-1];
                        continue loop;
                    }
                    seq.push(line);
                }
                else {
                    const line = B.pop();
                    if (line > k) {
                        ans[i] = [-1];
                        continue loop;
                    }
                    seq.push(line);
                }
            }
        }
        ans[i] = seq;
    }
    console.log(ans.map((seq) => seq.join(' ')).join('\n'));
}
main();
//# sourceMappingURL=aoj.js.map

process.stdin.resume();

process.stdin.setEncoding('utf8');

var input = '';

process.stdin.on('data' , data=>{
    input += data;
});
process.stdin.on('end' , ()=>{
    main(input);
});

function main(input) {
    input = input.trim().split("\n");
    let z = 0;
    let testCases = +input[z++].trim();

    while(testCases--){
        let blank = input[z++];
        let [k, n, m] = input[z++].trim().split(' ').map(Number);
        let arrN = input[z++].trim().split(' ').map(Number);
        let arrM = input[z++].trim().split(' ').map(Number);

        let line = +k;
        for (let i = 0; i < n; i++) {
            if(arrN[i] === 0) line++;
        }
        for (let i = 0; i < m; i++) {
            if(arrM[i] === 0) line++;
        }

        let maxN = Math.max(...arrN);
        let maxM = Math.max(...arrM);
        let max = Math.max(maxM, maxN);

        if(line >= max){
            let result = [];
            let counter = 0;
            for (let i = 0; i < n+ m; i++){
                if(arrN[counter] < arrM[counter]){
                    result.push(arrN[counter]);
                    result.push(arrM[counter]);
                }else{
                    result.push(arrM[counter]);
                    result.push(arrN[counter]);
                }
                counter++;
            }
            result = result.filter(x=>x!= undefined);
            console.log(...result);
        }
        else{
            console.log(-1);
        }
    }
}

process.stdin.resume();

process.stdin.setEncoding('utf8');

var input = '';

process.stdin.on('data' , data=>{
    input += data;
});
process.stdin.on('end' , ()=>{
    main(input);
});

function main(input) {
    input = input.trim().split("\n");
    let z = 0;
    let testCases = +input[z++].trim();

    while(testCases--){
        let blank = input[z++];
        let [k, n, m] = input[z++].trim().split(' ').map(Number);
        let arrN = input[z++].trim().split(' ').map(Number);
        let arrM = input[z++].trim().split(' ').map(Number);

        let line = +k;
        for (let i = 0; i < n; i++) {
            if(arrN[i] === 0) line++;
        }
        for (let i = 0; i < m; i++) {
            if(arrM[i] === 0) line++;
        }

        let maxN = Math.max(...arrN);
        let maxM = Math.max(...arrM);
        let max = Math.max(maxM, maxN);

        if(line >= max){
            let result = [];
            let counter = 0;
            for (let i = 0; i < n+ m; i+=2){
                if(arrN[counter] < arrM[counter]){
                    result.push(arrN[counter]);
                    result.push(arrM[counter]);
                }else{
                    result.push(arrM[counter]);
                    result.push(arrN[counter]);
                }
                counter++;
            }
            result = result.filter(x=>x!= undefined);
            console.log(...result);
        }
        else{
            console.log(-1);
        }
    }
}

var readline = require('readline');

var rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
});
var lines = [];
rl.on('line', function(input) {
    lines.push(input);
});
rl.on('close', function() {
    var l = 0;
    var t = +lines[l++]
    for (var i = 0; i < t; i++) {
        l++
        var [k, n, m] = lines[l++].trim().split(' ').map(Number)
        var a1 = lines[l++].trim().split(' ').map(Number)
        var a2 = lines[l++].trim().split(' ').map(Number)
        console.log(solve(k, n, m, a1, a2))
    }
});

function solve(k, n, m, a1, a2) {
    // console.log(a1, a2)
    let i = 0
    let j = 0
    const r = []
    while (i < n && j < m) {
        const b1 = a1[i] && a1[i] > k
        const b2 = a2[j] && a2[j] > k
        if (b1 && b2) {
            return -1
        } else if (b1) {
            if (!a2[j]) k++
            r.push(a2[j++])
        } else if (b2) {
            if (!a1[i]) k++
            r.push(a1[i++])
        } else {
            if (!a1[i]) k++
            if (!a2[j]) k++
            r.push(a1[i++])
            r.push(a2[j++])
        }
    }
    while (i < n) {
        if (a1[i] > k) return -1
        if (!a1[i]) k++
        r.push(a1[i++])
    }
    while (j < m) {
        if (a2[j] > k) return -1
        r.push(a2[j++])
        r.push(a2[j++])
    }
    return r.join(' ')
}

var readline = require('readline');

var rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
});
var lines = [];
rl.on('line', function(input) {
    lines.push(input);
});
rl.on('close', function() {
    var l = 0;
    var t = +lines[l++]
    for (var i = 0; i < t; i++) {
        l++
        var [k, n, m] = lines[l++].trim().split(' ').map(Number)
        var a1 = lines[l++].trim().split(' ').map(Number)
        var a2 = lines[l++].trim().split(' ').map(Number)
        console.log(solve(k, n, m, a1, a2))
    }
});

function solve(k, n, m, a1, a2) {
    // console.log(a1, a2)
    let i = 0
    let j = 0
    const r = []
    while (i < n && j < m) {
        const b1 = a1[i] && a1[i] > k
        const b2 = a2[j] && a2[j] > k
        if (b1 && b2) {
            return -1
        } else if (b1) {
            if (!a2[j]) k++
            r.push(a2[j++])
        } else if (b2) {
            if (!a1[i]) k++
            r.push(a1[i++])
        } else {
            if (!a1[i]) k++
            if (!a2[j]) k++
            r.push(a1[i++])
            r.push(a2[j++])
        }
    }
    while (i < n) {
        if (a1[i] > k) return -1
        r.push(a1[i++])
    }
    while (j < m) {
        if (a2[j] > k) return -1
        r.push(a2[j++])
    }
    return r.join(' ')
}

"use strict";

const fs = require("fs");
//let filename = "0.txt";
let filename = 0;
const input = fs.readFileSync(filename, "utf8").trim().split("\n");
let line = 0;
function readline() {
  return input[line++];
}

const solve = () => {
  let t = parseInt(readline());
  while (t--) {
    readline();
    let [k, n, m] = readline()
      .trim()
      .split(" ")
      .map((cur) => parseInt(cur));
    let arr1 = readline()
      .trim()
      .split(" ")
      .map((cur) => parseInt(cur));
    let arr2 = readline()
      .trim()
      .split(" ")
      .map((cur) => parseInt(cur));
    let res = "";
    let i = 0,
      j = 0,
      flag = 1;
    while (i < n && j < m) {
      if (arr1[i] === 0 && arr2[j] === 0) {
        res += 0 + " " + 0 + " ";
        k += 2;
      } else if (arr1[i] === 0) {
        res += 0 + " ";
        k++;
        if (arr2[j] <= k) res += arr2[j] + " ";
        else {
          flag = 0;
          break;
        }
      } else if (arr2[j] === 0) {
        res += 0 + " ";
        k++;
        if (arr1[i] <= k) res += arr1[j] + " ";
        else {
          flag = 0;
          break;
        }
      } else {
        if (arr1[i] <= k && arr2[j] <= k) res += arr1[i] + " " + arr2[j] + " ";
        else {
          flag = 0;
          break;
        }
      }
      i++;
      j++;
    }
    if (flag === 0) {
      console.log(-1);
      continue;
    }
    while (i < n) res += arr1[i++] + " ";
    while (j < m) res += arr2[j++] + " ";
    console.log(res);
  }
};
solve();

//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] = BigInt(next());
		}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 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 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 s = next();
		var K = nextInt();
		var N = nextInt();
		var M = nextInt();
		var alist = nextIntArray(N);
		var blist = nextIntArray(M);
		var output = [];
		while(alist.length + blist.length > 0){
			if(alist.length > 0){
				if(alist[0] == 0){
					output.push(alist.shift());
					K++;
					continue;
				}else if(alist[0] - 1 <= K){
					output.push(alist.shift());
					continue;
				}
			}
			if(blist.length > 0){
				if(blist[0] == 0){
					output.push(blist.shift());
					K++;
					continue;
				}else if(blist[0] - 1 <= K){
					output.push(blist.shift());
					continue;
				}
			}
			output = -1;
			break;
		}
		if(output == -1){
			myout(output);
		}else{
			myout(myconv(output, 8));
		}
	}
}


Mike and Ann are sitting in the classroom. The lesson is boring, so they decided to play an interesting game. Fortunately, all they need to play this game is a string $$$s$$$ and a number $$$k$$$ ($$$0 \le k < |s|$$$).At the beginning of the game, players are given a substring of $$$s$$$ with left border $$$l$$$ and right border $$$r$$$, both equal to $$$k$$$ (i.e. initially $$$l=r=k$$$). Then players start to make moves one by one, according to the following rules: A player chooses $$$l^{\prime}$$$ and $$$r^{\prime}$$$ so that $$$l^{\prime} \le l$$$, $$$r^{\prime} \ge r$$$ and $$$s[l^{\prime}, r^{\prime}]$$$ is lexicographically less than $$$s[l, r]$$$. Then the player changes $$$l$$$ and $$$r$$$ in this way: $$$l := l^{\prime}$$$, $$$r := r^{\prime}$$$. Ann moves first. The player, that can't make a move loses.Recall that a substring $$$s[l, r]$$$ ($$$l \le r$$$) of a string $$$s$$$ is a continuous segment of letters from s that starts at position $$$l$$$ and ends at position $$$r$$$. For example, "ehn" is a substring ($$$s[3, 5]$$$) of "aaaehnsvz" and "ahz" is not.Mike and Ann were playing so enthusiastically that they did not notice the teacher approached them. Surprisingly, the teacher didn't scold them, instead of that he said, that he can figure out the winner of the game before it starts, even if he knows only $$$s$$$ and $$$k$$$.Unfortunately, Mike and Ann are not so keen in the game theory, so they ask you to write a program, that takes $$$s$$$ and determines the winner for all possible $$$k$$$.

The first line of the input contains a single string $$$s$$$ ($$$1 \leq |s| \leq 5 \cdot 10^5$$$) consisting of lowercase English letters.

Print $$$|s|$$$ lines. In the line $$$i$$$ write the name of the winner (print Mike or Ann) in the game with string $$$s$$$ and $$$k = i$$$, if both play optimally

"use strict";

var str = readline();
var winners = [];
var min = str[0];
var minAvailable = [false];

for (var i = 1; i < str.length; i++) {
  if (str[i] < min) {
    min = str[i];
  }

  minAvailable.push(str[i] > min);
}

var currentMinimum = undefined;

for (var _i = 0; _i < str.length; _i++) {
  winners.push(minAvailable[_i] ? 'Ann' : 'Mike');
}

write(winners.join('\n'));


You are given an array $$$a$$$ of $$$n$$$ integers $$$a_1, a_2, a_3, \ldots, a_n$$$.You have to answer $$$q$$$ independent queries, each consisting of two integers $$$l$$$ and $$$r$$$.   Consider the subarray $$$a[l:r]$$$ $$$=$$$ $$$[a_l, a_{l+1}, \ldots, a_r]$$$. You can apply the following operation to the subarray any number of times (possibly zero)-   Choose two integers $$$L$$$, $$$R$$$ such that $$$l \le L \le R \le r$$$ and $$$R - L + 1$$$ is odd.  Replace each element in the subarray from $$$L$$$ to $$$R$$$ with the XOR of the elements in the subarray $$$[L, R]$$$.   The answer to the query is the minimum number of operations required to make all elements of the subarray $$$a[l:r]$$$ equal to $$$0$$$ or $$$-1$$$ if it is impossible to make all of them equal to $$$0$$$. You can find more details about XOR operation here.

The first line contains two integers $$$n$$$ and $$$q$$$ $$$(1 \le n, q \le 2 \cdot 10^5)$$$  — the length of the array $$$a$$$ and the number of queries. The next line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ $$$(0 \le a_i \lt 2^{30})$$$  — the elements of the array $$$a$$$. The $$$i$$$-th of the next $$$q$$$ lines contains two integers $$$l_i$$$ and $$$r_i$$$ $$$(1 \le l_i \le r_i \le n)$$$  — the description of the $$$i$$$-th query.

For each query, output a single integer  — the answer to that query.

NoteIn the first query, $$$l = 3, r = 4$$$, subarray = $$$[3, 3]$$$. We can apply operation only to the subarrays of length $$$1$$$, which won't change the array; hence it is impossible to make all elements equal to $$$0$$$.In the second query, $$$l = 4, r = 6$$$, subarray = $$$[3, 1, 2]$$$. We can choose the whole subarray $$$(L = 4, R = 6)$$$ and replace all elements by their XOR $$$(3 \oplus 1 \oplus 2) = 0$$$, making the subarray $$$[0, 0, 0]$$$.In the fifth query, $$$l = 1, r = 6$$$, subarray = $$$[3, 0, 3, 3, 1, 2]$$$. We can make the operations as follows:   Choose $$$L = 4, R = 6$$$, making the subarray $$$[3, 0, 3, 0, 0, 0]$$$.  Choose $$$L = 1, R = 5$$$, making the subarray $$$[0, 0, 0, 0, 0, 0]$$$.

'use strict';

var fs = require('fs');

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

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

function solve(read) {
  const [rn, rb, rns, re, rbs] = convertInput(read);
  const [n, q] = rns(),
        a = rns(),
        b = [];
  const xorsum = [0],
        sum = [0],
        res = [];
  for (let i = 1; i <= n; i++) {
    xorsum[i] = xorsum[i - 1] ^ a[i - 1];
    sum[i] = sum[i - 1] + a[i - 1];
  }
  for (let i = 0; i < q; i++) {
    let [x, y] = rns();
    if ((xorsum[y] ^ xorsum[x - 1]) !== 0) {
      res[i] = -1;
    } else if (sum[y] - sum[x - 1] === 0) {
      res[i] = 0;
    } else {
      let d = y - x + 1;
      if (d & 1) {
        res[i] = 1;
      } else {
        b.push([x, y, i]);
      }
    }
  }
  b.sort((a, b) => a[1] - b[1]);
  let map = new Map();
  map.set(0, [0]);
  for (let i = 1, j = 0; i <= n; i++) {
    var _map$get;
    const cur = xorsum[i];
    let l = (_map$get = map.get(cur)) === null || _map$get === void 0 ? void 0 : _map$get[i & 1 ^ 1];
    while (j < b.length && b[j][1] === i) {
      const [x, y, k] = b[j];
      if (l !== undefined && l >= x) {
        if (a[x - 1] === 0 || a[y - 1] === 0) {
          res[k] = 1;
        } else {
          res[k] = 2;
        }
      } else {
        res[k] = -1;
      }
      j++;
    }
    if (!map.has(cur)) map.set(cur, []);
    map.get(cur)[i & 1] = i;
  }
  return res.join('\n');
}
function convertInput(read) {
  const rn = () => Number(read());
  const rb = () => BigInt(read());
  const rns = () => read().split(/\s+/).map(Number);
  const re = () => read().split(/\s+/).map(s => Number(s) - 1);
  const rbs = () => read().split(/\s+/).map(BigInt);
  return [rn, rb, rns, re, rbs];
}
function main(r) {
  try {
    let t = 1;
    let res = new Array(t);
    let limit = 0;
    for (let i = 0; i < t; i++) {
      let s = solve(r);
      if (s === undefined) s = '';
      if (t < limit) ; else {
        res[i] = s;
      }
    }
    if (t >= limit) {
      return res.join('\n');
    }
  } catch (error) {
    console.log(error);
  }
}

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

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

function solve(n, arr, qs) {
    const sum = Array(n)
    sum[0] = arr[0]
    const xor = Array(n)
    xor[0] = arr[0]
    for (let i = 1; i < arr.length; i++) {
        sum[i] = sum[i - 1] + arr[i]
        xor[i] = xor[i - 1] ^ arr[i]
    }
    //
    const even = {}
    even[0] = [-1]
    const odd = {}
    let x = 0
    for (let i = 0; i < arr.length; i++) {
        x ^= arr[i]
        const [get, set] = (i & 1) ? [odd, even] : [even, odd]
        set[x] = (set[x] || [])
        ;set[x].push(i)
    }
// console.log(even, odd)
    return qs.map(([l, r]) => {
        l--; r--
        if (!rangeSum(l, r)) return 0
        if (rangeXor(l, r)) return -1
        const len = r - l + 1
        if (len & 1) return 1
        // [l, x] = 0
        const [get, set] = (r & 1) ? [odd, even] : [even, odd]
        const lst = get[xor[r]] || []
        const j = binarySearch(0, lst.length - 1, x => lst[x] <= r)
// console.log(l, r, lst, j)
        return lst[j] >= l ? ((!arr[l] || !arr[r]) ? 1 : 2) : -1
    }).join('\n')

    function rangeXor(l, r) {
        return xor[r] ^ (xor[l - 1] || 0)
    }
    function rangeSum(l, r) {
        return sum[r] - (sum[l - 1] || 0)
    }
}
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
}

'use strict';

var fs = require('fs');

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

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

function solve(read) {
  const [rn, rb, rns, re, rbs] = convertInput(read);
  const [n, q] = rns(),
        a = rns(),
        b = [];
  const xorsum = [0],
        sum = [0],
        res = [];
  for (let i = 1; i <= n; i++) {
    xorsum[i] = xorsum[i - 1] ^ a[i - 1];
    sum[i] = sum[i - 1] + a[i - 1];
  }
  for (let i = 0; i < q; i++) {
    let [x, y] = rns();
    if ((xorsum[y] ^ xorsum[x - 1]) !== 0) {
      res[i] = -1;
    } else if (sum[y] - sum[x - 1] === 0) {
      res[i] = 0;
    } else {
      let d = y - x + 1;
      if (d & 1) {
        res[i] = 1;
      } else {
        b.push([x, y, i]);
      }
    }
  }
  b.sort((a, b) => a[1] - b[1]);
  const map = new Map();
  map.set(0, [0]);
  for (let i = 1, j = 0; i <= n; i++) {
    var _map$get;
    const cur = xorsum[i];
    let k = i & 1 ^ 1;
    let l = (_map$get = map.get(cur)) === null || _map$get === void 0 ? void 0 : _map$get[k];
    while (j < b.length && b[j][1] === i) {
      if (l !== undefined && l > b[j][0]) {
        var _sum$l;
        if (sum[i] - ((_sum$l = sum[l]) !== null && _sum$l !== void 0 ? _sum$l : 0) === 0) {
          res[b[j][2]] = 1;
        } else {
          res[b[j][2]] = 2;
        }
      } else {
        res[b[j][2]] = -1;
      }
      j++;
    }
    if (!map.has(cur)) map.set(cur, []);
    map.get(cur)[i & 1] = i;
  }
  return res.join('\n');
}
function convertInput(read) {
  const rn = () => Number(read());
  const rb = () => BigInt(read());
  const rns = () => read().split(/\s+/).map(Number);
  const re = () => read().split(/\s+/).map(s => Number(s) - 1);
  const rbs = () => read().split(/\s+/).map(BigInt);
  return [rn, rb, rns, re, rbs];
}
function main(r) {
  try {
    let t = 1;
    let res = new Array(t);
    let limit = 0;
    for (let i = 0; i < t; i++) {
      let s = solve(r);
      if (s === undefined) s = '';
      if (t < limit) ; else {
        res[i] = s;
      }
    }
    if (t >= limit) {
      return res.join('\n');
    }
  } catch (error) {
    console.log(error);
  }
}

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

'use strict';

var fs = require('fs');

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

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

function solve(read) {
  const [rn, rb, rns, re, rbs] = convertInput(read);
  const [n, q] = rns(),
        a = rns(),
        b = [];
  const xorsum = [],
        sum = [],
        res = [];
  for (let i = 0; i < n; i++) {
    var _xorsum, _sum;
    xorsum[i] = ((_xorsum = xorsum[i - 1]) !== null && _xorsum !== void 0 ? _xorsum : 0) ^ a[i];
    sum[i] = ((_sum = sum[i - 1]) !== null && _sum !== void 0 ? _sum : 0) + a[i];
  }
  for (let i = 0; i < q; i++) {
    var _xorsum2, _sum2;
    let [x, y] = rns();
    x--;
    y--;
    if ((xorsum[y] ^ ((_xorsum2 = xorsum[x - 1]) !== null && _xorsum2 !== void 0 ? _xorsum2 : 0)) !== 0) {
      res[i] = -1;
    } else if (sum[y] - ((_sum2 = sum[x - 1]) !== null && _sum2 !== void 0 ? _sum2 : 0) === 0) {
      res[i] = 0;
    } else {
      let d = y - x + 1;
      if (d & 1) {
        res[i] = 1;
      } else {
        b.push([x, y, i]);
      }
    }
  }
  b.sort((a, b) => a[1] - b[1]);
  const map = new Map();
  map.set(0, [, -1]);
  for (let i = 0, j = 0; i < n; i++) {
    const cur = xorsum[i];
    let k = i & 1 ^ 1;
    while (j < b.length && b[j][1] === i) {
      var _map$get;
      let l = (_map$get = map.get(cur)) === null || _map$get === void 0 ? void 0 : _map$get[k];
      if (l !== undefined && l > b[j][0]) {
        var _sum$l;
        if (sum[i] - ((_sum$l = sum[l]) !== null && _sum$l !== void 0 ? _sum$l : 0) === 0) {
          res[b[j][2]] = 1;
        } else {
          res[b[j][2]] = 2;
        }
      } else {
        res[b[j][2]] = -1;
      }
      j++;
    }
    if (!map.has(cur)) map.set(cur, []);
    map.get(cur)[i & 1] = i;
  }
  return res.join('\n');
}
function convertInput(read) {
  const rn = () => Number(read());
  const rb = () => BigInt(read());
  const rns = () => read().split(/\s+/).map(Number);
  const re = () => read().split(/\s+/).map(s => Number(s) - 1);
  const rbs = () => read().split(/\s+/).map(BigInt);
  return [rn, rb, rns, re, rbs];
}
function main(r) {
  try {
    let t = 1;
    let res = new Array(t);
    let limit = 0;
    for (let i = 0; i < t; i++) {
      let s = solve(r);
      if (s === undefined) s = '';
      if (t < limit) ; else {
        res[i] = s;
      }
    }
    if (t >= limit) {
      return res.join('\n');
    }
  } catch (error) {
    console.log(error);
  }
}

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

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

function solve(n, arr, qs) {
    const sum = Array(n)
    sum[0] = arr[0]
    const xor = Array(n)
    xor[0] = arr[0]
    for (let i = 1; i < arr.length; i++) {
        sum[i] = sum[i - 1] + arr[i]
        xor[i] = xor[i - 1] ^ arr[i]
    }
    //
    const even = {}
    even[0] = [-1]
    const odd = {}
    let x = 0
    for (let i = 0; i < arr.length; i++) {
        x ^= arr[i]
        const [get, set] = (i & 1) ? [odd, even] : [even, odd]
        set[x] = (set[x] || [])
        ;set[x].push(i)
    }
// console.log(even, odd)
    return qs.map(([l, r]) => {
        l--; r--
        if (!rangeSum(l, r)) return 0
        if (rangeXor(l, r)) return -1
        const len = r - l + 1
        if (len & 1) return 1
        // [l, x] = 0
        const [get, set] = (r & 1) ? [odd, even] : [even, odd]
        const lst = get[xor[r]] || []
        const j = binarySearch(0, lst.length - 1, x => lst[x] <= r)
// console.log(l, r, lst, j)
        return lst[j] >= l ? 2 : -1
    }).join('\n')

    function rangeXor(l, r) {
        return xor[r] ^ (xor[l - 1] || 0)
    }
    function rangeSum(l, r) {
        return sum[r] - (sum[l - 1] || 0)
    }
}
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
}


Maxim wants to buy some games at the local game shop. There are $$$n$$$ games in the shop, the $$$i$$$-th game costs $$$c_i$$$.Maxim has a wallet which can be represented as an array of integers. His wallet contains $$$m$$$ bills, the $$$j$$$-th bill has value $$$a_j$$$.Games in the shop are ordered from left to right, Maxim tries to buy every game in that order.When Maxim stands at the position $$$i$$$ in the shop, he takes the first bill from his wallet (if his wallet is empty then he proceeds to the next position immediately) and tries to buy the $$$i$$$-th game using this bill. After Maxim tried to buy the $$$n$$$-th game, he leaves the shop.Maxim buys the $$$i$$$-th game if and only if the value of the first bill (which he takes) from his wallet is greater or equal to the cost of the $$$i$$$-th game. If he successfully buys the $$$i$$$-th game, the first bill from his wallet disappears and the next bill becomes first. Otherwise Maxim leaves the first bill in his wallet (this bill still remains the first one) and proceeds to the next game.For example, for array $$$c = [2, 4, 5, 2, 4]$$$ and array $$$a = [5, 3, 4, 6]$$$ the following process takes place: Maxim buys the first game using the first bill (its value is $$$5$$$), the bill disappears, after that the second bill (with value $$$3$$$) becomes the first one in Maxim's wallet, then Maxim doesn't buy the second game because $$$c_2 > a_2$$$, the same with the third game, then he buys the fourth game using the bill of value $$$a_2$$$ (the third bill becomes the first one in Maxim's wallet) and buys the fifth game using the bill of value $$$a_3$$$.Your task is to get the number of games Maxim will buy.

The first line of the input contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 1000$$$) — the number of games and the number of bills in Maxim's wallet. The second line of the input contains $$$n$$$ integers $$$c_1, c_2, \dots, c_n$$$ ($$$1 \le c_i \le 1000$$$), where $$$c_i$$$ is the cost of the $$$i$$$-th game. The third line of the input contains $$$m$$$ integers $$$a_1, a_2, \dots, a_m$$$ ($$$1 \le a_j \le 1000$$$), where $$$a_j$$$ is the value of the $$$j$$$-th bill from the Maxim's wallet.

Print a single integer — the number of games Maxim will buy.

NoteThe first example is described in the problem statement.In the second example Maxim cannot buy any game because the value of the first bill in his wallet is smaller than the cost of any game in the shop.In the third example the values of the bills in Maxim's wallet are large enough to buy any game he encounter until he runs out of bills in his wallet.

var n = readline().split(' ')
var c = readline().split(' ').map(Number)
var a = readline().split(' ').map(Number)

var k = 0

for(var i = 0;i < n[0];i++){
	if(c[i] <= a[k]){
		k++
	}
	if(k >= n[1]) break
}

print(k)

var k = readline().split(" ").map(function(d){
  return parseInt(d)
})

var c = readline().split(' ').map(function(d){
  return parseInt(d)
})
var a =readline().split(' ').map(function(d){
  return parseInt(d)
})
var idx = 0,counter=0;
 for(var i=0;i<c.length;i++)
    {

      if(c[i]<=a[idx]  )
        {
          counter++;
          idx++;
          if(idx==a.length){

             break;
      }
        }

    }

print(counter)

function main() {
  const is = new Scanner();
  const [n, m] = is.nextArray().map(Number);
  const games = is.nextArray();
  const bills = is.nextArray();
  for (let i = 0; i < n; i += 1) {
    games[i] = parseInt(games[i], 10);
  }
  for (let i = 0; i < bills.length; i += 1) {
    bills[i] = parseInt(bills[i], 10);
  }

  let i = 0, j = 0;
  while (i < n && j < m) {
    if (bills[j] >= games[i]) {
      j += 1;
    }
    i += 1;
  }

  console.log(j);
}

/*
 *  Api Scanner
 */

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

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

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

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

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

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

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

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

//Don't have to see. end------------------------------------------
function Main(){
	var one = nextIntArray();
	var N = one[0];
	var M = one[1];
	var nlist = nextIntArray();
	var mlist = nextIntArray();
	var count = 0;
	for(var i = 0; i < N; i++){
		if(mlist.length == 0){
			break;
		}
		if(nlist[i] <= mlist[0]){
			count++;
			mlist.shift();
		}
	}
	myout(count);
}

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

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

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

  money = d.split(' ').map(Number);

  let ans = 0;
  let bill = 0;

  for (let i = 0; i < games.length; i++) {
    if (money[bill] >= games[i]) {
      ans++;
      bill++;
    }
  }

  console.log(ans);

  c++;
});

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

var lines = [];
rl.on('line', (line) => {
  lines.push(line.trim());
  if (lines.length === 3) {
      main();
  }
}).on('close', () => {
  process.exit(0);
});

function main() {
    // parse input
    // throw away count line
    var costs = lines[1].split(" ").map(function(x) { return parseInt(x); })
    var bills = lines[2].split(" ").map(function(x) { return parseInt(x); })
    console.log(solve(costs, bills));
}

function solve(costs, bills) {
    // console.log('costs ', costs, ' bills ', bills);
    var billIndex = 0;
    var purchasedGames = 0;
    for (var i = 0; i < costs.length; i++) {
        // console.log('Comparing cost ', costs[i], ' and bill ', bills[billIndex]);
        if (bills[billIndex] >= costs[i]) {
            // console.log('can afford');
            // we can afford this game
            purchasedGames++;
            billIndex++;
            // console.log('purchased Games: ', purchasedGames, ' and billIndex: ', billIndex);
            // console.log('bills length', bills.length);
            if (billIndex === bills.length) {
                // console.log('breaking');
                // no more money left
                break;
            }
        } // else if we can't afford the game, keep looping to next cost
    }
    return purchasedGames;
}

// uncomment for testing
// console.log(solve([2,4,5,2,4], [5,3,4,6]));
// console.log(solve([20,40,50,20,40], [19,20]));
// console.log(solve([4,8,15,16,23,42], [1000,1000,1000,1000]));

// uncomment for submission
//main();

var k = readline().split(' ').map(function(d){
  return parseInt(k)
})

var c = readline().split(' ').map(function(d){
  return parseInt(k)
})
var a =readline().split(' ').map(function(d){
  return parseInt(k)
})
var idx = 0,counter=0;
 for(var i=0;i<c.length;i++)
    {

      if(c[i]<=a[idx]  )
        {
          counter++;
          idx++;
          if(idx==a.length){

             break;
      }
        }

    }

print(counter)