#include <bits/stdc++.h>
using namespace std;
long long q = -3000000002;
int n, k;
int solve(vector<long long> &v) {
  int prev = 0;
  for (int ii = 1; ii < v.size(); ii++) {
    if (v[ii] == q) continue;
    if (ii - prev > v[ii] - v[prev]) return 0;
    if (v[prev] >= 0) {
      for (int jj = 1; jj < ii - prev; jj++) {
        v[prev + jj] = v[prev] + jj;
      }
    } else if (v[ii] <= 0) {
      for (int jj = 1; ii - jj > prev; jj++) {
        v[ii - jj] = v[ii] - jj;
      }
    } else {
      int d = (ii - prev - 1) / 2 + (ii - prev - 1) % 2;
      if (v[ii] <= d) {
        for (int jj = 1; ii - jj > prev; jj++) {
          v[ii - jj] = v[ii] - jj;
        }
      } else if (v[prev] >= -d) {
        for (int jj = 1; jj < ii - prev; jj++) {
          v[prev + jj] = v[prev] + jj;
        }
      } else {
        for (int jj = 1; jj < ii - prev; jj++) {
          v[prev + jj] = -d + jj;
        }
      }
    }
    prev = ii;
  }
  return 1;
}
int main() {
  long long seq[100007];
  vector<long long> vs[100007];
  cin >> n >> k;
  for (int ii = 0; ii < n; ii++) {
    string s;
    cin >> s;
    if (s == "?") {
      seq[ii] = q;
    } else {
      seq[ii] = atoi(s.c_str());
    }
  }
  for (int ii = 0; ii < k; ii++) {
    vs[ii].push_back(q + 1);
    for (int jj = 0; ii + jj * k < n; jj++) {
      vs[ii].push_back(seq[ii + jj * k]);
    }
    vs[ii].push_back(-(q + 1));
    if (solve(vs[ii]) == 0) {
      cout << "Incorrect sequence" << endl;
      return 0;
    }
  }
  int ii = 1;
  while (true) {
    int printed = 0;
    for (int jj = 0; jj < k; jj++) {
      if (ii < vs[jj].size() - 1) {
        cout << vs[jj][ii] << " ";
        printed = 1;
      }
    }
    ii++;
    if (!printed) break;
  }
  cout << endl;
}
