#include<bits/stdc++.h>
using namespace std;
using ll = long long;
ll n,d,a[1000001],b[1000001];
int main () {
cin >> n>> d;
for(int i = 0; i<n; i++){
cin >> a[i];
a[i]=b[i];
}
sort(b, b+n);
int x=b[0],m=b[n-1];
for(int i = 0; i<n;i++){
if(a[i]>d){
a[i]=m;
}else if(a[i]<d){
a[i]=x;
}
cout << a[i]<<" ";
}
return 0;
}