#include <bits/stdc++.h>
using namespace std;
int n, A[100005], K;
const int inf = (int)1e9 + 300005 + 7;
bool gao(vector<int> &p) {
  int m = (int)(p).size();
  vector<int> pp = p;
  for (int i = 0; i < m;) {
    if (p[i] != inf)
      ++i;
    else {
      int j = i;
      for (; j < m && p[j] == inf; ++j)
        ;
      int l = -inf, r = inf;
      if (i > 0) l = p[i - 1] + 1;
      if (j < m) r = p[j] - 1;
      if (j - i > r - l + 1) return 0;
      if (r <= 0) {
        for (int k = (int)(j - 1); k >= (int)(i); --k) p[k] = r--;
      } else if (l >= 0) {
        for (int k = (int)(i); k <= (int)(j - 1); ++k) p[k] = l++;
      } else {
        int len = j - i;
        if (len & 1) {
          int a = len / 2;
          if (abs(l) >= a && abs(r) >= a) {
            a = -a;
            for (int k = (int)(i); k <= (int)(j - 1); ++k) p[k] = a++;
          } else if (abs(l) < a) {
            for (int k = (int)(i); k <= (int)(j - 1); ++k) p[k] = l++;
          } else if (abs(r) < a) {
            for (int k = (int)(j - 1); k >= (int)(i); --k) p[k] = r--;
          } else {
            assert(0);
          }
        } else {
          int a = len / 2 - 1, b = len / 2 - 1;
          a = -a;
          if (abs(l) >= abs(r))
            --a;
          else
            ++b;
          if (abs(l) >= abs(a) && abs(r) >= b) {
            for (int k = (int)(i); k <= (int)(j - 1); ++k) p[k] = a++;
          } else if (abs(l) < abs(a)) {
            for (int k = (int)(i); k <= (int)(j - 1); ++k) p[k] = l++;
          } else if (abs(r) < b) {
            for (int k = (int)(j - 1); k >= (int)(i); --k) p[k] = r--;
          } else {
            assert(0);
          }
        }
      }
      i = j;
    }
  }
  for (int i = 0; i < m - 1; ++i) {
    if (p[i] >= p[i + 1]) {
      return 0;
    }
  }
  return 1;
}
int main() {
  scanf("%d%d", &n, &K);
  for (int i = 0; i < (int)(n); ++i) {
    static char ss[100];
    scanf("%s", ss);
    if (ss[0] == '?')
      A[i] = inf;
    else
      A[i] = atoi(ss);
  }
  vector<int> p;
  for (int i = 0; i < K; ++i) {
    p.clear();
    for (int j = i; j < n; j += K) p.push_back(A[j]);
    if (!gao(p)) return puts("Incorrect sequence") & 0;
    for (int j = i, k = 0; j < n; j += K) A[j] = p[k++];
  }
  int s = 0;
  for (int i = 0; i < (int)(n); ++i) printf("%d ", A[i]), s += abs(A[i]);
  puts("");
  return 0;
}
