#include <bits/stdc++.h>
using namespace std;
long long N[1000010], P[1000010], A[1000010];
set<pair<long long, long long> > S;
long long p[1000010], v[1000010], n, m;
bool cmp(int a, int b) { return p[a] < p[b]; }
long long d(long long a, long long b) {
  if (a == b) return 0x3f3f3f3f;
  long long ret = (p[b] - p[a] + m) % m;
  ret += v[b] * (a > b);
  ret %= m;
  if (ret <= v[a]) return 1;
  if (v[a] <= v[b]) return 0x3f3f3f3f;
  return 1 + (ret - v[b] - 1) / (v[a] - v[b]);
}
int main() {
  scanf("%lld%lld", &n, &m);
  for (int i = 1; i <= n; i++) scanf("%lld%lld", &p[i], &v[i]), A[i] = i;
  sort(A + 1, A + 1 + n, cmp);
  for (int i = 1; i <= n; i++) {
    if (i != n)
      N[A[i]] = A[i + 1];
    else
      N[A[i]] = A[1];
    P[N[A[i]]] = A[i];
  }
  for (int i = 1; i <= n; i++) {
    S.insert(make_pair(d(i, N[i]), i));
  }
  while (!S.empty()) {
    set<pair<long long, long long> >::iterator it = S.begin();
    if ((*it).first == 0x3f3f3f3f) break;
    long long i = (*it).second;
    S.erase(it);
    S.erase(make_pair(d(N[i], N[N[i]]), N[i]));
    S.erase(make_pair(d(P[i], i), P[i]));
    p[i] += d(i, N[i]);
    v[i]--;
    N[i] = N[N[i]];
    P[N[i]] = i;
    S.insert(make_pair(d(P[i], i), P[i]));
    S.insert(make_pair(d(i, N[i]), i));
  }
  printf("%u\n", S.size());
  for (set<pair<long long, long long> >::iterator it = S.begin(); it != S.end();
       it++)
    printf("%lld ", (*it).second);
}
