#include <bits/stdc++.h>
using namespace std;
const int N = 200001;
const int INF = 2e9;
int a[N];
int n, k;
bool used[N];
int StringToInt(string s) {
  bool isPositive = true;
  if (s[0] == '-') {
    s.erase(s.begin());
    isPositive = false;
  }
  int p = 1;
  int ans = 0;
  for (int i = 0; i < s.size(); ++i) ans = ans * 10 + s[i] - '0';
  if (isPositive == false) ans *= -1;
  return ans;
}
bool check() {
  for (int i = 1; i <= k; ++i) {
    for (int j = i + k; j <= n; j += k) {
      if (a[j] <= a[j - k]) return false;
    }
  }
  return true;
}
int main() {
  scanf("%d%d\n", &n, &k);
  for (int i = 1; i <= n; ++i) {
    string s;
    cin >> s;
    if (s == "?") {
      used[i] = true;
      a[i] = -INF;
    } else
      a[i] = StringToInt(s);
  }
  a[0] = -INF;
  for (int i = 1; i <= k; ++i) a[n + i] = INF;
  for (int i = 1; i <= k; ++i) {
    int p = 0;
    int len = 0;
    for (int j = i; j <= n + k; j += k) {
      if (used[j] == true) {
        len++;
        continue;
      }
      if (a[p] < 0 && a[j] <= 0) {
        for (int c = j - k; c > p; c -= k) a[c] = a[c + k] - 1;
      } else if (a[p] >= 0 && a[j] > 0) {
        for (int c = (p == 0 ? i : p + k); c < j; c += k) a[c] = a[c - k] + 1;
      } else {
        int l = 0, r = 0;
        len--;
        while (len > 0) {
          bool flag = false;
          if (l - 1 > a[p]) {
            l--;
            len--;
            flag = true;
          }
          if (len > 0 && r + 1 < a[j]) {
            r++;
            len--;
            flag = true;
          }
          if (flag == false) break;
        }
        for (int c = (p == 0 ? i : p + k); c < j; c += k) a[c] = l++;
      }
      p = j;
      len = 0;
    }
  }
  if (check() == false) {
    cout << "Incorrect sequence" << endl;
    return 0;
  }
  for (int i = 1; i <= n; ++i) cout << a[i] << " ";
  return 0;
}
