#include <bits/stdc++.h>
using namespace std;
const int OO = 1e9 + 1e6;
const int UN = 1e9 + 1e7;
void wa() {
  cout << "Incorrect sequence";
  exit(0);
}
int main() {
  int n, k;
  cin >> n >> k;
  int arr[n + 2 * k];
  for (int i = 0; i < k; i++) arr[i] = -OO + i;
  for (int i = n + k; i < n + 2 * k; i++) arr[i] = OO + i - n;
  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    if (s == "?")
      arr[i + k] = UN;
    else
      arr[i + k] = atoi(s.c_str());
  }
  for (int i = 0; i < k; i++) {
    int ln, fp;
    ln = -1;
    fp = -1;
    for (int j = i; j < n + 2 * k; j += k) {
      if (arr[j] != UN) {
        if (arr[j] < 0)
          ln = j;
        else if (fp == -1)
          fp = j;
      }
    }
    if (ln > fp) wa();
    int avail = arr[fp] - arr[ln] - 1;
    int num = (fp - ln) / k - 1;
    if (num > avail) wa();
    int st = -(num / 2);
    int en = num / 2;
    if (num % 2 == 0) st++;
    if (en > arr[fp] - 1) st = arr[fp] - 1 - num + 1, en = st + num - 1;
    if (st < arr[ln] + 1) st = arr[ln] + 1, en = st + num - 1;
    for (int j = ln + k; j < fp; j += k) arr[j] = st - 1 + (j - ln) / k;
    int prev = arr[ln];
    for (int j = ln; j >= 0; j -= k) {
      if (arr[j] == UN) {
        arr[j] = prev;
        prev--;
      } else if (arr[j] > prev) {
        wa();
      } else {
        prev = arr[j] - 1;
      }
    }
    prev = arr[fp];
    for (int j = fp; j < n + 2 * k; j += k) {
      if (arr[j] == UN) {
        arr[j] = prev;
        prev++;
      } else if (arr[j] < prev) {
        wa();
      } else {
        prev = arr[j] + 1;
      }
    }
  }
  for (int i = k; i < n + k; i++) {
    printf("%d ", arr[i]);
  }
}
