#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e6 + 7;
const int inf = 1e9 + 7;
int n, m;
int p[maxn], a[maxn];
int nxt[maxn], pre[maxn];
set<pair<int, int> > S;
pair<int, int> c[maxn];
int time(int x, int y) {
  if (x == y) return inf;
  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 inf;
  int l = 1, r = inf, ans = inf;
  while (l <= r) {
    int mid = (l + r) / 2;
    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() {
  scanf("%d%d", &n, &m);
  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 == inf) 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 (auto s : S) printf("%d ", s.second + 1);
  printf("\n");
}
