#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:640000000")
using namespace std;
const int nmax = 200000;
int n, m, mt[nmax], x, y, it1 = 1, it2 = 1;
pair<int, int> a[nmax], b[nmax];
bool used[nmax];
vector<pair<int, int> > ans;
int main() {
  scanf("%d%d%d%d", &n, &m, &x, &y);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i].first), a[i].second = i;
  for (int j = 1; j <= m; j++) scanf("%d", &b[j].first), b[j].second = j;
  sort(a + 1, a + n + 1);
  sort(b + 1, b + m + 1);
  while (true) {
    if (it1 > n || it2 > m) break;
    if (b[it2].first > a[it1].first + y) {
      if (it1 < n)
        it1++;
      else
        it2++;
      continue;
    };
    if (b[it2].first < a[it1].first - x) {
      if (it2 < m)
        it2++;
      else
        it1++;
      continue;
    };
    if (b[it2].first >= a[it1].first - x && b[it2].first <= a[it1].first + y) {
      ans.push_back(make_pair(a[it1].second, b[it2].second));
      it1++;
      it2++;
    };
  };
  printf("%d\n", ans.size());
  for (int i = 0; i < ans.size(); i++)
    printf("%d %d\n", ans[i].first, ans[i].second);
  return 0;
}
