#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
const int inf = 2e9;
int gi() {
  int x = 0, o = 1;
  char ch = getchar();
  while ((ch < '0' || ch > '9') && ch != '-') ch = getchar();
  if (ch == '-') o = -1, ch = getchar();
  while (ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar();
  return x * o;
}
int n, m, p[N], a[N], pre[N], nxt[N], id[N];
set<pair<int, int> > s;
bool cmp(int a, int b) { return p[a] < p[b]; }
int calc(int x, int y) {
  if (x == y) return inf;
  int d = ((p[y] - p[x] + m) % m + (y < x) * 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 (int i = 1; i <= n; i++) p[i] = gi() - 1, a[i] = gi(), id[i] = i;
  sort(id + 1, id + n + 1, cmp);
  for (int i = 1; i <= n; i++)
    pre[id[i]] = i - 1 ? id[i - 1] : id[n],
    nxt[id[i]] = i + 1 <= n ? id[i + 1] : id[1];
  for (int i = 1; i <= n; i++) s.insert(make_pair(calc(i, nxt[i]), i));
  while (s.begin()->first < inf) {
    int i = s.begin()->second, j = s.begin()->first;
    s.erase(s.begin());
    s.erase(make_pair(calc(nxt[i], nxt[nxt[i]]), nxt[i]));
    s.erase(make_pair(calc(pre[i], i), pre[i]));
    p[i] = (p[i] + j) % m;
    a[i]--;
    nxt[i] = nxt[nxt[i]];
    pre[nxt[i]] = i;
    s.insert(make_pair(calc(i, nxt[i]), i));
    s.insert(make_pair(calc(pre[i], i), pre[i]));
  }
  printf("%d\n", s.size());
  for (auto x : s) printf("%d ", x.second);
  return 0;
}
