#include <bits/stdc++.h>
using namespace std;
template <typename T>
inline bool upmin(T &x, T y) {
  return y < x ? x = y, 1 : 0;
}
template <typename T>
inline bool upmax(T &x, T y) {
  return x < y ? x = y, 1 : 0;
}
const long double eps = 1e-11;
const long double pi = acos(-1);
const int oo = 1 << 30;
const long long loo = 1ll << 62;
const int mods = 1e9 + 7;
const int MAXN = 200005;
const int INF = 0x3f3f3f3f;
inline int read() {
  int f = 1, x = 0;
  char c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') {
    x = (x << 3) + (x << 1) + (c ^ 48);
    c = getchar();
  }
  return x * f;
}
set<pair<int, int> > Set;
map<int, int> Map;
int nxt[MAXN], lst[MAXN], id[MAXN], n, m;
pair<int, int> a[MAXN];
int get(int x) {
  int y = nxt[x];
  if (x == y) return INF;
  int s = (a[y].first - a[x].first + m) % m, v = (a[x].second - a[y].second);
  if (y < x) s = (a[y].second + s) % m;
  if (s <= a[x].second) return 1;
  if (v <= 0) return INF;
  return (s - a[y].second - 1) / v + 1;
}
signed main() {
  n = read(), m = read();
  for (int i = 1; i <= n; i++)
    a[i].first = read() - 1, a[i].second = read(), id[i] = i;
  sort(id + 1, id + n + 1,
       [&](int x, int y) { return a[x].first < a[y].first; });
  for (int i = 1; i <= n; i++) {
    nxt[id[i]] = (i == n ? id[1] : id[i + 1]),
    lst[id[i]] = (i == 1 ? id[n] : id[i - 1]);
    Set.insert(make_pair(get(id[i]), id[i]));
  }
  while (Set.size()) {
    pair<int, int> q = *Set.begin();
    if (q.first == INF) break;
    Set.erase(Set.begin());
    Set.erase(Set.find(make_pair(get(nxt[q.second]), nxt[q.second])));
    if (Set.size())
      Set.erase(Set.find(make_pair(get(lst[q.second]), lst[q.second])));
    (a[q.second].first += q.first) %= m, a[q.second].second--;
    nxt[q.second] = nxt[nxt[q.second]], lst[nxt[q.second]] = q.second;
    Set.insert(make_pair(get(q.second), q.second));
    Set.insert(make_pair(get(lst[q.second]), lst[q.second]));
  }
  printf("%d\n", Set.size());
  for (auto v : Set) printf("%d ", v.second);
  return 0;
}
