#include <bits/stdc++.h>
using namespace std;
int n, m;
int from[100010], to[100010], p[100010], a[100010];
set<pair<int, int> > s;
int num[100010];
int dis(int x, int y) {
  if (x == y) return 2147483647;
  int d = ((p[y] - p[x] + m) % m + (x <= y ? 0 : a[y])) % m;
  if (d <= a[x]) return 1;
  if (a[x] <= a[y]) return 2147483647;
  return (d - a[y] - 1) / (a[x] - a[y]) + 1;
}
bool pd(int i, int j) { return p[i] < p[j]; }
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; ++i) {
    scanf("%d%d", &p[i], &a[i]);
    num[i] = i;
  }
  sort(num + 1, num + 1 + n, pd);
  for (int i = 1; i <= n; ++i) {
    to[num[i]] = num[i % n + 1];
    from[to[num[i]]] = num[i];
  }
  for (int i = 1; i <= n; ++i) {
    s.insert(make_pair(dis(i, to[i]), i));
  }
  for (; !s.empty();) {
    pair<int, int> i = *s.begin();
    if (i.first == 2147483647) break;
    int o = i.second;
    s.erase(i);
    s.erase(make_pair(dis(to[o], to[to[o]]), to[o]));
    s.erase(make_pair(dis(from[o], o), from[o]));
    p[o] += dis(o, to[o]);
    --a[o];
    to[o] = to[to[o]];
    from[to[o]] = o;
    s.insert(make_pair(dis(from[o], o), from[o]));
    s.insert(make_pair(dis(o, to[o]), o));
  }
  printf("%d\n", s.size());
  for (set<pair<int, int> >::iterator it = s.begin(); it != s.end(); ++it) {
    printf("%d ", (*it).second);
  }
}
