#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10, Inf = 1e9;
int n, m, a[N], p[N], pre[N], aft[N];
struct node {
  int _p, x, id;
} f[N];
bool cmp(node A, node B) { return A._p < B._p; }
struct node2 {
  int id, ti;
  friend bool operator<(node2 A, node2 B) {
    if (A.ti == B.ti) return A.id < B.id;
    return A.ti < B.ti;
  }
};
int tim(int i, int j) {
  if (i == j) return Inf;
  int d = (p[j] - p[i] + m) % m;
  if (i > j) d += a[j], d %= m;
  if (d <= a[i]) return 1;
  if (a[i] <= a[j]) return Inf;
  return (d - a[j] - 1) / (a[i] - a[j]) + 1;
}
set<node2> g;
set<node2>::iterator it;
signed main() {
  scanf("%d %d", &n, &m);
  for (register int i = (1); i <= (n); ++i)
    scanf("%d %d", &p[i], &a[i]), p[i]--, f[i]._p = p[i], f[i].x = a[i],
                                          f[i].id = i;
  sort(f + 1, f + 1 + n, cmp);
  for (register int i = (1); i <= (n); ++i)
    pre[f[i].id] = f[i - 1].id, aft[f[i].id] = f[i + 1].id;
  aft[f[n].id] = f[1].id;
  pre[f[1].id] = f[n].id;
  for (register int i = (1); i <= (n); ++i)
    g.insert((node2){i, tim(i, aft[i])});
  while (g.size()) {
    it = g.begin();
    if (it->ti == Inf) break;
    int i = it->id;
    g.erase(it);
    g.erase((node2){pre[i], tim(pre[i], i)});
    g.erase((node2){aft[i], tim(aft[i], aft[aft[i]])});
    p[i] += tim(i, aft[i]);
    a[i]--;
    aft[i] = aft[aft[i]];
    pre[aft[i]] = i;
    g.insert((node2){i, tim(i, aft[i])});
    g.insert((node2){pre[i], tim(pre[i], i)});
  }
  printf("%d\n", g.size());
  for (it = g.begin(); it != g.end(); ++it) printf("%d ", it->id);
  printf("\n");
  return 0;
}
