#include <bits/stdc++.h>
using namespace std;
int n, k, ad, a[444444], u[444444];
char str[11];
int getnum(char str[]) {
  int ret = 0, neg = -1, i = 1;
  if (str[0] != '-') {
    neg = 1;
    i = 0;
  }
  for (; str[i]; i++) {
    ret = ret * 10 + str[i] - '0';
  }
  ret *= neg;
  return ret;
}
int main() {
  int i, j, fg = 0, nd, pd, ll, lt, rt, ds, mid, ld;
  scanf("%d%d", &n, &k);
  ad = k;
  for (i = 1; i <= n; i++) {
    scanf("%s", str);
    if (str[0] == '?')
      a[i + ad] = 1;
    else
      u[i + ad] = getnum(str);
  }
  for (i = 1; i <= ad; i++) {
    u[i] = -1010000000 + i;
    u[ad + n + i] = 1010000000 + i;
  }
  for (i = 1; i <= k; i++) {
    if (fg) break;
    nd = pd = -1;
    ll = u[i];
    for (j = i + k; j <= n + 2 * ad; j += k) {
      if (a[j]) continue;
      if (u[j] <= ll) {
        fg = 1;
        break;
      }
      ll = u[j];
    }
    if (fg) break;
    for (j = i; j <= n + 2 * ad; j += k) {
      if (pd == -1 && !a[j] && u[j] >= 0) {
        pd = j;
        break;
      }
    }
    for (j = pd; j >= 1; j -= k) {
      if (nd == -1 && !a[j] && u[j] < 0) {
        nd = j;
        break;
      }
    }
    for (j = pd + k; j <= n + 2 * ad; j += k) {
      ld = j - k;
      if (!a[j]) {
        if (u[ld] >= u[j]) fg = 1;
        continue;
      }
      if (fg) break;
      a[j] = 0;
      u[j] = u[ld] + 1;
    }
    if (fg) break;
    for (j = nd - k; j >= 1; j -= k) {
      ld = j + k;
      if (!a[j]) {
        if (u[j] >= u[ld]) fg = 1;
        continue;
      }
      if (fg) break;
      a[j] = 0;
      u[j] = u[ld] - 1;
    }
    mid = (pd - nd) / k - 1;
    if (mid > u[pd] - u[nd]) {
      fg = 1;
      break;
    }
    lt = -((mid - 1) / 2);
    rt = mid / 2;
    if (u[pd] <= rt) {
      ds = rt - u[pd] + 1;
      rt -= ds;
      lt -= ds;
    }
    if (u[nd] >= lt) {
      ds = u[nd] - lt + 1;
      rt += ds;
      lt += ds;
    }
    for (j = nd + k; j < pd; j += k) {
      u[j] = lt;
      lt++;
    }
  }
  if (fg)
    puts("Incorrect sequence");
  else {
    for (i = k + 1; i <= k + n; i++) printf("%d ", u[i]);
    puts("");
  }
  return 0;
}
