#include <bits/stdc++.h>
using namespace std;
long long n, k, a[1200000], i, j, kk, p[1200000], e, lst, s, pl[1200000];
inline int read() {
  int x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    if (ch == '?') return 2e9 + 1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = (x << 1) + (x << 3) + (ch ^ 48);
    ch = getchar();
  }
  return x * f;
}
int main() {
  cin >> n >> k;
  p[0] = -2e9 - 2;
  for (i = 1; i <= n; ++i) {
    a[i] = read();
  }
  for (i = 1; i <= k; ++i) {
    s = i;
    e = 0;
    lst = 0;
    while (s <= n) {
      p[++e] = a[s];
      if (p[e] != 2e9 + 1) pl[e] = lst, lst = e;
      s += k;
    }
    p[e + 1] = 2e9 + 2;
    pl[e + 1] = lst;
    for (j = 1; j <= e + 1; ++j) {
      if (p[j] != 2e9 + 1) {
        if (p[j] - p[pl[j]] < j - pl[j]) {
          cout << "Incorrect sequence";
          return 0;
        }
        if (p[j] >= 0 && p[pl[j]] >= 0) {
          for (kk = pl[j] + 1; kk < j; ++kk) p[kk] = p[pl[j]] + kk - pl[j];
        } else if (p[j] < 0 && p[pl[j]] < 0) {
          for (kk = j - 1; kk > pl[j]; --kk) p[kk] = p[j] - j + kk;
        } else {
          int mid = (pl[j] + j) >> 1;
          if (mid - pl[j] >= -p[pl[j]]) mid = pl[j] - p[pl[j]];
          if (j - mid > p[j]) mid = j - p[j];
          for (kk = j - 1; kk > pl[j]; --kk) p[kk] = kk - mid;
        }
      }
    }
    for (j = 1; j <= e; ++j)
      if (p[j] <= p[j - 1] || p[j] > 2e9 || p[j] < -2e9) {
        cout << "Incorrect sequence";
        return 0;
      } else
        a[(j - 1) * k + i] = p[j];
  }
  for (i = 1; i <= n; ++i) printf("%lld ", a[i]);
}
