#include <bits/stdc++.h>
using namespace std;
long n, k;
string st;
vector<pair<long, long> > v[1 << 20];
long q;
vector<pair<long, long> > block;
long l1;
vector<long> tv;
long er;
long ans[1 << 20];
vector<long> solve(vector<pair<long, long> > v, long lwr, long upr) {
  long sz = v.size();
  if (lwr + sz >= upr) er = 1;
  vector<long> res;
  res.resize(v.size());
  if (er) return res;
  if (upr <= sz - 1 - sz / 2) {
    for (int i = 0; i < v.size(); i++) res[i] = upr - sz + i;
    return res;
  }
  if (lwr >= -(sz / 2)) {
    for (int i = 0; i < v.size(); i++) {
      res[i] = lwr + i + 1;
    }
    return res;
  }
  for (int i = 0; i < v.size(); i++) res[i] = i - sz / 2;
  return res;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin >> n >> k;
  for (int i = 1; i <= n; i++) {
    cin >> st;
    if (st == "?") {
      v[i % k].push_back(make_pair(i, -2000000000));
    } else {
      stringstream s(st);
      s >> q;
      v[i % k].push_back(make_pair(i, q));
    }
  }
  for (int i = 0; i < k; i++) {
    block.clear();
    l1 = -1100000001;
    for (int j = 0; j < v[i].size(); j++) {
      if (v[i][j].second > -1.5e9) {
        if (block.size()) {
          tv = solve(block, l1, v[i][j].second);
          for (int q = 0; q < tv.size(); q++)
            v[i][j - tv.size() + q].second = tv[q];
        }
        block.clear();
        if (j > 0 && v[i][j].second <= v[i][j - 1].second) er = 1;
        l1 = v[i][j].second;
      } else {
        block.push_back(v[i][j]);
      }
    }
    if (block.size()) {
      tv = solve(block, l1, 1100000001);
      for (int j = 0; j < tv.size(); j++)
        v[i][v[i].size() - tv.size() + j].second = tv[j];
    }
  }
  if (er)
    cout << "Incorrect sequence" << endl;
  else {
    for (int i = 0; i < k; i++)
      for (int j = 0; j < v[i].size(); j++) ans[v[i][j].first] = v[i][j].second;
    for (int i = 1; i <= n; i++) {
      if (i > 1) cout << " ";
      cout << ans[i];
    }
    cout << endl;
  }
  cin.get();
  cin.get();
  return 0;
}
