#include <bits/stdc++.h>
using namespace std;
int n, m;
int p[1000100], a[1000100];
int nxt[1000100], pre[1000100];
set<pair<int, int> > S;
pair<int, int> c[1000100];
int time(int x, int y) {
  if (x == y) return 0x3f3f3f3f;
  long long p1 = p[x], p2 = p[y];
  if (x > y) p2 = (p2 + a[y]) % m;
  if (p2 < p1) p2 += m;
  if (p2 - p1 <= a[x]) return 1;
  if (a[y] >= a[x]) return 0x3f3f3f3f;
  int l = 1, r = 0x3f3f3f3f, ans = 0x3f3f3f3f;
  while (l <= r) {
    int mid = (l + r) >> 1;
    if (p1 + 1ll * a[x] * mid >= p2 + 1ll * a[y] * (mid - 1))
      ans = mid, r = mid - 1;
    else
      l = mid + 1;
  }
  return ans;
}
int main() {
  int t, C = 1;
  while (scanf("%d%d", &n, &m) != EOF) {
    for (int i = 0; i < n; i++) {
      scanf("%d%d", &p[i], &a[i]);
      p[i]--;
      c[i].first = p[i];
      c[i].second = i;
    }
    sort(c, c + n);
    for (int i = 0; i < n; i++) {
      nxt[c[i].second] = c[(i + 1) % n].second;
      pre[c[i].second] = c[(i - 1 + n) % n].second;
    }
    for (int i = 0; i < n; i++) S.insert(make_pair(time(i, nxt[i]), i));
    while (!S.empty()) {
      pair<int, int> now = *S.begin();
      if (now.first == 0x3f3f3f3f) break;
      S.erase(now);
      int x = now.second;
      S.erase(make_pair(time(nxt[x], nxt[nxt[x]]), nxt[x]));
      S.erase(make_pair(time(pre[x], x), pre[x]));
      p[x] += now.first;
      a[x]--;
      nxt[x] = nxt[nxt[x]];
      pre[nxt[x]] = x;
      S.insert(make_pair(time(pre[x], x), pre[x]));
      S.insert(make_pair(time(x, nxt[x]), x));
    }
    printf("%d\n", S.size());
    for (set<pair<int, int> >::iterator it = S.begin(); it != S.end(); it++)
      printf("%d ", (*it).second + 1);
    printf("\n");
  }
  return 0;
}
