public static void main(String args[]) throws IOException {
		StreamTokenizer st = new StreamTokenizer(new BufferedReader(
				new InputStreamReader(System.in)));

		while (st.nextToken() != StreamTokenizer.TT_EOF) {
			int n = (int) st.nval;
			st.nextToken();
			int m = (int) st.nval;

			ListNode head1 = null, previous = null;
			for (int i = 0; i < n; i++) {
				st.nextToken();
				ListNode tmp = new ListNode((int) st.nval);
				if (previous == null) {
					head1 = tmp;
					previous = tmp;
				} else {
					previous.next = tmp;
					previous = tmp;
				}
			}
			
			ListNode head2 = null;
			previous = null;
			for (int i = 0; i < m; i++) {
				st.nextToken();
				ListNode tmp = new ListNode((int) st.nval);
				if (previous == null) {
					head2 = tmp;
					previous = tmp;
				} else {
					previous.next = tmp;
					previous = tmp;
				}
			}
			
			ListNode newhead = mergeList(head1,head2);
			if(newhead==null){				
				System.out.println("NULL");
			}else{
				StringBuilder sb=new StringBuilder();
				ListNode p=newhead;
				sb.append(p.data);
				p=p.next;
				while(p!=null){
					sb.append(" ");
					sb.append(p.data);
					p=p.next;
				}
				System.out.println(sb.toString());
			}
		}
	}