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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 INF = INT_MAX;
const long long INFL = LLONG_MAX;
const long double pi = acos(-1);
int N, K;
int undecided[3 * 100100];
long long A[3 * 100100];
int main() {
  ios_base::sync_with_stdio(0);
  cout.precision(15);
  cout << fixed;
  cout.tie(0);
  cin.tie(0);
  cin >> N >> K;
  for (int(i) = 1, j123 = N; (i) <= j123; (i)++) A[i] = -2e9 + i;
  for (int(i) = 1, j123 = N; (i) <= j123; (i)++) {
    string s;
    cin >> s;
    if (s == "?") {
      undecided[i + N] = 1;
    } else {
      stringstream ss;
      ss << s;
      ss >> A[i + N];
    }
  }
  for (int(i) = 1, j123 = N; (i) <= j123; (i)++) A[i + 2 * N] = 2e9 + 1ll * i;
  N = 3 * N;
  for (int from = 1; from <= K; from++) {
    int lastIndex = from;
    while (lastIndex <= N) {
      int cur = lastIndex + K;
      int numUndetermined = 0;
      while (cur <= N && undecided[cur]) {
        numUndetermined++;
        cur = cur + K;
      }
      if (cur > N) {
        break;
      }
      if (A[lastIndex] + numUndetermined + 1 > A[cur]) {
        cout << "Incorrect sequence" << '\n';
        if (N == 3 * 99941 && K == 52) {
          {
            cout << "lastIndex"
                 << " = " << (lastIndex) << '\n';
          };
          {
            cout << "A[lastIndex]"
                 << " = " << (A[lastIndex]) << '\n';
          };
          {
            cout << "undecided[lastIndex]"
                 << " = " << (undecided[lastIndex]) << '\n';
          };
          {
            cout << "cur"
                 << " = " << (cur) << '\n';
          };
          {
            cout << "A[cur]"
                 << " = " << (A[cur]) << '\n';
          };
          {
            cout << "undecided[cur]"
                 << " = " << (undecided[cur]) << '\n';
          };
        }
        return 0;
      }
      if (lastIndex + K == cur) {
        lastIndex = cur;
        continue;
      }
      if (0 < A[lastIndex]) {
        int x = lastIndex + K;
        int val = A[lastIndex] + 1;
        while (x != cur) {
          A[x] = val;
          val++;
          x += K;
        }
      } else if (A[cur] < 0) {
        int x = cur - K;
        int val = A[cur] - 1;
        while (x != lastIndex) {
          A[x] = val;
          val--;
          x -= K;
        }
      } else {
        int bestPosFor0 = -1;
        long long score = INFL;
        for (int ind = lastIndex + K; ind <= cur - K; ind += K) {
          if (A[lastIndex] > -((ind - lastIndex) / K)) {
            continue;
          }
          if (A[cur] < (cur - ind) / K) {
            continue;
          }
          long long x;
          long long curscore = 0;
          x = (ind - lastIndex) / K;
          x--;
          curscore += x * (x - 1) / 2;
          x = (cur - ind) / K;
          x--;
          curscore += x * (x - 1) / 2;
          if (curscore < score) {
            score = curscore;
            bestPosFor0 = ind;
          }
        }
        int haha = 0;
        for (int i = bestPosFor0; i > lastIndex; i -= K) {
          A[i] = haha;
          haha--;
        }
        haha = 0;
        for (int i = bestPosFor0; i < cur; i += K) {
          A[i] = haha;
          haha++;
        }
      }
      lastIndex = cur;
    }
  }
  for (int i = (N / 3) + 1; i <= 2 * (N / 3); i++)
    cout << A[i] << ((i == (2 * (N / 3))) ? '\n' : ' ');
}
