#include <bits/stdc++.h>
using namespace std;
struct Node {
  int key, idx;
  bool operator<(const Node &node) const { return key < node.key; }
} a[100005], b[100005];
int n, m, x, y;
pair<int, int> ans[100005];
int main() {
  while (scanf("%d%d%d%d", &n, &m, &x, &y) == 4) {
    for (int i = 0; i < n; i++) {
      a[i].idx = i + 1;
      scanf("%d", &a[i].key);
    }
    for (int i = 0; i < m; i++) {
      b[i].idx = i + 1;
      scanf("%d", &b[i].key);
    }
    sort(a, a + n);
    sort(b, b + m);
    int res = 0;
    for (int i = 0, j = 0; i < n && j < m;) {
      if (b[j].key >= a[i].key - x && b[j].key <= a[i].key + y) {
        ans[res++] = make_pair(a[i].idx, b[j].idx);
        i++;
        j++;
      } else if (b[j].key < a[i].key - x)
        j++;
      else
        i++;
    }
    printf("%d\n", res);
    for (int i = 0; i < res; i++)
      printf("%d %d\n", ans[i].first, ans[i].second);
  }
}
