#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, k;
  cin >> n >> k;
  vector<long long> arr(n);
  vector<bool> fnd(n, 1);
  for (long long i = 0; i < n; ++i) {
    string x;
    cin >> x;
    if (x[0] == '?')
      fnd[i] = 0;
    else {
      arr[i] = 0;
      long long j = 0;
      if (x[0] == '-') j++;
      for (; j < (long long)x.length(); j++) {
        arr[i] *= 10;
        arr[i] += x[j] - '0';
      }
      if (x[0] == '-') arr[i] = -arr[i];
    }
  }
  for (long long i = 0; i < k; ++i) {
    long long m = -100000000002;
    long long M = -m;
    long long j = i;
    long long cnt = 0;
    while (j < n) {
      long long prev = j;
      cnt = 0;
      M = 100000000002;
      while (j < n && fnd[j] == 0) {
        j += k;
        cnt++;
      }
      if (j < n) {
        M = arr[j];
      }
      if (M <= m + cnt) {
        cout << "Incorrect sequence\n";
        return 0;
      }
      if (cnt != 0) {
        if (m >= -(cnt / 2 + 1)) {
          for (long long q = prev; q < j; q += k) arr[q] = arr[q - k] + 1;
        } else if (M <= cnt / 2 + 1) {
          for (long long q = j - k; q >= prev; q -= k) arr[q] = arr[q + k] - 1;
        } else {
          arr[prev] = -(cnt / 2);
          for (long long q = prev + k; q < j; q += k) arr[q] = arr[q - k] + 1;
        }
      }
      m = M;
      j += k;
    }
  }
  for (long long i = 0; i < n; ++i) cout << arr[i] << " ";
  cout << endl;
  return 0;
}
