#include <bits/stdc++.h>
using namespace std;
char s[200005];
bool vis[200005];
int a[200005];
int n, m;
double p;
void doit() {
  memset(vis, 0, sizeof(vis));
  for (int i = 1; i <= n; ++i) {
    scanf("%s", s);
    if (s[0] != '?') {
      a[i] = atoi(s);
      vis[i] = 1;
    }
  }
  for (int i = 1; i <= m; ++i) {
    a[n + i] = 1001000000;
    vis[n + i] = 1;
  }
  n += m;
  long long ans = 0;
  for (int i = 1; i <= m; ++i) {
    int last = -1001000000, ff, t = 0;
    for (int j = i; j <= n; j += m)
      if (vis[j]) {
        if (a[j] - last <= t) {
          printf("Incorrect sequence\n");
          return;
        }
        if (!t) {
          last = a[j];
          continue;
        }
        if (last <= 0 && a[j] >= 0) {
          if (last < 0 && a[j] > 0) t--;
          if (!t) {
            for (int k = ff; k < j; k += m) a[k] = 0;
            last = a[j];
            continue;
          }
          int k1 = max(0, last + 1), k2 = 0;
          while (t) {
            if (k2 + 1 < a[j]) k2++, t--;
            if (!t) break;
            if (k1 - 1 > last) k1--, t--;
          }
          last = k1 - 1;
          for (int k = ff; k < j; k += m) a[k] = ++last;
          last = a[j];
        } else if (last > 0) {
          for (int k = ff; k < j; k += m) a[k] = ++last;
          last = a[j];
          t = 0;
        } else {
          last = a[j];
          for (int k = j - m; k >= ff; k -= m) a[k] = --last;
          last = a[j];
          t = 0;
        }
      } else {
        t++;
        if (t == 1) ff = j;
      }
  }
  n -= m;
  for (int i = 1; i <= n - 1; ++i) printf("%d ", a[i]);
  printf("%d\n", a[n]);
}
int main() {
  while (scanf("%d%d", &n, &m) != EOF) doit();
}
