#include <bits/stdc++.h>
using namespace std;
const int INF = (int)1E9 + (int)2E5;
int N, K;
int x[100005];
void fillgap(stack<int> &stk, int r, int l) {
  int n = stk.size();
  int dr = 0 + n / 2;
  int dl = dr - n + 1;
  if (dr >= r) {
    int shift = dr - (r - 1);
    dr -= shift;
    dl -= shift;
  }
  if (dl <= l) {
    int shift = l + 1 - dl;
    dl += shift;
    dr += shift;
  }
  int v = dr;
  while (stk.size()) {
    int j = stk.top();
    stk.pop();
    x[j] = v--;
  }
}
int main() {
  cin >> N >> K;
  for (int i = (0); i < (N); i++) {
    char buf[20];
    scanf("%s", buf);
    if (buf[0] == '?') {
      x[i] = INF;
    } else {
      sscanf(buf, "%d", &x[i]);
    }
  }
  for (int s = 0; s < K; s++) {
    int maxv = -INF;
    int lasti = -1;
    stack<int> stk;
    for (int i = s; i < N; i += K) {
      if (x[i] != INF) {
        if (x[i] < maxv) return puts("Incorrect sequence"), 0;
        maxv = max(maxv, x[i]);
        if (lasti == -1) {
          fillgap(stk, x[i], -INF);
        } else {
          int gap = x[i] - x[lasti] - 1;
          if ((int)stk.size() > gap) return puts("Incorrect sequence"), 0;
          fillgap(stk, x[i], x[lasti]);
        }
        lasti = i;
      } else {
        stk.push(i);
      }
    }
    if (stk.size()) {
      fillgap(stk, INF, lasti != -1 ? x[lasti] : -INF);
    }
  }
  for (int i = (0); i < (N); i++) {
    printf("%d ", x[i]);
  }
  return 0;
}
