#include <bits/stdc++.h>
using namespace std;
int n, m, a[100001], v[100001], posa[100001], posv[100001], x, y;
int inx[100001];
inline void kspxa(int s, int t) {
  if (s < t) {
    int i = s, j = t, k = (i + j) >> 1;
    int l = a[i];
    a[i] = a[k];
    a[k] = l;
    l = posa[i];
    posa[i] = posa[k];
    posa[k] = l;
    k = a[i];
    l = posa[i];
    while (i != j) {
      while (i < j && a[j] > k) --j;
      if (i < j) a[i] = a[j], posa[i++] = posa[j];
      while (i < j && a[i] < k) ++i;
      if (i < j) a[j] = a[i], posa[j--] = posa[i];
    }
    a[i] = k;
    posa[i] = l;
    kspxa(s, i - 1);
    kspxa(i + 1, t);
  }
}
inline void kspxv(int s, int t) {
  if (s < t) {
    int i = s, j = t, k = (i + j) >> 1;
    int l = v[i];
    v[i] = v[k];
    v[k] = l;
    l = posv[i];
    posv[i] = posv[k];
    posv[k] = l;
    k = v[i];
    l = posv[i];
    while (i != j) {
      while (i < j && v[j] > k) --j;
      if (i < j) v[i] = v[j], posv[i++] = posv[j];
      while (i < j && v[i] < k) ++i;
      if (i < j) v[j] = v[i], posv[j--] = posv[i];
    }
    v[i] = k;
    posv[i] = l;
    kspxv(s, i - 1);
    kspxv(i + 1, t);
  }
}
int main() {
  scanf("%d%d%d%d", &n, &m, &x, &y);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]), posa[i] = i;
  for (int i = 1; i <= m; i++) scanf("%d", &v[i]), posv[i] = i;
  kspxa(1, n);
  kspxv(1, m);
  int left = 1, ans = 0;
  memset(inx, 0, sizeof(inx));
  for (int i = 1; i <= n; i++) {
    if (left > m) break;
    while (left <= m && v[left] < a[i] - x) ++left;
    if (left > m) break;
    if (v[left] >= a[i] - x && v[left] <= a[i] + y)
      inx[posa[i]] = posv[left], ++left, ++ans;
  }
  printf("%d\n", ans);
  for (int i = 1; i <= n; i++)
    if (inx[i]) printf("%d %d\n", i, inx[i]);
}
