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

using std::vector;
typedef std::pair<int,int> pii;

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

class QueueMin {
  vector <pii> list;
  int start;
public:
  QueueMin() {
    start = 0;
  }

  void push_back(int index, int value) {
    while (!empty() && list.back().second >= value) {
      list.pop_back();
    }
    list.push_back(pii(index, value));
  }

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

  pii 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, 1);
  vector <int> prev(n + 1, -1);
  vector <QueueMin> queues(2);
  queues[dp[0]].push_back(0, sum[0]);

  for (int i = 1; i <= n; ++i) {
    dp[i] = dp[i - 1] - 2;

    for (int x = int(queues.size()) - 2; x < int(queues.size()); ++x) {
      QueueMin & q = queues[x];
      if (q.empty()) { continue; }
      pii best = q.getMin();
      int cur = x + sign(sum[i] - best.second);
      if (cur > dp[i]) {
        dp[i] = cur;
        prev[i] = best.first;
      }
    }
    if (dp[i] == int(queues.size())) {
      queues.push_back(QueueMin());
    }
    queues[dp[i]].push_back(i, sum[i]);
    if (i >= r) {
      queues[dp[i - r]].pop_front(i - r);
    }
  }

  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;
}
