#include <bits/stdc++.h>
using namespace std;
const int inf = 1e9 + 7;
int bSearch(long long sum, long long cha, long long tmp, long long tmp2) {
  long long l = 0, r = inf, mid;
  while (l <= r) {
    mid = (l + r) >> 1;
    if (tmp + cha * mid >= sum + tmp2)
      r = mid - 1;
    else
      l = mid + 1;
  }
  if (l + 2 >= inf) return inf;
  return l + 2;
}
struct fro {
  int pos, abi, id;
};
int m;
bool cmppos(fro a, fro b) { return a.pos < b.pos; }
bool cmpid(fro a, fro b) { return a.id < b.id; }
fro frogs[1000050];
int bef[1000050], aft[1000050];
set<pair<int, int> > S;
int cal(int me) {
  int nxt = aft[me];
  if (me == nxt) return inf;
  int np = frogs[nxt].pos;
  int mp = frogs[me].pos;
  if (frogs[me].id < frogs[nxt].id) {
    int cha;
    if (np < mp) {
      np += m;
    }
    cha = np - mp;
    cha -= frogs[me].abi;
    if (cha <= 0) return 1;
    if (frogs[nxt].abi >= frogs[me].abi) return inf;
    return bSearch(cha, frogs[me].abi - frogs[nxt].abi, frogs[me].abi,
                   frogs[nxt].abi);
  } else {
    int cha;
    np += frogs[nxt].abi;
    np %= m;
    if (np < mp) {
      np += m;
    }
    cha = np - mp;
    cha -= frogs[me].abi;
    if (cha <= 0) return 1;
    if (frogs[nxt].abi >= frogs[me].abi) return inf;
    return bSearch(cha, frogs[me].abi - frogs[nxt].abi, frogs[me].abi,
                   frogs[nxt].abi);
  }
}
int main() {
  int n;
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n; i++) {
    scanf("%d%d", &frogs[i].pos, &frogs[i].abi);
    frogs[i].pos--;
    frogs[i].id = i;
  }
  sort(frogs, frogs + n, cmppos);
  for (int i = 0; i < n - 1; i++) {
    aft[frogs[i].id] = frogs[i + 1].id;
  }
  aft[frogs[n - 1].id] = frogs[0].id;
  for (int i = n - 1; i > 0; i--) {
    bef[frogs[i].id] = frogs[i - 1].id;
  }
  bef[frogs[0].id] = frogs[n - 1].id;
  sort(frogs, frogs + n, cmpid);
  S.clear();
  for (int i = 0; i < n; i++) {
    S.insert(make_pair(cal(i), i));
  }
  int last;
  while (!S.empty()) {
    pair<int, int> me = *S.begin();
    if (me.first == inf) break;
    S.erase(me);
    S.erase(make_pair(cal(bef[me.second]), bef[me.second]));
    S.erase(make_pair(cal(aft[me.second]), aft[me.second]));
    frogs[me.second].pos += me.first;
    frogs[me.second].abi--;
    aft[me.second] = aft[aft[me.second]];
    bef[aft[me.second]] = me.second;
    S.insert(make_pair(cal(bef[me.second]), bef[me.second]));
    S.insert(make_pair(cal(me.second), me.second));
  }
  printf("%d\n", S.size());
  while (!S.empty()) {
    pair<int, int> me;
    me = *S.begin();
    S.erase(S.begin());
    printf("%d ", me.second + 1);
  }
}
