#include <bits/stdc++.h>
using namespace std;
const long long N = 1e5 + 23, inf = 0x3f3f3f3f;
long long a[N];
inline long long inp() {
  long long c = getchar(), x = 0;
  bool neg = 0;
  for (; ((c < 48 or c > 57) and c != '-' and c != '?'); c = getchar())
    ;
  if (c == '?') return inf;
  if (c == '-') neg = 1, c = getchar();
  for (; c > 47 and c < 58; c = getchar()) x = (x << 1) + (x << 3) + c - 48;
  return neg ? -x : x;
}
bool fix(long long st, long long en, long long n, long long k) {
  long long lo = (st < 0 ? -inf : a[st]) + 1;
  long long hi = (en >= n ? inf : a[en]) - 1;
  long long num = (en - st) / k - 1;
  if (hi - lo + 1 < num) return false;
  if (lo >= 0) {
    for (long long i = st + k; i < en; i += k) a[i] = lo++;
    return true;
  }
  if (hi <= 0) {
    for (long long i = en - k; i > st; i -= k) a[i] = hi--;
    return true;
  }
  long long fst = (num - 1) / 2;
  long long snd = num / 2;
  if (fst > abs(lo)) {
    snd += fst - abs(lo);
    fst = abs(lo);
  } else if (snd > hi) {
    fst += snd - hi;
    snd = hi;
  }
  long long cur = -fst;
  for (long long i = st + k; i < en; i += k) a[i] = cur++;
  return true;
}
bool go(long long r, long long n, long long k) {
  long long prev = r - k;
  for (long long i = r; i < n; i += k) {
    if (a[i] < inf) {
      if (prev >= 0 and a[prev] >= a[i]) return false;
      prev = i;
      continue;
    }
    while (i < n and a[i] == inf) i += k;
    bool can = fix(prev, i, n, k);
    if (!can) return false;
    prev = i;
  }
  return true;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long n = inp(), k = inp();
  for (long long i = 0; i < n; i++) a[i] = inp();
  for (long long i = 0; i < k; i++)
    if (!go(i, n, k)) {
      cout << "Incorrect sequence\n";
      return 0;
    }
  for (long long i = 0; i < n; i++) cout << a[i] << " ";
  cout << "\n";
  return 0;
}
