Problem: Consider placing N flags on a line. Flags are numbered through 1 to N.

Flag i can be placed on the coordinate X_i or Y_i. For any two different flags, the distance between them should be at least D.

Decide whether it is possible to place all N flags. If it is possible, print such a configulation.

Constraints

* 1 \leq N \leq 1000
* 0 \leq D \leq 10^9
* 0 \leq X_i < Y_i \leq 10^9
* All values in Input are integer.

Input

Input is given from Standard Input in the following format:


N D
X_1 Y_1
X_2 Y_2
\vdots
X_N Y_N


Output

Print `No` if it is impossible to place N flags.

If it is possible, print `Yes` first. After that, print N lines. i-th line of them should contain the coodinate of flag i.

Examples

Input

3 2
1 4
2 5
0 6


Output

Yes
4
2
0


Input

3 3
1 4
2 5
0 6


Output

No

Solution (in CPP):

Solution:
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#include <tuple>
#define mkp make_pair
#define mkt make_tuple
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define all(v) v.begin(),v.end()
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;
template<class T> void chmin(T &a,const T &b){if(a>b) a=b;}
template<class T> void chmax(T &a,const T &b){if(a<b) a=b;}

/* example
    int n=scc.scc();
    scc.build(n,g);
    (g:outside)
*/
struct SCC{
    vector<int> used,cmp,vs;
    vector<vector<int>> ori;
    vector<vector<int>> v,rv;
    SCC(){}
    SCC(int n):used(n),cmp(n,-1),v(n),rv(n){}
 
    void add_edge(int x,int y){
        v[x].push_back(y);
        rv[y].push_back(x);
    }
    void dfs(int x){
        used[x]=true;
        for(auto to:v[x]) if(!used[to]) dfs(to);
        vs.push_back(x);
    }
 
    void rdfs(int x,int k){
        cmp[x]=k;
        for(auto to:rv[x]) if(cmp[to]==-1) rdfs(to,k);
    }
 
    int scc(){
        for(int i=0;i<used.size();i++) if(!used[i]) dfs(i);
        reverse(vs.begin(),vs.end());
        int k=0;
        for(auto x:vs) if(cmp[x]==-1) rdfs(x,k++);

        ori.resize(k);
        for(int i=0;i<used.size();i++) ori[cmp[i]].push_back(i);

        return k;//k:size
    }

    void build(int k,vector<vector<int>> &g){
        g.resize(k);
        for(int i=0;i<v.size();i++){
            for(auto to:v[i]){
                int x=cmp[i],y=cmp[to];
                if(x!=y) g[x].push_back(y);
            }
        }
    }
};

// depends on SCC
// !x:2*x, x:2*x+1
struct two_SAT{
    int N;
    SCC graph;
    vector<bool> answer;

    two_SAT(){}
    two_SAT(int n):N(n),graph(2*N),answer(N){}

    void add_edge(int i,bool f,int j,bool g){
        graph.add_edge(2 * i + (f ? 0 : 1), 2 * j + (g ? 1 : 0));
        graph.add_edge(2 * j + (g ? 0 : 1), 2 * i + (f ? 1 : 0));
    }
    
    bool satisfiable(){
        int K=graph.scc();
        auto ids=graph.cmp;
        for(int i=0;i<N;++i){
            if(ids[2*i]==ids[2*i+1]) return false;
            answer[i]=(ids[2*i] < ids[2*i+1]);
        }
        return true;
    }

    vector<bool> getAnswer(){
        return answer;
    }
};

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);

  int N;
  ll D;
  cin>>N>>D;
  vector<ll> X(N),Y(N);
  rep(i,N) cin>>X[i]>>Y[i];

  two_SAT sat(N);
  for(int i=0;i<N;i++) for(int j=i+1;j<N;j++){
      if(abs(X[i]-X[j])<D) sat.add_edge(i,false,j,false);
      if(abs(X[i]-Y[j])<D) sat.add_edge(i,false,j,true);
      if(abs(Y[i]-X[j])<D) sat.add_edge(i,true,j,false);
      if(abs(Y[i]-Y[j])<D) sat.add_edge(i,true,j,true);
  }

  if(sat.satisfiable()==false){
      cout<<"No"<<endl;
      return 0;
  }

  cout<<"Yes"<<"\n";
  vector<bool> ans=sat.getAnswer();
  rep(i,N){
      if(ans[i]) cout<<X[i]<<"\n";
      else cout<<Y[i]<<"\n";
  }

  return 0;
}