#include <bits/stdc++.h>
using namespace std;
int anext[110000];
int alast[110000];
int num, m;
long long abi[110000];
long long sta[110000];
struct XX {
  int number;
  long long location;
  long long ability;
  int w;
};
XX S[110000];
bool operator<(const XX &x, const XX &y) {
  if (x.w == -1 && y.w == -1) {
    if (x.number < y.number) {
      return 1;
    } else {
      return 0;
    }
  } else if (y.w == -1) {
    return 1;
  } else if (x.w == -1) {
    return 0;
  }
  if (x.w < y.w) {
    return 1;
  } else if (x.w == y.w) {
    if (x.number < y.number) {
      return 1;
    }
  }
  return 0;
}
int cmp1(XX x, XX y) { return x.location < y.location; }
int cmp2(XX x, XX y) { return x.number < y.number; }
int givew(int i, int nb) {
  int kkk;
  if (sta[i] < sta[nb]) {
    if (abi[i] <= abi[nb]) {
      if (i < nb && (sta[nb] - sta[i]) <= abi[i]) {
        kkk = 1;
      } else {
        kkk = -1;
      }
    } else {
      if (i < nb) {
        long long chx = sta[nb] - sta[i];
        long long abch = abi[i] - abi[nb];
        if (chx <= abi[i]) {
          kkk = 1;
        } else {
          chx -= abi[i];
          chx += abch;
          chx--;
          kkk = 1 + chx / abch;
        }
      } else {
        long long chx = sta[nb] - sta[i];
        long long abch = abi[i] - abi[nb];
        chx += abch;
        chx--;
        kkk = chx / abch;
      }
    }
  } else {
    if (abi[i] <= abi[nb]) {
      if (i < nb && (m + (sta[nb] - sta[i])) <= abi[i]) {
        kkk = 1;
      } else {
        kkk = -1;
      }
    } else {
      if (i < nb) {
        long long chx = sta[nb] - sta[i] + m;
        long long abch = abi[i] - abi[nb];
        if (chx <= abi[i]) {
          kkk = 1;
        } else {
          chx -= abi[i];
          chx += abch;
          chx--;
          kkk = 1 + chx / abch;
        }
      } else {
        long long chx = sta[nb] - sta[i] + m;
        long long abch = abi[i] - abi[nb];
        chx += abch;
        chx--;
        kkk = chx / abch;
      }
    }
  }
  return kkk;
}
int ans[110000];
int main() {
  while (scanf("%d%d", &num, &m) != EOF) {
    for (int i = 1; i <= num; i++) {
      scanf("%I64d%I64d", &sta[i], &abi[i]);
      S[i].number = i;
      S[i].ability = abi[i];
      S[i].location = sta[i];
    }
    if (num == 1) {
      printf("1\n1\n");
      continue;
    }
    sort(S + 1, S + 1 + num, cmp1);
    for (int i = 2; i < num; i++) {
      anext[S[i].number] = S[i + 1].number;
      alast[S[i].number] = S[i - 1].number;
    }
    anext[S[1].number] = S[2].number;
    alast[S[1].number] = S[num].number;
    anext[S[num].number] = S[1].number;
    alast[S[num].number] = S[num - 1].number;
    multiset<XX> Q;
    if (!Q.empty()) {
      Q.erase(Q.begin());
    }
    sort(S + 1, S + 1 + num, cmp2);
    for (int i = 1; i <= num; i++) {
      int nb;
      nb = anext[i];
      S[i].w = givew(i, nb);
    }
    for (int i = 1; i <= num; i++) {
      Q.insert(S[i]);
    }
    multiset<XX>::iterator gogo;
    while (!Q.empty()) {
      if (Q.size() == 1) {
        break;
      }
      gogo = Q.begin();
      int wt = gogo->w;
      if (wt == -1) {
        break;
      }
      int tnext, tlast;
      tnext = anext[gogo->number];
      tlast = alast[gogo->number];
      int nums = gogo->number;
      abi[nums]--;
      sta[nums] += wt;
      sta[nums] %= m;
      anext[nums] = anext[tnext];
      alast[anext[nums]] = nums;
      XX pp;
      Q.erase(S[tnext]);
      pp.number = S[tlast].number;
      pp.location = S[tlast].location;
      pp.ability = S[tlast].ability;
      pp.w = givew(tlast, nums);
      Q.erase(S[tlast]);
      S[tlast].w = pp.w;
      if (pp.number != tnext) Q.insert(pp);
      pp.number = S[nums].number;
      pp.location = S[nums].location;
      pp.ability = S[nums].ability;
      pp.w = givew(nums, anext[nums]);
      Q.erase(S[nums]);
      S[nums].w = pp.w;
      if (pp.number != tnext) Q.insert(pp);
      if (Q.size() == 1) {
        break;
      }
    }
    printf("%d\n", Q.size());
    int flag = 0;
    while (!Q.empty()) {
      gogo = Q.begin();
      ans[flag] = gogo->number;
      flag++;
      Q.erase(*gogo);
    }
    for (int i = 0; i < flag; i++) {
      if (i != 0) {
        printf(" ");
      }
      printf("%d", ans[i]);
    }
    printf("\n");
  }
  return 0;
}
