#include <bits/stdc++.h>
using namespace std;
const double EPS = 1e-9;
const int INF = ((int)1e9) + 7;
int toint(string tmp) {
  bool t = (tmp[0] == '-');
  int l = 0;
  if (t) {
    l = 1;
  }
  int ans = 0;
  for (int i = l; i < tmp.size(); i++) {
    ans *= 10;
    ans += (tmp[i] - '0');
  }
  if (t) {
    ans *= -1;
  }
  return ans;
}
int main() {
  int n, k;
  string tmp;
  getline(cin, tmp);
  int lll = 0;
  for (int i = 0; i < tmp.size(); i++) {
    if (tmp[i] != ' ') {
      lll++;
    } else {
      break;
    }
  }
  n = toint(tmp.substr(0, lll));
  k = toint(tmp.substr(lll + 1, tmp.size() - lll - 1));
  vector<int> a;
  tmp.clear();
  getline(cin, tmp);
  for (int i = 0; i < tmp.size(); i++) {
    if (tmp[i] == '?') {
      a.push_back(INF);
    } else if (tmp[i] != ' ') {
      int len = 0;
      for (int j = i; j < tmp.size(); j++) {
        if (tmp[j] != ' ') {
          len++;
        } else {
          break;
        }
      }
      a.push_back(toint(tmp.substr(i, len)));
      i += len;
    }
  }
  for (int i = 0; i < k; i++) {
    int l = -1, j;
    for (j = 0; k * j + i < n; j++) {
      int y = k * j + i;
      if (l > -1 && a[y] != INF) {
        if (a[y] >= 0 && a[k * l + i] >= 0) {
          for (int q = l + 1; q < j; q++) {
            a[k * q + i] = a[k * (q - 1) + i] + 1;
          }
        } else if (a[y] < 0 && a[k * l + i] < 0) {
          for (int q = j - 1; q > l; q--) {
            a[k * q + i] = a[k * (q + 1) + i] - 1;
          }
        } else if (a[y] >= 0 && a[k * l + i] < 0) {
          int tmp = max(0, (j - l - 2) / 2);
          if (max(0, (j - l - 2)) % 2 != 0) {
            tmp++;
          }
          if (a[y] <= tmp) {
            for (int q = j - 1; q > l; q--) {
              a[k * q + i] = a[k * (q + 1) + i] - 1;
            }
          } else if (a[k * l + i] >= -tmp) {
            for (int q = l + 1; q < j; q++) {
              a[k * q + i] = a[k * (q - 1) + i] + 1;
            }
          } else {
            tmp *= -1;
            for (int q = l + 1; q < j; q++) {
              a[k * q + i] = tmp;
              tmp++;
            }
          }
        }
        l = j;
      }
      if (l == -1 && a[y] != INF) {
        l = j;
      }
      if (l == -2 && a[y] != INF) {
        l = -1;
        if (a[y] < 0) {
          for (int q = j - 1; q > l; q--) {
            a[k * q + i] = a[k * (q + 1) + i] - 1;
          }
        } else {
          int tmp = (j - 1) / 2;
          if (a[y] <= tmp) {
            for (int q = j - 1; q > l; q--) {
              a[k * q + i] = a[k * (q + 1) + i] - 1;
            }
          } else {
            if ((j - 1) % 2 != 0) {
              tmp++;
            }
            tmp *= -1;
            for (int q = l + 1; q < j; q++) {
              a[k * q + i] = tmp;
              tmp++;
            }
          }
        }
        l = j;
      }
      if (l == -1 && a[y] == INF) {
        l = -2;
      }
    }
    if (l == -2) {
      l = -1;
      int tmp = (j - 1) / 2;
      tmp *= -1;
      for (int q = l + 1; q < j; q++) {
        a[k * q + i] = tmp;
        tmp++;
      }
      l = j;
    }
    if (j != l) {
      int y = k * j + i;
      if (a[k * l + i] >= 0) {
        for (int q = l + 1; q < j; q++) {
          a[k * q + i] = a[k * (q - 1) + i] + 1;
        }
      } else {
        int tmp = max(0, (j - l - 2) / 2);
        if (a[k * l + i] >= -tmp) {
          for (int q = l + 1; q < j; q++) {
            a[k * q + i] = a[k * (q - 1) + i] + 1;
          }
        } else {
          tmp *= -1;
          for (int q = l + 1; q < j; q++) {
            a[k * q + i] = tmp;
            tmp++;
          }
        }
      }
    }
    vector<int> tmp, ch;
    for (int j = 0; k * j + i < n; j++) {
      int y = k * j + i;
      tmp.push_back(a[y]);
    }
    ch = tmp;
    sort(ch.begin(), ch.end());
    bool t = false;
    for (int i = 1; i < ch.size(); i++) {
      if (ch[i] <= ch[i - 1]) {
        t = true;
        break;
      }
    }
    if (ch != tmp || t) {
      cout << "Incorrect sequence";
      return 0;
    }
  }
  for (int i = 0; i < n; i++) {
    cout << a[i] << " ";
  }
  return 0;
}
