#include <bits/stdc++.h>
using namespace std;
const int max_n = 1000 * 100 + 10, inf = 1000 * 1000 * 1000 + 10;
int n, m;
pair<int, int> b[max_n];
int a[max_n], p[max_n], nex[max_n], pre[max_n];
set<pair<int, int> > s;
inline int when(int i, int j) {
  if (i == j) return inf;
  int pi = p[i], pj = p[j];
  if (i > j) pj += a[j], pj %= m;
  int d = (pj + m - pi) % m;
  if (d <= a[i]) return 1;
  if (a[j] >= a[i]) return inf;
  int k = a[i] - a[j];
  return (d - a[j] + k - 1) / k;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    cin >> p[i] >> a[i];
    p[i]--;
    b[i].second = i;
    b[i].first = p[i];
  }
  sort(b, b + n);
  for (int i = 0; i < n; i++) {
    nex[b[i].second] = b[(i + 1) % n].second;
    pre[b[(i + 1) % n].second] = b[i].second;
  }
  for (int i = 0; i < n; i++) {
    s.insert(pair<int, int>(when(i, nex[i]), i));
  }
  while (!s.empty()) {
    auto Q = s.begin();
    int i = Q->second;
    if ((Q->first) == inf) break;
    s.erase(Q);
    s.erase(pair<int, int>(when(nex[i], nex[nex[i]]), nex[i]));
    s.erase(pair<int, int>(when(pre[i], i), pre[i]));
    p[i] += when(i, nex[i]), a[i]--;
    nex[i] = nex[nex[i]];
    pre[nex[i]] = i;
    s.insert(pair<int, int>(when(pre[i], i), pre[i]));
    s.insert(pair<int, int>(when(i, nex[i]), i));
  }
  cout << s.size() << '\n';
  for (auto i : s) cout << i.second + 1 << ' ';
  cout << '\n';
}
