#include <bits/stdc++.h>
using namespace std;
using INT = long long;
using pii = pair<int, int>;
using pi3 = pair<int, pii>;
int n, m;
int nxt[100010];
int a[100010], b[100010];
set<pii> A, B;
set<pi3> ans;
int calc_max(int u, set<pair<int, int> > &st) {
  auto it = st.upper_bound({m - 1 - u, n + 100});
  if (it == st.begin()) return 0;
  return (*--it).second;
}
int update_A(int u) {
  int id2 = calc_max(a[u], B);
  if (id2 == 0) return 0;
  int id1 = calc_max(b[id2], A);
  if (id1 == 0) return 0;
  ans.insert(pi3(a[id1] + b[id2], pii(id1, id2)));
}
int update_B(int u) {
  int id2 = calc_max(b[u], A);
  if (id2 == 0) return 0;
  int id1 = calc_max(a[id2], B);
  if (id1 == 0) return 0;
  ans.insert(pi3(a[id2] + b[id1], pii(id2, id1)));
}
int del_A(int u) {
  int id = calc_max(a[u], B);
  if (id == 0) return 0;
  if (calc_max(b[id], A) == u) {
    auto p = pi3(a[u] + b[id], pii(u, id));
    if (ans.find(p) != ans.end()) ans.erase(p);
  }
}
int del_B(int u) {
  int id = calc_max(b[u], A);
  if (id == 0) return 0;
  if (calc_max(b[id], B) == u) {
    auto p = pi3(b[u] + a[id], pii(id, u));
    if (ans.find(p) != ans.end()) ans.erase(p);
  }
}
int main() {
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    int u;
    scanf("%d", &u);
    a[i] = u;
    A.insert({u, i});
  }
  for (int i = 1; i <= n; i++) {
    int u;
    scanf("%d", &u);
    b[i] = u;
    B.insert({u, i});
  }
  for (int i = 1; i <= n; i++) {
    update_A(i);
    update_B(i);
  }
  while (!A.empty()) {
    int u = 0, v = 0;
    pi3 p;
    if (!ans.empty()) p = *--ans.end();
    if (ans.empty() ||
        p.first < ((*--A.end()).first + (*--B.end()).first) % m) {
      u = (*--A.end()).second, v = (*--B.end()).second;
    } else
      u = p.second.first, v = p.second.second;
    printf("%d ", (a[u] + b[v]) % m);
    del_A(u);
    del_B(v);
    A.erase({a[u], u});
    B.erase({b[v], v});
    auto it = A.lower_bound({a[u], u});
    if (it != A.begin()) update_A((*--it).second);
    it = B.lower_bound({b[v], v});
    if (it != B.begin()) update_B((*--it).second);
  }
  return 0;
}
