#include <bits/stdc++.h>
using namespace std;
template <typename T1, typename T2>
inline T1 max(T1 a, T2 b) {
  return a < b ? b : a;
}
template <typename T1, typename T2>
inline T1 min(T1 a, T2 b) {
  return a < b ? a : b;
}
const char lf = '\n';
namespace ae86 {
const int bufl = 1 << 15;
char buf[bufl], *s = buf, *t = buf;
inline int fetch() {
  if (s == t) {
    t = (s = buf) + fread(buf, 1, bufl, stdin);
    if (s == t) return EOF;
  }
  return *s++;
}
inline int ty() {
  int a = 0;
  int b = 1, c = fetch();
  while (!isdigit(c)) b ^= c == '-', c = fetch();
  while (isdigit(c)) a = a * 10 + c - 48, c = fetch();
  return b ? a : -a;
}
}  // namespace ae86
using ae86::ty;
const int _ = 100007, inf = 0x3f3f3f3f;
int n, m, loc[_], pw[_], q[_];
int dl[_] = {0}, dr[_] = {0};
int duang(int a, int b) {
  if (a == b) return inf;
  int dis = (loc[b] - loc[a] + m) % m;
  if (b < a) dis = (dis + pw[b]) % m;
  if (dis <= pw[a]) return 1;
  if (pw[a] <= pw[b]) return inf;
  return (dis - pw[b] - 1) / (pw[a] - pw[b]) + 1;
}
set<pair<int, int>> s;
int main() {
  ios::sync_with_stdio(0), cout.tie(nullptr);
  n = ty(), m = ty();
  for (int i = 1; i <= n; i++) loc[i] = ty() - 1, pw[i] = ty();
  for (int i = 1; i <= n; i++) q[i] = i;
  sort(q + 1, q + n + 1, [](int a, int b) { return loc[a] < loc[b]; });
  q[0] = q[n], q[n + 1] = q[1];
  for (int i = 1; i <= n; i++) dl[q[i]] = q[i - 1], dr[q[i]] = q[i + 1];
  for (int i = 1; i <= n; i++) s.emplace(duang(i, dr[i]), i);
  while (1) {
    auto temp = *s.begin();
    if (temp.first >= inf) break;
    int a = temp.second;
    s.erase(s.begin());
    s.erase(make_pair(duang(dr[a], dr[dr[a]]), dr[a]));
    s.erase(make_pair(duang(dl[a], a), dl[a]));
    loc[a] = (loc[a] + temp.first) % m, pw[a]--;
    dr[a] = dr[dr[a]], dl[dr[a]] = a;
    s.emplace(duang(dl[a], a), dl[a]);
    s.emplace(duang(a, dr[a]), a);
  }
  cout << s.size() << lf;
  for (auto i : s) cout << i.second << ' ';
  cout << lf;
  return 0;
}
