#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 10;
int done[3][maxn], cnt[3][maxn], ans[maxn];
int n, m;
set<int> s[3];
inline int next(int ind, int act) {
  set<int>::iterator it = s[act].upper_bound(ind);
  if (it == s[act].begin()) return *(--s[act].end());
  return *(--it);
}
void f(int ind, int level, int act) {
  if (level < 0) return;
  if (s[act].empty()) return;
  int other = next((((m - 1 - ind - done[act][ind]) % m) + m) % m, 1 - act);
  done[act][ind] = m - 1 - ((other + ind) % m);
  for (int i = done[act][ind]; i <= level && cnt[act][ind] > 0;) {
    f(other, i - 1, 1 - act);
    int M = min(cnt[act][ind], cnt[1 - act][other]);
    cnt[act][ind] -= M;
    cnt[1 - act][other] -= M;
    ans[m - 1 - i] += M;
    done[1 - act][other] = i + 1;
    other = next((other - 1 + m) % m, 1 - act);
    i = m - 1 - ((other + ind) % m);
  }
  if (cnt[act][ind] == 0) s[act].erase(ind);
  done[act][ind] = level + 1;
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n; i++) {
    int x;
    scanf("%d", &x);
    x %= m;
    if (++cnt[0][x] == 1) s[0].insert(x);
  }
  for (int i = 0; i < n; i++) {
    int x;
    scanf("%d", &x);
    x %= m;
    if (++cnt[1][x] == 1) s[1].insert(x);
  }
  for (int i = 0; i < m; i++) {
    if (cnt[0][i]) f(i, m, 0);
  }
  for (int i = m - 1; i >= 0; i--) {
    for (int j = 0; j < ans[i]; j++) printf("%d ", i);
  }
}
