#include <bits/stdc++.h>
using namespace std;
struct initon {
  initon() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    srand((unsigned)clock() + (unsigned)time(NULL));
  };
} __initon;
struct T {
  int f, s, t;
  T() { f = -1, s = -1, t = -1; }
  T(int f, int s, int t) : f(f), s(s), t(t) {}
  bool operator<(const T &r) const {
    return f != r.f ? f < r.f : s != r.s ? s < r.s : t < r.t;
  }
  bool operator>(const T &r) const {
    return f != r.f ? f > r.f : s != r.s ? s > r.s : t > r.t;
  }
  int operator[](int i) {
    assert(i < 3);
    return i == 0 ? f : i == 1 ? s : t;
  }
};
using dou = long double;
using itn = long long;
using str = string;
using bo = bool;
using P = pair<long long, long long>;
using vi = vector<long long>;
using vb = vector<bool>;
using vs = vector<string>;
using vl = vector<long long>;
using vd = vector<long double>;
using vc = vector<char>;
using vp = vector<P>;
using vt = vector<T>;
using seti = set<long long>;
const long long inf = (long long)1e9 + 100;
const long long linf = (long long)1e18 + 100;
const long double eps = 1e-9;
const long long y4[] = {-1, 1, 0, 0};
const long long x4[] = {0, 0, -1, 1};
const long long y8[] = {0, 1, 0, -1, -1, 1, 1, -1};
const long long x8[] = {1, 0, -1, 0, 1, -1, 1, -1};
namespace std_vector_bounds_checking {
using namespace std;
template <class T, class A = std::allocator<T>>
struct vector : std::vector<T, A> {
  using std::vector<T, A>::vector;
  typename std::vector<T>::reference operator[](
      typename std::vector<T>::size_type n) {
    return this->at(n);
  }
};
}  // namespace std_vector_bounds_checking
namespace std {
template <>
class hash<std::pair<signed, signed>> {
 public:
  size_t operator()(const std::pair<signed, signed> &x) const {
    return hash<long long>()(((long long)x.first << 32) + x.second);
  }
};
template <>
class hash<std::pair<long long, long long>> {
 public:
  size_t operator()(const std::pair<long long, long long> &x) const {
    return hash<long long>()(((long long)x.first << 32) + x.second);
  }
};
}  // namespace std
istream &operator>>(istream &iss, P &a) {
  iss >> a.first >> a.second;
  return iss;
}
template <typename T>
istream &operator>>(istream &iss, vector<T> &vector) {
  for (T &x : vector) iss >> x;
  return iss;
}
template <typename T>
ostream &operator<<(ostream &os, vector<T> &vector) {
  for (long long i = 0; i < vector.size(); i++)
    os << vector[i] << (i + 1 == vector.size() ? "" : " ");
  return os;
}
template <typename V, typename H>
void resize(vector<V> &vector, const H head) {
  vector.resize(head);
}
template <typename V, typename H, typename... T>
void resize(vector<V> &vector, const H &head, const T... tail) {
  vector.resize(head);
  for (auto &v : vector) resize(v, tail...);
}
template <class T>
T pop(set<T> &set) {
  T res = *set.begin();
  set.erase(set.find(res));
  return res;
}
template <class T>
T pop(multiset<T> &set) {
  T res = *set.begin();
  set.erase(set.find(res));
  return res;
}
template <class T>
T popBack(set<T> &set) {
  T res = *set.rbegin();
  set.erase(set.find(res));
  return res;
}
template <class T>
T popBack(multiset<T> &set) {
  T res = *set.rbegin();
  set.erase(set.find(res));
  return res;
}
template <class T>
inline void sort(vector<T> &a) {
  sort(a.begin(), a.end());
};
template <class T>
inline void rsort(vector<T> &a) {
  sort(a.begin(), a.end(), greater<T>());
};
template <class T>
inline void sort(vector<T> &a, long long len) {
  sort(a.begin(), a.begin() + len);
};
template <class T>
inline void rsort(vector<T> &a, long long len) {
  sort(a.begin(), a.begin() + len, greater<T>());
};
template <class U>
inline void sortp(vector<U> &a, vector<U> &b) {
  vp c;
  long long n = (a.size());
  assert(n == (b.size()));
  for (long long i = 0, _lim = n; i < _lim; i++) c.emplace_back(a[i], b[i]);
  sort(c);
  for (long long i = 0, _lim = n; i < _lim; i++) {
    a[i] = c[i].first;
    b[i] = c[i].second;
  }
};
template <class U>
inline void rsortp(vector<U> &a, vector<U> &b) {
  vp c;
  long long n = (a.size());
  assert(n == (b.size()));
  for (long long i = 0, _lim = n; i < _lim; i++) c.emplace_back(a[i], b[i]);
  rsort(c);
  for (long long i = 0, _lim = n; i < _lim; i++) {
    a[i] = c[i].first;
    b[i] = c[i].second;
  }
};
template <class T>
inline void sort2(vector<vector<T>> &a) {
  for (long long i = 0, n = a.size(); i < n; i++) sort(a[i]);
}
template <class T>
inline void rsort2(vector<vector<T>> &a) {
  for (long long i = 0, n = a.size(); i < n; i++) rsort(a[i]);
}
template <typename A, size_t N, typename T>
void fill(A (&a)[N], const T &v) {
  for (long long i = 0, _lim = N; i < _lim; i++) a[i] = v;
}
template <typename A, size_t N, size_t O, typename T>
void fill(A (&a)[N][O], const T &v) {
  for (long long i = 0, _lim = N; i < _lim; i++)
    for (long long j = 0, _lim = O; j < _lim; j++) a[i][j] = v;
}
template <typename A, size_t N, size_t O, size_t P, typename T>
void fill(A (&a)[N][O][P], const T &v) {
  for (long long i = 0, _lim = N; i < _lim; i++)
    for (long long j = 0, _lim = O; j < _lim; j++)
      for (long long k = 0, _lim = P; k < _lim; k++) a[i][j][k] = v;
}
template <typename A, size_t N, size_t O, size_t P, size_t Q, typename T>
void fill(A (&a)[N][O][P][Q], const T &v) {
  for (long long i = 0, _lim = N; i < _lim; i++)
    for (long long j = 0, _lim = O; j < _lim; j++)
      for (long long k = 0, _lim = P; k < _lim; k++)
        for (long long l = 0, _lim = Q; l < _lim; l++) a[i][j][k][l] = v;
}
template <typename A, size_t N, size_t O, size_t P, size_t Q, size_t R,
          typename T>
void fill(A (&a)[N][O][P][Q][R], const T &v) {
  for (long long i = 0, _lim = N; i < _lim; i++)
    for (long long j = 0, _lim = O; j < _lim; j++)
      for (long long k = 0, _lim = P; k < _lim; k++)
        for (long long l = 0, _lim = Q; l < _lim; l++)
          for (long long m = 0, _lim = R; m < _lim; m++) a[i][j][k][l][m] = v;
}
template <typename A, size_t N, size_t O, size_t P, size_t Q, size_t R,
          size_t second, typename T>
void fill(A (&a)[N][O][P][Q][R][second], const T &v) {
  for (long long i = 0, _lim = N; i < _lim; i++)
    for (long long j = 0, _lim = O; j < _lim; j++)
      for (long long k = 0, _lim = P; k < _lim; k++)
        for (long long l = 0, _lim = Q; l < _lim; l++)
          for (long long m = 0, _lim = R; m < _lim; m++)
            for (long long n = 0, _lim = second; n < _lim; n++)
              a[i][j][k][l][m][n] = v;
}
template <typename V, typename T>
void fill(V &xx, const T &vall) {
  xx = vall;
}
template <typename V, typename T>
void fill(vector<V> &vecc, const T &vall) {
  for (auto &vx : vecc) fill(vx, vall);
}
template <typename T = long long>
T in() {
  T x;
  cin >> x;
  return (x);
}
string sin() { return in<string>(); }
long double din() { return in<long double>(); }
long long lin() { return in<long long>(); }
template <class T>
void out(T x) {
  typeid(x) == typeid(long double)
      ? cout << fixed << setprecision(10) << x << endl
      : cout << x << endl;
}
class UnionFind {
 public:
  vi par, rank, sizes;
  long long n, trees;
  UnionFind(long long n) : n(n), trees(n) {
    par.resize(n), rank.resize(n), sizes.resize(n);
    for (long long i = 0, _lim = n; i < _lim; i++) par[i] = i, sizes[i] = 1;
  }
  long long root(long long x) {
    if (par[x] == x)
      return x;
    else
      return par[x] = root(par[x]);
  }
  long long find(long long x) { return root(x); }
  void unite(long long x, long long y) {
    x = root(x);
    y = root(y);
    if (x == y) return;
    if (rank[x] < rank[y]) swap(x, y);
    trees--;
    par[y] = x;
    sizes[x] += sizes[y];
    if (rank[x] == rank[y]) rank[x]++;
  }
  bool same(long long x, long long y) { return root(x) == root(y); }
  long long size(long long x) { return sizes[root(x)]; }
  vector<vi> sets() {
    vector<vi> res(trees);
    unordered_map<long long, vi> map;
    for (long long i = 0, _lim = n; i < _lim; i++) map[root(i)].push_back(i);
    long long i = 0;
    for (auto &&p : map) {
      long long r = p.first;
      res[i].push_back(r);
      for (auto &&v : p.second) {
        if (r == v) continue;
        res[i].push_back(v);
      }
      i++;
    }
    return res;
  }
};
long long MOD = (long long)1e9 + 7;
class mint {
 public:
  long long x;
  mint() : x(0) {}
  mint(signed y) : x(y >= 0 ? y % MOD : MOD - (-y) % MOD) {}
  mint(long long y) : x(y >= 0 ? y % MOD : MOD - (-y) % MOD) {}
  static long long _mpow(long long v, long long a) {
    long long x = v, n = a, res = 1;
    while (n) {
      if (n & 1) res = (res * x) % MOD;
      x = (x * x) % MOD;
      n >>= 1;
    }
    return res;
  }
  mint &operator+=(mint that) {
    if ((x += that.x) >= MOD) x -= MOD;
    return *this;
  }
  mint &operator-=(mint that) {
    if ((x += MOD - that.x) >= MOD) x -= MOD;
    return *this;
  }
  mint &operator*=(mint that) {
    x = 1LL * x * that.x % MOD;
    return *this;
  }
  mint &operator/=(const mint &that);
  mint &operator^=(const mint &that) {
    this->x = _mpow(x, that.x);
    return *this;
  }
  mint &operator%=(mint that) {
    x %= that.x;
    return *this;
  }
  mint &operator+=(const long long that) { return *this += mint(that); }
  mint &operator-=(const long long that) { return *this -= mint(that); }
  mint &operator*=(const long long that) { return *this *= mint(that); }
  mint &operator/=(const long long that);
  mint &operator^=(const long long that) {
    this->x = _mpow(x, that);
    return *this;
  }
  mint &operator%=(const long long that) { return *this %= mint(that); }
  mint &operator+=(const signed that) { return *this += mint(that); }
  mint &operator-=(const signed that) { return *this -= mint(that); }
  mint &operator*=(const signed that) { return *this *= mint(that); }
  mint &operator/=(const signed that);
  mint &operator^=(const signed that) {
    this->x = _mpow(x, that);
    return *this;
  }
  mint &operator%=(const signed that) { return *this %= mint(that); }
  bool operator<(mint that) { return x < that.x; }
  bool operator>(mint that) { return x > that.x; }
  bool operator<=(mint that) { return x <= that.x; }
  bool operator>=(mint that) { return x >= that.x; }
  bool operator!=(mint that) { return x != that.x; }
  bool operator==(mint that) { return x == that.x; }
  bool operator!=(long long that) { return x != that; }
  bool operator==(long long that) { return x == that; }
  bool operator!=(signed that) { return x != that; }
  bool operator==(signed that) { return x == that; }
  unsigned getval() const { return x; }
  operator long long() { return x; }
  mint operator+(mint that) const { return mint(*this) += that; }
  mint operator-(mint that) const { return mint(*this) -= that; }
  mint operator*(mint that) const { return mint(*this) *= that; }
  mint operator%(mint that) const { return mint(*this) %= that; }
  mint operator+(const long long that) const { return mint(*this) += that; }
  mint operator-(const long long that) const { return mint(*this) -= that; }
  mint operator*(const long long that) const { return mint(*this) *= that; }
  mint operator%(const long long that) const { return mint(*this) %= that; }
  mint operator=(const long long that) { return *this = mint(that); }
  mint operator+(const signed that) const { return mint(*this) += that; }
  mint operator-(const signed that) const { return mint(*this) -= that; }
  mint operator*(const signed that) const { return mint(*this) *= that; }
  mint operator%(const signed that) const { return mint(*this) %= that; }
  mint operator=(const signed that) { return *this = mint(that); }
  friend void operator+=(long long &a, const mint &b) {
    a = mint(a % MOD + b.x);
  }
  friend void operator-=(long long &a, const mint &b) {
    a = mint(a % MOD - b.x);
  }
  friend void operator*=(long long &a, const mint &b) {
    a = mint(a % MOD * b.x);
  }
  friend void operator/=(long long &a, const mint &b);
  friend mint operator+(const long long a, const mint &b) {
    return mint(a % MOD + b.x);
  }
  friend mint operator-(const long long a, const mint &b) {
    return mint(a % MOD - b.x);
  }
  friend mint operator*(const long long a, const mint &b) {
    return mint(a % MOD * b.x);
  }
  friend mint operator^(const long long a, const mint &b) {
    return _mpow(a, b.x);
  }
};
const long long setModMax = 510000;
mint fac[setModMax], finv[setModMax], inv[setModMax];
void setMod() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (long long i = 2; i < setModMax; i++) {
    fac[i] = fac[i - 1].x * i % MOD;
    inv[i] = MOD - inv[MOD % i].x * (MOD / i) % MOD;
    finv[i] = finv[i - 1].x * inv[i].x % MOD;
  }
}
mint mpow(long long v, long long a) { return mint::_mpow(v, a); }
mint com(long long n, long long r) {
  if (n < r || n < 0 || r < 0) return 0;
  if (fac[0] == 0) setMod();
  return fac[n] * finv[r] * finv[n - r];
}
mint ncr(long long n, long long r) { return com(n, r); }
mint nhr(long long n, long long r) { return com(n + r - 1, r); }
mint minv(long long a) {
  if (fac[0] == 0) setMod();
  if (a < setModMax) return inv[a];
  a %= MOD;
  long long b = MOD, x = 1, y = 0;
  while (b) {
    long long t = a / b;
    a -= t * b;
    swap(a, b);
    x -= t * y;
    swap(x, y);
  }
  return x;
}
mint &mint::operator/=(const mint &that) { return *this *= minv(that.x); }
mint &mint::operator/=(const long long a) { return *this *= minv(a); }
mint &mint::operator/=(const signed a) { return *this *= minv(a); }
void operator/=(long long &a, const mint &b) { a = (a * minv(b.x)).x; }
using vm = vector<mint>;
bool isPrime[4010101];
vi primes;
void setPrime() {
  fill(isPrime, true);
  long long len = sizeof(isPrime) / sizeof(isPrime[0]);
  isPrime[0] = isPrime[1] = false;
  for (long long i = 2; i <= sqrt(len) + 5; ++i) {
    if (!isPrime[i]) continue;
    for (long long j = 2; i * j < len; ++j) {
      isPrime[i * j] = false;
    }
  }
  for (long long i = 0, _lim = len; i < _lim; i++)
    if (isPrime[i]) primes.push_back(i);
}
void iota(vector<long long> ve, long long s, long long n) {
  ve.resize(n);
  iota((ve).begin(), (ve).end(), s);
}
char ranc() { return (char)('a' + rand() % 26); }
void ole() {
  string a = "a";
  for (long long i = 0, _lim = 30; i < _lim; i++) a += a;
  for (long long i = 0, _lim = 1 << 17; i < _lim; i++) cout << a << endl;
  cout << "OLE 出力長制限超過" << endl;
  exit(0);
}
void tle() {
  while (inf) cout << inf << endl;
}
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }
bool equal(long double a, long double b) { return fabs(a - b) < eps; }
long long reverse(long long a) {
  long long res = 0;
  while (a) {
    res *= 10;
    res += a % 10;
    a /= 10;
  }
  return res;
}
long long ceil(long long a, long long b) {
  if (b == 0) {
    ole();
    return -1;
  } else
    return (a + b - 1) / b;
}
long long sqrt(long long a) {
  if (a < 0) ole();
  long long res = (long long)std::sqrt(a);
  while (res * res < a) res++;
  return res;
}
long double log(long double e, long double x) { return log(x) / log(e); }
long long sig(long long t) { return (1 + t) * t / 2; }
long long sig(long long s, long long t) { return (s + t) * (t - s + 1) / 2; }
vi divisors(long long v) {
  vi res;
  for (long long i = 1; i <= sqrt(v); ++i) {
    if (v % i == 0) {
      res.push_back(i);
      if (i != v / i) res.push_back(v / i);
    }
  }
  return res;
}
vi factorization(long long v) {
  long long tv = v;
  vi res;
  if (!isPrime[2]) setPrime();
  for (auto &&p : primes) {
    if (v % p == 0) res.push_back(p);
    while (v % p == 0) {
      v /= p;
    }
    if (v == 1 || p * p > tv) break;
  }
  if (v > 1) res.push_back(v);
  return res;
}
unordered_map<long long, long long> factorizationMap(long long v) {
  long long tv = v;
  unordered_map<long long, long long> res;
  if (!isPrime[2]) setPrime();
  for (auto &&p : primes) {
    while (v % p == 0) {
      res[p]++;
      v /= p;
    }
    if (v == 1 || p * p > tv) break;
  }
  if (v > 1) res[v]++;
  return res;
}
long long get(long long a, long long keta) {
  return (a / (long long)pow(10, keta)) % 10;
}
long long keta(long long v) {
  long long cou = 0;
  while (v) {
    cou++, v %= 10;
  }
  return cou;
}
template <class T>
void imo(vector<T> &v) {
  long long n = v.size();
  for (long long i = 0, _lim = n - 1; i < _lim; i++) v[i + 1] += v[i];
}
template <class T, class U>
vector<U> keys(map<T, U> a) {
  vector<U> res;
  for (auto &&k : a) res.push_back(k.first);
  return res;
}
template <class T, class U>
vector<U> keys(unordered_map<T, U> a) {
  vector<U> res;
  for (auto &&k : a) res.push_back(k.first);
  return res;
}
template <class T, class U>
vector<T> values(map<T, U> a) {
  vector<T> res;
  for (auto &&k : a) res.push_back(k.second);
  return res;
}
template <class T, class U>
vector<T> values(unordered_map<T, U> a) {
  vector<T> res;
  for (auto &&k : a) res.push_back(k.second);
  return res;
}
vi list(long long a) {
  vi res;
  while (a) {
    res.insert(res.begin(), a % 10);
    a /= 10;
  }
  return res;
}
template <class T, class U>
bool chmax(T &a, const U &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T, class U>
bool chmin(T &a, const U &b) {
  if (b < a) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
T min(T a, signed b) {
  return a < b ? a : b;
}
template <class T>
T max(T a, signed b) {
  return a < b ? b : a;
}
template <class T>
T min(vector<T> a) {
  return *min_element((a).begin(), (a).end());
}
template <class T>
T min(vector<T> a, long long n) {
  return *min_element(a.begin(), a.begin() + n);
}
template <class T>
T min(vector<T> a, long long s, long long n) {
  return *min_element(a.begin() + s, a.begin() + n);
}
template <class T>
T max(vector<T> a) {
  return *max_element((a).begin(), (a).end());
}
template <class T>
T max(vector<T> a, long long n) {
  return *max_element(a.begin(), a.begin() + n);
}
template <class T>
T max(vector<T> a, long long s, long long n) {
  return *max_element(a.begin() + s, a.begin() + n);
}
template <class T>
T min(T a[]) {
  T res = a[0];
  for (long long i = 0, _lim = (sizeof(a) / sizeof(a[0])); i < _lim; i++)
    chmin(res, a[i]);
  return res;
}
template <class T>
T max(T a[]) {
  T res = a[0];
  for (long long i = 0, _lim = (sizeof(a) / sizeof(a[0])); i < _lim; i++)
    chmax(res, a[i]);
  return res;
}
template <class T>
T sum(vector<T> &v, long long len = -1) {
  if (len == -1) len = v.size();
  T res = 0;
  chmin(len, v.size());
  for (long long i = 0, _lim = len; i < _lim; i++) res += v[i];
  return res;
}
template <class T>
T sum(vector<vector<T>> &v, long long h = -1, long long w = -1) {
  if (h == -1) h = v.size();
  if (w == -1) w = v[0].size();
  T res = 0;
  chmin(h, v.size());
  chmin(w, v[0].size());
  for (long long i = 0, _lim = h; i < _lim; i++)
    for (long long j = 0, _lim = w; j < _lim; j++) res += v[i][j];
  return res;
}
P sump(vp &v, long long len = -1) {
  if (len == -1) len = v.size();
  P res = {0, 0};
  chmin(len, v.size());
  for (long long i = 0, _lim = len; i < _lim; i++) {
    res.first += v[i].first;
    res.second += v[i].second;
  }
  return res;
}
template <class T>
T mul(vector<T> &v, long long len = -1) {
  if (len == -1) len = v.size();
  T res = 1;
  chmin(len, v.size());
  for (long long i = 0, _lim = len; i < _lim; i++) res *= v[i];
  return res;
}
void clear(
    priority_queue<long long, vector<long long>, greater<long long>> &q) {
  while (q.size()) q.pop();
}
template <class T>
void clear(queue<T> &q) {
  while (q.size()) q.pop();
}
template <class T>
T *negarr(long long size) {
  T *body = (T *)malloc((size * 2 + 1) * sizeof(T));
  return body + size;
}
template <class T>
T *negarr2(long long h, long long w) {
  long double **dummy1 = new long double *[2 * h + 1];
  long double *dummy2 = new long double[(2 * h + 1) * (2 * w + 1)];
  dummy1[0] = dummy2 + w;
  for (long long i = 1; i <= 2 * h + 1; i++) {
    dummy1[i] = dummy1[i - 1] + 2 * w + 1;
  }
  long double **a = dummy1 + h;
}
template <class T>
vector<T> ruiv(vector<T> &a) {
  vector<T> res(a.size() + 1);
  for (long long i = 0, _lim = a.size(); i < _lim; i++)
    res[i + 1] = res[i] + a[i];
  return res;
}
template <class T>
vector<T> ruim(vector<T> &a) {
  vector<T> res(a.size() + 1, 1);
  for (long long i = 0, _lim = a.size(); i < _lim; i++)
    res[i + 1] = res[i] * a[i];
  return res;
}
template <class T>
T *rrui(vector<T> &a) {
  long long len = a.size();
  T *body = (T *)malloc((len + 1) * sizeof(T));
  T *res = body + 1;
  for (long long i = len - 1; i >= 0; i--) res[i - 1] = res[i] + a[i];
  return res;
}
template <class T>
T *rruim(vector<T> &a) {
  long long len = a.size();
  T *body = (T *)malloc((len + 1) * sizeof(T));
  T *res = body + 1;
  res[len - 1] = 1;
  for (long long i = len - 1; i >= 0; i--) res[i - 1] = res[i] * a[i];
  return res;
}
template <class T>
void plus(vector<T> &a, T v = 1) {
  for (auto &&u : a) u += v;
}
template <class T>
void minu(vector<T> &a, T v = 1) {
  for (auto &&u : a) u -= v;
}
template <class T>
void minus(vector<T> &a, T v = 1) {
  for (auto &&u : a) u -= v;
}
inline bool inside(long long y, long long x, long long H, long long W) {
  return y >= 0 && x >= 0 && y < H && x < W;
}
long long u(long long a) { return a < 0 ? 0 : a; }
template <class T>
T min(vector<vector<T>> &a) {
  T res = numeric_limits<T>::max();
  for (long long i = 0, _lim = a.size(); i < _lim; i++)
    chmin(res, *min_element((a[i]).begin(), (a[i]).end()));
  return res;
}
template <class T>
T max(vector<vector<T>> &a) {
  T res = numeric_limits<T>::min();
  for (long long i = 0, _lim = a.size(); i < _lim; i++)
    chmax(res, *max_element((a[i]).begin(), (a[i]).end()));
  return res;
}
bool bget(long long m, long long keta) { return (m >> keta) & 1; }
long long bget(long long m, long long keta, long long sinsuu) {
  m /= (long long)pow(sinsuu, keta);
  return m % sinsuu;
}
inline long long bit(long long n) { return (1LL << (n)); }
inline long long bit(long long n, long long sinsuu) {
  return (long long)pow(sinsuu, n);
}
long long bcou(long long m) {
  return __builtin_popcount(m & 0xFFFFFFFF) + __builtin_popcount(m >> 32);
}
long long nextComb(long long &mask, long long n, long long r) {
  if (!mask) return mask = (1LL << r) - 1;
  long long x = mask & -mask;
  long long y = mask + x;
  long long res = ((mask & ~y) / x >> 1) | y;
  if (bget(res, n))
    return mask = 0;
  else
    return mask = res;
}
vl bitCombList(long long n, long long r) {
  vl res;
  long long m = 0;
  while (nextComb(m, n, r)) {
    res.push_back(m);
  }
  return res;
}
long long altoiaZ(char c) {
  if ('A' <= c && c <= 'Z') return c - 'A';
  return c - 'a' + 26;
}
char itoalaZ(long long i) {
  if (i < 26) return 'A' + i;
  return 'a' + i - 26;
}
long long altoi(char c) {
  if ('A' <= c && c <= 'Z') return c - 'A';
  return c - 'a';
}
char itoal(long long i) { return 'a' + i; }
long long ctoi(char c) { return c - '0'; }
void compress(vi &a) {
  vi b;
  long long len = a.size();
  for (long long i = 0; i < len; ++i) {
    b.push_back(a[i]);
  }
  sort(b);
  b.erase(unique(b.begin(), b.end()), b.end());
  ;
  for (long long i = 0; i < len; ++i) {
    a[i] = lower_bound((b).begin(), (b).end(), a[i]) - b.begin();
  }
}
void compress(long long a[], long long len) {
  vi b;
  for (long long i = 0; i < len; ++i) {
    b.push_back(a[i]);
  }
  sort(b);
  b.erase(unique(b.begin(), b.end()), b.end());
  ;
  for (long long i = 0; i < len; ++i) {
    a[i] = lower_bound((b).begin(), (b).end(), a[i]) - b.begin();
  }
}
template <class T>
inline void fin(T s) {
  cout << s << endl, exit(0);
}
template <class T>
struct edge {
  long long from, to;
  T cost;
  long long id;
  long long type;
  edge(long long f, long long t, T c = 1, long long id = -1, long long ty = -1)
      : from(f), to(t), cost(c), id(id), type(ty) {}
  bool operator<(const edge &b) const { return cost < b.cost; }
  bool operator>(const edge &b) const { return cost > b.cost; }
};
template <typename T>
class graph {
 protected:
  vector<bool> _used;

 public:
  vector<vector<edge<T>>> g;
  vector<edge<T>> edges;
  long long n, root = -1;
  graph(long long n) : n(n) { g.resize(n), _used.resize(n); }
  void clear() { g.clear(), edges.clear(); }
  void resize(long long n) {
    this->n = n;
    g.resize(n);
    _used.resize(n);
  }
  long long size() { return g.size(); }
  bool isleaf(long long v) {
    assert(root != -1);
    return g[v].size() == 1 && g[v][0].from != root;
  }
  vector<edge<T>> &operator[](long long i) { return g[i]; }
  virtual void add(long long from, long long to, T cost, long long ty) = 0;
  virtual bool used(edge<T> &e) = 0;
  virtual bool used(long long id) = 0;
  virtual void del(edge<T> &e) = 0;
  virtual void del(long long id) = 0;
};
template <class T = long long>
class undigraph : public graph<T> {
 public:
  using graph<T>::g;
  using graph<T>::n;
  using graph<T>::edges;
  using graph<T>::_used;
  undigraph(long long n) : graph<T>(n) {}
  void add(long long f, long long t, T cost = 1, long long ty = -1) {
    if (!(0 <= f && f < n && 0 <= t && t < n)) ole();
    long long id = edges.size();
    g[f].emplace_back(f, t, cost, id, ty);
    g[t].emplace_back(t, f, cost, id + 1, ty);
    edges.emplace_back(f, t, cost, id, ty);
    edges.emplace_back(t, f, cost, id + 1, ty);
  }
  void add(edge<T> &e) {
    long long f = e.from, t = e.to, ty = e.type;
    T cost = e.cost;
    add(f, t, cost, ty);
  }
  bool used(edge<T> &e) { return _used[e.id]; }
  bool used(long long id) { return _used[id]; }
  void del(edge<T> &e) { _used[e.id] = _used[e.id ^ 1] = 1; }
  void del(long long id) { _used[id] = _used[id ^ 1] = 1; }
};
template <typename T = long long>
class digraph : public graph<T> {
 public:
  using graph<T>::g;
  using graph<T>::n;
  using graph<T>::edges;
  using graph<T>::_used;
  digraph(long long n) : graph<T>(n) {}
  void add(long long f, long long t, T cost = 1, long long ty = -1) {
    if (!(0 <= f && f < n && 0 <= t && t < n)) ole();
    long long id = edges.size();
    g[f].emplace_back(f, t, cost, ty, id);
    edges.emplace_back(f, t, cost, ty, id);
  }
  bool used(edge<T> &e) { return _used[e.id]; }
  bool used(long long id) { return _used[id]; }
  void del(edge<T> &e) { _used[e.id] = _used[e.id ^ 1] = 1; }
  void del(long long id) { _used[id] = _used[id ^ 1] = 1; }
};
template <class T>
bool nibu(const graph<T> &g) {
  UnionFind uf(g.n * 2);
  for (auto &&e : g.edges) uf.unite(e.f, e.t + g.n), uf.unite(e.f + g.n, e.t);
  return !uf.same(0, g.n);
}
template <class T>
vector<T> &dijkstra(const graph<T> &g, long long s) {
  if (!(0 <= s && s < g.n)) ole();
  T initValue = numeric_limits<T>::max();
  vector<T> dis(g.n, initValue);
  priority_queue<pair<T, long long>, vector<pair<T, long long>>,
                 greater<pair<T, long long>>>
      q;
  dis[s] = 0;
  q.emplace(0, s);
  while (q.size()) {
    T nowc = q.top().first;
    long long i = q.top().second;
    q.pop();
    if (dis[i] != nowc) continue;
    for (auto &&e : g.g[i]) {
      long long to = e.to;
      T cost = nowc + e.cost;
      if (dis[to] > cost) {
        dis[to] = cost;
        q.emplace(dis[to], to);
      }
    }
  }
  for (auto &&d : dis)
    if (d == initValue) d = -1;
  return dis;
}
template <class T, class U>
void operator+=(queue<T> &a, U v) {
  a.push(v);
}
template <class T, class U>
priority_queue<T, vector<T>, greater<T>> &operator+=(
    priority_queue<T, vector<T>, greater<T>> &a, U v) {
  a.push(v);
  return a;
}
template <class T, class U>
priority_queue<T> &operator+=(priority_queue<T> &a, U v) {
  a.push(v);
  return a;
}
template <class T, class U>
set<T> &operator+=(set<T> &a, U v) {
  a.insert(v);
  return a;
}
template <class T, class U>
vector<T> &operator+=(vector<T> &a, U v) {
  a.push_back(v);
  return a;
}
template <class T>
vector<T> &operator+=(vector<T> &a, vector<T> &b) {
  a.push_back(b);
  return a;
}
template <class T>
vector<T> &operator-=(vector<T> &a, vector<T> &b) {
  if ((a.size()) != (b.size())) ole();
  for (long long i = 0, _lim = (a.size()); i < _lim; i++) a[i] -= b[i];
  return a;
}
template <class T>
vector<T> &operator-(vector<T> &a, vector<T> &b) {
  if ((a.size()) != (b.size())) ole();
  vector<T> res;
  for (long long i = 0, _lim = (a.size()); i < _lim; i++) res[i] = a[i] - b[i];
  return res;
}
template <typename T>
void remove(vector<T> &v, unsigned long long i) {
  v.erase(v.begin() + i);
}
template <typename T>
void remove(vector<T> &v, unsigned long long s, unsigned long long e) {
  v.erase(v.begin() + s, v.begin() + e);
}
template <typename T>
void removen(vector<T> &v, unsigned long long s, unsigned long long n) {
  v.erase(v.begin() + s, v.begin() + s + n);
}
template <typename T>
void erase(vector<T> &v, unsigned long long i) {
  v.erase(v.begin() + i);
}
template <typename T>
void erase(vector<T> &v, unsigned long long s, unsigned long long e) {
  v.erase(v.begin() + s, v.begin() + e);
}
template <typename T>
void erasen(vector<T> &v, unsigned long long s, unsigned long long n) {
  v.erase(v.begin() + s, v.begin() + s + n);
}
template <typename T>
void insert(vector<T> &v, unsigned long long i, T t) {
  v.insert(v.begin() + i, t);
}
template <typename T>
void insert(vector<T> &v, unsigned long long i, vector<T> list) {
  for (auto &&va : list) v.insert(v.begin() + i++, va);
}
template <typename T>
void insert(vector<T> &v, unsigned long long i, initializer_list<T> list) {
  for (auto &&va : list) v.insert(v.begin() + i++, va);
}
template <typename T>
void insert(set<T> &v, vector<T> list) {
  for (auto &&va : list) v.insert(va);
}
template <typename T>
void insert(set<T> &v, initializer_list<T> list) {
  for (auto &&va : list) v.insert(va);
}
long long ma = numeric_limits<long long>::min();
long long mi = numeric_limits<long long>::max();
bool topo(vi &res, digraph<long long> &g) {
  long long n = g.g.size();
  vi nyu(n);
  for (long long i = 0, _lim = n; i < _lim; i++)
    for (auto &&e : g[i]) nyu[e.to]++;
  queue<long long> st;
  for (long long i = 0, _lim = n; i < _lim; i++)
    if (nyu[i] == 0) st.push(i);
  while (st.size()) {
    long long v = st.front();
    st.pop();
    res.push_back(v);
    for (auto &&e : g[v])
      if (--nyu[e.to] == 0) st.push(e.to);
  }
  return res.size() == n;
}
bool topos(vi &res, digraph<long long> &g) {
  long long n = g.g.size();
  vi nyu(n);
  for (long long i = 0, _lim = n; i < _lim; i++)
    for (auto &&e : g[i]) nyu[e.to]++;
  priority_queue<long long, vector<long long>, greater<long long>> q;
  for (long long i = 0, _lim = n; i < _lim; i++)
    if (nyu[i] == 0) q.push(i);
  while (q.size()) {
    long long i = q.top();
    q.pop();
    res.push_back(i);
    for (auto &&e : g[i])
      if (--nyu[e.to] == 0) q.push(e.to);
  }
  return res.size() == n;
}
vector<string> split(const string a, const char deli) {
  string b = a + deli;
  long long l = 0, r = 0, n = b.size();
  vector<string> res;
  for (long long i = 0, _lim = n; i < _lim; i++) {
    if (b[i] == deli) {
      r = i;
      if (l < r) res.push_back(b.substr(l, r - l));
      l = i + 1;
    }
  }
  return res;
}
vector<string> split(const string a, const string deli) {
  string b = a + deli;
  long long l = 0, r = 0, n = b.size(), dn = deli.size();
  vector<string> res;
  for (long long i = 0, _lim = n; i < _lim; i++) {
    if (i + dn <= n && b.substr(i, i + dn) == deli) {
      r = i;
      if (l < r) res.push_back(b.substr(l, r - l));
      i += dn - 1;
      l = i + 1;
    }
  }
  return res;
}
template <typename T = long long>
class BIT {
 public:
  long long n;
  vector<T> dat;
  BIT(long long n) : n(n) { dat.assign(n, 0); }
  T sum(long long k) {
    if (k >= n) k = n - 1;
    T ret = 0;
    for (long long x = k - 1; x >= 0; x = (x & (x + 1)) - 1) {
      ret += dat[x];
    }
    return ret;
  }
  T sum(long long l, long long r) { return sum(r) - sum(l); }
  T operator[](long long k) {
    assert(0 <= k && k < n);
    return sum(k + 1) - sum(k);
  }
  void add(long long k, T val = 1) {
    for (long long x = k; x < n; x |= x + 1) dat[x] += val;
  }
  void update(long long k, T val = 0) { add(k, -operator[](k) + val); }
  void clear() { fill(dat, 0); }
  long long lower_bound(long long w) {
    if (w <= 0) return -1;
    long long x = 0;
    long long k = 1;
    while (k * 2 <= n) k *= 2;
    for (; k > 0; k /= 2) {
      if (x + k <= n && dat[x + k - 1] < w) {
        w -= dat[x + k - 1];
        x += k;
      }
    }
    return x;
  }
};
long long n, k, d, m, h, w, x, y, z, q;
long long cou;
string s;
vi a, b, c;
vp p;
signed main() {
  cin >> n >> m;
  p.resize(n);
  for (long long i = 0, _lim = n; i < _lim; i++) cin >> p[i];
  ;
  ;
  sort((p).begin(), (p).end(),
       [](P a, P b) { return a.second - a.first < b.second - b.first; });
  vi ls(n);
  for (long long i = 0, _lim = n; i < _lim; i++)
    ls[i] = p[i].second - p[i].first;
  BIT<> bt(m + 5);
  for (long long i = 1, pi = 0; i < m + 1; i++) {
    cou = 0;
    for (long long v = 0; v < m + 1; v += i) {
      cou += bt.sum(v + 1);
    }
    cout << n - pi + cou << endl;
  }
  return 0;
}
