#include <bits/stdc++.h>
using namespace std;
template <typename T>
inline void mx(T& x, const T& y) {
  if (x < y) x = y;
}
template <typename T>
inline void mn(T& x, const T& y) {
  if (y < x) x = y;
}
template <typename T>
inline int sz(const T& x) {
  return (int)x.size();
}
const int UNDEF = 1e9 + 1e7;
const int MAX = 1e9 + 1e6;
const long long INF = 1e18 + 1e6;
long long sum(long long r) {
  if (r <= 0) {
    return 0;
  }
  long long l = r + 1;
  if (l & 1) {
    r >>= 1;
  } else {
    l >>= 1;
  }
  return l * r;
}
long long score(long long l, long long r) {
  if (l < 0 && r > 0) {
    return score(l, 0) + score(0, r);
  }
  if (l < 0) {
    return score(-r, -l);
  }
  return sum(r) - sum(l - 1);
}
void gen(int l, int r, int count, vector<int>::iterator out) {
  if (count % 2 == 1) {
    int half = count / 2;
    int left = -half;
    int right = half;
    if (l < left && right < r) {
      for (int i = 0; i < (count); ++i) {
        *(out++) = left + i;
      }
      return;
    }
  } else {
    int half = count / 2;
    int left1 = -half;
    int right1 = half - 1;
    if (l < left1 && right1 < r) {
      for (int i = 0; i < (count); ++i) {
        *(out++) = left1 + i;
      }
      return;
    }
    int left2 = -(half - 1);
    int right2 = half;
    if (l < left2 && right2 < r) {
      for (int i = 0; i < (count); ++i) {
        *(out++) = left2 + i;
      }
      return;
    }
  }
  long long way1 = score(l + 1, l + count);
  long long way2 = score(r - count, r - 1);
  long long minWay = min(way1, way2);
  if (way1 == minWay) {
    for (int i = 0; i < (count); ++i) {
      *(out++) = l + 1 + i;
    }
    return;
  }
  if (way2 == minWay) {
    for (int i = 0; i < (count); ++i) {
      *(out++) = r - count + i;
    }
    return;
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  for (int i = 0; i < (n); ++i) {
    string s;
    cin >> s;
    if (s == "?") {
      a[i] = UNDEF;
    } else {
      a[i] = atoi(s.c_str());
    }
  }
  for (int i = 0; i < (k); ++i) {
    vector<int> b;
    for (int j = i; j < n; j += k) {
      b.push_back(a[j]);
    }
    b.insert(b.begin(), -MAX);
    b.push_back(+MAX);
    for (int l = 0; l + 1 < sz(b);) {
      int r = l + 1;
      while (r < sz(b) && b[r] == UNDEF) {
        r++;
      }
      if (b[r] - b[l] < r - l) {
        cout << "Incorrect sequence" << endl;
        return 0;
      }
      gen(b[l], b[r], r - l - 1, b.begin() + l + 1);
      l = r;
    }
    b.erase(b.begin());
    b.pop_back();
    for (int j = 0; j < (sz(b)); ++j) {
      a[i + j * k] = b[j];
    }
  }
  for (int x : a) {
    cout << x << ' ';
  }
  cout << endl;
  return 0;
}
