#include <bits/stdc++.h>
const int inf = 1 << 30;
const int N = 100010;
std::vector<int> sequence;
char buf[15];
int num[N];
int main() {
  int n, k;
  scanf("%d%d", &n, &k);
  for (int i = 0; i < n; i++) {
    scanf("%s", buf);
    int sign = 1;
    for (int j = 0; buf[j]; j++) {
      if (buf[j] == '?') {
        num[i] = inf;
        break;
      } else if (buf[j] == '-') {
        sign = -1;
      } else {
        num[i] = num[i] * 10 + (buf[j] - '0');
      }
    }
    num[i] *= sign;
  }
  int ok = 1;
  for (int i = 0; i < k; i++) {
    sequence.clear();
    for (int j = i; j < n; j += k) {
      sequence.push_back(num[j]);
    }
    int s = -1, t = -1, sz = sequence.size();
    for (int j = 0; j < sz; j++) {
      if (sequence[j] != inf) {
        s = t;
        t = j;
        int l = s != -1 ? sequence[s] : -inf, r = sequence[t];
        int d = t - s - 1;
        if (r - l - 1 < t - s - 1) ok = -1;
        if ((long long)l * r >= 0) {
          if (r <= 0) {
            for (int o = t - 1, c = 1; o > s; o--, c++) sequence[o] = r - c;
          } else {
            for (int o = s + 1, c = 1; o < t; o++, c++) sequence[o] = l + c;
          }
        } else {
          if (abs(l) <= abs(r)) {
            for (int o = s + 1, c = 0; o < t; o++, c++)
              sequence[o] = std::max(l + 1, -(d - 1) / 2) + c;
          } else {
            for (int o = t - 1, c = 0; o > s; o--, c++)
              sequence[o] = std::min(r - 1, (d - 1) / 2) - c;
          }
        }
      }
    }
    int d = sz - t - 1;
    if (t != sz - 1 && ~t) {
      for (int o = t + 1, c = 0; o < sequence.size(); o++, c++)
        sequence[o] = std::max(sequence[t] + 1, -(d - 1) / 2) + c;
    }
    if (s == -1 && t == -1) {
      for (int o = 0, c = 0; o < sz; o++, c++) sequence[o] = -(sz - 1) / 2 + c;
    }
    if (ok == -1) return puts("Incorrect sequence"), 0;
    for (int j = i; j < n; j += k) num[j] = sequence[j / k];
  }
  for (int i = 0; i < n; i++) printf("%d%c", num[i], " \n"[i == n - 1]);
  return 0;
}
