#include <cstdio>
#include <cassert>
#include <vector>
#include <algorithm>
#include <functional>

using namespace std;

const int INF = (1 << 29);

static inline int sign(int x) {
  if (x > 0) {
    return 1;
  } else if (x < 0) {
    return -1;
  } else {
    return 0;
  }
}

template < class T, class Comparator = less<T> >
class QueueMin {
  Comparator comparator;
  vector < pair<int, T> > list;
  int start;
public:
  QueueMin() : comparator(), start(0) {
  }

  void push_back(int index, T value) {
    while (!empty() && !comparator(list.back().second, value)) {
      list.pop_back();
    }
    list.push_back(make_pair(index, value));
  }

  void pop_front(int index) {
    assert(!empty());
    if (list[start].first == index) {
      start++;
    }
  }

  pair<int, T> getMin() const {
    assert(!empty());
    return list[start];
  }

  bool empty() const {
    return int(list.size()) == start;
  }
};

int main() {
  freopen("demo.in", "r", stdin);
  freopen("demo.out", "w", stdout);

  int n, l, r;
  scanf("%d%d%d", &n, &l, &r);
  vector <int> sum(n + 1, 0);
  for (int i = 1; i <= n; ++i) {
    int x, y;
    scanf("%d%d", &x, &y);
    sum[i] = sum[i - 1] + (x - y);
  }

  vector <int> dp(n + 1, 0);
  vector <int> prev(n + 1, -1);
  QueueMin<int, greater<int> > all;
  vector <QueueMin<int> > queues(2 * n + 1);

  for (int i = 1; i <= n; ++i) {
    if (i >= r + 1 && dp[i - r - 1] != -INF) {
      all.pop_front(i - r - 1);
      queues[dp[i - r - 1] + n].pop_front(i - r - 1);
    }
    if (i >= l && dp[i - l] != -INF) {
      all.push_back(i - l, dp[i - l]);
      queues[dp[i - l] + n].push_back(i - l, sum[i - l]);
    }

    dp[i] = -INF;
    if (all.empty()) { continue; }

    int x = all.getMin().second;
    for (int y = -1; y <= 1; ++y) {
      int z = x + y;
      if (!(-n <= z && z <= n)) { continue; }

      QueueMin<int> & q = queues[z + n];
      if (q.empty()) { continue; }

      pair<int,int> best = q.getMin();
      int cur = z + sign(sum[i] - best.second);
      if (cur > dp[i]) {
        dp[i] = cur;
        prev[i] = best.first;
      }
    }
  }

  assert(dp[n] != -INF);

  vector <int> res;
  int cur;
  for (cur = n; cur > 0; cur = prev[cur]) {
    res.push_back(cur);
  }
  assert(cur == 0);
  res.push_back(0);

  std::reverse(res.begin(), res.end());

  int x = int(res.size()) - 1;
  printf("%d\n", x);
  for (int i = 1; i <= x; ++i) {
    printf("%d %d\n", res[i - 1] + 1, res[i]);
  }

  return 0;
}
