#include <bits/stdc++.h>
using namespace std;
const int Nmax = 1e5 + 10;
const int inf = 0x3f3f3f3f;
int n, m, i;
int p[Nmax], j[Nmax];
pair<int, int> a[Nmax];
int nxt[Nmax], prv[Nmax], where[Nmax];
set<pair<int, int> > second;
int tmp(int x, int y) {
  if (x == y) return inf;
  int px = p[x];
  int py = p[y];
  if (x > y) py += j[y], py %= m;
  int d = (py - px + m) % m;
  if (d <= j[x]) return 1;
  if (j[x] <= j[y]) return inf;
  int c = j[x] - j[y];
  int t = (d - j[y]) / c;
  if ((d - j[y]) % c) t++;
  return t;
}
int main() {
  scanf("%d %d", &n, &m);
  for (i = 1; i <= n; ++i) {
    scanf("%d %d", &p[i], &j[i]);
    a[i].first = p[i];
    a[i].second = i;
  }
  sort(a + 1, a + n + 1);
  for (i = 1; i < n; ++i) nxt[a[i].second] = a[i + 1].second;
  nxt[a[n].second] = a[1].second;
  for (i = 2; i <= n; ++i) prv[a[i].second] = a[i - 1].second;
  prv[a[1].second] = a[n].second;
  for (i = 1; i <= n; ++i) second.insert({tmp(i, nxt[i]), i});
  int node, t;
  while (second.size()) {
    if (second.begin()->first == inf) break;
    node = second.begin()->second;
    t = second.begin()->first;
    second.erase(second.begin());
    second.erase({tmp(nxt[node], nxt[nxt[node]]), nxt[node]});
    second.erase({tmp(prv[node], node), prv[node]});
    p[node] += t;
    j[node]--;
    nxt[node] = nxt[nxt[node]];
    prv[nxt[node]] = node;
    second.insert({tmp(prv[node], node), prv[node]});
    second.insert({tmp(node, nxt[node]), node});
  }
  printf("%d\n", (int)second.size());
  for (auto& it : second) printf("%d ", it.second);
  return 0;
}
