#include <bits/stdc++.h>
using namespace std;
const int N = 322228;
long long a[N];
int n, k;
int cou[N];
bool solve(int l, int r) {
  long long need = cou[l % k];
  long long tl = l - k >= 0 ? a[l - k] + 1 : -1000000000000ll;
  long long tr = r + k < n ? a[r + k] - 1 : 1000000000000ll;
  if (tr - tl + 1 < need) return 0;
  if (tl >= 0) {
    for (long long i = tl; i < tl + need; i++) a[l + (i - tl) * k] = i;
  } else if (tr <= 0) {
    for (long long i = tr; i > tr - need; i--) a[r - (tr - i) * k] = i;
  } else {
    long long ttl = 0, ttr = need - 1;
    while (ttl - 1 >= tl && (abs(ttl - 1) <= abs(ttr) || ttr > tr))
      ttl--, ttr--;
    for (int i = 0; i < need; i++) a[l + i * k] = ttl + i;
  }
  return 1;
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> k;
  int tn = ((n - 1) / k + 2) * k;
  for (int i = 0; i < tn; i++) {
    string s;
    if (i < n)
      cin >> s;
    else if (i < tn - k)
      s = "1000000000000";
    else
      s = "1000000000001";
    if (s == "?") {
      cou[i % k]++;
    } else {
      a[i] = atoll(s.c_str());
      if (cou[i % k]) {
        if (!solve(i - k * cou[i % k], i - k))
          return cout << "Incorrect sequence", 0;
        cou[i % k] = 0;
      } else if (i - k >= 0 && a[i] <= a[i - k])
        return cout << "Incorrect sequence", 0;
    }
  }
  for (int i = 0; i < n; i++) cout << a[i] << " ";
}
