#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:16777216")
using namespace std;
const double pi = 3.14159265358979323846264338327950288419716939937511;
const double eps = 1e-9;
char ch_ch_ch[1 << 20];
string gs() {
  scanf("%s", ch_ch_ch);
  return string(ch_ch_ch);
}
string gl() {
  gets(ch_ch_ch);
  return string(ch_ch_ch);
}
pair<int, int> sol[111111];
pair<int, int> bron[111111];
int ns, nb, x, y;
void solution() {
  scanf("%d%d%d%d", &nb, &ns, &x, &y);
  for (int i = 0; i < (nb); ++i) {
    scanf("%d", &bron[i].first);
    bron[i].second = i + 1;
  }
  for (int i = 0; i < (ns); ++i) {
    scanf("%d", &sol[i].first);
    sol[i].second = i + 1;
  }
  sort(sol, sol + ns);
  sort(bron, bron + nb);
  int ps = 0, push_back = 0;
  vector<int> rf, rs;
  while (ps < ns && push_back < nb) {
    while (push_back < nb && bron[push_back].first + y < sol[ps].first)
      push_back++;
    if (push_back < nb && bron[push_back].first - x <= sol[ps].first) {
      rf.push_back(sol[ps].second), rs.push_back(bron[push_back].second);
      push_back++;
    }
    ps++;
  }
  printf("%d\n", rf.size());
  for (int i = 0; i < (rf.size()); ++i) printf("%d %d\n", rs[i], rf[i]);
}
int main() {
  solution();
  return 0;
}
