#include <bits/stdc++.h>
using namespace std;
int p[100006], a[100006], n, m, q[100006], nxt[100006], pre[100006];
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 1e9;
  int d = (p[y] - p[x] + m) % m;
  if (y < x) d = (d + a[y]) % m;
  if (d <= a[x]) return 1;
  if (a[x] <= a[y]) return 1e9;
  return (d - a[y] - 1) / (a[x] - a[y]) + 1;
}
int main() {
  cin >> n >> m;
  for (int i = 1; i <= n; ++i)
    scanf("%d", &p[i]), --p[i], scanf("%d", &a[i]), q[i] = i;
  sort(q + 1, q + n + 1, cmp);
  for (int i = 1; i <= n; ++i) nxt[q[i]] = q[i + 1], pre[q[i]] = q[i - 1];
  nxt[q[n]] = q[1], pre[q[1]] = q[n];
  for (int i = 1; i <= n; ++i) S.insert(make_pair(calc(i, nxt[i]), i));
  while ("Gavin Ak IOI") {
    pair<int, int> u = *S.begin();
    if (u.first == 1e9) break;
    int v = u.second;
    S.erase(S.begin());
    S.erase(make_pair(calc(nxt[v], nxt[nxt[v]]), nxt[v]));
    if (!S.empty()) S.erase(make_pair(calc(pre[v], v), pre[v]));
    p[v] += u.first, p[v] %= m;
    --a[v];
    nxt[v] = nxt[nxt[v]], pre[nxt[v]] = v;
    S.insert(make_pair(calc(pre[v], v), pre[v]));
    S.insert(make_pair(calc(v, nxt[v]), v));
  }
  printf("%d\n", S.size());
  for (auto it = S.begin(); it != S.end(); ++it) printf("%d ", it->second);
  return 0;
}
