#include <bits/stdc++.h>
using namespace std;
bool debug = 0;
int n, m, k;
int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};
string direc = "RDLU";
long long ln, lk, lm;
int p[100005], a[100005], pre[100005], nxt[100005];
pair<int, int> vp[100005];
long long cc(int i, int j) {
  if (i == j) return (1LL << 60);
  long long dis = (p[j] - p[i] + m) % m;
  if (j < i) dis += a[j];
  dis %= m;
  long long step = a[i] - a[j];
  if (dis <= step) return 1;
  if (dis <= a[i]) return 1;
  if (step <= 0) return (1LL << 60);
  return (dis - a[j] + step - 1) / step;
}
long long cal(int i, int j) {
  long long g = cc(i, j);
  return g;
}
set<pair<long long, int>> sp;
void fmain() {
  scanf("%d%d", &n, &m);
  for (int(i) = 1; (i) <= (int)(n); (i)++) {
    scanf("%d%d", p + i, a + i);
    p[i]--;
  }
  for (int(i) = 1; (i) <= (int)(n); (i)++) vp[i] = {p[i], i};
  sort(vp + 1, vp + 1 + n);
  for (int(i) = 1; (i) <= (int)(n); (i)++) pre[vp[i].second] = vp[i - 1].second;
  for (int i = n; i; i--) nxt[vp[i].second] = vp[i + 1].second;
  pre[vp[1].second] = vp[n].second;
  nxt[vp[n].second] = vp[1].second;
  for (int(i) = 1; (i) <= (int)(n); (i)++) {
    sp.insert({cal(i, nxt[i]), i});
  }
  while (!sp.empty()) {
    auto it = *sp.begin();
    int i = it.second;
    if (it.first == (1LL << 60)) break;
    sp.erase(it);
    sp.erase({cal(pre[i], i), pre[i]});
    sp.erase({cal(nxt[i], nxt[nxt[i]]), nxt[i]});
    p[i] += cal(i, nxt[i]);
    a[i]--;
    int j = nxt[i];
    nxt[i] = nxt[nxt[i]];
    pre[nxt[j]] = i;
    sp.insert({cal(pre[i], i), pre[i]});
    sp.insert({cal(i, nxt[i]), i});
  }
  printf("%d\n", sp.size());
  for (auto p : sp) printf("%d ", p.second);
}
int main() {
  fmain();
  return 0;
}
