#include<bits/stdc++.h>
#define pb(x) push_back(x)
#define all(x) x.begin(), x.end()
#define cout2(x, y) cout << x << " " << y << endl
#define N 100004
#define INF (1LL<<40)
using namespace std;
long long a[N];
bool vis[N];
long long trans(string &s){
long long ans = 0;
if(s[0] == '-'){
for(int i = 1; i < s.size(); i++)ans = ans * 10 + s[i] - '0';
return -1 * ans;
}
for(int i = 0; i < s.size(); i++)ans = ans * 10 + s[i] - '0';
return ans;
}
long long F(long long val, long long n){
if(val + n - 1 <= 0)return abs(val * n) + n * (n - 1)/2;
if(val >= 0)return abs(val * n) + n * (n - 1)/2;
n = abs(abs(val) - abs(val + n - 1));
return val * n + n * (n - 1)/2;
}
bool solve(vector<long long>&seq){
int n = seq.size() - 2;
long long menor = seq[0], mayor = seq.back();
if(mayor - menor - 1 < n)return false;
long long lo = menor + 2 * INF + 1, hi = mayor + 2 * INF - n, me1, me2;
while(hi - lo > 3){
me1 = (2 * lo + hi)/3;
me2 = (lo + 2 * hi)/3;
if(F(me1 - 2 * INF, n) > F(me2 - 2 * INF, n))lo = me1;
else hi = me2;
}
lo -= 2 * INF;
hi -= 2 * INF;
long long pos = lo;
for(long long i = lo; i <= hi; i++)if(F(pos, n) > F(i, n))pos = i;
for(int i = 1; i < seq.size() - 1; i++)a[seq[i]] = pos + i - 1;
return true;
}
int main(){
int n, k;
while(cin>>n>>k){
string s, aux;
getline(cin, s);
getline(cin, s);
istringstream in(s);
for(int i = 0; i < n; i++){
in>>aux;
if(aux == "?")a[i] = INF;
else a[i] = trans(aux);
}
memset(vis, false, sizeof vis);
vector<vector<long long> >S;
vector<long long>seq;
for(int i = 0; i < n; i++){
if(vis[i])continue;
if(a[i] != INF)continue;
seq.clear();
if(i - k >= 0)seq.pb(a[i - k]);
else seq.pb(-INF);
while(i < n && a[i] == INF)seq.pb(i), vis[i] = true, i += k;
if(i < n)seq.pb(a[i]);
else seq.pb(INF);
S.pb(seq);
}
bool ok = true;
for(int i = 0; i < S.size() && ok; i++)if(!solve(S[i]))ok = false;
for(int i = 0; i < n; i++){
if(i - k >= 0 && a[i - k] >= a[i])ok = false;
if(i + k < n && a[i + k] <= a[i])ok = false;
}
if(ok){
printf("%I64d", a[0]);
for(int i = 1; i < n; i++)printf(" %I64d", a[i]);
puts("");
}
else puts("Incorrect sequence");
}
}
I2luY2x1ZGU8Yml0cy9zdGRjKysuaD4KI2RlZmluZSBwYih4KSBwdXNoX2JhY2soeCkKI2RlZmluZSBhbGwoeCkgeC5iZWdpbigpLCB4LmVuZCgpCiNkZWZpbmUgY291dDIoeCwgeSkgY291dCA8PCB4IDw8ICIgIiA8PCB5IDw8ICBlbmRsCiNkZWZpbmUgTiAxMDAwMDQKI2RlZmluZSBJTkYgKDFMTDw8NDApCgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKbG9uZyBsb25nIGFbTl07CmJvb2wgdmlzW05dOwoKbG9uZyBsb25nIHRyYW5zKHN0cmluZyAmcyl7CgkKCWxvbmcgbG9uZyBhbnMgPSAwOwoJaWYoc1swXSA9PSAnLScpewoJCQoJCWZvcihpbnQgaSA9IDE7IGkgPCBzLnNpemUoKTsgaSsrKWFucyA9IGFucyAqIDEwICsgc1tpXSAtICcwJzsKCQlyZXR1cm4gLTEgKiBhbnM7CQoJfQoJCglmb3IoaW50IGkgPSAwOyBpIDwgcy5zaXplKCk7IGkrKylhbnMgPSBhbnMgKiAxMCArIHNbaV0gLSAnMCc7CglyZXR1cm4gYW5zOwoJCn0KCmxvbmcgbG9uZyBGKGxvbmcgbG9uZyB2YWwsIGxvbmcgbG9uZyBuKXsKCQoKCWlmKHZhbCArIG4gLSAxIDw9IDApcmV0dXJuIGFicyh2YWwgKiBuKSArIG4gKiAobiAtIDEpLzI7CglpZih2YWwgPj0gMClyZXR1cm4gYWJzKHZhbCAqIG4pICsgbiAqIChuIC0gMSkvMjsKCQoJbiA9IGFicyhhYnModmFsKSAtIGFicyh2YWwgKyBuIC0gMSkpOwoJcmV0dXJuIHZhbCAqIG4gKyBuICogKG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