#include <bits/stdc++.h>
using namespace std;
int Q = 1001000001;
int s[201010];
int u[101010];
int mn[101010];
int mx[101010];
int n, k;
bool jee;
void mk() {
  mn[0] = -Q - 1;
  mx[u[0]] = Q + 1;
  for (int i = 1; i < u[0]; ++i) {
    if (u[i] != Q) {
      if (u[i] <= mn[i - 1]) jee = 0;
      mn[i] = u[i];
    } else
      mn[i] = mn[i - 1] + 1;
  }
  for (int i = u[0] - 1; i > 0; --i) {
    if (u[i] != Q) {
      if (u[i] >= mx[i + 1]) jee = 0;
      mx[i] = u[i];
    } else
      mx[i] = mx[i + 1] - 1;
  }
  int a = 0;
  for (int i = 1; i < u[0]; ++i) {
    if (u[i] == Q) {
      if (a == 0)
        for (a = 1; u[i + a] == Q && i + a < u[0]; ++a)
          ;
      if (mx[i] < mn[i]) jee = 0;
      if (mx[i] == mn[i])
        u[i] = mx[i];
      else if (mn[i] > 0)
        u[i] = mn[i];
      else if (mx[i + a - 1] < 0)
        u[i] = mx[i];
      else {
        u[i] = min(max(-a / 2, mn[i]), mx[i + a - 1] - a + 1);
        for (int j = 1; j < a; ++j) mn[i + j] = u[i] + j;
      }
      --a;
    }
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  jee = 1;
  for (int i = 0; i < 101010; ++i) s[i] = Q;
  cin >> n >> k;
  char c;
  for (int i = 0; i < n; ++i) {
    cin >> ws;
    c = cin.peek();
    if (c == '?')
      cin >> c;
    else
      cin >> s[i];
  }
  for (int i = 0; i < k; ++i) {
    for (int j = i; j < n; j += k) {
      u[j / k + 1] = s[j];
      u[0] = j / k + 2;
    }
    mk();
    for (int j = i; j < n; j += k) {
      s[j] = u[j / k + 1];
    }
  }
  if (jee)
    for (int i = 0; i < n; ++i) cout << s[i] << " ";
  else
    cout << "Incorrect sequence";
}
