#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
int p[100010], a[100010];
int m;
int cost_time(int x, int y) {
  if (x == y) return INF;
  int p1 = p[x], p2 = p[y];
  if (x > y) p2 += a[y], p2 %= m;
  if (p2 < p1) p2 += m;
  if (p2 - p1 <= a[x]) return 1;
  if (a[x] <= a[y]) return INF;
  int l = 1, r = INF;
  while (l != r) {
    int mid = (l + r) >> 1;
    if (p1 + (long long)a[x] * mid >= p2 + (long long)a[y] * (mid - 1))
      r = mid;
    else
      l = mid + 1;
  }
  return r;
}
pair<int, int> frogs[100010];
int pre[100010], nxt[100010];
set<pair<int, int> > dic;
int main() {
  int n;
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) {
    scanf("%d%d", p + i, a + i);
    frogs[i] = pair<int, int>(p[i], i);
  }
  sort(frogs + 1, frogs + 1 + n);
  for (int i = 1; i <= n; i++) {
    int id = frogs[i].second;
    pre[id] = frogs[(i == 1 ? n : i - 1)].second;
    nxt[id] = frogs[(i == n ? 1 : i + 1)].second;
    dic.insert(pair<int, int>(cost_time(id, nxt[id]), id));
  }
  while (!dic.empty()) {
    pair<int, int> cur = *dic.begin();
    int min_cost = cur.first, cur_id = cur.second;
    if (min_cost == INF) break;
    dic.erase(cur);
    dic.erase(
        pair<int, int>(cost_time(nxt[cur_id], nxt[nxt[cur_id]]), nxt[cur_id]));
    dic.erase(pair<int, int>(cost_time(pre[cur_id], cur_id), pre[cur_id]));
    p[cur_id] += min_cost, a[cur_id]--;
    pre[nxt[nxt[cur_id]]] = cur_id;
    nxt[cur_id] = nxt[nxt[cur_id]];
    dic.insert(pair<int, int>(cost_time(pre[cur_id], cur_id), pre[cur_id]));
    dic.insert(pair<int, int>(cost_time(cur_id, nxt[cur_id]), cur_id));
  }
  printf("%d\n", (int)dic.size());
  for (set<pair<int, int> >::iterator it = dic.begin(); it != dic.end(); it++)
    printf("%d ", it->second);
  puts("");
  return 0;
}
