#include <bits/stdc++.h>
using namespace std;
inline int read() {
  register int x = 0, t = 1;
  register char ch = getchar();
  while ((ch < '0' || ch > '9') && ch != '-') ch = getchar();
  if (ch == '-') t = -1, ch = getchar();
  while (ch <= '9' && ch >= '0') x = x * 10 + ch - 48, ch = getchar();
  return x * t;
}
int p[111111], a[111111], n, m, q[111111], nt[111111], lt[111111];
set<pair<int, int> > S;
bool cmp(int a, int b) { return p[a] < p[b]; }
int calc(int x, int y) {
  if (x == y) return 1e9;
  int d = (p[y] - p[x] + m) % m;
  if (y < x) d = (d + a[y]) % m;
  if (d <= a[x]) return 1;
  if (a[x] <= a[y]) return 1e9;
  return (d - a[y] - 1) / (a[x] - a[y]) + 1;
}
int main() {
  n = read();
  m = read();
  for (int i = 1; i <= n; ++i) p[i] = read() - 1, a[i] = read(), q[i] = i;
  sort(&q[1], &q[n + 1], cmp);
  for (int i = 1; i <= n; ++i) nt[q[i]] = q[i + 1], lt[q[i]] = q[i - 1];
  nt[q[n]] = q[1];
  lt[q[1]] = q[n];
  for (int i = 1; i <= n; ++i) S.insert(make_pair(calc(i, nt[i]), i));
  while (233) {
    pair<int, int> u = *S.begin();
    if (u.first == 1e9) break;
    int v = u.second;
    S.erase(S.begin());
    S.erase(make_pair(calc(nt[v], nt[nt[v]]), nt[v]));
    if (!S.empty()) S.erase(make_pair(calc(lt[v], v), lt[v]));
    p[v] += calc(v, nt[v]);
    p[v] %= m;
    --a[v];
    nt[v] = nt[nt[v]];
    lt[nt[v]] = v;
    S.insert(make_pair(calc(lt[v], v), lt[v]));
    S.insert(make_pair(calc(v, nt[v]), v));
  }
  printf("%d\n", S.size());
  for (set<pair<int, int> >::iterator it = S.begin(); it != S.end(); ++it)
    printf("%d ", it->second);
  puts("");
  return 0;
}
