#include <bits/stdc++.h>
using namespace std;
int n, m, a[100005];
char buf[12];
int main() {
  scanf("%d %d", &n, &m);
  for (int i = (0); i < (n); i++) {
    scanf("%s", buf);
    if (buf[0] == '?')
      a[i] = (1 << 30);
    else
      a[i] = atoi(buf);
  }
  for (int i = (0); i < (m); i++) {
    int prev = -(1 << 30), s = (n - i - 1) / m + 1;
    for (int j = (0); j < (s); j++) {
      int k = j, next = (1 << 30);
      while (k < s && a[i + k * m] == (1 << 30)) k++;
      if (k < s) next = a[i + k * m];
      if (next <= k - j + prev) {
        puts("Incorrect sequence");
        return 0;
      }
      int up = (k - j + 1) / 2;
      up = min(up, next);
      up = max(up, prev + k - j + 1);
      for (int x = (j); x < (k); x++) a[i + x * m] = up - k + x;
      prev = next;
      j = k;
    }
  }
  for (int i = (0); i < (n); i++) printf("%d%c", a[i], i == n - 1 ? '\n' : ' ');
}
