#include <bits/stdc++.h>
using namespace std;
const long long maxN = 1e6 + 100;
const long long maxM = 1e3 + 100;
const long long mod = 1e9 + 7;
const long long hmod = 1e16 + 7;
const long double PI = 3.141592653;
const long double eps = 1e-8;
const long long D = 1379;
const long long INF = 1e18 + 20;
const long long Inf = 1e9 + 140;
void NO() {
  cout << "Incorrect sequence" << endl;
  exit(0);
}
void YES() {
  cout << "YES" << endl;
  exit(0);
}
long long n, k, a[maxN];
long long done(string s, long long p = 0) {
  if (!p)
    if (s[0] == '-') return -1 * done(s, 1);
  long long x = 0;
  for (long long i = p; i <= ((int)(s).size()) - 1; i++) {
    x *= 10;
    x += s[i] - '0';
  }
  return x;
}
string s;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> k;
  for (long long i = 0; i <= n - 1; i++) {
    cin >> s;
    if (s[0] == '?')
      a[i] = INF;
    else
      a[i] = done(s);
  }
  for (long long i = n; i <= n + k - 1; i++) a[i] = INF - 1;
  for (long long i = 0; i <= k - 1; i++) {
    long long m = -INF;
    long long cnt = 0;
    for (long long j = i; j < n + k; j += k) {
      if (a[j] == INF)
        cnt++;
      else {
        if (a[j] - m <= cnt) {
          NO();
        }
        long long bagh = max(m + 1, min(-cnt / 2, a[j] - cnt));
        for (long long x = cnt; x >= 1; x--) {
          long long ind = j - x * k;
          a[ind] = bagh++;
        }
        m = a[j];
        cnt = 0;
      }
    }
  }
  for (long long i = 0; i <= n - 1; i++) cout << a[i] << ' ';
}
