#include <bits/stdc++.h>
using namespace std;
int n, k;
const int MAX_INT = 0x3f3f3f3f;
int seq[100010];
int convert(char a[]) {
  int len = strlen(a), f, s;
  if (a[0] == '-')
    f = -1, s = 1;
  else
    f = 1, s = 0;
  int ans = 0;
  for (int i = s; i < len; ++i) ans = ans * 10 + a[i] - '0';
  return f * ans;
}
void setnum(int to, int need, int da, int xiao) {
  if ((-need / 2) <= xiao) {
    int cn = 1;
    for (int i = to - need * k; i < to; i += k) {
      seq[i] = xiao + cn;
      cn++;
    }
  } else if (need / 2 >= da) {
    int cn = 1;
    for (int i = to - k; i >= to - need * k; i -= k) {
      seq[i] = da - cn;
      cn++;
    }
  } else {
    int cn = need / 2;
    for (int i = to - k; i >= to - need * k; i -= k) {
      seq[i] = cn;
      cn--;
    }
  }
}
int main() {
  scanf("%d%d", &n, &k);
  char a[15];
  for (int i = 0; i < n; ++i) {
    scanf("%s", a);
    if (strcmp(a, "?") == 0)
      seq[i] = MAX_INT;
    else
      seq[i] = convert(a);
  }
  int flag = 0;
  for (int i = 0; i < k; ++i) {
    int j = i;
    int need = 0;
    while (j < n) {
      if (seq[j] == MAX_INT) {
        need++;
      } else {
        if (need == 0) {
          if (j >= k && seq[j] <= seq[j - k]) {
            flag = 1;
            break;
          }
        } else {
          if (j - (need + 1) * k >= 0) {
            if (seq[j] - seq[j - (need + 1) * k] > need) {
              setnum(j, need, seq[j], seq[j - (need + 1) * (k)]);
            } else {
              flag = 1;
              break;
            }
          } else {
            setnum(j, need, seq[j], -1e10);
          }
          need = 0;
        }
      }
      j = j + k;
    }
    if (need > 0) {
      if (j - (need + 1) * k >= 0) {
        setnum(j, need, 1e10, seq[j - (need + 1) * k]);
      } else {
        setnum(j, need, 1e10, -1e10);
      }
    }
    if (flag == 1) break;
  }
  if (flag == 1)
    printf("Incorrect sequence\n");
  else {
    for (int i = 0; i < n; ++i) {
      printf("%d ", seq[i]);
    }
  }
  return 0;
}
