#include <bits/stdc++.h>
using namespace std;
const int N = 100005;
using ll = long long;
set<pair<int, ll>> st;
int n, m, p[N], a[N], num[N], pre[N], nxt[N];
int dis(int x, int y) {
  if (x == y) return INT_MAX;
  int d = (p[y] - p[x] + m) % m;
  if (x > y) d = (d + a[y]) % m;
  if (d <= a[x]) return 1;
  if (a[x] <= a[y]) return INT_MAX;
  return (d - a[y] - 1) / (a[x] - a[y]) + 1;
}
int main() {
  ios::sync_with_stdio(false);
  cin >> n >> m;
  for (int i = 1; i <= n; i++) cin >> p[i] >> a[i], num[i] = i;
  sort(num + 1, num + n + 1, [](int x, int y) { return p[x] < p[y]; });
  for (int i = 1; i <= n; i++) {
    if (i < n)
      nxt[num[i]] = num[i + 1];
    else
      nxt[num[i]] = num[1];
    pre[nxt[num[i]]] = num[i];
  }
  for (int i = 1; i <= n; i++) st.insert({dis(i, nxt[i]), i});
  while (!st.empty()) {
    auto it = st.begin();
    if (it->first == INT_MAX) break;
    int cur = it->second;
    st.erase(it);
    st.erase({dis(nxt[cur], nxt[nxt[cur]]), nxt[cur]});
    st.erase({dis(pre[cur], cur), pre[cur]});
    p[cur] += dis(cur, nxt[cur]);
    --a[cur];
    nxt[cur] = nxt[nxt[cur]];
    pre[nxt[cur]] = cur;
    st.insert({dis(pre[cur], cur), pre[cur]});
    st.insert({dis(cur, nxt[cur]), cur});
  }
  cout << st.size() << endl;
  for (auto &i : st) cout << i.second << ' ';
  return 0;
}
