#include <bits/stdc++.h>

using namespace std;

void solveA(){
    int n, m ;
    scanf("%d%d", &n, &m);
    char k[n][m];
    int ra_n[n], ra_m[m];
    int factor_delete[n][m];
    for(int i = 0; i < n; ++i)ra_n[i] = 0;
    for(int j = 0; j < m; ++j)ra_m[j] = 0;
    for(int i = 0; i < n; ++i){
        scanf("\n");
        for(int j = 0; j < m; ++j){
            scanf("%c", &k[i][j]);
            //cerr << k[i][j];
        }
    }
    int new_i, new_j;
    int ans = 0;
    int curr = 0;
    for(int i = 0; i < n; ++i){
        for(int j = 0; j < m; ++j){
            new_i = i;
            new_j = j;
            ++new_i;
            ++new_j;
            if(new_i == n)new_i = 0;
            if(new_j == m)new_j = 0;
            if(k[i][j] == k[new_i][new_j] && k[i][j] == k[new_i][j] && k[i][j] == k[i][new_j]){
                ++ra_n[new_i];
                ++ra_m[new_j];
                ++curr;
                factor_delete[i][j] = 1;
            }
            else factor_delete[i][j] = 0;
        }
    }
    for(int i = 0; i < n; ++i){
        new_i = i;
        ++new_i;
        if(new_i == n)new_i = 0;
        curr -= ra_n[new_i];
        for(int j = 0; j < m; ++j){
            new_j = j;
            ++new_j;
            if(new_j == m)new_j = 0;
            curr -= ra_m[new_j];
            ans = max(curr + factor_delete[i][j], ans);
            curr += ra_m[new_j];

        }

        curr += ra_n[new_i];
    }
    cout << ans << endl;
}

inline int ask(int from, int to){
    printf("? %d %d\n", from, to);
    fflush(stdout);
    int ans;
    scanf("%d", &ans);
    return ans;
}

void solveB(){
    int n;
    scanf("%d", &n);
    int k;
    k = ask(1, n);
    int u = 1, l = 1, r = n, mid;
    int ans[n + 1];
    memset(ans, 0, n * sizeof(int));
    ans[0] = k;
    while(u <= n){
            if(u == n){
                ans[n] = k;
                break;
            }
        l = u;
        r = n;
        while(l != r){
            mid = (l + r + 1) / 2;
            if(ask(l, mid) == 1){
                l = mid;
            }
            else r = mid - 1;
            mid = (l + r + 1) / 2;
        }
        //cerr << "MID!:" << mid << endl;
        for(; u <= mid; ++u){
            ans[u] = k;
        }
        --k;
    }
    printf("Ready!\n%d\n", ans[0]);
    fflush(stdout);
    for(int i = 1; i <= n; ++i){
        printf("%d ", ans[i]);
        fflush(stdout);
    }
}

int main(){
/*
    freopen("video.in", "r", stdin);
    freopen("video.out", "w", stdout);
    solveA();
*/
    solveB();
    return 0;
}
