//Hello. I'm Peter.
#include<cstdio>
#include<iostream>
#include<sstream>
#include<cstring>
#include<string>
#include<cmath>
#include<cstdlib>
#include<algorithm>
#include<functional>
#include<cctype>
#include<ctime>
#include<stack>
#include<queue>
#include<vector>
#include<set>
#include<map>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef unsigned int uin;
#define peter cout<<"i am peter"<<endl
#define input freopen("data.txt","r",stdin)
#define randin srand((unsigned int)time(NULL))
#define INT (0x3f3f3f3f)*2
#define LL (0x3f3f3f3f3f3f3f3f)*2
#define gsize(a) (int)a.size()
#define len(a) (int)strlen(a)
#define slen(s) (int)s.length()
#define pb(a) push_back(a)
#define clr(a) memset(a,0,sizeof(a))
#define clr_minus1(a) memset(a,-1,sizeof(a))
#define clr_INT(a) memset(a,INT,sizeof(a))
#define clr_true(a) memset(a,true,sizeof(a))
#define clr_false(a) memset(a,false,sizeof(a))
#define clr_queue(q) while(!q.empty()) q.pop()
#define clr_stack(s) while(!s.empty()) s.pop()
#define rep(i, a, b) for (int i = a; i < b; i++)
#define dep(i, a, b) for (int i = a; i > b; i--)
#define repin(i, a, b) for (int i = a; i <= b; i++)
#define depin(i, a, b) for (int i = a; i >= b; i--)
#define pi 3.1415926535898
#define eps 1e-9
#define MOD 1000000007
#define MAXN
#define N 30010
#define M
int n,k;
char s[100];
int lens;
void printno(){
    printf("Incorrect sequence\n");
    exit(0);
}
int stringtoint(char *s,int lens){
    int res=0,ten=1;
    depin(i,lens-1,0){
        if(!isdigit(s[i])) break;
        res+=(s[i]-'0')*ten;
        ten*=10;
    }
    if(s[0]=='-') res=-res;
    return res;
}
int num_b,p[N],pos[N];
ll a[N],b[N];
bool vis[N];
void make_it(ll *b,int num){
    int num_pos=0;
    pos[num_pos++]=0;
    b[0]=-INT;
    repin(i,1,num){
        if(b[i]!=INT) pos[num_pos++]=i;
    }
    b[num+1]=INT;
    pos[num_pos++]=num+1;
//    rep(i,0,num_pos){
//        printf("pos[%d]=%d\n",i,pos[i]);
//    }
    rep(i,1,num_pos){
        if(b[pos[i]]-b[pos[i-1]]<pos[i]-pos[i-1]) printno();
        if(pos[i-1]+1==pos[i]) continue;
        if(b[pos[i]]<=0){
            dep(j,pos[i]-1,pos[i-1]){
                b[j]=b[j+1]-1;
            }
        }
        else if(b[pos[i-1]]>=0){
            rep(j,pos[i-1]+1,pos[i]){
                b[j]=b[j-1]+1;
            }
        }
        else{
            int mid=(pos[i-1]+pos[i])>>1;
            b[mid]=0;
            rep(j,mid+1,pos[i]){
                b[j]=b[j-1]+1;
            }
            dep(j,mid-1,pos[i-1]){
                b[j]=b[j+1]-1;
            }
            ll d=0;
            if(b[pos[i-1]+1]<=b[pos[i-1]]){
                d=b[pos[i-1]]-b[pos[i-1]+1]+1;
            }
            else if(b[pos[i]-1]>=b[pos[i]]){
                d=b[pos[i]]-b[pos[i]-1]-1;
            }
            rep(j,pos[i-1]+1,pos[i]){
                b[j]+=d;
            }
        }
    }
//    repin(i,1,num){
//        printf("b[%d]=%lld\n",i,b[i]);
//    }
//    cout<<endl;
}
int main(){
//    input;
    scanf("%d %d",&n,&k);
    repin(i,1,n){
        scanf("%s",s);
        lens=len(s);
        if(s[0]=='?') a[i]=INT;
        else a[i]=stringtoint(s,lens);
    }
    //构造
    repin(i,1,n){
        if(vis[i]) continue;
        num_b=0;
        for(int j=i;j<=n;j+=k){
            vis[j]=true;
            b[++num_b]=a[j];
            p[num_b]=j;
        }
//        repin(l,1,num_b){
//            printf("b[%d]=%lld p[%d]=%d\n",l,b[l],l,p[l]);
//        }
        make_it(b,num_b);
        repin(j,1,num_b){
            a[p[j]]=b[j];
        }
    }
//    repin(i,1,n){
//        printf("a[%d]=%d\n",i,a[i]);
//    }
    //判断..
    repin(i,1,n){
        if(i-k>=1 && a[i-k]>=a[i]){
            printno();
        }
        if(i+k<=n && a[i]>=a[i+k]){
            printno();
        }
    }
    repin(i,1,n){
        if(i!=1) printf(" ");
        printf("%lld",a[i]);
    }
    printf("\n");
}


//Hello. I'm Peter.
#include<cstdio>
#include<iostream>
#include<sstream>
#include<cstring>
#include<string>
#include<cmath>
#include<cstdlib>
#include<algorithm>
#include<functional>
#include<cctype>
#include<ctime>
#include<stack>
#include<queue>
#include<vector>
#include<set>
#include<map>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef unsigned int uin;
#define peter cout<<"i am peter"<<endl
#define input freopen("data.txt","r",stdin)
#define randin srand((unsigned int)time(NULL))
#define INT (0x3f3f3f3f)*2
#define LL (0x3f3f3f3f3f3f3f3f)*2
#define gsize(a) (int)a.size()
#define len(a) (int)strlen(a)
#define slen(s) (int)s.length()
#define pb(a) push_back(a)
#define clr(a) memset(a,0,sizeof(a))
#define clr_minus1(a) memset(a,-1,sizeof(a))
#define clr_INT(a) memset(a,INT,sizeof(a))
#define clr_true(a) memset(a,true,sizeof(a))
#define clr_false(a) memset(a,false,sizeof(a))
#define clr_queue(q) while(!q.empty()) q.pop()
#define clr_stack(s) while(!s.empty()) s.pop()
#define rep(i, a, b) for (int i = a; i < b; i++)
#define dep(i, a, b) for (int i = a; i > b; i--)
#define repin(i, a, b) for (int i = a; i <= b; i++)
#define depin(i, a, b) for (int i = a; i >= b; i--)
#define pi 3.1415926535898
#define eps 1e-9
#define MOD 1000000007
#define MAXN
#define N 100100
#define M
int n,k;
char s[100];
int lens;
void printno(){
    printf("Incorrect sequence\n");
    exit(0);
}
ll stringtoint(char *s,int lens){
    ll res=0,ten=1;
    depin(i,lens-1,0){
        if(!isdigit(s[i])) break;
        res+=(s[i]-'0')*ten;
        ten*=10LL;
    }
    if(s[0]=='-') res=-res;
    return res;
}
int num_b,p[N],pos[N];
ll a[N],b[N];
bool vis[N];
void make_it(ll *b,int num){
    int num_pos=0;
    pos[num_pos++]=0;
    b[0]=-INT;
    repin(i,1,num){
        if(b[i]!=INT) pos[num_pos++]=i;
    }
    b[num+1]=INT;
    pos[num_pos++]=num+1;
    rep(i,1,num_pos){
        if(b[pos[i]]-b[pos[i-1]]<pos[i]-pos[i-1]) printno();
        if(pos[i-1]+1==pos[i]) continue;
        if(b[pos[i]]<=0){
            dep(j,pos[i]-1,pos[i-1]){
                b[j]=b[j+1]-1;
            }
        }
        else if(b[pos[i-1]]>=0){
            rep(j,pos[i-1]+1,pos[i]){
                b[j]=b[j-1]+1;
            }
        }
        else{
            int mid=(pos[i-1]+pos[i])>>1;
            b[mid]=0;
            rep(j,mid+1,pos[i]){
                b[j]=b[j-1]+1;
            }
            dep(j,mid-1,pos[i-1]){
                b[j]=b[j+1]-1;
            }
            ll d=0;
            if(b[pos[i-1]+1]<=b[pos[i-1]]){
                d=b[pos[i-1]]-b[pos[i-1]+1]+1;
            }
            else if(b[pos[i]-1]>=b[pos[i]]){
                d=b[pos[i]]-b[pos[i]-1]-1;
            }
            rep(j,pos[i-1]+1,pos[i]){
                b[j]+=d;
            }
        }
    }
}
int main(){
//    input;
    scanf("%d %d",&n,&k);
    repin(i,1,n){
        scanf("%s",s);
        lens=len(s);
        if(s[0]=='?') a[i]=INT;
        else a[i]=stringtoint(s,lens);
    }
    //构造
    repin(i,1,n){
        if(vis[i]) continue;
        num_b=0;
        for(int j=i;j<=n;j+=k){
            vis[j]=true;
            b[++num_b]=a[j];
            p[num_b]=j;
        }
        make_it(b,num_b);
        repin(j,1,num_b){
            a[p[j]]=b[j];
        }
    }
    //判断..
    repin(i,1,n){
        if(i-k>=1 && a[i-k]>=a[i]){
            printno();
        }
        if(i+k<=n && a[i]>=a[i+k]){
            printno();
        }
    }
    repin(i,1,n){
        if(i!=1) printf(" ");
        printf("%lld",a[i]);
    }
    printf("\n");
}


//Hello. I'm Peter.
#include<cstdio>
#include<iostream>
#include<sstream>
#include<cstring>
#include<string>
#include<cmath>
#include<cstdlib>
#include<algorithm>
#include<functional>
#include<cctype>
#include<ctime>
#include<stack>
#include<queue>
#include<vector>
#include<set>
#include<map>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef unsigned int uin;
#define peter cout<<"i am peter"<<endl
#define input freopen("data.txt","r",stdin)
#define randin srand((unsigned int)time(NULL))
#define INT (0x3f3f3f3f)*2
#define LL (0x3f3f3f3f3f3f3f3f)*2
#define gsize(a) (int)a.size()
#define len(a) (int)strlen(a)
#define slen(s) (int)s.length()
#define pb(a) push_back(a)
#define clr(a) memset(a,0,sizeof(a))
#define clr_minus1(a) memset(a,-1,sizeof(a))
#define clr_INT(a) memset(a,INT,sizeof(a))
#define clr_true(a) memset(a,true,sizeof(a))
#define clr_false(a) memset(a,false,sizeof(a))
#define clr_queue(q) while(!q.empty()) q.pop()
#define clr_stack(s) while(!s.empty()) s.pop()
#define rep(i, a, b) for (int i = a; i < b; i++)
#define dep(i, a, b) for (int i = a; i > b; i--)
#define repin(i, a, b) for (int i = a; i <= b; i++)
#define depin(i, a, b) for (int i = a; i >= b; i--)
#define pi 3.1415926535898
#define eps 1e-9
#define MOD 1000000007
#define MAXN
#define N 30010
#define M
int n,k;
int a[N];
char s[100];
int lens;
void printno(){
    printf("Incorrect sequence\n");
    exit(0);
}
int stringtoint(char *s,int lens){
    int res=0,ten=1;
    depin(i,lens-1,0){
        if(!isdigit(s[i])) break;
        res+=(s[i]-'0')*ten;
        ten*=10;
    }
    if(s[0]=='-') res=-res;
    return res;
}
int main(){
//    input;
    scanf("%d %d",&n,&k);
    repin(i,1,n){
        scanf("%s",s);
        lens=len(s);
        if(s[0]=='?') a[i]=INT;
        else a[i]=stringtoint(s,lens);
    }
    //构造
    repin(i,1,n){
        if(a[i]==INT){
            if(i-k>=1 && a[i-k]!=INT){
                a[i]=a[i-k]+1;
            }
        }
    }
    depin(i,n,1){
        if(a[i]==INT){
            if(i+k<=n && a[i+k]!=INT){
                if(a[i+k]>0) a[i]=0;
                else a[i]=a[i+k]-1;
            }
        }
    }
    repin(i,1,n){
        if(a[i]==INT){
            if(i-k>=1) a[i]=a[i-k]+1;
            else a[i]=0;
        }
    }
    //判断..
    repin(i,1,n){
        if(i-k>=1 && a[i-k]>=a[i]){
            printno();
        }
        if(i+k<=n && a[i]>=a[i+k]){
            printno();
        }
    }
    repin(i,1,n){
        if(i!=1) printf(" ");
        printf("%d",a[i]);
    }
    printf("\n");
}


#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <cstdio>
#include <deque>
#include <stack>
#include <string>
#include <ctime>
#include <list>
#include <cstdlib>
#include <algorithm>
#include <fstream>
#include <cmath>
#include <queue>
#include <sstream>
#include <unordered_set>
#include <unordered_map>
#include <assert.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>

#define mp make_pair
#define pb push_back

#define _USE_MATH_DEFINES
#define pi M_PI
#define endl '\n'

// using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector <vector<ll> > graph;
// typedef tree <ll,
//     null_type,
//     less <ll>,
//     rb_tree_tag,
//     tree_order_statistics_node_update> oset; // order_of_key, ...

ll toll(string s)
{
    bool mi = 0;
    if (s[0] == '-')
    {
        mi = 1;
        string tmp = "";
        for (ll i = 1; i < (ll)s.size(); i++)
            tmp += s[i];
        s = tmp;
    }
    ll ans = 0;
    for (ll i = 0; i < (ll)s.size(); i++)
    {
        ans = (ans * 10ll) + (s[i] - '0');
    }
    if (mi)
        ans = -ans;
    // cout << s << " " << ans << endl;
    return ans;

}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    ll n, k;
    cin >> n >> k;
    vector <ll> V(n);
    vector <ll> wtf(n, 0);
    for (ll i = 0; i < n; i++)
    {
        string s;
        cin >> s;
        if (s == "?")
        {
            wtf[i] = 1;
            V[i] = -123;
        }
        else
        {
            ll t = toll(s);
            V[i] = t;
        }
    }
    for (ll i = 0; i < n; i++)
    {
        if (wtf[i])
        {
            ll st = i;
            ll end = i;
            ll num = 1;
            wtf[st] = 0;
            while (end + k < n && wtf[end + k])
            {
                num++;
                end += k;
                wtf[end] = 0;
            }
            ll left = -1000 * 1000 * 1000 - 5;
            ll right = 1000 * 1000 * 1000 + 5;
            if (st - k >= 0)
                left = V[st - k];
            if (end + k < n)
                right = V[end + k];
            if (left >= right)
            {
                cout << "Incorrect sequence\n";
                return 0;
            }
            ll w = 0;
            if ((left <= 0 && right <= 0) || (left >= 0 && right >= 0))
            {
                w = max(abs(right), abs(left)) - min(abs(right), abs(left)) - 1;
            }
            else
            {
                w += max(-left - 1, 0ll);
                w += max(right - 1, 0ll);
                w ++;
            }
            // cout << left << " " << right << " " << w << endl;
            if (num > w)
            {
                cout << "Incorrect sequence\n";
                return 0;
            }
            else
            {
                if (left >= 0)
                {
                    for (ll j = st; j <= end; j += k)
                    {
                        V[j] = V[j - k] + 1;
                    }
                }
                else if (right <= 0)
                {
                    for (ll j = end; j >= st; j -= k)
                    {
                        V[j] = V[j + k] - 1;
                    }
                }
                else
                {
                    ll less = max(-left - 1, 0ll);
                    ll grt = max(right - 1, 0ll);
                    if (less <= grt)
                    {
                        ll wh = st;
                        for (ll j = 0; j < min(less, num / 2); j++)
                            wh += k;
                        V[wh] = 0;
                        for (ll j = wh - k; j >= st; j -= k)
                            V[j] = V[j + k] - 1;
                        for (ll j = wh + k; j <= end; j += k)
                            V[j] = V[j - k] + 1;
                    }
                    else
                    {
                        ll wh = end;
                        for (ll j = 0; j < min(grt, num / 2); j++)
                            wh -= k;
                        V[wh] = 0;
                        for (ll j = wh - k; j >= st; j -= k)
                            V[j] = V[j + k] - 1;
                        for (ll j = wh + k; j <= end; j += k)
                            V[j] = V[j - k] + 1;
                    }
                }
            }
        }
    }
    bool ok = 1;
    for (ll i = 0; i < n; i++)
    {
        if (i - k >= 0)
        {
            if (V[i - k] >= V[i])
                ok = 0;
        }
    }
    if (!ok)
    {
        cout << "Incorrect sequence\n";
    }
    else
    {
        for (ll i = 0; i < n; i++)
            cout << V[i] << " ";
        cout << endl;
    }
    #ifdef HOME
        cerr << "\ntime = " << clock() / 1000 << " ms\n";
    #endif
    return 0;
}


#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <cstdio>
#include <deque>
#include <stack>
#include <string>
#include <ctime>
#include <list>
#include <cstdlib>
#include <algorithm>
#include <fstream>
#include <cmath>
#include <queue>
#include <sstream>
#include <unordered_set>
#include <unordered_map>
#include <assert.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>

#define mp make_pair
#define pb push_back

#define _USE_MATH_DEFINES
#define pi M_PI
#define endl '\n'

// using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector <vector<ll> > graph;
// typedef tree <ll,
//     null_type,
//     less <ll>,
//     rb_tree_tag,
//     tree_order_statistics_node_update> oset; // order_of_key, ...

ll toll(string s)
{
    bool mi = 0;
    if (s[0] == '-')
    {
        mi = 1;
        string tmp = "";
        for (ll i = 1; i < (ll)s.size(); i++)
            tmp += s[i];
        s = tmp;
    }
    ll ans = 0;
    for (ll i = 0; i < (ll)s.size(); i++)
    {
        ans = (ans * 10ll) + (s[i] - '0');
    }
    if (mi)
        ans = -ans;
    // cout << s << " " << ans << endl;
    return ans;

}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    ll n, k;
    cin >> n >> k;
    vector <ll> V(n);
    vector <ll> wtf(n, 0);
    for (ll i = 0; i < n; i++)
    {
        string s;
        cin >> s;
        if (s == "?")
        {
            wtf[i] = 1;
            V[i] = -123;
        }
        else
        {
            ll t = toll(s);
            V[i] = t;
        }
    }
    for (ll i = 0; i < n; i++)
    {
        if (wtf[i])
        {
            ll st = i;
            ll end = i;
            ll num = 1;
            wtf[st] = 0;
            while (end + k < n && wtf[end + k])
            {
                num++;
                end += k;
                wtf[end] = 0;
            }
            ll left = -1000 * 4000 * 1000 - 5;
            ll right = 1000 * 4000 * 1000 + 5;
            if (st - k >= 0)
                left = V[st - k];
            if (end + k < n)
                right = V[end + k];
            if (left >= right)
            {
                cout << "Incorrect sequence\n";
                return 0;
            }
            ll w = 0;
            if ((left <= 0 && right <= 0) || (left >= 0 && right >= 0))
            {
                w = max(abs(right), abs(left)) - min(abs(right), abs(left)) - 1;
            }
            else
            {
                w += max(-left - 1, 0ll);
                w += max(right - 1, 0ll);
                w ++;
            }
            // cout << left << " " << right << " " << w << endl;
            if (num > w)
            {
                cout << "Incorrect sequence\n";
                return 0;
            }
            else
            {
                if (left >= 0)
                {
                    for (ll j = st; j <= end; j += k)
                    {
                        V[j] = V[j - k] + 1;
                    }
                }
                else if (right <= 0)
                {
                    for (ll j = end; j >= st; j -= k)
                    {
                        V[j] = V[j + k] - 1;
                    }
                }
                else
                {
                    ll less = max(-left - 1, 0ll);
                    ll grt = max(right - 1, 0ll);
                    if (less <= grt)
                    {
                        ll wh = st;
                        for (ll j = 0; j < min(less, num / 2); j++)
                            wh += k;
                        V[wh] = 0;
                        for (ll j = wh - k; j >= st; j -= k)
                            V[j] = V[j + k] - 1;
                        for (ll j = wh + k; j <= end; j += k)
                            V[j] = V[j - k] + 1;
                    }
                    else
                    {
                        ll wh = end;
                        for (ll j = 0; j < min(grt, num / 2); j++)
                            wh -= k;
                        V[wh] = 0;
                        for (ll j = wh - k; j >= st; j -= k)
                            V[j] = V[j + k] - 1;
                        for (ll j = wh + k; j <= end; j += k)
                            V[j] = V[j - k] + 1;
                    }
                }
            }
        }
    }
    bool ok = 1;
    for (ll i = 0; i < n; i++)
    {
        if (i - k >= 0)
        {
            if (V[i - k] >= V[i])
                ok = 0;
        }
    }
    if (!ok)
    {
        cout << "Incorrect sequence\n";
    }
    else
    {
        for (ll i = 0; i < n; i++)
            cout << V[i] << " ";
        cout << endl;
    }
    #ifdef HOME
        cerr << "\ntime = " << clock() / 1000 << " ms\n";
    #endif
    return 0;
}


#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <cstdio>
#include <deque>
#include <stack>
#include <string>
#include <ctime>
#include <list>
#include <cstdlib>
#include <algorithm>
#include <fstream>
#include <cmath>
#include <queue>
#include <sstream>
#include <unordered_set>
#include <unordered_map>
#include <assert.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>

#define mp make_pair
#define pb push_back

#define _USE_MATH_DEFINES
#define pi M_PI
#define endl '\n'

// using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector <vector<ll> > graph;
// typedef tree <ll,
//     null_type,
//     less <ll>,
//     rb_tree_tag,
//     tree_order_statistics_node_update> oset; // order_of_key, ...

ll toll(string s)
{
    bool mi = 0;
    if (s[0] == '-')
    {
        mi = 1;
        string tmp = "";
        for (ll i = 1; i < (ll)s.size(); i++)
            tmp += s[i];
        s = tmp;
    }
    ll ans = 0;
    for (ll i = 0; i < (ll)s.size(); i++)
    {
        ans = (ans * 10ll) + (s[i] - '0');
    }
    if (mi)
        ans = -ans;
    // cout << s << " " << ans << endl;
    return ans;

}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    ll n, k;
    cin >> n >> k;
    vector <ll> V(n);
    vector <ll> wtf(n, 0);
    for (ll i = 0; i < n; i++)
    {
        string s;
        cin >> s;
        if (s == "?")
        {
            wtf[i] = 1;
            V[i] = -123;
        }
        else
        {
            ll t = toll(s);
            V[i] = t;
        }
    }
    for (ll i = 0; i < n; i++)
    {
        if (wtf[i])
        {
            ll st = i;
            ll end = i;
            ll num = 1;
            wtf[st] = 0;
            while (end + k < n && wtf[end + k])
            {
                num++;
                end += k;
                wtf[end] = 0;
            }
            ll left = -1000 * 1000 * 1000 - 1000000;
            ll right = 1000 * 1000 * 1000 + 1000000;
            if (st - k >= 0)
                left = V[st - k];
            if (end + k < n)
                right = V[end + k];
            if (left >= right)
            {
                cout << "Incorrect sequence\n";
                return 0;
            }
            ll w = 0;
            if ((left <= 0 && right <= 0) || (left >= 0 && right >= 0))
            {
                w = max(abs(right), abs(left)) - min(abs(right), abs(left)) - 1;
            }
            else
            {
                w += max(-left - 1, 0ll);
                w += max(right - 1, 0ll);
                w ++;
            }
            // cout << left << " " << right << " " << w << endl;
            if (num > w)
            {
                cout << "Incorrect sequence\n";
                return 0;
            }
            else
            {
                if (left >= 0)
                {
                    for (ll j = st; j <= end; j += k)
                    {
                        V[j] = V[j - k] + 1;
                    }
                }
                else if (right <= 0)
                {
                    for (ll j = end; j >= st; j -= k)
                    {
                        V[j] = V[j + k] - 1;
                    }
                }
                else
                {
                    ll less = max(-left - 1, 0ll);
                    ll grt = max(right - 1, 0ll);
                    if (less <= grt)
                    {
                        ll wh = st;
                        for (ll j = 0; j < min(less, num / 2); j++)
                            wh += k;
                        V[wh] = 0;
                        for (ll j = wh - k; j >= st; j -= k)
                            V[j] = V[j + k] - 1;
                        for (ll j = wh + k; j <= end; j += k)
                            V[j] = V[j - k] + 1;
                    }
                    else
                    {
                        ll wh = end;
                        for (ll j = 0; j < min(grt, num / 2); j++)
                            wh -= k;
                        V[wh] = 0;
                        for (ll j = wh - k; j >= st; j -= k)
                            V[j] = V[j + k] - 1;
                        for (ll j = wh + k; j <= end; j += k)
                            V[j] = V[j - k] + 1;
                    }
                }
            }
        }
    }
    bool ok = 1;
    for (ll i = 0; i < n; i++)
    {
        if (i - k >= 0)
        {
            if (V[i - k] >= V[i])
                ok = 0;
        }
    }
    if (!ok)
    {
        cout << "Incorrect sequence\n";
    }
    else
    {
        for (ll i = 0; i < n; i++)
            cout << V[i] << " ";
        cout << endl;
    }
    #ifdef HOME
        cerr << "\ntime = " << clock() / 1000 << " ms\n";
    #endif
    return 0;
}


#include <bits/stdc++.h>

#define REP(i, a) for (int i = 0; i < (int) (a); i ++)
#define REPP(i, a, b) for (int i = (int) (a); i <= (int) (b); i ++)
#define MST(a, b) memset(a, b, sizeof(a))

using namespace std;

const int N = 1e5 + 5;
const int INF = 0x3f3f3f3f;

int a[N], n, k;

int in(string s) {
	if (s[0] == '?') return INF;
	else {
		int ans = 0, flag = 0;
		REP(i, s.size()) {
			if (s[i] == '-') flag = 1;
			else ans = 10 * ans + s[i] - '0';
		}
		return flag ? -ans : ans;
	}
}

long long getsum(int start, int n) {
	long long ans = 0;
	REP(i, n) {
		ans += abs(start++);
	}
	return ans;
}

int main() {
	ios :: sync_with_stdio(0);
	cin >> n >> k;
	string s;
	REPP(i, 1, n) {
		cin >> s;
		a[i] = in(s);
	}
	bool bad = 0;
	REPP(i, 1, k) {
		int j = i;
		vector<int> tmp;
		while (j <= n) {
			tmp.push_back(a[j]);
			j += k;
		}
		REP(t, tmp.size()) {
			if(tmp[t] == INF) {
				int now = t;
				while (now < (int) tmp.size() && tmp[now] == INF) {
					now++;
				}
				if (now == (int) tmp.size()) {
					int st = -(now - t - 1) / 2;
					if (t) {
						st = max(tmp[t - 1] + 1, st);
					}
					REPP(r, t, tmp.size() - 1) {
						a[i + k * r] = st++;
					}
				}
				else {
					if (t == 0) {
						int st = -(now - t) / 2;
						int ed = st + now - t - 1;
						ed = min(ed, tmp[now] - 1);
						for (int r = now - 1; r >= t; r--) {
							a[i + k * r] = ed--;
						}
					}
					else {
						int left = tmp[t - 1], right = tmp[now];
						if (right - left <= now - t) {
							bad = 1;
							break;
						}
						int lo = left + 1, hi = right - (now - t);
						while (lo + 5 < hi) {
							int mid1 = (2LL * lo + hi) / 3;
							int mid2 = (lo + 2LL * hi) / 3;
							long long sum1 = getsum(mid1, now - t), sum2 = getsum(mid2, now - t);
							if (sum1 >= sum2) {
								lo = mid1;
							}
							else {
								hi = mid2;
							}
						}
						long long ans = 1LL << 60;
						int id = INF;
						REPP(i, lo, hi) {
							long long tmp = 0;
							REPP(j, t, now - 1) {
								tmp += abs(i + j);
							}
							if (tmp < ans) {
								ans = tmp;
								id = i;
							}
						}
						lo = id;
						REPP(r, t, now - 1) {
							a[i + k * r] = lo++;
						}
					}
				}
				t = now - 1;
			}
		}
		if (bad) break;
	}
	if (!bad) {
		REPP(i, 1, n) {
			if (i + k <= n && a[i] >= a[i + k]) {
				bad = 1;
				break;
			}
		}
	}
	if (bad) {
		cout << "Incorrect sequence" << endl;
	}
	else {
		REPP(i, 1, n) {
			cout << a[i] << " \n"[i == n];
		}
	}

	return 0;
}


#include <bits/stdc++.h>

#define REP(i, a) for (int i = 0; i < (int) (a); i ++)
#define REPP(i, a, b) for (int i = (int) (a); i <= (int) (b); i ++)
#define MST(a, b) memset(a, b, sizeof(a))

using namespace std;

const int N = 1e5 + 5;
const int INF = 0x3f3f3f3f;

int a[N], n, k;

int in(string s) {
	if (s[0] == '?') return INF;
	else {
		int ans = 0, flag = 0;
		REP(i, s.size()) {
			if (s[i] == '-') flag = 1;
			else ans = 10 * ans + s[i] - '0';
		}
		return flag ? -ans : ans;
	}
}

long long getsum(int start, int n) {
	long long ans = 0;
	REP(i, n) {
		ans += abs(start++);
	}
	return ans;
}

int main() {
	ios :: sync_with_stdio(0);
	cin >> n >> k;
	string s;
	REPP(i, 1, n) {
		cin >> s;
		a[i] = in(s);
	}
	bool bad = 0;
	REPP(i, 1, k) {
		int j = i;
		vector<int> tmp;
		while (j <= n) {
			tmp.push_back(a[j]);
			j += k;
		}
		REP(t, tmp.size()) {
			if(tmp[t] == INF) {
				int now = t;
				while (now < (int) tmp.size() && tmp[now] == INF) {
					now++;
				}
				if (now == (int) tmp.size()) {
					int st = -(now - t - 1) / 2;
					if (t) {
						st = max(tmp[t - 1] + 1, st);
					}
					REPP(r, t, tmp.size() - 1) {
						a[i + k * r] = st++;
					}
				}
				else {
					if (t == 0) {
						int st = -(now - t) / 2;
						int ed = st + now - t - 1;
						ed = min(ed, tmp[now] - 1);
						for (int r = now - 1; r >= t; r--) {
							a[i + k * r] = ed--;
						}
					}
					else {
						int left = tmp[t - 1], right = tmp[now];
						if (right - left <= now - t) {
							bad = 1;
							break;
						}
						int lo = left + 1, hi = right - (now - t);
						while (lo + 5 < hi) {
							int mid1 = (2LL * lo + hi) / 3;
							int mid2 = (lo + 2LL * hi) / 3;
							long long sum1 = getsum(mid1, now - t), sum2 = getsum(mid2, now - t);
							if (sum1 >= sum2) {
								lo = mid1;
							}
							else {
								hi = mid2;
							}
						}
						long long ans = 1LL << 60;
						int id = INF;
						REPP(i, lo, hi) {
							long long tmp = 0;
							int tt = i;
							REPP(j, t, now - 1) {
								tmp += abs(tt++);
							}
							if (tmp < ans) {
								ans = tmp;
								id = i;
							}
						}
						lo = id;
						REPP(r, t, now - 1) {
							a[i + k * r] = lo++;
						}
					}
				}
				t = now - 1;
			}
		}
		if (bad) break;
	}
	if (!bad) {
		REPP(i, 1, n) {
			if (i + k <= n && a[i] >= a[i + k]) {
				bad = 1;
				break;
			}
		}
	}
	if (bad) {
		cout << "Incorrect sequence" << endl;
	}
	else {
		REPP(i, 1, n) {
			cout << a[i] << " \n"[i == n];
		}
	}

	return 0;
}


#include <bits/stdc++.h>

#define REP(i, a) for (int i = 0; i < (int) (a); i ++)
#define REPP(i, a, b) for (int i = (int) (a); i <= (int) (b); i ++)
#define MST(a, b) memset(a, b, sizeof(a))

using namespace std;

const int N = 1e5 + 5;
const int INF = 0x3f3f3f3f;

int a[N], n, k;

int in(string s) {
	if (s[0] == '?') return INF;
	else return stoi(s);
}

long long getsum(int start, int n) {
	long long ans = 0;
	REP(i, n) {
		ans += abs(start++);
	}
	return ans;
}

int main() {
	ios :: sync_with_stdio(0);
	cin >> n >> k;
	string s;
	REPP(i, 1, n) {
		cin >> s;
		a[i] = in(s);
	}
	bool bad = 0;
	REPP(i, 1, k) {
		int j = i;
		vector<int> tmp;
		while (j <= n) {
			tmp.push_back(a[j]);
			j += k;
		}
		REP(t, tmp.size()) {
			if(tmp[t] == INF) {
				int now = t;
				while (now < (int) tmp.size() && tmp[now] == INF) {
					now++;
				}
				if (now == (int) tmp.size()) {
					int st = -(now - t - 1) / 2;
					if (t) {
						st = max(tmp[t - 1] + 1, st);
					}
					REPP(r, t, tmp.size() - 1) {
						a[i + k * r] = st++;
					}
				}
				else {
					if (t == 0) {
						int st = -(now - t) / 2;
						int ed = st + now - t - 1;
						ed = min(ed, tmp[now] - 1);
						for (int r = now - 1; r >= t; r--) {
							a[i + k * r] = ed--;
						}
					}
					else {
						int left = tmp[t - 1], right = tmp[now];
						if (right - left <= now - t) {
							bad = 1;
							break;
						}
						int lo = left + 1, hi = right - (now - t);
						while (lo + 5 < hi) {
							int mid1 = (2LL * lo + hi) / 3;
							int mid2 = (lo + 2LL * hi) / 3;
							long long sum1 = getsum(mid1, now - t), sum2 = getsum(mid2, now - t);
							if (sum1 >= sum2) {
								lo = mid1;
							}
							else {
								hi = mid2;
							}
						}
						long long ans = 1LL << 60;
						int id = INF;
						REPP(i, lo, hi) {
							long long tmp = 0;
							REPP(j, t, now - 1) {
								tmp += abs(i + j);
							}
							if (tmp < ans) {
								ans = tmp;
								id = i;
							}
						}
						lo = id;
						REPP(r, t, now - 1) {
							a[i + k * r] = lo++;
						}
					}
				}
				t = now - 1;
			}
		}
		if (bad) break;
	}
	if (!bad) {
		REPP(i, 1, n) {
			if (i + k <= n && a[i] >= a[i + k]) {
				bad = 1;
				break;
			}
		}
	}
	if (bad) {
		cout << "Incorrect sequence" << endl;
	}
	else {
		REPP(i, 1, n) {
			cout << a[i] << " \n"[i == n];
		}
	}

	return 0;
}


#include<cstdio>
#include<algorithm>
#include<iostream>
#include<cstdlib>
#include<cassert>
#include<stack>
#include<cstring>
#include<vector>
#include<string>
#include<cmath>
#include<ctime>
#include<set>
#include<map>
#include<queue>
#include<fstream>
#include<sstream>
#include<iomanip>
#include<complex>

#define mp(makepairtmp1,makepairtmp2) make_pair(makepairtmp1,makepairtmp2)
#define X real()
#define Y imag()

using namespace std;

//def
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
const int MOD = 10;
const double eps = 1e-5;
const int maxN = 1e5 + 100;
const int maxM = 1;
const int inf = 1e10;
int n, k;
vector <int> O[maxN];
string s;
int A[maxN];

//init
inline void init()
{
    int t;
    cin >> n >> k;
    for (int i = 0; i < n; i++)
    {
        cin >> s;
        if (s == "?") O[i%k].push_back(-inf);
        else
        {
            t = 0;
            if (s[0] == '-')
            {
                for (int i = 1; i < s.size(); i++)
                    t = t * 10 + (s[i] - '0');
                t = -t;
            }
            else
            {
                for (int i = 0; i < s.size(); i++)
                    t = t * 10 + (s[i] - '0');
            }
            O[i%k].push_back(t);
        }
    }
    for (int i = 0; i < k; i++)
    {
        int s = -1;
        for (int j = 0; j < O[i].size(); j++)
        {
            if (O[i][j] == -inf) continue;
            if (j - s > 1)
            {
                int lo = (s == -1) ? -inf : O[i][s];
                int up = O[i][j];
                for (int x = s + 1; x < j; x++) O[i][x] = x - ((j + s) / 2);
                int KL = O[i][s + 1];
                if (O[i][s + 1] <= lo) for (int x = s + 1; x < j; x++) O[i][x] += lo - KL + 1;
                KL = O[i][j - 1];
                if (O[i][j - 1] >= up) for (int x = s + 1; x < j; x++) O[i][x] -= KL + 1 - up;
            }
            s = j;
        }
        if (s + 1 != O[i].size())
        {
            int lo = (s == -1) ? -inf : O[i][s];
            for (int x = s + 1; x < O[i].size(); x++) O[i][x] = x - ((O[i].size() + s) / 2);
            int KL = O[i][s + 1];
            if (O[i][s + 1] <= lo) for (int x = s + 1; x < O[i].size(); x++) O[i][x] += lo - KL + 1;
        }
    }
    for (int i = 0; i < k; i++)
    {
        for (int j = 1; j < O[i].size(); j++)
        {
            if (O[i][j] <= O[i][j - 1])
            {
                cout << "Incorrect sequence" << endl;
                return;
            }
        }
    }
    for (int i = 0; i < n; i++)
    {
        A[i] = O[i%k][i / k];
        cout << A[i] << " ";
    }
}

//Solve
inline void solve()
{

}

int main()
{
    ios_base::sync_with_stdio(0);
    //freopen("superbull.in", "r", stdin);
    //freopen("superbull.out", "w", stdout);
    init();
    solve();
    //system("pause");
    return 0;
}


    #include<cstdio>
#include<algorithm>
#include<iostream>
#include<cstdlib>
#include<cassert>
#include<stack>
#include<cstring>
#include<vector>
#include<string>
#include<cmath>
#include<ctime>
#include<set>
#include<map>
#include<queue>
#include<fstream>
#include<sstream>
#include<iomanip>
#include<complex>

#define mp(makepairtmp1,makepairtmp2) make_pair(makepairtmp1,makepairtmp2)
#define X real()
#define Y imag()

using namespace std;

//def
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
const int MOD = 10;
const double eps = 1e-5;
const int maxN = 2e3 + 10;
const int maxM = 1;
const int inf = 1e9 + 10;
int n, k;
vector <int> O[maxN];
string s;
int A[maxN];

//init
inline void init()
{
    int t;
    cin >> n >> k;
    for (int i = 0; i < n; i++)
    {
        cin >> s;
        if (s == "?") O[i%k].push_back(-inf);
        else
        {
            t = 0;
            if (s[0] == '-')
            {
                for (int i = 1; i < s.size(); i++)
                    t = t * 10 + (s[i] - '0');
                t = -t;
            }
            else
            {
                for (int i = 0; i < s.size(); i++)
                    t = t * 10 + (s[i] - '0');
            }
            O[i%k].push_back(t);
        }
    }
    for (int i = 0; i < k; i++)
    {
        int s = -1;
        for (int j = 0; j < O[i].size(); j++)
        {
            if (O[i][j] == -inf) continue;
            if (j - s > 1)
            {
                int lo = (s == -1) ? -inf : O[i][s];
                int up = O[i][j];
                for (int x = s + 1; x < j; x++) O[i][x] = x - ((j + s) / 2);
                if (O[i][s + 1] <= lo) for (int x = s + 1; x < j; x++) O[i][x] += lo - O[i][s + 1] + 1;
                if (O[i][j - 1] >= up) for (int x = s + 1; x < j; x++) O[i][x] -= O[i][j - 1] + 1 - up;
            }
            s = j;
        }
        if (s + 1 != O[i].size())
        {
            int lo = (s == -1) ? -inf : O[i][s];
            for (int x = s + 1; x < O[i].size(); x++) O[i][x] = x - ((O[i].size() + s) / 2);
            if (O[i][s + 1] <= lo) for (int x = s + 1; x < O[i].size(); x++) O[i][x] += lo - O[i][s + 1] + 1;
        }
    }
    for (int i = 0; i < k; i++)
    {
        for (int j = 1; j < O[i].size(); j++)
        {
            if (O[i][j] <= O[i][j - 1])
            {
                cout << "Incorrect sequence" << endl;
                return;
            }
        }
    }
    for (int i = 0; i < n; i++)
    {
        A[i] = O[i%k][i / k];
        cout << A[i] << " ";
    }
}

//Solve
inline void solve()
{

}

int main()
{
    ios_base::sync_with_stdio(0);
    //freopen("superbull.in", "r", stdin);
    //freopen("superbull.out", "w", stdout);
    init();
    solve();
    //system("pause");
    return 0;
}


#include<cstdio>
#include<algorithm>
#include<iostream>
#include<cstdlib>
#include<cassert>
#include<stack>
#include<cstring>
#include<vector>
#include<string>
#include<cmath>
#include<ctime>
#include<set>
#include<map>
#include<queue>
#include<fstream>
#include<sstream>
#include<iomanip>
#include<complex>

#define mp(makepairtmp1,makepairtmp2) make_pair(makepairtmp1,makepairtmp2)
#define X real()
#define Y imag()

using namespace std;

//def
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
const int MOD = 10;
const double eps = 1e-5;
const int maxN = 2e3 + 10;
const int maxM = 1;
const int inf = 1e9 + 10;
int n, k;
vector <int> O[maxN];
string s;
int A[maxN];

//init
inline void init()
{
    int t;
    cin >> n >> k;
    for (int i = 0; i < n; i++)
    {
        cin >> s;
        if (s == "?") O[i%k].push_back(-inf);
        else
        {
            t = 0;
            if (s[0] == '-')
            {
                for (int i = 1; i < s.size(); i++)
                    t = t * 10 + (s[i] - '0');
                t = -t;
            }
            else
            {
                for (int i = 0; i < s.size(); i++)
                    t = t * 10 + (s[i] - '0');
            }
            O[i%k].push_back(t);
        }
    }
    for (int i = 0; i < k; i++)
    {
        int s = -1;
        for (int j = 0; j < O[i].size(); j++)
        {
            if (O[i][j] == -inf) continue;
            if (j - s > 1)
            {
                int lo = (s == -1) ? -inf : O[i][s];
                int up = O[i][j];
                for (int x = s + 1; x < j; x++) O[i][x] = x - ((j + s) / 2);
                if (O[i][s + 1] <= lo) for (int x = s + 1; x < j; x++) O[i][x] += lo - O[i][s] + 1;
                if (O[i][j - 1] >= up) for (int x = s + 1; x < j; x++) O[i][x] -= O[i][j - 1] + 1 - up;
            }
            s = j;
        }
        if (s + 1 != O[i].size())
        {
            int lo = (s == -1) ? -inf : O[i][s];
            for (int x = s + 1; x < O[i].size(); x++) O[i][x] = x - ((O[i].size() + s) / 2);
            if (O[i][s + 1] <= lo) for (int x = s + 1; x < O[i].size(); x++) O[i][x] += lo - O[i][s] + 1;
        }
    }
    for (int i = 0; i < k; i++)
    {
        for (int j = 1; j < O[i].size(); j++)
        {
            if (O[i][j] <= O[i][j - 1])
            {
                cout << "Incorrect sequence" << endl;
                return;
            }
        }
    }
    for (int i = 0; i < n; i++)
    {
        A[i] = O[i%k][i / k];
        cout << A[i] << " ";
    }
}

//Solve
inline void solve()
{

}

int main()
{
    ios_base::sync_with_stdio(0);
    //freopen("superbull.in", "r", stdin);
    //freopen("superbull.out", "w", stdout);
    init();
    solve();
    //system("pause");
    return 0;
}


#include<cstdio>
#include<algorithm>
#include<iostream>
#include<cstdlib>
#include<cassert>
#include<stack>
#include<cstring>
#include<vector>
#include<string>
#include<cmath>
#include<ctime>
#include<set>
#include<map>
#include<queue>
#include<fstream>
#include<sstream>
#include<iomanip>
#include<complex>

#define mp(makepairtmp1,makepairtmp2) make_pair(makepairtmp1,makepairtmp2)
#define X real()
#define Y imag()

using namespace std;

//def
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
const int MOD = 10;
const double eps = 1e-5;
const int maxN = 2e3 + 10;
const int maxM = 1;
const int inf = 1e9 + 10;
int n, k;
vector <int> O[maxN];
string s;
int A[maxN];

//init
inline void init()
{
    int t;
    cin >> n >> k;
    for (int i = 0; i < n; i++)
    {
        cin >> s;
        if (s == "?") O[i%k].push_back(-inf);
        else
        {
            t = 0;
            if (s[0] == '-')
            {
                for (int i = 1; i < s.size(); i++)
                    t = t * 10 + (s[i] - '0');
                t = -t;
            }
            else
            {
                for (int i = 0; i < s.size(); i++)
                    t = t * 10 + (s[i] - '0');
            }
            O[i%k].push_back(t);
        }
    }
    for (int i = 0; i < k; i++)
    {
        int s = -1;
        for (int j = 0; j < O[i].size(); j++)
        {
            if (O[i][j] == -inf) continue;
            if (j - s > 1)
            {
                int lo = (s == -1) ? -inf : O[i][s];
                int up = O[i][j];
                for (int x = s + 1; x < j; x++) O[i][x] = x - ((j + s) / 2);
                int KL = O[i][s + 1];
                if (O[i][s + 1] <= lo) for (int x = s + 1; x < j; x++) O[i][x] += lo - KL + 1;
                KL = O[i][j - 1];
                if (O[i][j - 1] >= up) for (int x = s + 1; x < j; x++) O[i][x] -= KL + 1 - up;
            }
            s = j;
        }
        if (s + 1 != O[i].size())
        {
            int lo = (s == -1) ? -inf : O[i][s];
            for (int x = s + 1; x < O[i].size(); x++) O[i][x] = x - ((O[i].size() + s) / 2);
            int KL = O[i][s + 1];
            if (O[i][s + 1] <= lo) for (int x = s + 1; x < O[i].size(); x++) O[i][x] += lo - KL + 1;
        }
    }
    for (int i = 0; i < k; i++)
    {
        for (int j = 1; j < O[i].size(); j++)
        {
            if (O[i][j] <= O[i][j - 1])
            {
                cout << "Incorrect sequence" << endl;
                return;
            }
        }
    }
    for (int i = 0; i < n; i++)
    {
        A[i] = O[i%k][i / k];
        cout << A[i] << " ";
    }
}

//Solve
inline void solve()
{

}

int main()
{
    ios_base::sync_with_stdio(0);
    //freopen("superbull.in", "r", stdin);
    //freopen("superbull.out", "w", stdout);
    init();
    solve();
    //system("pause");
    return 0;
}


#include<cstdio>
#include<algorithm>
#include<iostream>
#include<cstdlib>
#include<cassert>
#include<stack>
#include<cstring>
#include<vector>
#include<string>
#include<cmath>
#include<ctime>
#include<set>
#include<map>
#include<queue>
#include<fstream>
#include<sstream>
#include<iomanip>
#include<complex>

#define mp(makepairtmp1,makepairtmp2) make_pair(makepairtmp1,makepairtmp2)
#define X real()
#define Y imag()

using namespace std;

//def
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
const int MOD = 10;
const double eps = 1e-5;
const int maxN = 2e3 + 10;
const int maxM = 1;
const int inf = 1e9 + 10;
int n, k;
vector <int> O[maxN];
string s;
int A[maxN];

//init
inline void init()
{
    int t;
    cin >> n >> k;
    for (int i = 0; i < n; i++)
    {
        cin >> s;
        if (s == "?") O[i%k].push_back(-inf);
        else
        {
            t = 0;
            if (s[0] == '-')
            {
                for (int i = 1; i < s.size(); i++)
                    t = t * 10 + (s[i] - '0');
                t = -t;
            }
            else
            {
                for (int i = 0; i < s.size(); i++)
                    t = t * 10 + (s[i] - '0');
            }
            O[i%k].push_back(t);
        }
    }
    for (int i = 0; i < k; i++)
    {
        int s = -1;
        for (int j = 0; j < O[i].size();j++)
        {
            if (O[i][j] == -inf) continue;
            if (j - s > 1)
            {
                int lo = (s==-1)?-inf:O[i][s];
                int up = O[i][j];
                if (lo < 0 == up < 0)
                {
                    if (abs(lo) < abs(up)) for (int x = s + 1; x < j; x++) O[i][x] = lo + (x - s);
                    else for (int x = j - 1; x > s; x--) O[i][x] = up - (j - x);
                }
                else
                {
                    for (int x = s+1; x < j; x++) O[i][x] = x - ((j + s) / 2);
                    if (O[i][s+1] <= lo) for (int x = s+1; x < j; x++) O[i][x] += lo - O[i][s] + 1;
                }
            }
            s = j;
        }
        if (s+1 != O[i].size())
        {
            int lo = O[i][s];
            if (lo == -inf) for (int x = s; x < O[i].size(); x++) O[i][x] = x - (O[i].size() / 2);
            else
            {
                for (int x = s+1; x < O[i].size(); x++) O[i][x] = x - (O[i].size() / 2);
                if (O[i][s+1] <= lo) for (int x = s+1; x < O[i].size(); x++) O[i][x] += lo - O[i][s] + 1;
            }
        }
    }
    for (int i = 0; i < k; i++)
    {
        for (int j = 1; j < O[i].size(); j++)
        {
            if (O[i][j] <= O[i][j - 1])
            {
                cout << "Incorrect sequence" << endl;
                return;
            }
        }
    }
    for (int i = 0; i < n; i++)
    {
        A[i] = O[i%k][i / k];
        cout << A[i] << " ";
    }
}

//Solve
inline void solve()
{

}

int main()
{
    ios_base::sync_with_stdio(0);
    //freopen("superbull.in", "r", stdin);
    //freopen("superbull.out", "w", stdout);
    init();
    solve();
    //system("pause");
    return 0;
}


#include<cstdio>
#include<algorithm>
#include<iostream>
#include<cstdlib>
#include<cassert>
#include<stack>
#include<cstring>
#include<vector>
#include<string>
#include<cmath>
#include<ctime>
#include<set>
#include<map>
#include<queue>
#include<fstream>
#include<sstream>
#include<iomanip>
#include<complex>

#define mp(makepairtmp1,makepairtmp2) make_pair(makepairtmp1,makepairtmp2)
#define X real()
#define Y imag()

using namespace std;

//def
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
const int MOD = 10;
const double eps = 1e-5;
const int maxN = 2e3 + 10;
const int maxM = 1;
const int inf = 1e9 + 10;
int n, k;
vector <int> O[maxN];
string s;
int A[maxN];

//init
inline void init()
{
    int t;
    cin >> n >> k;
    for (int i = 0; i < n; i++)
    {
        cin >> s;
        if (s == "?") O[i%k].push_back(-inf);
        else
        {
            t = 0;
            if (s[0] == '-')
            {
                for (int i = 1; i < s.size(); i++)
                    t = t * 10 + (s[i] - '0');
                t = -t;
            }
            else
            {
                for (int i = 0; i < s.size(); i++)
                    t = t * 10 + (s[i] - '0');
            }
            O[i%k].push_back(t);
        }
    }
    for (int i = 0; i < k; i++)
    {
        int s = -1;
        for (int j = 0; j < O[i].size(); j++)
        {
            if (O[i][j] == -inf) continue;
            if (j - s > 1)
            {
                int lo = (s == -1) ? -inf : O[i][s];
                int up = O[i][j];
                for (int x = s + 1; x < j; x++) O[i][x] = x - ((j + s) / 2);
                if (O[i][s + 1] <= lo) for (int x = s + 1; x < j; x++) O[i][x] += lo - O[i][s] + 1;
                if (O[i][j - 1] >= up) for (int x = s + 1; x < j; x++) O[i][x] -= O[i][j-1] + 1 - up;
            }
            s = j;
        }
        if (s + 1 != O[i].size())
        {
            int lo = O[i][s];
            for (int x = s + 1; x < O[i].size(); x++) O[i][x] = x - (O[i].size() / 2);
            if (O[i][s + 1] <= lo) for (int x = s + 1; x < O[i].size(); x++) O[i][x] += lo - O[i][s] + 1;
        }
    }
    for (int i = 0; i < k; i++)
    {
        for (int j = 1; j < O[i].size(); j++)
        {
            if (O[i][j] <= O[i][j - 1])
            {
                cout << "Incorrect sequence" << endl;
                return;
            }
        }
    }
    for (int i = 0; i < n; i++)
    {
        A[i] = O[i%k][i / k];
        cout << A[i] << " ";
    }
}

//Solve
inline void solve()
{

}

int main()
{
    ios_base::sync_with_stdio(0);
    //freopen("superbull.in", "r", stdin);
    //freopen("superbull.out", "w", stdout);
    init();
    solve();
    //system("pause");
    return 0;
}


#include <iostream>
#include <fstream>
#include <sstream>

#include <vector>
#include <set>
#include <bitset>
#include <map>
#include <deque>
#include <string>

#include <algorithm>
#include <numeric>

#include <cstdio>
#include <cassert>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>

#define pb push_back
#define pbk pop_back
#define mp make_pair
#define fs first
#define sc second
#define all(x) (x).begin(), (x).end()
#define foreach(i, a) for (__typeof((a).begin()) i = (a).begin(); i != (a).end(); ++i)
#define len(a) ((int) (a).size())

#ifdef CUTEBMAING
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define eprintf(...) 42
#endif

using namespace std;

typedef long long int64;
typedef long double ld;
typedef unsigned long long lint;

const int inf = (1 << 30) - 1;
const int64 linf = (1ll << 62) - 1;
const int N = 1e5 + 100;

#define count _count

int n, m;
int ans[N];
vector<pair<int, int> > c[N];

inline int64 getSum(int n) {
    if (n <= 0) {
        return 0;
    }
    return 1ll * n * (n - 1) / 2;
}

inline int64 getSum(int a, int b) {
    if (a <= 0) {
        return getSum(-a) + getSum(b);
    }
    return getSum(b) - getSum(a - 1);
}

void solve(const vector<pair<int, int> > &c) {
    for (int i = 0; i < len(c); ) {
        if (c[i].fs != inf) {
            ans[c[i].sc] = c[i].fs;
            i++;
            continue;
        }
        int prev = i > 0 ? c[i - 1].fs : -inf;
        int it = i;
        while (it < len(c) && c[it].fs == inf) {
            it++;
        }
        int next;
        if (it == len(c)) {
            next = inf;
        } else {
            next = c[it].fs;
        }
        int count = it - i;
        if (next - prev - 1 < count) {
            puts("Incorrect sequence");
            exit(0);
        }
        if (count % 2 == 1 && prev < -((count - 1) / 2) && next > (count - 1) / 2) {
            for (int j = i; j < it; j++) {
                ans[c[j].sc] = j - i - (count - 1) / 2;
            }
        } else if (prev < -count / 2 + 1 && next > count / 2) {
            for (int j = i; j < it; j++) {
                ans[c[j].sc] = j - i - count / 2 + 1;
            }
        } else if (prev < -count / 2 && next > count / 2 + 1) {
            for (int j = i; j < it; j++) {
                ans[c[j].sc] = j - i - count / 2;
            }
        } else {
            if (getSum(prev + 1, prev + count) < getSum(next - count, next - 1)) {
                for (int j = i, cur = prev + 1; j < it; j++, cur++) {
                    ans[c[j].sc] = cur;
                }
            } else {
                for (int j = i, cur = next - count; j < it; j++, cur++) {
                    ans[c[j].sc] = cur;
                }
            }
        }
        i = it;
    }
}

int main() {
    assert(scanf("%d%d", &n, &m) == 2);
    for (int i = 0; i < n; i++) {
        static char buf[100];
        assert(scanf("%s", buf) == 1);
        if (*buf == '?') {
            c[i % m].pb(mp(inf, i));
        } else {
            int v; sscanf(buf, "%d", &v);
            c[i % m].pb(mp(v, i));
        }
    }
    for (int i = 0; i < n; i++) {
        solve(c[i]);
    }
    for (int i = 0; i < n - m; i++) {
        if (ans[i] >= ans[i + m]) {
            puts("Incorrect sequence");
            return 0;
        }
    }
    for (int i = 0; i < n; i++) {
        printf("%d ", ans[i]);
    }
    puts("");
    return 0;
}


#include <iostream>
#include <fstream>
#include <sstream>

#include <vector>
#include <set>
#include <bitset>
#include <map>
#include <deque>
#include <string>

#include <algorithm>
#include <numeric>

#include <cstdio>
#include <cassert>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>

#define pb push_back
#define pbk pop_back
#define mp make_pair
#define fs first
#define sc second
#define all(x) (x).begin(), (x).end()
#define foreach(i, a) for (__typeof((a).begin()) i = (a).begin(); i != (a).end(); ++i)
#define len(a) ((int) (a).size())

#ifdef CUTEBMAING
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define eprintf(...) 42
#endif

using namespace std;

typedef long long int64;
typedef long double ld;
typedef unsigned long long lint;

const int inf = (1 << 30) - 1;
const int64 linf = (1ll << 62) - 1;
const int N = 1e5 + 100;

#define count _count

int n, m;
int ans[N];
vector<pair<int, int> > c[N];

inline int64 getSum(int n) {
    if (n <= 0) {
        return 0;
    }
    return 1ll * n * (n - 1) / 2;
}

inline int64 getSum(int a, int b) {
    if (a <= 0 && b >= 0) {
        return getSum(-a) + getSum(b);
    }
    if (b <= 0) {
        return getSum(-b, -a);
    }
    return getSum(b) - getSum(a - 1);
}

void solve(const vector<pair<int, int> > &c) {
    for (int i = 0; i < len(c); ) {
        if (c[i].fs != inf) {
            ans[c[i].sc] = c[i].fs;
            i++;
            continue;
        }
        int prev = i > 0 ? c[i - 1].fs : -inf;
        int it = i;
        while (it < len(c) && c[it].fs == inf) {
            it++;
        }
        int next;
        if (it == len(c)) {
            next = inf;
        } else {
            next = c[it].fs;
        }
        int count = it - i;
        if (next - prev - 1 < count) {
            puts("Incorrect sequence");
            exit(0);
        }
        if (count % 2 == 1 && prev < -((count - 1) / 2) && next > (count - 1) / 2) {
            for (int j = i; j < it; j++) {
                ans[c[j].sc] = j - i - (count - 1) / 2;
            }
        } else if (prev < -count / 2 + 1 && next > count / 2) {
            for (int j = i; j < it; j++) {
                ans[c[j].sc] = j - i - count / 2 + 1;
            }
        } else if (prev < -count / 2 && next > count / 2 + 1) {
            for (int j = i; j < it; j++) {
                ans[c[j].sc] = j - i - count / 2;
            }
        } else {
            if (getSum(prev + 1, prev + count) < getSum(next - count, next - 1)) {
                for (int j = i, cur = prev + 1; j < it; j++, cur++) {
                    ans[c[j].sc] = cur;
                }
            } else {
                for (int j = i, cur = next - count; j < it; j++, cur++) {
                    ans[c[j].sc] = cur;
                }
            }
        }
        i = it;
    }
}

int main() {
    assert(scanf("%d%d", &n, &m) == 2);
    for (int i = 0; i < n; i++) {
        static char buf[100];
        assert(scanf("%s", buf) == 1);
        if (*buf == '?') {
            c[i % m].pb(mp(inf, i));
        } else {
            int v; sscanf(buf, "%d", &v);
            c[i % m].pb(mp(v, i));
        }
    }
    for (int i = 0; i < n; i++) {
        solve(c[i]);
    }
    for (int i = 0; i < n - m; i++) {
        if (ans[i] >= ans[i + m]) {
            puts("Incorrect sequence");
            return 0;
        }
    }
    for (int i = 0; i < n; i++) {
        printf("%d ", ans[i]);
    }
    puts("");
    return 0;
}


#include <iostream>
#include <fstream>
#include <sstream>

#include <vector>
#include <set>
#include <bitset>
#include <map>
#include <deque>
#include <string>

#include <algorithm>
#include <numeric>

#include <cstdio>
#include <cassert>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>

#define pb push_back
#define pbk pop_back
#define mp make_pair
#define fs first
#define sc second
#define all(x) (x).begin(), (x).end()
#define foreach(i, a) for (__typeof((a).begin()) i = (a).begin(); i != (a).end(); ++i)
#define len(a) ((int) (a).size())

#ifdef CUTEBMAING
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define eprintf(...) 42
#endif

using namespace std;

typedef long long int64;
typedef long double ld;
typedef unsigned long long lint;

const int inf = (1 << 30) - 1;
const int64 linf = (1ll << 62) - 1;
const int N = 1e5 + 100;

#define count _count

int n, m;
int ans[N];
vector<pair<int, int> > c[N];

inline int64 getSum(int n) {
    if (n <= 0) {
        return 0;
    }
    return 1ll * n * (n - 1) / 2;
}

inline int64 getSum(int a, int b) {
    if (a <= 0) {
        return getSum(-a) + getSum(b);
    }
    return getSum(b) - getSum(a - 1);
}

void solve(const vector<pair<int, int> > &c) {
    for (int i = 0; i < len(c); ) {
        if (c[i].fs != inf) {
            ans[c[i].sc] = c[i].fs;
            i++;
            continue;
        }
        int prev = i > 0 ? c[i - 1].fs : -inf;
        int it = i;
        while (it < len(c) && c[it].fs == inf) {
            it++;
        }
        int next;
        if (it == len(c)) {
            next = inf;
        } else {
            next = c[it].fs;
        }
        int count = it - i;
        if (next - prev - 1 < count) {
            puts("Incorrect sequence");
            exit(0);
        }
        if (count % 2 == 1 && prev < -((count - 1) / 2) && next > (count - 1) / 2) {
            for (int j = i; j < it; j++) {
                ans[c[j].sc] = j - i - (count - 1) / 2;
            }
        } else if (prev < -count / 2 + 1 && next > count / 2) {
            for (int j = i; j < it; j++) {
                ans[c[j].sc] = j - i - count / 2 + 1;
            }
        } else if (prev < -count / 2 && next > count / 2 + 1) {
            for (int j = i; j < it; j++) {
                ans[c[j].sc] = j - i - count / 2;
            }
        } else {
            if (getSum(prev + 1, prev + count) < getSum(next - count, next - 1)) {
                for (int j = i, cur = prev + 1; j < it; j++, cur++) {
                    ans[c[j].sc] = cur;
                }
            } else {
                for (int j = i, cur = next - count; j < it; j++, cur++) {
                    ans[c[j].sc] = cur;
                }
            }
        }
        i = it;
    }
}

int main() {
    assert(scanf("%d%d", &n, &m) == 2);
    for (int i = 0; i < n; i++) {
        static char buf[100];
        assert(scanf("%s", buf) == 1);
        if (*buf == '?') {
            c[i % m].pb(mp(inf, i));
        } else {
            int v; sscanf(buf, "%d", &v);
            c[i % m].pb(mp(v, i));
        }
    }
    for (int i = 0; i < n; i++) {
        solve(c[i]);
    }
    for (int i = 0; i <= n - m; i++) {
        if (ans[i] >= ans[i + m]) {
            puts("Incorrect sequence");
            return 0;
        }
    }
    for (int i = 0; i < n; i++) {
        printf("%d ", ans[i]);
    }
    puts("");
    return 0;
}


#include <vector>
#include <list>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <limits>
#include <tuple>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <iterator>
#include <string>
#include <fstream>
#include <stdio.h>
#define REP(k,a) for(int k=0; k < (a); ++k)
#define REPP(k,a,b) for(int k= (a); k < (b); ++k)
#define INF 200000000
#define mp make_pair
#define len(s) (int)((s).size())
#define pb push_back
#define all(X) (X).begin(), (X).end()
#define DRI(X) int (X); scanf("%d", &X)
#define DRII(X, Y) int X, Y; scanf("%d%d", &X, &Y)
#define DRIII(X, Y, Z) int X, Y, Z; scanf("%d%d%d", &X, &Y, &Z)

using namespace std;
typedef long long ll;
typedef unsigned int uint;
using vi = vector<int>;
using vii = vector<vector<int>>;
using pii = pair<int,int>;
template <class T>
void print(vector<T> v){ bool first=true; for(T x : v) { if(!first) cout << " "; first = false; cout << x; } cout << endl;}

ll toint(string x){
	bool negative=false;
	if(x[0] == '-') negative = true;
	ll ans = 0;
	for(char c : x){
		if(c == '-') continue;
		ans *= 10;
		ans += int(c-'0');
	}
	if(negative) ans *= -1;
	return ans;
}

int main(){
	DRII(n,k);
	vector<ll> a(n,0);
	vector<ll> bit(n+1,0);
	vector<bool> qm(n, false);

	REP(i, n){
		string x;
		cin >> x;
		if(x == "?"){
			a[i] = 0;
			qm[i] = true;
		}
		else{
			a[i] = toint(x);
		}
 	}

	bool possible = true;
	REP(i, k){
		if(!possible) break;
		int qm_start = -1;
		REP(j, n/k+1){
			if(k*j+i >= n) continue;
			if(qm[k*j+i] && k*(j+1)+i < n){
				if(qm_start == -1) qm_start = j;
			} else {
				if(qm_start != -1){
					ll before = k*(qm_start-1)+i >= 0 ? a[k*(qm_start-1)+i] : -100000000000000ll;
					ll after = (qm[k*j+i]) ? 100000000000000ll : a[k*j+i];
					ll s=0;
					ll length=j-qm_start;
					if(after-before < length){
						possible = false;
						break;
					}
					if(qm[k*j+i]) length++;
					if(before >= 0 && after >= 0){
						s = before+1;
					} else if(before < 0 && after < 0){

						s = after-(j-qm_start);
					} else{
						s = max(-length/2, before+1);
					}
					REP(r, length){
						a[i+k*(qm_start+r)] = s + r;
					}
				}
				qm_start = -1;
			}
		}
	}
	REP(i, k){
		if(!possible) break;
		REP(j, n/k){
			if(i+k*(j+1) >= n) continue;

			if(a[i+k*j] >= a[i+k*(j+1)]){
				possible = false;
				break;
			}
		}
	}
	if(possible){
		print(a);
	} else{
		cout << "Incorrect sequence" << endl;
	}
}


#include <vector>
#include <list>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <limits>
#include <tuple>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <iterator>
#include <string>
#include <fstream>
#include <stdio.h>
#define REP(k,a) for(int k=0; k < (a); ++k)
#define REPP(k,a,b) for(int k= (a); k < (b); ++k)
#define INF 200000000
#define mp make_pair
#define len(s) (int)((s).size())
#define pb push_back
#define all(X) (X).begin(), (X).end()
#define DRI(X) int (X); scanf("%d", &X)
#define DRII(X, Y) int X, Y; scanf("%d%d", &X, &Y)
#define DRIII(X, Y, Z) int X, Y, Z; scanf("%d%d%d", &X, &Y, &Z)

using namespace std;
typedef long long ll;
typedef unsigned int uint;
using vi = vector<int>;
using vii = vector<vector<int>>;
using pii = pair<int,int>;
template <class T>
void print(vector<T> v){ bool first=true; for(T x : v) { if(!first) cout << " "; first = false; cout << x; } cout << endl;}

ll toint(string x){
	bool negative=false;
	if(x[0] == '-') negative = true;
	ll ans = 0;
	for(char c : x){
		if(c == '-') continue;
		ans *= 10;
		ans += int(c-'0');
	}
	if(negative) ans *= -1;
	return ans;
}

int main(){
	DRII(n,k);
	vector<ll> a(n,0);
	vector<ll> bit(n+1,0);
	vector<bool> qm(n, false);

	REP(i, n){
		string x;
		cin >> x;
		if(x == "?"){
			a[i] = 0;
			qm[i] = true;
		}
		else{
			a[i] = toint(x);
		}
 	}

	bool possible = true;
	REP(i, k){
		if(!possible) break;
		int qm_start = -1;
		REP(j, n/k+1){
			if(k*j+i >= n) continue;
			if(qm[k*j+i] && k*(j+1)+i < n){
				if(qm_start == -1) qm_start = j;
			} else {
				if(qm_start != -1){
					ll before = k*(qm_start-1)+i >= 0 ? a[k*(qm_start-1)+i] : -100000000000000ll;
					ll after = (qm[k*j+i]) ? 100000000000000ll : a[k*j+i];
					ll s=0;
					ll length=j-qm_start;
					if(after-before < length){
						//possible = false;
						//break;
					}
					if(qm[k*j+i]) length++;
					if(before >= 0 && after >= 0){
						s = before+1;
					} else if(before < 0 && after < 0){

						s = after-(j-qm_start);
					} else{
						s = max(-length/2, before+1);
					}
					REP(r, length){
						a[i+k*(qm_start+r)] = s + r;
					}
				}
				qm_start = -1;
			}
		}
	}
	REP(i, k){
		if(!possible) break;
		REP(j, n/k){
			if(i+k*(j+1) >= n) continue;

			if(a[i+k*j] >= a[i+k*(j+1)]){
				possible = false;
				break;
			}
		}
	}
	if(possible){
		print(a);
	} else{
		cout << "Incorrect sequence" << endl;
	}
}


#include <vector>
#include <list>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <limits>
#include <tuple>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <iterator>
#include <string>
#include <fstream>
#include <stdio.h>
#define REP(k,a) for(int k=0; k < (a); ++k)
#define REPP(k,a,b) for(int k= (a); k < (b); ++k)
#define INF 200000000
#define mp make_pair
#define len(s) (int)((s).size())
#define pb push_back
#define all(X) (X).begin(), (X).end()
#define DRI(X) int (X); scanf("%d", &X)
#define DRII(X, Y) int X, Y; scanf("%d%d", &X, &Y)
#define DRIII(X, Y, Z) int X, Y, Z; scanf("%d%d%d", &X, &Y, &Z)

using namespace std;
typedef long long ll;
typedef unsigned int uint;
using vi = vector<int>;
using vii = vector<vector<int>>;
using pii = pair<int,int>;
template <class T>
void print(vector<T> v){ bool first=true; for(T x : v) { if(!first) cout << " "; first = false; cout << x; } cout << endl;}

// binary indexed tree
ll getSum(const vector<ll>& bitree, const int index){
	int i = index+1;
	ll ans=0;
	while(i > 0){
		ans += bitree[i];
		i -= (i & (-i));
	}
	return ans;
}

ll getSum(const int l, const int r, const vector<ll>& bitree){
	if(l == 0)
		return getSum(bitree, r);
	return getSum(bitree, r)-getSum(bitree, l-1);
}

void update(const int index, const ll value, vector<ll>& bitree){
	int i = index+1;
	int n=(int)bitree.size();
	while(i < n){
		bitree[i] += value;
		i += (i & (-i));
	}
}

ll toint(string x){
	bool negative=false;
	if(x[0] == '-') negative = true;
	ll ans = 0;
	for(char c : x){
		if(c == '-') continue;
		ans *= 10;
		ans += int(c-'0');
	}
	if(negative) ans *= -1;
	return ans;
}

int main(){
	DRII(n,k);
	vector<ll> a(n,0);
	vector<ll> bit(n+1,0);
	vector<bool> qm(n, false);
	vi qms(n, 0);

	REP(i, n){
		string x;
		cin >> x;
		if(x == "?"){
			a[i] = 0;
			qm[i] = true;
			qms.pb(i);
		}
		else{
			a[i] = toint(x);
			update(i, a[i], bit);
		}
 	}

	bool possible = true;
	REP(i, k){
		if(!possible) break;
		int qm_start = -1;
		REP(j, n/k+1){
			if(k*j+i >= n) continue;
			if(qm[k*j+i] && k*(j+1)+i < n){
				if(qm_start == -1) qm_start = j;
			} else {
				if(qm_start != -1){
					ll before = k*(qm_start-1)+i >= 0 ? a[k*(qm_start-1)+i] : -1E16;
					ll after = (qm[k*j+i]) ? 1E16 : a[k*j+i];
					ll s=0;
					ll length=j-qm_start;
					if(after-before < length){
						possible = false;
						break;
					}
					if(qm[k*j+i]) length++;
					if(before >= 0 && after >= 0){
						s = before+1;
					} else if(before < 0 && after < 0){

						s = after-(j-qm_start);
					} else{
						s = max(-length/2, before+1);
					}
					REP(r, length){
						a[i+k*(qm_start+r)] = s + r;
					}
				}
				qm_start = -1;
			}
		}
	}
	REP(i, k){
		if(!possible) break;
		REP(j, n/k){
			if(i+k*(j+1) >= n) continue;

			if(a[i+k*j] >= a[i+k*(j+1)]){
				possible = false;
				break;
			}
		}
	}
	if(possible){
		print(a);
	} else{
		cout << "Incorrect sequence" << endl;
	}
}


#include <vector>
#include <list>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <limits>
#include <tuple>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <iterator>
#include <string>
#include <fstream>
#include <stdio.h>
#define REP(k,a) for(int k=0; k < (a); ++k)
#define REPP(k,a,b) for(int k= (a); k < (b); ++k)
#define INF 200000000
#define mp make_pair
#define len(s) (int)((s).size())
#define pb push_back
#define all(X) (X).begin(), (X).end()
#define DRI(X) int (X); scanf("%d", &X)
#define DRII(X, Y) int X, Y; scanf("%d%d", &X, &Y)
#define DRIII(X, Y, Z) int X, Y, Z; scanf("%d%d%d", &X, &Y, &Z)

using namespace std;
typedef long long ll;
typedef unsigned int uint;
using vi = vector<int>;
using vii = vector<vector<int>>;
using pii = pair<int,int>;
template <class T>
void print(vector<T> v){ bool first=true; for(T x : v) { if(!first) cout << " "; first = false; cout << x; } cout << endl;}

ll toint(string x){
	bool negative=false;
	if(x[0] == '-') negative = true;
	ll ans = 0;
	for(char c : x){
		if(c == '-') continue;
		ans *= 10;
		ans += int(c-'0');
	}
	if(negative) ans *= -1;
	return ans;
}

int main(){
	DRII(n,k);
	vector<ll> a(n,0);
	vector<ll> bit(n+1,0);
	vector<bool> qm(n, false);

	REP(i, n){
		string x;
		cin >> x;
		if(x == "?"){
			a[i] = 0;
			qm[i] = true;
		}
		else{
			a[i] = toint(x);
		}
 	}

	bool possible = true;
	REP(i, k){
		if(!possible) break;
		int qm_start = -1;
		REP(j, n/k+1){
			if(k*j+i >= n) continue;
			if(qm[k*j+i] && k*(j+1)+i < n){
				if(qm_start == -1) qm_start = j;
			} else {
				if(qm_start != -1){
					ll before = k*(qm_start-1)+i >= 0 ? a[k*(qm_start-1)+i] : -100000000000000000ll;
					ll after = (qm[k*j+i]) ? 100000000000000000ll : a[k*j+i];
					ll s=0;
					ll length=j-qm_start;
					if(after-before < length){
						possible = false;
						break;
					}
					if(qm[k*j+i]) length++;
					if(before >= 0 && after >= 0){
						s = before+1;
					} else if(before < 0 && after < 0){

						s = after-(j-qm_start);
					} else{
						s = max(-length/2, before+1);
					}
					REP(r, length){
						a[i+k*(qm_start+r)] = s + r;
					}
				}
				qm_start = -1;
			}
		}
	}
	REP(i, k){
		if(!possible) break;
		REP(j, n/k){
			if(i+k*(j+1) >= n) continue;

			if(a[i+k*j] >= a[i+k*(j+1)]){
				possible = false;
				break;
			}
		}
	}
	if(possible){
		print(a);
	} else{
		cout << "Incorrect sequence" << endl;
	}
}


#include <vector>
#include <list>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <limits>
#include <tuple>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <iterator>
#include <string>
#include <fstream>
#include <stdio.h>
#define REP(k,a) for(int k=0; k < (a); ++k)
#define REPP(k,a,b) for(int k= (a); k < (b); ++k)
#define INF 200000000
#define mp make_pair
#define len(s) (int)((s).size())
#define pb push_back
#define all(X) (X).begin(), (X).end()
#define DRI(X) int (X); scanf("%d", &X)
#define DRII(X, Y) int X, Y; scanf("%d%d", &X, &Y)
#define DRIII(X, Y, Z) int X, Y, Z; scanf("%d%d%d", &X, &Y, &Z)

using namespace std;
typedef long long ll;
typedef unsigned int uint;
using vi = vector<int>;
using vii = vector<vector<int>>;
using pii = pair<int,int>;
template <class T>
void print(vector<T> v){ bool first=true; for(T x : v) { if(!first) cout << " "; first = false; cout << x; } cout << endl;}

ll toint(string x){
	bool negative=false;
	if(x[0] == '-') negative = true;
	ll ans = 0;
	for(char c : x){
		if(c == '-') continue;
		ans *= 10;
		ans += int(c-'0');
	}
	if(negative) ans *= -1;
	return ans;
}

int main(){
	DRII(n,k);
	vector<ll> a(n,0);
	vector<ll> bit(n+1,0);
	vector<bool> qm(n, false);

	REP(i, n){
		string x;
		cin >> x;
		if(x == "?"){
			a[i] = 0;
			qm[i] = true;
		}
		else{
			a[i] = toint(x);
		}
 	}

	bool possible = true;
	REP(i, k){
		if(!possible) break;
		int qm_start = -1;
		REP(j, n/k+1){
			if(k*j+i >= n) continue;
			if(qm[k*j+i] && k*(j+1)+i < n){
				if(qm_start == -1) qm_start = j;
			} else {
				if(qm_start != -1){
					ll before = k*(qm_start-1)+i >= 0 ? a[k*(qm_start-1)+i] : -100000000000000ll;
					ll after = (qm[k*j+i]) ? 100000000000000ll : a[k*j+i];
					ll s=0;
					ll length=j-qm_start;
					if(after-before < length){
						possible = false;
						break;
					}
					if(qm[k*j+i]) length++;
					if(before >= 0 && after >= 0){
						s = before+1;
					} else if(before < 0 && after < 0){

						s = after-(j-qm_start);
					} else{
						s = min(after-(j-qm_start), max(-length/2, before+1));
					}
					REP(r, length){
						a[i+k*(qm_start+r)] = s + r;
					}
				}
				qm_start = -1;
			}
		}
	}
	REP(i, k){
		if(!possible) break;
		REP(j, n/k){
			if(i+k*(j+1) >= n) continue;

			if(a[i+k*j] >= a[i+k*(j+1)]){
				possible = false;
				break;
			}
		}
	}
	if(possible){
		print(a);
	} else{
		cout << "Incorrect sequence" << endl;
	}
}


#include <vector>
#include <list>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <limits>
#include <tuple>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <iterator>
#include <string>
#include <fstream>
#include <stdio.h>
#define REP(k,a) for(int k=0; k < (a); ++k)
#define REPP(k,a,b) for(int k= (a); k < (b); ++k)
#define INF 200000000
#define mp make_pair
#define len(s) (int)((s).size())
#define pb push_back
#define all(X) (X).begin(), (X).end()
#define DRI(X) int (X); scanf("%d", &X)
#define DRII(X, Y) int X, Y; scanf("%d%d", &X, &Y)
#define DRIII(X, Y, Z) int X, Y, Z; scanf("%d%d%d", &X, &Y, &Z)

using namespace std;
typedef long long ll;
typedef unsigned int uint;
using vi = vector<int>;
using vii = vector<vector<int>>;
using pii = pair<int,int>;
template <class T>
void print(vector<T> v){ bool first=true; for(T x : v) { if(!first) cout << " "; first = false; cout << x; } cout << endl;}

ll toint(string x){
	bool negative=false;
	if(x[0] == '-') negative = true;
	ll ans = 0;
	for(char c : x){
		if(c == '-') continue;
		ans *= 10;
		ans += int(c-'0');
	}
	if(negative) ans *= -1;
	return ans;
}

int main(){
	DRII(n,k);
	vector<ll> a(n,0);
	vector<bool> qm(n, false);

	REP(i, n){
		string x;
		cin >> x;
		if(x == "?"){
			a[i] = 0;
			qm[i] = true;
		}
		else{
			a[i] = toint(x);
		}
 	}

	bool possible = true;
	REP(i, k){
		int j=0;
		while(true){
			if(i+k*j >= n) break;
			int length = 0;
			while(k*(j+length)+i < n && qm[k*(j+length)+i]){
				length++;
			}
			if(length > 0){
				ll before = (k*(j-1)+i >= 0) ? a[k*(j-1)+i] : -10e14;
				ll after = (k*(j+length)+i >= n) ? 10e14 : a[k*(j+length)+i];
				if(after-before < length){
					possible = false;
					break;
				}
				ll next=0;
				//cout << i << " " <<  j << " " << before << " " << after << endl;
				if(before >= 0){
					next = before+1;
				} else if(after <= 0){
					next = after-length;
				} else{
					next = min(after-length, max(before+1, -(ll)length/2));
				}
				REP(r, length){
					a[k*(j+r)+i] = next+r;
				}
				j += length;
			} else{
				j++;
			}
		}
	}
	REP(i, k){
		if(!possible) break;
		REP(j, n/k){
			if(i+k*(j+1) >= n) continue;

			if(a[i+k*j] >= a[i+k*(j+1)]){
				possible = false;
				break;
			}
		}
	}
	if(possible){
		print(a);
	} else{
		cout << "Incorrect sequence" << endl;
	}
}


#include <vector>
#include <list>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <limits>
#include <tuple>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <iterator>
#include <string>
#include <fstream>
#define REP(k,a) for(int k=0; k < (a); ++k)
#define REPP(k,a,b) for(int k= (a); k < (b); ++k)
#define INF 200000000
#define mp make_pair
#define len(s) (int)((s).size())
#define pb push_back
#define all(X) (X).begin(), (X).end()
#define DRI(X) int (X); scanf("%d", &X)
#define DRII(X, Y) int X, Y; scanf("%d%d", &X, &Y)
#define DRIII(X, Y, Z) int X, Y, Z; scanf("%d%d%d", &X, &Y, &Z)

using namespace std;
typedef long long ll;
typedef unsigned int uint;
using vi = vector<int>;
using vii = vector<vector<int>>;
using pii = pair<int,int>;

int main(){
	int n,t;
	double p;
	cin >> n >> p >> t;
	vector<vector<double>> dp(n+10, vector<double>(t+10, 0.0));
	dp[0][0] = 1.0;
	REPP(j, 1, t+1){
		REPP(i, 0, n+1){
			if(i >= n)
				dp[i][j] = dp[i][j-1];
			else
				dp[i][j] = (1-p)*dp[i][j-1];
			if(i > 0)
				dp[i][j] += p*dp[i-1][j-1];
		}
	}
	double E=0.0;
	REP(i, n+1){
		E += i*dp[i][t];
	}
	printf("%.7f\n", E);
	return 0;
}


#include <iostream>
#include <algorithm>
#include <cstring>
#include <cctype>
#include <vector>
#include <utility>

#define inf 1000000007ll
#define int long long int
using namespace std;

char sir[10000005];
int poz;

int lung;

inline void cit () {
    cin.get();
    cin.get(sir + 1, 10000005);

    poz = 1;
    lung = strlen(sir + 1);
}

inline int gett () {
    int ans = 0;
    while (poz <= lung && sir[poz] == ' ')
        poz ++;

    if (sir[poz] == '?') {
        poz ++;
        return (inf + 1);
    }

    int semn = 1;
    if (sir[poz] == '-') {
        poz ++;
        semn = -1;
    }

    while (poz <= lung && isdigit(sir[poz])) {
        ans *= 10;
        ans += sir[poz] - '0';
        poz ++;
    }

    return semn * ans;
}

int gauss (int n) {
    return (n * (n + 1ll) / 2);
}

int suma (int st, int dr) {
    if (st >= 0) {
        return gauss(dr) - gauss(st - 1);
    }
    else if (dr <= 0) {
        st *= -1;
        dr *= -1;

        swap(st, dr);

        return gauss(dr) - gauss(st - 1);
    }
    else {
        return suma(st, 0) + suma(0, dr);
    }
}

int best (int lung, int st, int dr) {
    //cout << "apel si aici " << st << ' ' << dr << endl;

    if (dr - st + 1 < lung)
        return inf + 7;

    int st_best = st;
    int ans_best = suma(st, st + lung - 1);

    if (suma(dr - lung + 1, dr) < ans_best) {
        st_best = dr - lung + 1;
        ans_best = suma(dr - lung + 1, dr);
    }

    int st_aux = - (lung - 1) / 2;
    int dr_aux = lung / 2;

    if (st_aux >= st && dr_aux <= dr) {
        if (suma(st_aux, dr_aux) < ans_best) {
            st_best = st_aux;
            ans_best = suma(st_aux, dr_aux);
        }
    }

    return st_best;
}

int v[100005];

vector <int> vects[100005];
vector <int> spec[100005];

inline bool create (vector<int> &v, vector<int> &spec) {
    for (int i = 0; i < v.size(); i++)
        if (v[i] != inf + 1)
            spec.push_back(i);

    for (int i = 1; i < spec.size(); i++)
        if (v[spec[i - 1]] >= v[spec[i]])
            return false;

    int y;
    int j, k;
    for (int i = 1; i < spec.size(); i++) {
        if (spec[i] - spec[i - 1] - 1 > 0) {
            y = best(spec[i] - spec[i - 1] - 1, v[spec[i - 1]] + 1, v[spec[i]] - 1);
            //cout << "apel " << spec[i] - spec[i - 1] - 1 << ' ' << v[spec[i - 1]] << ' ' << v[spec[i]] << endl;

            if (y == inf + 7)
                return false;

           // cout << "initial " << y << endl;
            for (j = spec[i - 1] + 1, k = y; j <= spec[i] - 1; j++, k++)
                v[j] = k;
        }
    }

    return true;
}

signed main()
{
    ios_base::sync_with_stdio(false);

    int n, k;
    cin >> n >> k;

    cit();

    for (int i = 1; i <= n; i++) {
        v[i] = gett();
        //cout << v[i] << endl;
    }

    for (int i = 0; i < k; i++)
        vects[i].push_back(-inf);

    for (int i = 1; i <= n; i++)
        vects[i % k].push_back(v[i]);

    for (int i = 0; i < k; i++)
        vects[i].push_back(inf);

    for (int i = 0; i < k; i++)
        if (!create(vects[i], spec[i])) {
            cout << "Incorrect sequence\n";
            return 0;
        }

    for (int i = 1; i <= n; i++) {
        v[i] = vects[i % k][(i - 1) / k + 1];
    }

    for (int i = 1; i <= n; i++)
        cout << v[i] << ' ';
    cout << endl;
    return 0;
}


#include <iostream>
#include <algorithm>
#include <cstring>
#include <cctype>
#include <vector>
#include <utility>

#define inf 1100000007ll
#define int long long int
using namespace std;

char sir[10000005];
int poz;
int lung;

inline void cit () {
    cin.get();
    cin.get(sir + 1, 10000005);

    poz = 1;
    lung = strlen(sir + 1);
}

inline int gett () {
    int ans = 0;
    while (poz <= lung && sir[poz] == ' ')
        poz ++;

    if (sir[poz] == '?') {
        poz ++;
        return (inf + 1);
    }

    int semn = 1;
    if (sir[poz] == '-') {
        poz ++;
        semn = -1;
    }

    while (poz <= lung && isdigit(sir[poz])) {
        ans *= 10;
        ans += sir[poz] - '0';
        poz ++;
    }

    return semn * ans;
}

int gauss (int n) {
    return (n * (n + 1ll) / 2);
}

int suma (int st, int dr) {
    if (st >= 0) {
        return gauss(dr) - gauss(st - 1);
    }
    else if (dr <= 0) {
        st *= -1;
        dr *= -1;

        swap(st, dr);

        return gauss(dr) - gauss(st - 1);
    }
    else {
        return suma(st, 0) + suma(0, dr);
    }
}

int best (int lung, int st, int dr) {
    //cout << "apel si aici " << st << ' ' << dr << endl;

    if (dr - st + 1 < lung)
        return inf + 7;

    int st_best = st;
    int ans_best = suma(st, st + lung - 1);

    if (suma(dr - lung + 1, dr) < ans_best) {
        st_best = dr - lung + 1;
        ans_best = suma(dr - lung + 1, dr);
    }

    int st_aux = - (lung - 1) / 2;
    int dr_aux = lung / 2;

    if (st_aux >= st && dr_aux <= dr) {
        if (suma(st_aux, dr_aux) < ans_best) {
            st_best = st_aux;
            ans_best = suma(st_aux, dr_aux);
        }
    }

    return st_best;
}

int v[100005];

vector <int> vects[100005];
vector <int> spec[100005];

inline bool create (vector<int> &v, vector<int> &spec) {
    for (int i = 0; i < v.size(); i++)
        if (v[i] != inf + 1)
            spec.push_back(i);

    for (int i = 1; i < spec.size(); i++)
        if (v[spec[i - 1]] >= v[spec[i]])
            return false;

    int y;
    int j, k;
    for (int i = 1; i < spec.size(); i++) {
        if (spec[i] - spec[i - 1] - 1 > 0) {
            y = best(spec[i] - spec[i - 1] - 1, v[spec[i - 1]] + 1, v[spec[i]] - 1);
            //cout << "apel " << spec[i] - spec[i - 1] - 1 << ' ' << v[spec[i - 1]] << ' ' << v[spec[i]] << endl;

            if (y == inf + 7)
                return false;

           // cout << "initial " << y << endl;
            for (j = spec[i - 1] + 1, k = y; j <= spec[i] - 1; j++, k++)
                v[j] = k;
        }
    }

    return true;
}

signed main()
{
    ios_base::sync_with_stdio(false);

    int n, k;
    cin >> n >> k;

    cit();

    for (int i = 1; i <= n; i++) {
        v[i] = gett();
        //cout << v[i] << endl;
    }

    for (int i = 0; i < k; i++)
        vects[i].push_back(-inf);

    for (int i = 1; i <= n; i++)
        vects[i % k].push_back(v[i]);

    for (int i = 0; i < k; i++)
        vects[i].push_back(inf);

    for (int i = 0; i < k; i++)
        if (!create(vects[i], spec[i])) {
            cout << "Incorrect sequence\n";
            return 0;
        }

    for (int i = 1; i <= n; i++) {
        v[i] = vects[i % k][(i - 1) / k + 1];
    }

    for (int i = 1; i <= n; i++)
        cout << v[i] << ' ';
    cout << endl;
    return 0;
}


#include <iostream>
#include <algorithm>
#include <cstring>
#include <cctype>
#include <vector>
#include <utility>

#define inf 4611686018427387903ll
#define int long long int
using namespace std;

char sir[10000005];
int poz;
int lung;

inline void cit () {
    cin.get();
    cin.get(sir + 1, 10000005);

    poz = 1;
    lung = strlen(sir + 1);
}

inline int gett () {
    int ans = 0;
    while (poz <= lung && sir[poz] == ' ')
        poz ++;

    if (sir[poz] == '?') {
        poz ++;
        return (inf + 1);
    }

    int semn = 1;
    if (sir[poz] == '-') {
        poz ++;
        semn = -1;
    }

    while (poz <= lung && isdigit(sir[poz])) {
        ans *= 10;
        ans += sir[poz] - '0';
        poz ++;
    }

    return semn * ans;
}

int gauss (int n) {
    return (n * (n + 1ll) / 2);
}

int suma (int st, int dr) {
    if (st >= 0) {
        return gauss(dr) - gauss(st - 1);
    }
    else if (dr <= 0) {
        st *= -1;
        dr *= -1;

        swap(st, dr);

        return gauss(dr) - gauss(st - 1);
    }
    else {
        return suma(st, 0) + suma(0, dr);
    }
}

int best (int lung, int st, int dr) {
    if (dr - st + 1 < lung)
        return inf + 7;

    int st_best = st;
    int ans_best = suma(st, st + lung - 1);

    if (suma(dr - lung + 1, dr) < ans_best) {
        st_best = dr - lung + 1;
        ans_best = suma(dr - lung + 1, dr);
    }

    int st_aux = - (lung - 1) / 2;
    int dr_aux = lung / 2;

    if (st_aux >= st && dr_aux <= dr) {
        if (suma(st_aux, dr_aux) < ans_best) {
            st_best = st_aux;
            ans_best = suma(st_aux, dr_aux);
        }
    }

    return st_best;
}

int v[100005];

vector <int> vects[100005];
vector <int> spec[100005];

inline bool create (vector<int> &v, vector<int> &spec) {
    for (int i = 0; i < v.size(); i++)
        if (v[i] != inf + 1)
            spec.push_back(i);

    for (int i = 1; i < spec.size(); i++)
        if (v[spec[i - 1]] >= v[spec[i]])
            return false;

    int y;
    int j, k;
    for (int i = 1; i < spec.size(); i++) {
        if (spec[i] - spec[i - 1] - 1 > 0) {
            y = best(spec[i] - spec[i - 1] - 1, v[spec[i - 1]] + 1, v[spec[i]] - 1);
            if (y == inf + 7)
                return false;

            for (j = spec[i - 1] + 1, k = y; j <= spec[i] - 1; j++, k++)
                v[j] = k;
        }
    }

    return true;
}

signed main()
{
    ios_base::sync_with_stdio(false);

    int n, k;
    cin >> n >> k;

    cit();

    for (int i = 1; i <= n; i++) {
        v[i] = gett();
        //cout << v[i] << endl;
    }

    for (int i = 0; i < k; i++)
        vects[i].push_back(-inf);

    for (int i = 1; i <= n; i++)
        vects[i % k].push_back(v[i]);

    for (int i = 0; i < k; i++)
        vects[i].push_back(inf);

    for (int i = 0; i < k; i++)
        if (!create(vects[i], spec[i])) {
            cout << "Incorrect sequence\n";
            return 0;
        }

    for (int i = 1; i <= n; i++) {
        v[i] = vects[i % k][(i - 1) / k + 1];
    }

    for (int i = 1; i <= n; i++)
        cout << v[i] << ' ';
    cout << endl;
    return 0;
}


#include <iostream>
#include <algorithm>
#include <cstring>
#include <cctype>
#include <vector>
#include <utility>

#define inf 1000000000000000007ll
#define int long long int
using namespace std;

char sir[10000005];
int poz;
int lung;

inline void cit () {
    cin.get();
    cin.get(sir + 1, 10000005);

    poz = 1;
    lung = strlen(sir + 1);
}

inline int gett () {
    int ans = 0;
    while (poz <= lung && sir[poz] == ' ')
        poz ++;

    if (sir[poz] == '?') {
        poz ++;
        return (inf + 1);
    }

    int semn = 1;
    if (sir[poz] == '-') {
        poz ++;
        semn = -1;
    }

    while (poz <= lung && isdigit(sir[poz])) {
        ans *= 10;
        ans += sir[poz] - '0';
        poz ++;
    }

    return semn * ans;
}

int gauss (int n) {
    return (n * (n + 1ll) / 2);
}

int suma (int st, int dr) {
    if (st >= 0) {
        return gauss(dr) - gauss(st - 1);
    }
    else if (dr <= 0) {
        st *= -1;
        dr *= -1;

        swap(st, dr);

        return gauss(dr) - gauss(st - 1);
    }
    else {
        return suma(st, 0) + suma(0, dr);
    }
}

int best (int lung, int st, int dr) {
    if (dr - st + 1 < lung)
        return inf + 7;

    int st_best = st;
    int ans_best = suma(st, st + lung - 1);

    if (suma(dr - lung + 1, dr) < ans_best) {
        st_best = dr - lung + 1;
        ans_best = suma(dr - lung + 1, dr);
    }

    int st_aux = - (lung - 1) / 2;
    int dr_aux = lung / 2;

    if (st_aux >= st && dr_aux <= dr) {
        if (suma(st_aux, dr_aux) < ans_best) {
            st_best = st_aux;
            ans_best = suma(st_aux, dr_aux);
        }
    }

    return st_best;
}

int v[100005];

vector <int> vects[100005];
vector <int> spec[100005];

inline bool create (vector<int> &v, vector<int> &spec) {
    for (int i = 0; i < v.size(); i++)
        if (v[i] != inf + 1)
            spec.push_back(i);

    for (int i = 1; i < spec.size(); i++)
        if (v[spec[i - 1]] >= v[spec[i]])
            return false;

    int y;
    int j, k;
    for (int i = 1; i < spec.size(); i++) {
        if (spec[i] - spec[i - 1] - 1 > 0) {
            y = best(spec[i] - spec[i - 1] - 1, v[spec[i - 1]] + 1, v[spec[i]] - 1);
            if (y == inf + 7)
                return false;

            for (j = spec[i - 1] + 1, k = y; j <= spec[i] - 1; j++, k++)
                v[j] = k;
        }
    }

    return true;
}

signed main()
{
    ios_base::sync_with_stdio(false);

    int n, k;
    cin >> n >> k;

    cit();

    for (int i = 1; i <= n; i++) {
        v[i] = gett();
        //cout << v[i] << endl;
    }

    for (int i = 0; i < k; i++)
        vects[i].push_back(-inf);

    for (int i = 1; i <= n; i++)
        vects[i % k].push_back(v[i]);

    for (int i = 0; i < k; i++)
        vects[i].push_back(inf);

    for (int i = 0; i < k; i++)
        if (!create(vects[i], spec[i])) {
            cout << "Incorrect sequence\n";
            return 0;
        }

    for (int i = 1; i <= n; i++) {
        v[i] = vects[i % k][(i - 1) / k + 1];
    }

    for (int i = 1; i <= n; i++)
        cout << v[i] << ' ';
    cout << endl;
    return 0;
}


#include <iostream>
#include <algorithm>
#include <cstring>
#include <cctype>
#include <vector>
#include <utility>

#define inf 4611686018427387703ll
#define int long long int
using namespace std;

char sir[10000005];
int poz;
int lung;

inline void cit () {
    cin.get();
    cin.get(sir + 1, 10000005);

    poz = 1;
    lung = strlen(sir + 1);
}

inline int gett () {
    int ans = 0;
    while (poz <= lung && sir[poz] == ' ')
        poz ++;

    if (sir[poz] == '?') {
        poz ++;
        return (inf + 1);
    }

    int semn = 1;
    if (sir[poz] == '-') {
        poz ++;
        semn = -1;
    }

    while (poz <= lung && isdigit(sir[poz])) {
        ans *= 10;
        ans += sir[poz] - '0';
        poz ++;
    }

    return semn * ans;
}

int gauss (int n) {
    return (n * (n + 1ll) / 2);
}

int suma (int st, int dr) {
    if (st >= 0) {
        return gauss(dr) - gauss(st - 1);
    }
    else if (dr <= 0) {
        st *= -1;
        dr *= -1;

        swap(st, dr);

        return gauss(dr) - gauss(st - 1);
    }
    else {
        return suma(st, 0) + suma(0, dr);
    }
}

int best (int lung, int st, int dr) {
    if (dr - st + 1 < lung)
        return inf + 7;

    int st_best = st;
    int ans_best = suma(st, st + lung - 1);

    if (suma(dr - lung + 1, dr) < ans_best) {
        st_best = dr - lung + 1;
        ans_best = suma(dr - lung + 1, dr);
    }

    int st_aux = - (lung - 1) / 2;
    int dr_aux = lung / 2;

    if (st_aux >= st && dr_aux <= dr) {
        if (suma(st_aux, dr_aux) < ans_best) {
            st_best = st_aux;
            ans_best = suma(st_aux, dr_aux);
        }
    }

    return st_best;
}

int v[100005];

vector <int> vects[100005];
vector <int> spec[100005];

inline bool create (vector<int> &v, vector<int> &spec) {
    for (int i = 0; i < v.size(); i++)
        if (v[i] != inf + 1)
            spec.push_back(i);

    for (int i = 1; i < spec.size(); i++)
        if (v[spec[i - 1]] >= v[spec[i]])
            return false;

    int y;
    int j, k;
    for (int i = 1; i < spec.size(); i++) {
        if (spec[i] - spec[i - 1] - 1 > 0) {
            y = best(spec[i] - spec[i - 1] - 1, v[spec[i - 1]] + 1, v[spec[i]] - 1);
            if (y == inf + 7)
                return false;

            for (j = spec[i - 1] + 1, k = y; j <= spec[i] - 1; j++, k++)
                v[j] = k;
        }
    }

    return true;
}

signed main()
{
    ios_base::sync_with_stdio(false);

    int n, k;
    cin >> n >> k;

    cit();

    for (int i = 1; i <= n; i++) {
        v[i] = gett();
        //cout << v[i] << endl;
    }

    for (int i = 0; i < k; i++)
        vects[i].push_back(-inf);

    for (int i = 1; i <= n; i++)
        vects[i % k].push_back(v[i]);

    for (int i = 0; i < k; i++)
        vects[i].push_back(inf);

    for (int i = 0; i < k; i++)
        if (!create(vects[i], spec[i])) {
            cout << "Incorrect sequence\n";
            return 0;
        }

    for (int i = 1; i <= n; i++) {
        v[i] = vects[i % k][(i - 1) / k + 1];
    }

    for (int i = 1; i <= n; i++)
        cout << v[i] << ' ';
    cout << endl;
    return 0;
}


#include <iostream>
#include <algorithm>
#include <cstring>
#include <cctype>
#include <vector>
#include <utility>

#define inf 4611686018427387903ll
#define int long long int
using namespace std;

char sir[10000005];

int poz;
int lung;

inline void cit () {
    cin.get();
    cin.get(sir + 1, 10000005);

    poz = 1;
    lung = strlen(sir + 1);
}

inline int gett () {
    int ans = 0;
    while (poz <= lung && sir[poz] == ' ')
        poz ++;

    if (sir[poz] == '?') {
        poz ++;
        return (inf + 1);
    }

    int semn = 1;
    if (sir[poz] == '-') {
        poz ++;
        semn = -1;
    }

    while (poz <= lung && isdigit(sir[poz])) {
        ans *= 10;
        ans += sir[poz] - '0';
        poz ++;
    }

    return semn * ans;
}

int gauss (int n) {
    return (n * (n + 1ll) / 2);
}

int suma (int st, int dr) {
    if (st >= 0) {
        return gauss(dr) - gauss(st - 1);
    }
    else if (dr <= 0) {
        st *= -1;
        dr *= -1;

        swap(st, dr);

        return gauss(dr) - gauss(st - 1);
    }
    else {
        return suma(st, 0) + suma(0, dr);
    }
}

int best (int lung, int st, int dr) {
    if (dr - st + 1 < lung)
        return inf + 7;

    int st_best = st;
    int ans_best = suma(st, st + lung - 1);

    if (suma(dr - lung + 1, dr) < ans_best) {
        st_best = dr - lung + 1;
        ans_best = suma(dr - lung + 1, dr);
    }

    int st_aux = - (lung - 1) / 2;
    int dr_aux = lung / 2;

    if (st_aux >= st && dr_aux <= dr) {
        if (suma(st_aux, dr_aux) < ans_best) {
            st_best = st_aux;
            ans_best = suma(st_aux, dr_aux);
        }
    }

    return st_best;
}

int v[100005];

vector <int> vects[100005];
vector <int> spec[100005];

inline bool create (vector<int> &v, vector<int> &spec) {
    for (int i = 0; i < v.size(); i++)
        if (v[i] != inf + 1)
            spec.push_back(i);

    for (int i = 1; i < spec.size(); i++)
        if (v[spec[i - 1]] >= v[spec[i]])
            return false;

    int y;
    int j, k;
    for (int i = 1; i < spec.size(); i++) {
        if (spec[i] - spec[i - 1] - 1 > 0) {
            y = best(spec[i] - spec[i - 1] - 1, v[spec[i - 1]] + 1, v[spec[i]] - 1);
            if (y == inf + 7)
                return false;

            for (j = spec[i - 1] + 1, k = y; j <= spec[i] - 1; j++, k++)
                v[j] = k;
        }
    }

    return true;
}

signed main()
{
    ios_base::sync_with_stdio(false);

    int n, k;
    cin >> n >> k;

    cit();

    for (int i = 1; i <= n; i++) {
        v[i] = gett();
        //cout << v[i] << endl;
    }

    for (int i = 0; i < k; i++)
        vects[i].push_back(-inf);

    for (int i = 1; i <= n; i++)
        vects[i % k].push_back(v[i]);

    for (int i = 0; i < k; i++)
        vects[i].push_back(inf);

    for (int i = 0; i < k; i++)
        if (!create(vects[i], spec[i])) {
            cout << "Incorrect sequence\n";
            return 0;
        }

    for (int i = 1; i <= n; i++) {
        v[i] = vects[i % k][(i - 1) / k + 1];
    }

    for (int i = 1; i <= n; i++)
        cout << v[i] << ' ';
    cout << endl;
    return 0;
}


#include <iostream>
#include <algorithm>
#include <cstring>
#include <cctype>
#include <vector>
#include <utility>

#define inf 1000000007
#define int long long int
using namespace std;

char sir[10000005];
int poz;
int lung;

inline void cit () {
    cin.get();
    cin.get(sir + 1, 10000005);

    poz = 1;
    lung = strlen(sir + 1);
}

inline int gett () {
    int ans = 0;
    while (poz <= lung && sir[poz] == ' ')
        poz ++;

    if (sir[poz] == '?') {
        poz ++;
        return (inf + 1);
    }

    int semn = 1;
    if (sir[poz] == '-') {
        poz ++;
        semn = -1;
    }

    while (poz <= lung && isdigit(sir[poz])) {
        ans *= 10;
        ans += sir[poz] - '0';
        poz ++;
    }

    return semn * ans;
}

int gauss (int n) {
    return (n * (n + 1ll) / 2);
}

int suma (int st, int dr) {
    if (st >= 0) {
        return gauss(dr) - gauss(st - 1);
    }
    else if (dr <= 0) {
        st *= -1;
        dr *= -1;

        swap(st, dr);

        return gauss(dr) - gauss(st - 1);
    }
    else {
        return suma(st, 0) + suma(0, dr);
    }
}

int best (int lung, int st, int dr) {
    if (dr - st + 1 < lung)
        return inf + 7;

    int st_best = st;
    int ans_best = suma(st, st + lung - 1);

    if (suma(dr - lung + 1, dr) < ans_best) {
        st_best = dr - lung + 1;
        ans_best = suma(dr - lung + 1, dr);
    }

    int st_aux = - (lung - 1) / 2;
    int dr_aux = lung / 2;

    if (st_aux >= st && dr_aux <= dr) {
        if (suma(st_aux, dr_aux) < ans_best) {
            st_best = st_aux;
            ans_best = suma(st_aux, dr_aux);
        }
    }

    return st_best;
}

int v[100005];

vector <int> vects[100005];
vector <int> spec[100005];

inline bool create (vector<int> &v, vector<int> &spec) {
    for (int i = 0; i < v.size(); i++)
        if (v[i] != inf + 1)
            spec.push_back(i);

    for (int i = 1; i < spec.size(); i++)
        if (v[spec[i - 1]] >= v[spec[i]])
            return false;

    int y;
    int j, k;
    for (int i = 1; i < spec.size(); i++) {
        if (spec[i] - spec[i - 1] - 1 > 0) {
            y = best(spec[i] - spec[i - 1] - 1, v[spec[i - 1]] + 1, v[spec[i]] - 1);
            if (y == inf + 7)
                return false;

            for (j = spec[i - 1] + 1, k = y; j <= spec[i] - 1; j++, k++)
                v[j] = k;
        }
    }

    return true;
}

signed main()
{
    ios_base::sync_with_stdio(false);

    int n, k;
    cin >> n >> k;

    cit();

    for (int i = 1; i <= n; i++) {
        v[i] = gett();
        //cout << v[i] << endl;
    }

    for (int i = 0; i < k; i++)
        vects[i].push_back(-inf);

    for (int i = 1; i <= n; i++)
        vects[i % k].push_back(v[i]);

    for (int i = 0; i < k; i++)
        vects[i].push_back(inf);

    for (int i = 0; i < k; i++)
        if (!create(vects[i], spec[i])) {
            cout << "Incorrect sequence\n";
            return 0;
        }

    for (int i = 1; i <= n; i++) {
        v[i] = vects[i % k][(i - 1) / k + 1];
    }

    for (int i = 1; i <= n; i++)
        cout << v[i] << ' ';
    cout << endl;
    return 0;
}