#include <bits/stdc++.h>
using namespace std;
int n, m, a[100005];
char buf[12];
vector<int> c[100005];
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 {
      int j = 0;
      bool neg = 0;
      if (buf[j] == '-') j++, neg = 1;
      for (; buf[j]; j++) a[i] = a[i] * 10 + buf[j] - '0';
      if (neg) a[i] = -a[i];
    }
    c[i % m].push_back(a[i]);
  }
  for (int i = (0); i < (m); i++) {
    int prev = (1 << 30);
    for (int j = (0); j < (c[i].size()); j++) {
      int k = j, next = (1 << 30);
      while (k < c[i].size() && c[i][k] == (1 << 30)) k++;
      if (k < c[i].size()) next = c[i][k];
      if (prev == (1 << 30)) {
        int up = min(next, (k - j + 1) / 2);
        for (int l = (j); l < (k); l++) a[i + l * m] = up - k + l;
      } else {
        if (next == (1 << 30)) {
          int lb = max(prev, -(k - j + 1) / 2);
          for (int l = (j); l < (k); l++) a[i + l * m] = lb + 1 + l - j;
        } else if (prev + (k - j) < next) {
          if (next <= (k - j + 1) / 2)
            for (int l = (j); l < (k); l++) a[i + l * m] = next - k + l;
          else if (prev >= -(k - j + 1) / 2)
            for (int l = (j); l < (k); l++) a[i + l * m] = prev + l - j + 1;
          else {
            int lb = -(k - j + 1) / 2;
            for (int l = (j); l < (k); l++) a[i + l * m] = lb + 1 + l - j;
          }
        } else {
          puts("Incorrect sequence");
          scanf("\n");
          return 0;
        }
      }
      prev = next;
      j = k;
    }
  }
  for (int i = (0); i < (n); i++) printf("%d%c", a[i], i == n - 1 ? '\n' : ' ');
  scanf("\n");
}
