#include <bits/stdc++.h>
using namespace std;
int p[100009], a[100009], pos[100009], m, n, ri[100009], le[100009];
set<pair<int, int>> st;
inline bool cmp(const int& A, const int& B) { return p[A] < p[B]; }
int getdis(int x, int y) {
  if (x == y) return 1000000000;
  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 1000000000;
  return (d - a[y] - 1) / (a[x] - a[y]) + 1;
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) scanf("%d%d", p + i, a + i), pos[i] = i, p[i]--;
  sort(pos + 1, pos + n + 1, cmp);
  for (int i = 1; i <= n; i++) ri[pos[i]] = pos[i + 1], le[pos[i]] = pos[i - 1];
  ri[pos[n]] = pos[1], le[pos[1]] = pos[n];
  for (int i = 1; i <= n; i++) st.insert(make_pair(getdis(i, ri[i]), i));
  while (1) {
    if (st.begin()->first == 1000000000) break;
    int u = st.begin()->second;
    st.erase(st.begin());
    st.erase(make_pair(getdis(ri[u], ri[ri[u]]), ri[u]));
    if (!st.empty()) st.erase(make_pair(getdis(le[u], u), le[u]));
    p[u] += getdis(u, ri[u]), p[u] %= m, a[u]--;
    ri[u] = ri[ri[u]], le[ri[u]] = u;
    st.insert(make_pair(getdis(le[u], u), le[u])),
        st.insert(make_pair(getdis(u, ri[u]), u));
  }
  printf("%lu\n", st.size());
  for (set<pair<int, int>>::iterator it = st.begin(); it != st.end(); it++)
    printf("%d ", it->second);
  return 0;
}
