#include <bits/stdc++.h>
using namespace std;
const int MaxN = 100010;
int N, M, L, R;
int t;
pair<int, int> A[MaxN], B[MaxN];
int p;
int run() {
  if (scanf("%d %d %d %d", &N, &M, &L, &R) != 4) return 0;
  for (int i = 0; i < N; ++i) {
    scanf("%d", &t);
    A[i] = make_pair(t, i);
  }
  for (int j = 0; j < M; ++j) {
    scanf("%d", &t);
    B[j] = make_pair(t, j);
  }
  sort(A, A + N);
  sort(B, B + M);
  p = 0;
  int res = 0;
  vector<int> U, V;
  for (int i = 0; i < N; ++i) {
    for (; p < M && B[p].first < A[i].first - L; ++p)
      ;
    if (p < M && B[p].first <= A[i].first + R) {
      ++res;
      U.push_back(A[i].second + 1);
      V.push_back(B[p].second + 1);
      ++p;
    }
  }
  printf("%d\n", res);
  for (int i = 0; i < res; ++i) printf("%d %d\n", U[i], V[i]);
  return 1;
}
int main() {
  while (run())
    ;
  return 0;
}
