#include <bits/stdc++.h>
using namespace std;
int N, M, X, Y, di, ai;
vector<pair<int, int> > desired, available, ans;
int main() {
  cin >> N >> M >> X >> Y;
  for (int i = 0; i < N; i++) {
    int tmp;
    cin >> tmp;
    desired.push_back(pair<int, int>(tmp, i + 1));
  }
  sort(desired.begin(), desired.end());
  for (int i = 0; i < M; i++) {
    int tmp;
    cin >> tmp;
    available.push_back(pair<int, int>(tmp, i + 1));
  }
  sort(available.begin(), available.end());
  while (true) {
    if (di == N || ai == M) break;
    if (desired[di].first - X <= available[ai].first &&
        available[ai].first <= desired[di].first + Y) {
      ans.push_back(pair<int, int>(desired[di].second, available[ai].second));
      di++;
      ai++;
    } else if (desired[di].first + Y < available[ai].first) {
      di++;
    } else if (desired[di].first - X > available[ai].first) {
      ai++;
    }
  }
  cout << ans.size() << ('\n');
  for (int i = 0; i < ans.size(); i++) {
    cout << ans[i].first << ' ' << ans[i].second << ('\n');
  }
  return 0;
}
