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-4 -3 -2 -1 0 1 2 10 11 12 13 14 100
 -5 -1 0
 -10 0 0 1 6 2 7
 Incorrect sequence
 -1 0 1 2 3 4
 0
 -10 0 -2 1 -1 2 0 3 1
 3 -2 5 -1 7 0 9 1 11 2
 -11 -2 -10 -1 0 0 10 1 11
 -1 -1 -1 0 0 0 1 1 1
 0 -1 10 0 11 1 12
 1000000000 1000000001 1000000002 1000000003 1000000004
 Incorrect sequence
 -11 -1 -10 0 -1 1 0
 -5 1 -13 -4 2 -12 -3 3 -11 -2 4 -10 -1 5 -9 0 6 -8 1 7 -7 2 8 -6 5 9 -5 6 10 -4 7 11 -3 8 12 -2 10 13 -1
 Incorrect sequence
 -2 -1 0 1 2 3 4
 -10 0 0 1 1 2 2
 -10 0 -7 1 -6 2 -1 3 0
 1 0 -1000000000 2 100 0 3
 -10 0 -3 1 -2 2 -1 3 0
 10 0 11 1 12 2 13 3 14
 -1 0 1
 -2 -1 0 1 2 3 4 5 6 10
 -1000000001 -1 -1000000000 0 0
 -1000000000 1000000000
 -10 0 -7 1 -6 2 0
 -1 0 0 0 2
 10 0 11 1 12 2 13
 -10 0 -2 1 -1 2 0
 -10 0 -1 1 0 2 1
 -11 -1 -10 0 10 1 11
 -3 -2 -1 0 1 3
 -10 0 -1 1 0 2 1 3 10
 Incorrect sequence
 -5 0 -1 -1 1 0 0 5 1
 -3 -2 -1 0 1 2 3 

#include <bits/stdc++.h>
using namespace std;
const int Bad = (int)2e9;
const int small = -(int)1e9 - (int)2e6;
const int big = -small;
int getint() {
  char ch;
  while (ch = getchar(), ch != '-' && ch != '?' && (ch < '0' || ch > '9'))
    ;
  if (ch == '?') return Bad;
  int sign = (ch == '-' ? -1 : 1);
  int x = 0;
  if (ch >= '0' && ch <= '9') x = ch - '0';
  while (true) {
    ch = getchar();
    if (ch < '0' || ch > '9') break;
    x *= 10, x += ch - '0';
  }
  return x * sign;
}
vector<int> solve_part(vector<int> part) {
  int n = (int)part.size();
  vector<int> set_vals;
  vector<int> where_set;
  for (int i = 0; i < n; i++)
    if (part[i] != Bad) set_vals.push_back(part[i]), where_set.push_back(i);
  vector<int> other_vals;
  int len = (int)set_vals.size();
  for (int i = 0; i < len - 1; i++) {
    int x = set_vals[i];
    int y = set_vals[i + 1];
    int dist = where_set[i + 1] - where_set[i] - 1;
    if (y <= 0) {
      for (int j = dist; j >= 1; j--) other_vals.push_back(y - j);
    } else if (x >= 0) {
      for (int j = 1; j <= dist; j++) other_vals.push_back(x + j);
    } else {
      assert(x < 0 && y > 0);
      int righthalf = dist - dist / 2;
      int lefthalf = dist / 2;
      if (righthalf > y)
        lefthalf += righthalf - y, righthalf = y;
      else if (lefthalf >= abs(x))
        righthalf += lefthalf - (abs(x) - 1), lefthalf = abs(x) - 1;
      assert(lefthalf + righthalf == dist);
      for (int i = lefthalf; i >= 1; i--) other_vals.push_back(-i);
      for (int i = 0; i < righthalf; i++) other_vals.push_back(i);
    }
  }
  int h = 0;
  for (int i = 0; i < n; i++)
    if (part[i] == Bad) {
      assert(h < (int)other_vals.size());
      part[i] = other_vals[h], h++;
    }
  return part;
}
void solve(int n) {
  int k;
  scanf(" %d", &k);
  vector<int> a(n);
  for (int i = 0; i < n; i++) a[i] = getint();
  vector<vector<int> > parts(k);
  for (int i = 0; i < k; i++) parts[i].push_back(small);
  for (int i = 0; i < n; i++) parts[i % k].push_back(a[i]);
  for (int i = 0; i < k; i++) parts[i].push_back(big);
  for (int i = 0; i < k; i++) {
    vector<int> v = solve_part(parts[i]);
    parts[i] = v;
  }
  for (int i = 0; i < k; i++)
    for (int j = 1; j < (int)parts[i].size() - 1; j++) {
      assert(i + (j - 1) * k < n);
      a[i + (j - 1) * k] = parts[i][j];
    }
  bool ok = true;
  for (int i = 0; i < n; i++)
    if (i >= k && a[i] <= a[i - k]) ok = false;
  if (!ok) {
    printf("Incorrect sequence\n");
    return;
  }
  for (int i = 0; i < n; i++) {
    assert(a[i] != Bad);
    assert(a[i] >= small && a[i] <= big);
    printf("%d ", a[i]);
  }
  printf("\n");
}
int main() {
  int n;
  while (cin >> n) solve(n);
}
