#include <bits/stdc++.h>
const int maxn = 100005;
const int X = ~0U >> 1;
const int INF = (int)X - 5;
int n, k;
int b[maxn];
int a[maxn];
inline int read() {
  char ch;
  bool flag = false;
  int a = 0;
  while (!((((ch = getchar()) >= '0') && (ch <= '9')) || (ch == '-') ||
           (ch == '?')))
    ;
  if (ch == '?') return X;
  if (ch != '-') {
    a *= 10;
    a += ch - '0';
  } else
    flag = true;
  while (((ch = getchar()) >= '0') && (ch <= '9')) {
    a *= 10;
    a += ch - '0';
  }
  if (flag) {
    a = -a;
  }
  return a;
}
inline bool jabs(int x) { return x < 0 ? 0 : 1; }
void solve() {
  bool flag = false;
  for (int T = 1; T <= k; T++) {
    int t = 0;
    for (int i = T; i <= n; i += k) b[++t] = i;
    b[0] = 0;
    b[++t] = n + 1;
    int hloc, tloc;
    int head, tail;
    hloc = tloc = 0;
    head = tail = -INF;
    for (int i = 1; i <= t; i++) {
      bool f = false;
      if (a[b[i]] != X) {
        f = true;
        head = tail;
        tail = a[b[i]];
        hloc = tloc;
        tloc = i;
      }
      if (f && (head >= tail || ((long long)tail - head) < (tloc - hloc))) {
        flag = true;
        break;
      }
      if (tloc - hloc > 1 && f) {
        if (jabs(head) == jabs(tail)) {
          if (jabs(tail)) {
            for (int z = hloc + 1; z < tloc; z++) a[b[z]] = a[b[z - 1]] + 1;
          } else {
            for (int z = tloc - 1; z > hloc; z--) a[b[z]] = a[b[z + 1]] - 1;
          }
        } else {
          int mi = ((((head) < 0 ? -(head) : (head))) <
                            (((tail) < 0 ? -(tail) : (tail)))
                        ? (((head) < 0 ? -(head) : (head)))
                        : (((tail) < 0 ? -(tail) : (tail))));
          int need = ((tloc - hloc - 1) / 2);
          if (mi > need) {
            a[b[tloc - 1]] = need;
            for (int z = tloc - 2; z > hloc; z--) a[b[z]] = a[b[z + 1]] - 1;
          } else {
            if (((head) < 0 ? -(head) : (head)) == mi)
              for (int z = hloc + 1; z < tloc; z++) a[b[z]] = a[b[z - 1]] + 1;
            else
              for (int z = tloc - 1; z > hloc; z--) a[b[z]] = a[b[z + 1]] - 1;
          }
        }
      }
    }
    if (flag == true) break;
  }
  if (flag)
    puts("Incorrect sequence");
  else
    for (int i = 1; i <= n; i++) printf("%d%c", a[i], i == n ? '\n' : ' ');
}
int main() {
  while (~scanf("%d %d\n", &n, &k) && n) {
    for (int i = 1; i <= n; i++) a[i] = read();
    a[0] = -INF;
    a[n + 1] = +INF;
    solve();
  }
  return 0;
}
