#include<bits/stdc++.h>
using ll = int_fast64_t;
using P = std::pair<ll,ll>;
using PP = std::pair<ll,P>;

#define REP(i,b,e) for(int i=b; i<e; i++)
#define PRINT(vec) {printf("[ ");for(auto &i:vec)printf("%ld ",i);puts("]");}
#define fi first
#define se second

const int MOD = 1e9+7;
int dx[] = {0, 1, 0, -1, 1, 1, -1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

int main(){
	int n, m;
	scanf("%d %d", &n, &m);
	int a[n+1], b[m+1];
	REP(i, 0, n) scanf("%d", &a[i]);
	REP(i, 0, m) scanf("%d", &b[i]);
	a[n] = b[m] = 1010;

	std::vector<int> ans;
	int i = 0, j = 0;
	while(i<n or j<m){
		if(i>=n){
			ans.push_back(b[j]);
			j++;
			continue;
		}else if(j>=m){
			ans.push_back(a[i]);
			i++;
			continue;
		}

		if(a[i]==b[j]){
			i++;
			j++;
		}else if(a[i]<b[j]){
			ans.push_back(a[i]);
			i++;
		}else{
			ans.push_back(b[j]);
			j++;
		}
	}

	for(int x: ans) if(x!=1010) printf("%d ", x);
	puts("");
	return 0;
}


#include <bits/stdc++.h>
using namespace std;

int main() {
  
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n,m;
  cin >> n >> m;
  vector<int> a(n);
  vector<int> b(m);
  for (int i=0;i<n;i++) cin >> a[i];
  for (int i=0;i<m;i++) cin >> b[i];
  vector<int> nums(1001,0);
  for (int i=0;i<n;i++) {
    nums[a[i]]++;
  }
  for (int i=0;i<m;i++) {
    nums[b[i]]++;
  }
  vector<int> ans;
  for (int i=1;i<=1000;i++) {
    if (nums[i] == 1) {
      ans.emplace_back(i);
    }
  }
  for (int i=0;i<ans.size();i++) {
    if (i != 0) cout << ' ';
    cout << ans[i];
  }
  cout << endl;
}