#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 15;
const int inf = 1e9;
const int md = 1e9 + 7;
class item {
 public:
  int first, num;
  item() {}
};
int n, m, first, second;
int u[maxn];
vector<item> a;
vector<item> b;
int p1, p2;
vector<pair<int, int> > ans;
void movePointer(int i) {
  for (; p1 < b.size(); ++p1)
    if (a[i].first - first <= b[p1].first && u[p1] == 0) break;
  for (; p2 < b.size(); ++p2)
    if (a[i].first + second < b[p2].first) break;
}
bool cmp(item a, item b) { return a.first < b.first; }
int main() {
  cin >> n >> m >> first >> second;
  a.resize(n);
  b.resize(m);
  for (int i = 0; i < n; ++i) cin >> a[i].first, a[i].num = i;
  for (int i = 0; i < m; ++i) cin >> b[i].first, b[i].num = i;
  sort(a.begin(), a.end(), cmp);
  sort(b.begin(), b.end(), cmp);
  for (int i = 0; i < n; ++i) {
    movePointer(i);
    if (p1 >= p2) continue;
    ans.push_back(make_pair(a[i].num + 1, b[p1].num + 1));
    u[p1] = 1;
  }
  cout << ans.size() << endl;
  for (int i = 0; i < ans.size(); ++i)
    cout << ans[i].first << " " << ans[i].second << endl;
  return 0;
}
