#include <bits/stdc++.h>
using namespace std;
int n, m;
int p[100000 + 10], a[100000 + 10];
int x[100000 + 10];
int nextt[100000 + 10], pre[100000 + 10];
bool cmp(int i, int j) { return p[i] < p[j]; }
set<pair<int, int> > st;
set<pair<int, int> >::iterator it;
const int inf = 0x3f3f3f3f;
int dis(int i, int j) {
  if (i == j) return inf;
  int d = (p[j] - p[i] + m) % m;
  if (i > j) d = (d + a[j]) % m;
  if (d <= a[i]) return 1;
  if (a[i] <= a[j]) return inf;
  int s = a[i] - a[j];
  return (d - a[j] - 1) / s + 1;
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) {
    scanf("%d%d", &p[i], &a[i]);
    p[i]--;
    x[i] = i;
  }
  sort(x + 1, x + n + 1, cmp);
  for (int i = 1; i <= n; i++) {
    if (i < n)
      nextt[x[i]] = x[i + 1];
    else
      nextt[x[i]] = x[1];
    pre[nextt[x[i]]] = x[i];
  }
  for (int i = 1; i <= n; i++) {
    st.insert(make_pair(dis(i, nextt[i]), i));
  }
  while (!st.empty()) {
    it = st.begin();
    if (it->first == inf) break;
    int i = it->second;
    st.erase(it);
    st.erase(make_pair(dis(nextt[i], nextt[nextt[i]]), nextt[i]));
    st.erase(make_pair(dis(pre[i], i), pre[i]));
    p[i] += dis(i, nextt[i]);
    a[i]--;
    nextt[i] = nextt[nextt[i]];
    pre[nextt[i]] = i;
    st.insert(make_pair(dis(pre[i], i), pre[i]));
    st.insert(make_pair(dis(i, nextt[i]), i));
  }
  printf("%d\n", st.size());
  for (it = st.begin(); it != st.end(); it++) {
    if (it != st.begin()) printf(" ");
    printf("%d", it->second);
  }
  printf("\n");
  return 0;
}
