#include <bits/stdc++.h>
using namespace std;
inline long long read() {
  long long x = 0, f = 1;
  char c = getchar();
  for (; !isdigit(c); c = getchar())
    if (c == '-') f = -1;
  for (; isdigit(c); c = getchar()) x = x * 10 + c - '0';
  return x * f;
}
const long long MAXN = 200010;
const long long INF = 1e9;
long long N, M;
struct data {
  long long p, id, a;
  long long tim, pt;
  bool operator<(const data &a) const { return a.pt > pt; }
} a[MAXN + 1];
struct Time {
  long long x, tim;
  bool operator<(const Time &a) const {
    if (tim != a.tim) return tim < a.tim;
    return x < a.x;
  }
} Tim;
inline Time make_time(long long tim, long long x) {
  Time n;
  n.tim = tim;
  n.x = x;
  return n;
}
multiset<pair<Time, data> > S;
multiset<data> P;
inline long long Pos(data A, Time T) {
  return (A.p + A.a * ((T.x >= A.id) + T.tim - A.tim - 1) % M - 1) % M + 1;
}
bool cmpp(data a, data b) { return a.p < b.p; }
inline long long dist(long long A, long long B) { return (B - A + M) % M; }
inline void calc(data A, data B, long long n) {
  long long val;
  bool Fir;
  if ((Tim.x >= A.id) == (Tim.x >= B.id)) {
    if (A.id < B.id)
      Fir = 1;
    else
      Fir = 0;
  } else {
    if (A.id > B.id)
      Fir = 1;
    else
      Fir = 0;
  }
  long long Len = dist(Pos(A, Tim), Pos(B, Tim)), id = A.id;
  if (Len <= A.a && Fir) {
    val = Tim.tim;
    if (Tim.x >= max(A.id, B.id)) val++;
  } else {
    if (A.a <= B.a)
      val = INF;
    else {
      if (Fir) {
        val = Tim.tim + (long long)ceil(1.0 * (Len - A.a) / (A.a - B.a));
        if (Tim.x >= max(A.id, B.id)) val++;
      } else {
        if (Tim.x >= min(A.id, B.id))
          val = Tim.tim + (long long)ceil(1.0 * Len / (A.a - B.a));
        else {
          val = Tim.tim + (long long)ceil(1.0 * Len / (A.a - B.a)) - 1;
        }
      }
    }
  }
  if (n == 1)
    S.insert(make_pair(make_time(val, id), A));
  else {
    if (S.find(make_pair(make_time(val, id), A)) != S.end())
      S.erase(S.find(make_pair(make_time(val, id), A)));
    else
      cerr << "==============" << endl;
  }
}
long long sta[MAXN + 1], top;
int main() {
  N = read(), M = read();
  for (long long i = 1; i <= N; i++) {
    a[i].p = read(), a[i].id = i, a[i].a = read();
  }
  sort(a + 1, a + N + 1, cmpp);
  Tim = make_time(0, N);
  for (long long i = 1; i <= N; i++) {
    a[i].pt = i;
    if (i < N)
      calc(a[i], a[i + 1], 1);
    else
      calc(a[i], a[1], 1);
    P.insert(a[i]);
  }
  while (P.size() != 1 && ((*S.begin()).first.tim < INF)) {
    pair<Time, data> k = *S.begin();
    multiset<data>::iterator it = P.find(k.second), l = it, r = it, rr, last;
    if (it == P.end()) {
      S.erase(S.find(k));
      continue;
    }
    Tim = k.first;
    --Tim.x;
    if (r != (--P.end()))
      ++r;
    else
      r = P.begin();
    rr = r;
    if (rr != (--P.end()))
      ++rr;
    else
      rr = P.begin();
    long long To = 0;
    while (dist(Pos(k.second, Tim), Pos(*r, Tim)) <= k.second.a &&
           P.size() > 1) {
      calc(*r, *rr, -1);
      last = r;
      if (r != (--P.end()))
        ++r;
      else
        r = P.begin();
      P.erase(last);
      if (rr != (--P.end()))
        ++rr;
      else
        rr = P.begin();
      ++To;
    }
    it = P.begin();
    it = P.find(k.second);
    l = it;
    if (l != P.begin())
      --l;
    else
      l = (--P.end());
    if (P.size() > 1) calc(*l, k.second, -1);
    P.erase(P.find(k.second));
    S.erase(S.find(k));
    k.second.p = Pos(k.second, Tim);
    (k.second.p += k.second.a - 1) %= M;
    k.second.p++;
    k.second.a -= To;
    k.second.a = max(k.second.a, 0LL);
    k.second.tim = Tim.tim;
    P.insert(k.second);
    Tim = k.first;
    if (P.size() > 1) calc(k.second, *r, 1), calc(*l, k.second, 1);
  }
  multiset<data>::iterator it = P.begin();
  while (it != P.end()) sta[++top] = (*it).id, ++it;
  printf("%lld\n", top);
  for (long long i = 1; i <= top; i++) printf("%lld ", sta[i]);
  return 0;
}
