#include <bits/stdc++.h>
using namespace std;
double Fib(double x, double z);
string BinDec(unsigned long long x);
string StringInt(long long x);
unsigned long long StringInt(string x);
unsigned long long BinDec(string x);
unsigned long long POWMOD(unsigned long long x, unsigned long long y,
                          unsigned long long mod);
unsigned long long POWE(long long, long long);
multimap<long long, int> se;
multimap<long long, int>::iterator it;
long long a, b, x, y, i, j, z[100200] = {}, d, k = 0, aa[100200] = {},
                            bb[100200] = {};
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> a >> b >> x >> y;
  for (i = 0; i < a; i++) cin >> z[i];
  se.insert({1e11, 1e6});
  se.insert({1e12, 1e6});
  se.insert({-1e10, -1e6});
  for (i = 0; i < b; i++) {
    cin >> d;
    se.insert({d, i + 1});
  }
  for (i = 0; i < a; i++) {
    it = se.lower_bound(z[i] - x);
    if (it->first >= z[i] - x && it->first <= z[i] + y) {
      aa[k] = i + 1;
      bb[k] = it->second;
      k++;
      se.erase(it);
    } else {
      it++;
      if (it->first >= z[i] - x && it->first <= z[i] + y) {
        aa[k] = i + 1;
        bb[k] = it->second;
        k++;
        se.erase(it);
      }
    }
  }
  cout << k << '\n';
  for (i = 0; i < k; i++) cout << aa[i] << ' ' << bb[i] << '\n';
  return 0;
}
double Fib(double x, double z) {
  int i = 0;
  double f = x, r = x, t;
  for (i = 2; i < z; i++) {
    t = f;
    f += r;
    r = t;
  }
  return f;
}
string BinDec(unsigned long long x) {
  string z;
  while (1) {
    z += ((x % 3) + '0');
    x /= 3;
    if (x == 0) break;
  }
  while (1) {
    if (z.size() == 30) break;
    z += '0';
  }
  reverse(z.begin(), z.end());
  return z;
}
unsigned long long BinDec(string x) {
  long long i;
  unsigned long long z = 1, a = 0;
  for (i = x.size() - 1; i >= 0; i--) {
    if (x[i] == '1') a += z;
    if (x[i] == '2') a += (2 * z);
    z *= 3;
  }
  return a;
}
unsigned long long StringInt(string x) {
  unsigned long long z = 0, i;
  for (i = 0; i < x.size(); i++) {
    z *= 10;
    z += (x[i] - '0');
  }
  return z;
}
string StringInt(long long x) {
  string z;
  while (x != 0) {
    z += (x % 10 + '0');
    x /= 10;
  }
  reverse(z.begin(), z.end());
  return z;
}
unsigned long long POWMOD(unsigned long long base, unsigned long long exp,
                          unsigned long long mod) {
  unsigned long long res = 1;
  while (exp > 0) {
    if (exp % 2 == 1) res = (res * base);
    res %= mod;
    exp /= 2;
    base = (base * base);
    base %= mod;
  }
  return res % mod;
}
unsigned long long POWE(long long base, long long exp) {
  unsigned long long res = 1;
  while (exp > 0) {
    if (exp % 2 == 1) res = (res * base);
    exp /= 2;
    base = (base * base);
  }
  return res;
}
