#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int f = 1, x = 0;
  char ch;
  do {
    ch = getchar();
    if (ch == '-') f = -1;
  } while (ch < '0' || ch > '9');
  do {
    x = x * 10 + ch - '0';
    ch = getchar();
  } while (ch >= '0' && ch <= '9');
  return f * x;
}
const int N = 1e5;
int n, m;
int dis[N + 1];
int pos[N + 1], val[N + 1], pre[N + 1], nxt[N + 1];
set<pair<int, int> > s;
int ans;
inline bool compare(int x, int y) { return pos[x] < pos[y]; }
inline int diss(int x, int y) {
  if (y > x)
    return y - x;
  else
    return m - x + y;
}
inline int calc(int x, int y) {
  if (x == y) return 1e9;
  int d = diss(pos[x], pos[y]);
  if (x < y) {
    if (d <= val[x]) return 1;
    if (val[y] >= val[x]) return 1e9;
    int step = (d - val[x]) / (val[x] - val[y]) +
               ((d - val[x]) % (val[x] - val[y]) != 0);
    return step + ((val[x] - val[y]) * step != 0);
  } else {
    if (val[y] >= val[x]) return 1e9;
    return d / (val[x] - val[y]) + (d % (val[x] - val[y]) != 0);
  }
}
int main() {
  n = read();
  m = read();
  for (int i = 1; i <= n; i++) {
    pos[i] = read();
    val[i] = read();
    dis[i] = i;
  }
  sort(dis + 1, dis + n + 1, compare);
  for (int i = 1; i <= n; i++) {
    nxt[dis[i]] = i == n ? dis[1] : dis[i + 1];
    pre[dis[i]] = i == 1 ? dis[n] : dis[i - 1];
  }
  for (int i = 1; i <= n; i++) s.insert(make_pair(calc(i, nxt[i]), i));
  while (!s.empty()) {
    if ((*s.begin()).first == 1e9) break;
    int u = (*s.begin()).second;
    s.erase(*s.begin());
    s.erase(make_pair(calc(pre[u], u), pre[u]));
    s.erase(make_pair(calc(nxt[u], nxt[nxt[u]]), nxt[u]));
    pos[u] = (pos[u] + calc(u, nxt[u]) - 1) % m + 1;
    val[u]--;
    nxt[u] = nxt[nxt[u]];
    pre[nxt[u]] = u;
    s.insert(make_pair(calc(pre[u], u), pre[u]));
    s.insert(make_pair(calc(u, nxt[u]), u));
  }
  printf("%d\n", s.size());
  for (set<pair<int, int> >::iterator it = s.begin(); it != s.end(); it++)
    printf("%d ", (*it).second);
  putchar('\n');
  return 0;
}
