#include <bits/stdc++.h>
#define N 200050
using namespace std;
int n, m, i, j, k, a[N], b[N], c[N];
int main(){
scanf("%d%d", &n, &m);
for(i=1; i<=n; i++){
scanf("%d", &a[i]);
c[++k] = a[i];
}
for(i=1; i<=m; i++){
scanf("%d", &b[i]);
c[++k] = b[i];
}
sort(c+1, c+k+1);
for(i=1; i<=n; i++){
printf("%d ", lower_bound(c+1, c+k+1, a[i])-c);
}//二分查找第一次出现的位置,即该数字的排名,可用于离散化
printf("\n");
for(i=1; i<=m; i++){
printf("%d ", lower_bound(c+1, c+k+1, b[i])-c);
}
return 0;
}