#include <bits/stdc++.h>
using namespace std;
template <typename T>
struct Pt {
  T x, y;
  void scan() { cin >> x >> y; }
};
template <typename T>
inline T sqr(const T& a) {
  return a * a;
}
template <typename T>
inline int sign(const T& a) {
  return a < 0 ? -1 : a > 0;
}
void task();
int main() {
  task();
  return 0;
}
const int INF = 1e9 + 5e5 + 100;
struct S {
  int real_pos;
  int value;
};
int n, k;
int a[int(1e5) + 10];
bool can_trans(vector<S>& v) {
  int is_free = 1;
  for (int i = 0; i < (int)v.size(); ++i)
    if (v[i].value != INF) {
      is_free = 0;
      break;
    }
  if (is_free) {
    int mn = -((int)v.size() / 2);
    for (int i = 0; i < (int)v.size(); ++i) v[i].value = mn, mn++;
    return true;
  }
  int id = 0;
  while (v[id].value == INF) ++id;
  if (id) {
    int mn = -id / 2;
    if (mn + id - 1 > v[id].value - 1) mn = v[id].value - id;
    for (int i = 0, val = mn; i < id; ++i, ++val) v[i].value = val;
  }
  int left_ = id;
  id = v.size() - 1;
  while (v[id].value == INF) --id;
  if (id != (int)v.size() - 1) {
    int len = (int)v.size() - id - 1;
    int mn = -(len / 2);
    if (mn < v[id].value + 1) mn = v[id].value + 1;
    for (int i = id + 1, val = mn; i < (int)v.size(); ++i, ++val)
      v[i].value = val;
  }
  int right_ = id;
  while (left_ != right_) {
    int id = left_ + 1;
    while (v[id].value == INF) ++id;
    if (v[id].value - v[left_].value < id - left_) return false;
    int len = id - left_ - 1;
    int mn = -(len / 2);
    if (mn < v[left_].value + 1) mn = v[left_].value + 1;
    if (mn + len - 1 > v[id].value - 1) mn = v[id].value - len;
    for (int i = left_ + 1, val = mn; i < id; ++i, ++val) v[i].value = val;
    left_ = id;
  }
  return true;
}
void task() {
  ios_base::sync_with_stdio(0);
  cin >> n >> k;
  for (int i = 0; i < n; ++i) {
    string s;
    cin >> s;
    if (s == "?")
      a[i] = INF;
    else
      a[i] = atoi(s.c_str());
  }
  for (int j = 0; j < k; ++j) {
    vector<S> v;
    for (int i = j; i < n; i += k) v.push_back({i, a[i]});
    if (!can_trans(v)) {
      cout << "Incorrect sequence";
      return;
    }
    for (auto& x : v) a[x.real_pos] = x.value;
  }
  for (int i = 0; i < n; ++i) cout << a[i] << ' ';
}
