#include <bits/stdc++.h>
using namespace std;
const long long INF = (long long)1e10;
void no_ans() {
  cout << "Incorrect sequence\n";
  exit(0);
}
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  long long n, k;
  cin >> n >> k;
  vector<string> arr(n);
  for (auto &x : arr) {
    cin >> x;
  }
  vector<long long> res(n);
  for (long long i = 0; i < k; i++) {
    vector<long long> boba;
    for (long long j = i; j < n; j += k) {
      if (arr[j] == "?") {
        boba.push_back(INF);
      } else {
        boba.push_back(stoi(arr[j]));
      }
    }
    boba.push_back(INF + 1);
    vector<long long> now_res;
    long long m = boba.size();
    long long prev = -1;
    for (long long j = 0; j < m; j++) {
      if (boba[j] == INF) {
        continue;
      }
      long long len = j - prev - 1;
      long long a = (prev == -1 ? -INF : boba[prev]);
      long long b = boba[j];
      if (b - a - 1 < len) {
        no_ans();
      }
      if (a <= 0 && b <= 0) {
        for (long long r = b - len; r < b; r++) {
          now_res.push_back(r);
        }
      } else if (a >= 0 && b >= 0) {
        for (long long r = a + 1; r < a + 1 + len; r++) {
          now_res.push_back(r);
        }
      } else if (len > 0) {
        long long l = -((len - 1) / 2);
        long long r = len / 2;
        while (a >= l) {
          l++;
          r++;
        }
        while (b <= r) {
          r--;
          l--;
        }
        for (long long t = l; t <= r; t++) {
          now_res.push_back(t);
        }
      }
      now_res.push_back(b);
      prev = j;
    }
    long long cnt = 0;
    for (long long j = i; j < n; j += k) {
      res[j] = now_res[cnt];
      cnt++;
    }
  }
  for (auto x : res) {
    cout << x << " ";
  }
  cout << '\n';
}
