#include <bits/stdc++.h>
int const maxn = 100007;
int const inf = 1 << 30;
using pair_type = std::pair<int, int>;
int next[maxn], prev[maxn];
bool kicked[maxn];
int turn[maxn];
int pos[maxn];
pair_type spos[maxn];
int a[maxn];
int n, m;
std::priority_queue<pair_type, std::vector<pair_type>, std::greater<pair_type>>
    pq;
void check(int u, int v) {
  int dist = pos[v] - pos[u];
  if (dist < 0) dist += m;
  if (dist <= a[u] && u < v)
    turn[u] = 1;
  else if (a[u] <= a[v])
    turn[u] = inf;
  else {
    if (v < u) {
      int k = dist / (a[u] - a[v]);
      if (dist % (a[u] - a[v])) k++;
      turn[u] = k;
    } else {
      int k = 1;
      dist -= a[u];
      k += dist / (a[u] - a[v]);
      if (dist % (a[u] - a[v])) k++;
      turn[u] = k;
    }
  }
  pq.push({turn[u], u});
}
int main() {
  std::ios::sync_with_stdio(false);
  std::cin >> n >> m;
  for (int i = 0; i < n; i++) {
    std::cin >> pos[i] >> a[i];
    spos[i].first = --pos[i];
    spos[i].second = i;
  }
  std::sort(spos, spos + n);
  spos[n] = spos[0];
  for (int i = 0; i < n; i++) {
    int u = spos[i].second;
    int v = spos[i + 1].second;
    next[u] = v;
    prev[v] = u;
    check(u, v);
  }
  int tot = n;
  while (!pq.empty()) {
    int val = pq.top().first, u = pq.top().second;
    pq.pop();
    if (turn[u] != val) continue;
    if (kicked[u]) continue;
    if (val == inf) break;
    int v = next[u];
    kicked[v] = true;
    tot--;
    if (tot == 1) break;
    v = next[v];
    next[u] = v;
    prev[v] = u;
    a[u]--;
    pos[u] += val;
    pos[u] %= m;
    check(u, v);
    v = u;
    u = prev[u];
    check(u, v);
  }
  std::cout << tot << '\n';
  for (int i = 0; i < n; i++)
    if (!kicked[i]) std::cout << i + 1 << ' ';
  std::cout << '\n';
}
