#include <bits/stdc++.h>
using namespace std;
int n, m, p[100010], a[100010], id[100010], Next[100010], Prev[100010];
set<pair<int, int> > s;
bool cmp(int a, int b) { return p[a] < p[b]; }
int calc(int x, int y) {
  if (x == y) return 1e9;
  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 1e9;
  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]);
    p[i]--;
    id[i] = i;
  }
  sort(id + 1, id + 1 + n, cmp);
  for (int i = 1; i <= n; i++) Next[id[i]] = id[i + 1], Prev[id[i]] = id[i - 1];
  Next[id[n]] = id[1l];
  Prev[id[1]] = id[n];
  for (int i = 1; i <= n; i++) s.insert(make_pair(calc(i, Next[i]), i));
  while (1) {
    pair<int, int> u = *s.begin();
    if (u.first == 1e9) break;
    int v = u.second;
    s.erase(s.begin());
    s.erase(make_pair(calc(Next[v], Next[Next[v]]), Next[v]));
    if (s.size()) s.erase(make_pair(calc(Prev[v], v), Prev[v]));
    p[v] += u.first;
    p[v] %= m;
    a[v]--;
    Next[v] = Next[Next[v]];
    Prev[Next[v]] = v;
    s.insert(make_pair(calc(Prev[v], v), Prev[v]));
    s.insert(make_pair(calc(v, Next[v]), v));
  }
  printf("%d\n", s.size());
  for (auto it : s) printf("%d ", it.second);
  return 0;
}
