#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5, inf = 2e9;
set<pair<int, int> > s;
int p[N], a[N], q[N], n, m, f[N], b[N];
inline int read() {
  int x = 0, f = 1;
  char c = getchar();
  while (!isdigit(c)) {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (isdigit(c)) x = (x << 3) + (x << 1) + c - '0', c = getchar();
  return x * f;
}
inline bool ctrl(int x, int y) { return p[x] < p[y]; }
int calc(int x, int y) {
  if (x == y) return inf;
  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 inf;
  return (d - a[y] - 1) / (a[x] - a[y]) + 1;
}
int main() {
  cin >> n >> m;
  for (register int i = 1; i <= n; ++i)
    p[i] = read() - 1, a[i] = read(), q[i] = i;
  sort(q + 1, q + n + 1, ctrl);
  for (register int i = 1; i <= n; ++i) f[q[i]] = q[i + 1], b[q[i]] = q[i - 1];
  f[q[n]] = q[1], b[q[1]] = q[n];
  for (register int i = 1; i <= n; ++i) s.insert(make_pair(calc(i, f[i]), i));
  while (1) {
    pair<int, int> u = *s.begin();
    if (u.first == inf) break;
    int v = u.second;
    s.erase(s.begin());
    s.erase(make_pair(calc(f[v], f[f[v]]), f[v]));
    if (!s.empty()) s.erase(make_pair(calc(b[v], v), b[v]));
    p[v] = (p[v] + u.first) % m;
    --a[v];
    f[v] = f[f[v]], b[f[v]] = v;
    s.insert(make_pair(calc(b[v], v), b[v]));
    s.insert(make_pair(calc(v, f[v]), v));
  }
  printf("%d\n", s.size());
  for (set<pair<int, int> >::iterator i = s.begin(); i != s.end(); ++i)
    printf("%d ", i->second);
  return 0;
}
