#include <bits/stdc++.h>
using namespace std;
int n, m, x[100010], p[100010], a[100010], pre[100010], nxt[100010];
inline int cmp(int x, int y) { return p[x] < p[y]; }
inline int getdis(int i, int j) {
  if (i == j) return 0x3f3f3f3f;
  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 0x3f3f3f3f;
  return (d - a[j] - 1) / (a[i] - a[j]) + 1;
}
set<pair<int, int> > st;
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) x[i] = i;
  for (int i = 1; i <= n; i++) {
    scanf("%d%d", &p[i], &a[i]);
    p[i]--;
  }
  sort(x + 1, x + n + 1, cmp);
  for (int i = 1; i < n; i++) {
    pre[x[i + 1]] = x[i];
    nxt[x[i]] = x[i + 1];
  }
  pre[x[1]] = x[n];
  nxt[x[n]] = x[1];
  for (int i = 1; i <= n; i++) st.insert(make_pair(getdis(i, nxt[i]), i));
  while (!st.empty()) {
    if (st.begin()->first == 0x3f3f3f3f) break;
    auto c = *st.begin();
    st.erase(st.begin());
    int P = c.second, Q = nxt[P];
    st.erase(make_pair(getdis(pre[P], P), pre[P]));
    st.erase(make_pair(getdis(Q, nxt[Q]), Q));
    p[P] += getdis(P, Q);
    a[P]--;
    pre[nxt[Q]] = P;
    nxt[P] = nxt[Q];
    st.insert(make_pair(getdis(pre[P], P), pre[P]));
    st.insert(make_pair(getdis(P, nxt[P]), P));
  }
  printf("%d\n", st.size());
  for (auto &x : st) printf("%d ", x.second);
  return 0;
}
