#include <bits/stdc++.h>
#pragma warning(disable : 4996)
using namespace std;
int n, m;
int a[200000];
char tmp[200000];
int b[200000];
int bi;
int c[200000];
int ci;
int d[200000];
vector<int> dab;
void calc() {
  int i, j;
  int cnt = 0;
  d[0] = -((1 << 30) - 1);
  ci = 0;
  for (i = 0; i < bi; i++) {
    if (b[i] == ((1 << 30) - 1))
      cnt++;
    else {
      c[++ci] = cnt;
      d[ci] = b[i];
      cnt = 0;
    }
  }
  c[++ci] = cnt;
  d[ci++] = ((1 << 30) - 1);
  for (i = 0; i < ci - 1; i++) {
    if (d[i + 1] - d[i] - 1 < c[i + 1]) {
      printf("Incorrect sequence");
      exit(0);
    }
  }
  dab.clear();
  for (i = 0; i < ci - 1; i++) {
    if (c[i + 1] == 0) continue;
    if (d[i] <= 0 && d[i + 1] <= 0) {
      for (j = d[i + 1] - c[i + 1]; j <= d[i + 1] - 1; j++) dab.push_back(j);
    } else if (d[i] >= 0 && d[i + 1] >= 0) {
      for (j = d[i] + 1; j <= d[i] + c[i + 1]; j++) dab.push_back(j);
    } else {
      if (min(abs(d[i + 1] - 1), abs(d[i] + 1)) * 2 + 1 >= c[i + 1]) {
        for (j = -(c[i + 1] - 1) / 2; j <= (c[i + 1] / 2); j++)
          dab.push_back(j);
      } else {
        int u = min(abs(d[i + 1] - 1), abs(d[i] + 1));
        if (abs(d[i + 1] - 1) > abs(d[i] + 1)) {
          for (j = -u; j <= u; j++) dab.push_back(j);
          for (j = u + 1;
               j <=
               u + c[i + 1] - min(abs(d[i + 1] - 1), abs(d[i] + 1)) * 2 - 1;
               j++)
            dab.push_back(j);
        } else {
          for (j = -u -
                   (c[i + 1] - min(abs(d[i + 1] - 1), abs(d[i] + 1)) * 2 - 1);
               j <= -u - 1; j++)
            dab.push_back(j);
          for (j = -u; j <= u; j++) dab.push_back(j);
        }
      }
    }
  }
}
int main() {
  int i, j, k;
  cin >> n >> m;
  for (i = 0; i < n; i++) {
    scanf("%s", tmp);
    if (tmp[0] == '?')
      a[i] = ((1 << 30) - 1);
    else
      a[i] = atoi(tmp);
  }
  for (i = 0; i < m; i++) {
    bi = 0;
    for (j = i; j < n; j += m) {
      b[bi++] = a[j];
    }
    calc();
    int u = 0;
    for (j = i; j < n; j += m) {
      if (a[j] == ((1 << 30) - 1)) a[j] = dab[u++];
    }
  }
  for (i = 0; i < n; i++) printf("%d ", a[i]);
  return 0;
}
