#include <bits/stdc++.h>
using namespace std;
const int N = 1000000;
bool need[N];
long long a[N];
int n, k;
long long f(int i, long long x) {
  long long ans = 0;
  while (i < n && need[i]) {
    ans += abs(x);
    x++;
    i += k;
  }
  return ans;
}
int main() {
  ios::sync_with_stdio(false);
  cin >> n >> k;
  for (int i = 0; i < n; i++) {
    string str;
    cin >> str;
    if (str == "?") {
      need[i] = 1;
    } else {
      int t = 1, g = 0;
      if (str[0] == '-') {
        t = -1;
        str.erase(0, 1);
      }
      for (int j = 0; j < str.size(); j++) {
        g *= 10;
        g += str[j] - '0';
      }
      a[i] = t * g;
    }
  }
  for (int i = 0; i < n; i++) {
    if (need[i]) {
      long long l = (i - k >= 0 ? a[i - k] + 1 : -(long long)(1e9 + 1e7)), r,
                d = 0;
      int j = i;
      while (j < n && need[j]) {
        j += k;
        d++;
      }
      if (j < n) {
        r = a[j] - d;
      } else {
        r = (long long)(1e9 + 1e7);
      }
      while (r - l > 5) {
        long long c1 = l + (r - l) / 3;
        long long c2 = r + (l - r) / 3;
        if (f(i, c1) < f(i, c2))
          r = c2;
        else
          l = c1;
      }
      long long t = (long long)(1e18);
      long long ti = -1;
      while (l <= r) {
        if (f(i, l) < t) {
          t = f(i, l);
          ti = l;
        }
        l++;
      }
      j = i;
      while (j < n && need[j]) {
        need[j] = 0;
        a[j] = ti;
        ti++;
        j += k;
      }
    }
  }
  for (int i = 0; i < n; i++) {
    if (i + k >= n) break;
    if (a[i] >= a[i + k]) {
      cout << "Incorrect sequence\n";
      return 0;
    }
  }
  for (int i = 0; i < n; i++) {
    cout << a[i] << " ";
  }
  cout << "\n";
  return 0;
}
