#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000007;
template <class T>
typename T::value_type arr_sum(const T& v, int n) {
  typename T::value_type sum = 0;
  for (int i = (0); i < (n); ++i) sum += v[i];
  return sum;
}
struct Sync_stdio {
  Sync_stdio() {
    cin.tie(NULL);
    ios_base::sync_with_stdio(false);
  }
} _sync_stdio;
int main() {
  const int INF = 2000000002;
  int n, k;
  cin >> n >> k;
  vector<int> v(n);
  for (int i = (0); i < (n); ++i) {
    string s;
    stringstream ss;
    cin >> s;
    if (s == "?") {
      v[i] = -INF;
      continue;
    }
    ss << s;
    int a;
    ss >> a;
    v[i] = a;
  }
  for (int i = (0); i < (k); ++i) {
    vector<int> a;
    int j = i;
    while (j < n) {
      a.push_back(v[j]);
      j += k;
    }
    int x = -1;
    int y = 0;
    while (y < a.size()) {
      while (y < a.size() && a[y] == -INF) {
        ++y;
      }
      if (y == x + 1) {
        if (x != -1 && y != a.size()) {
          if (a[x] >= a[y]) {
            cout << "Incorrect sequence";
            return 0;
          }
        }
      } else if (x == -1 && y == a.size()) {
        int start = -(y - 1) / 2;
        for (int j = (x + 1); j < (y); ++j) {
          a[j] = start;
          ++start;
        }
      } else if (x == -1) {
        int start = min(a[y] - 1, (y - 1) / 2);
        for (int j = (y - 1); j > (-1); --j) {
          a[j] = start;
          --start;
        }
      } else if (y == a.size()) {
        int start = max(a[x] + 1, -(y - 1 - x - 1) / 2);
        for (int j = (x + 1); j < (y); ++j) {
          a[j] = start;
          ++start;
        }
      } else {
        int len = y - x - 2;
        if (a[y] - a[x] < len + 2) {
          cout << "Incorrect sequence";
          return 0;
        }
        int start = max(min(a[y] - 1, len / 2), a[x] + len + 1);
        for (int j = (y - 1); j > (x); --j) {
          a[j] = start;
          --start;
        }
      }
      x = y;
      y = x + 1;
    }
    for (int j = (0); j < (a.size()); ++j) {
      v[j * k + i] = a[j];
    }
  }
  for (auto i : v) {
    cout << i << " ";
  }
}
