#include <bits/stdc++.h>
using namespace std;
int n, m, xb, p[120000], c[120000], pre[120000], nxt[120000], out[120000];
set<pair<int, int> > se;
struct node {
  int x, y, i;
  bool operator<(const node p) const { return x < p.x; }
} a[120000];
int dist(int x, int y) {
  if (x == y) return 0x3f3f3f3f;
  int d = (p[y] - p[x] + m) % m;
  if (y < x) d += c[y];
  if (d >= m) return 0x3f3f3f3f;
  if (d <= c[x]) return 1;
  if (c[x] <= c[y]) return 0x3f3f3f3f;
  return (d - c[y] - 1) / (c[x] - c[y]) + 1;
}
int main() {
  scanf("%d%d", &n, &m);
  if (n == 1) {
    puts("1\n1");
    return 0;
  }
  for (int i = 1; i <= n; ++i) {
    scanf("%d%d", &a[i].x, &a[i].y);
    p[i] = a[i].x;
    c[i] = a[i].y;
    a[i].i = i;
  }
  sort(a + 1, a + n + 1);
  for (int i = 2; i < n; ++i) {
    pre[a[i].i] = a[i - 1].i;
    nxt[a[i].i] = a[i + 1].i;
    se.insert(make_pair(dist(a[i].i, nxt[a[i].i]), a[i].i));
  }
  nxt[a[1].i] = a[2].i;
  pre[a[1].i] = a[n].i;
  se.insert(make_pair(dist(a[1].i, a[2].i), a[1].i));
  nxt[a[n].i] = a[1].i;
  pre[a[n].i] = a[n - 1].i;
  se.insert(make_pair(dist(a[n].i, a[1].i), a[n].i));
  while (1) {
    if (se.size() < 2 || se.begin()->first >= 0x3f3f3f3f) break;
    int i = se.begin()->second, j = nxt[i];
    se.erase(make_pair(dist(j, nxt[j]), j));
    se.erase(make_pair(dist(i, j), i));
    se.erase(make_pair(dist(pre[i], i), pre[i]));
    pre[nxt[j]] = pre[j];
    nxt[pre[j]] = nxt[j];
    p[i] += dist(i, j);
    --c[i];
    se.insert(make_pair(dist(pre[i], i), pre[i]));
    se.insert(make_pair(dist(i, nxt[i]), i));
  }
  printf("%d\n", se.size());
  while (!se.empty()) {
    out[++xb] = se.begin()->second;
    se.erase(se.begin());
  }
  for (int i = 1; i <= xb; ++i) printf(i == xb ? "%d\n" : "%d ", out[i]);
  return 0;
}
