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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 

import java.io.*;
import java.util.*;
import java.math.BigInteger;

public class Main{
    final boolean isFileIO =  false;
    BufferedReader in;
    PrintWriter out;
    StringTokenizer st = new StringTokenizer("");
    String delim = " ";

    public static void main(String[] args) throws IOException {
        Main m = new Main();
        m.initIO();
        m.solve();
        m.in.close();
        m.out.close();
    }

    public void initIO() throws IOException {
        if(!isFileIO) {
            in = new BufferedReader(new InputStreamReader(System.in));
            out = new PrintWriter(System.out);
        } else {
            in = new BufferedReader(new FileReader("input.txt"));
            out = new PrintWriter("output.txt");
        }
    }

    String nt() throws IOException {
        if(!st.hasMoreTokens()) {
            st = new StringTokenizer(in.readLine());
        }
        return st.nextToken(delim);
    }

    String rl() throws IOException {
        return in.readLine();
    }

    int ni() throws IOException {
        return Integer.parseInt(nt());
    }

    long nl() throws IOException {
        return Long.parseLong(nt());
    }

    double nd() throws IOException {
        return Double.parseDouble(nt());
    }

    class Pair {
        public long x;
        public long y;

        public Pair(long x, long y) {
            this.x = x;
            this.y = y;
        }

        public String toString() {
            return String.format("{%d, %d}", x, y);
        }
    }

    public void solve() throws IOException {
        int n, k;
        n = ni(); k = ni();
        String[] tokens = new String[n];
        for(int i = 0; i < n; i++) {
            tokens[i] = nt();
        }
        int[] ans = new int[n];
        for(int i = 0; i < k; i++) {
            ArrayList<String> s = new ArrayList<String>();
            for(int j = i; j < n; j += k) {
                s.add(tokens[j]);
            }
            ArrayList<Integer> prev = new ArrayList<Integer>();
            int cur = -1;
            int size = s.size();
            for(int j = 0; j < size; ) {
                if(s.get(j).equals("?")) {
                    prev.add(cur);
                    ++j;
                    continue;
                }
                prev.add(cur);
                cur = j;
                int z = j + 1;
                for(; z < size; z++) {
                    if(!s.get(z).equals("?")) {
                        int prevValue, curValue;
                        prevValue = Integer.parseInt(s.get(cur));
                        curValue = Integer.parseInt(s.get(z));
                        if (prevValue >= curValue || (curValue - prevValue - 1 < z - cur - 1)) {
                            out.println("Incorrect sequence");
                            return;
                        }
                        break;
                    } else {
                        prev.add(cur);
                    }
                }

                j = z;
            }

            int[] tempAns = new int[size];
            int index = -1;
            if(s.get(size - 1).equals("?")) {
                int prevIndex = prev.get(size - 1);
                if(prevIndex == -1) {
                    int start = -size / 2;
                    for(int j = 0; j < size; j++) {
                        tempAns[j] = start++;
                    }
                } else {
                    int value = Integer.parseInt(s.get(prevIndex));
                    if (value >= 0) {
                        int start = value;
                        for (int j = prevIndex; j < size; j++) {
                            tempAns[j] = start++;
                        }
                    } else {

                        int cnt = size - prevIndex - 1;
                        int start = Math.max(value + 1, -(size - 1) / 2);
                        tempAns[prevIndex] = value;
                        for(int j = prevIndex + 1; j < size; j++) {
                            tempAns[j] = start++;
                        }
                    }
                }
                index = prevIndex;
            } else {
                index = size - 1;
            }
            if(index != -1) {
                for(int j = index; j >= 0; ) {
                    int rightValue = Integer.parseInt(s.get(j));
                    int leftIndex = prev.get(j);
                    if(leftIndex == -1) {
                        if(rightValue < 0) {
                            int start = rightValue;
                            for(int z = j; z >= 0; z--) {
                                tempAns[z] = start--;
                            }
                        } else {
                            int start = Math.min(rightValue - 1, j / 2);
                            tempAns[j] = rightValue;
                            for(int z = j - 1; z >= 0; z--) {
                                tempAns[z] = start--;
                            }
                        }
                        j = -1;
                    } else {
                        int leftValue = Integer.parseInt(s.get(leftIndex));
                        if(leftValue >= 0 && rightValue >= 0) {
                            int start = leftValue + 1;
                            for(int z = leftIndex + 1; z <= j; z++) {
                                tempAns[z] = start++;
                            }
                        }
                        if(leftValue < 0 && rightValue < 0) {
                            int start = rightValue;
                            for(int z = j; z > leftIndex; z--) {
                                tempAns[z] = start--;
                            }
                        }
                        if(leftValue < 0 && rightValue >= 0) {
                            int cnt = (j - leftIndex - 1);
                            int startLeft = Math.max(leftValue + 1, -cnt / 2);
                            int startRight = Math.min(rightValue - 1, cnt / 2);
                            if(startLeft + cnt - 1 < startRight) {

                            } else if(startRight - cnt + 1 > startLeft) {
                                startLeft = startRight - cnt + 1;
                            }
                            tempAns[leftIndex] = leftValue;
                            tempAns[j] = rightValue;
                            for(int z = leftIndex + 1; z < j; z++) {
                                tempAns[z] = startLeft++;
                            }
                        }
                        j = leftIndex;
                    }
                }
            }
            for(int j = i, z = 0; j < n; j += k, z++) {
                ans[j] = tempAns[z];
            }
        }
        for(int i = 0; i < n; i++) {
            out.print(ans[i] + " ");
        }
        out.println();
    }
}

class Utils {

    public static long binpow(long a, long exp, long mod) {
        if(exp == 0) {
            return 1;
        }
        if(exp % 2 == 0) {
            long temp = binpow(a, exp / 2, mod);
            return (temp * temp) % mod;
        } else {
            return (binpow(a, exp - 1, mod) * a) % mod;
        }
    }

    public static long inv(long a, long mod) {
        return binpow(a, mod - 2, mod);
    }

    public static long addmod(long a, long b, long mod) {
        return ((a + b) % mod + mod) % mod;
    }

    public static long gcd(long a, long b) {
        if(b == 0)
            return a;
        return gcd(b, a % b);
    }

    //mul must be < 10^18
    public static long mulmod(long a, long b, long mod) {
        return (a * b + (((a * b) / mod) + 1) * mod) % mod;
    }
}