Problem: This problem is different with easy version only by constraints on total answers length

It is an interactive problem

Venya joined a tour to the madhouse, in which orderlies play with patients the following game. Orderlies pick a string s of length n, consisting only of lowercase English letters. The player can ask two types of queries: 

  * ? l r – ask to list all substrings of s[l..r]. Substrings will be returned in random order, and in every substring, all characters will be randomly shuffled. 
  * ! s – guess the string picked by the orderlies. This query can be asked exactly once, after that the game will finish. If the string is guessed correctly, the player wins, otherwise he loses. 



The player can ask no more than 3 queries of the first type.

To make it easier for the orderlies, there is an additional limitation: the total number of returned substrings in all queries of the first type must not exceed \left⌈ 0.777(n+1)^2 \right⌉ (⌈ x ⌉ is x rounded up).

Venya asked you to write a program, which will guess the string by interacting with the orderlies' program and acting by the game's rules.

Your program should immediately terminate after guessing the string using a query of the second type. In case your program guessed the string incorrectly, or it violated the game rules, it will receive verdict Wrong answer.

Note that in every test case the string is fixed beforehand and will not change during the game, which means that the interactor is not adaptive.

Input

First line contains number n (1 ≤ n ≤ 100) — the length of the picked string.

Interaction

You start the interaction by reading the number n.

To ask a query about a substring from l to r inclusively (1 ≤ l ≤ r ≤ n), you should output

? l r

on a separate line. After this, all substrings of s[l..r] will be returned in random order, each substring exactly once. In every returned substring all characters will be randomly shuffled.

In the case, if you ask an incorrect query, ask more than 3 queries of the first type or there will be more than \left⌈ 0.777(n+1)^2 \right⌉ substrings returned in total, you will receive verdict Wrong answer.

To guess the string s, you should output

! s

on a separate line.

After printing each query, do not forget to flush the output. Otherwise, you will get Idleness limit exceeded. To flush the output, you can use: 

  * fflush(stdout) or cout.flush() in C++; 
  * System.out.flush() in Java; 
  * flush(output) in Pascal; 
  * stdout.flush() in Python; 
  * see documentation for other languages. 



If you received - (dash) as an answer to any query, you need to terminate your program with exit code 0 (for example, by calling exit(0)). This means that there was an error in the interaction protocol. If you don't terminate with exit code 0, you can receive any unsuccessful verdict. 

Hack format

To hack a solution, use the following format:

The first line should contain one integer n (1 ≤ n ≤ 100) — the length of the string, and the following line should contain the string s.

Example

Input


4

a
aa
a

cb
b
c

c

Output


? 1 2

? 3 4

? 4 4

! aabc

Solution (in JAVA):

Solution:
//package main;
import java.io.*;
import java.util.*;
import java.lang.*;
import java.math.*;
public class Submission {
    public static void main(String[] args) throws IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter (System.out);
        //BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream("input.txt")));
    	StringTokenizer st = new StringTokenizer(reader.readLine()," ");
    	int answered=0;
    	int n = Integer.parseInt(st.nextToken());
    	if (n>3) {
    	int[] vals = new int[26];
    	int[] answer= new int[n];
    	for (int i=0;i<n;i++) answer[i]=-1;
    	int[][] instancesOfSize = new int[26][n+1];
    	out.println("? 1 "+n);
    	out.flush();
    	for (int i=0;i<n*(n+1)/2;i++) {
    		String s = reader.readLine();
    		if (s.length()==1) vals[s.charAt(0)-'a']++;
    		if (s.length()<=(n+1)/2) 
    			for (int j=0;j<s.length();j++)
    				instancesOfSize[s.charAt(j)-'a'][s.length()]++;
    	}
    	int secGoSize = (n+3)/2;
    	int[][] secGoInstancesOfSize = new int[26][n+1]; // iterations at size of letter for left
    	out.println("? 1 "+secGoSize);
    	out.flush();
    	for (int i=0;i<secGoSize*(secGoSize+1)/2;i++) {
    		String s = reader.readLine();
    		if (s.length()<=(secGoSize+1)/2) 
    			for (int j=0;j<s.length();j++)
    				secGoInstancesOfSize[s.charAt(j)-'a'][s.length()]++;
    		if (s.length()==1) vals[s.charAt(0)-'a']--;
    	}
    	int thdGoSize = (n)/2;
    	int[][] thdGoInstancesOfSize = new int[26][n+1]; // iterations at size of letter for left
    	out.println("? "+secGoSize+" "+n);
    	out.flush();
    	for (int i=0;i<thdGoSize*(thdGoSize+1)/2;i++) {
    		String s = reader.readLine();
    		if (s.length()<=(thdGoSize+1)/2) 
    			for (int j=0;j<s.length();j++)
    				thdGoInstancesOfSize[s.charAt(j)-'a'][s.length()]++;
    		if (s.length()==1) vals[s.charAt(0)-'a']--;
    	}
    	int mid=0;
    	for (int i=0;i<26;i++)
    		if (vals[i]==-1) mid=i;
    	for (int i=0;i<n;i++)
    		secGoInstancesOfSize[mid][i+1]--;
    	for (int i=0;i<n;i++)
    		thdGoInstancesOfSize[mid][i+1]--;
    	
    	
    	//second doubles run
    	List<List<Integer>> secDoubles = new ArrayList<>();
    	for (int i=0;i<=n;i++) secDoubles.add(new ArrayList<>());
    	for (int i=0;i<=(secGoSize+1)/2;i++) secDoubles.add(new ArrayList<>());
    	for (int i=2;i<=(secGoSize+1)/2;i++) {
    		for (int j=0;j<26;j++) {
    			if (secGoInstancesOfSize[j][i]%i!=0) {
    				//out.println((char)(j+'a')+" "+i+" "+instancesOfSize[j][i]);
    				secDoubles.get(i-1).add(j);
    				for (int k=0;k<=secGoSize;k++) secGoInstancesOfSize[j][k]-=(i-1);
    			}
    			if (secGoInstancesOfSize[j][i]%i!=0) { //again! for doubles
    				//out.println(j+"XX"+i);
    				secDoubles.get(i-1).add(j);
    				for (int k=0;k<=secGoSize;k++) secGoInstancesOfSize[j][k]-=(i-1);
    			}
    		}
    	}
    	for (int i=0;i<26;i++) {
    		if (secGoInstancesOfSize[i][(secGoSize+1)/2]!=0) {
    			secGoInstancesOfSize[i][(secGoSize+1)/2]-=(secGoSize+1)/2;
    			secDoubles.get((secGoSize+1)/2).add(i);
    		}
    		if (secGoInstancesOfSize[i][(secGoSize+1)/2]!=0) {//again!
    			secGoInstancesOfSize[i][(secGoSize+1)/2]-=(secGoSize+1)/2;
    			secDoubles.get((secGoSize+1)/2).add(i);
    		}
    	}
    	int first = secDoubles.get(1).get(0);
    	secDoubles.get(1).remove(0);
    	secDoubles.get(1).add(mid);
    	answer[0]=first;
    	answered++;
    	
    	

    	//THIRD doubles run
    	List<List<Integer>> thdDoubles = new ArrayList<>();
    	for (int i=0;i<=n;i++) thdDoubles.add(new ArrayList<>());
    	for (int i=0;i<=(thdGoSize+1)/2;i++) thdDoubles.add(new ArrayList<>());
    	for (int i=2;i<=(thdGoSize+1)/2;i++) {
    		for (int j=0;j<26;j++) {
    			if (thdGoInstancesOfSize[j][i]%i!=0) {
    				//out.println((char)(j+'a')+" "+i+" "+instancesOfSize[j][i]);
    				thdDoubles.get(i-1).add(j);
    				for (int k=0;k<=thdGoSize;k++) thdGoInstancesOfSize[j][k]-=(i-1);
    			}
    			if (thdGoInstancesOfSize[j][i]%i!=0) { //again! for doubles
    				//out.println(j+"XX"+i);
    				thdDoubles.get(i-1).add(j);
    				for (int k=0;k<=thdGoSize;k++) thdGoInstancesOfSize[j][k]-=(i-1);
    			}
    		}
    	}
    	for (int i=0;i<26;i++) {
    		if (thdGoInstancesOfSize[i][(thdGoSize+1)/2]!=0) {
    			thdGoInstancesOfSize[i][(thdGoSize+1)/2]-=(thdGoSize+1)/2;
    			thdDoubles.get((thdGoSize+1)/2).add(i);
    		}
    		if (thdGoInstancesOfSize[i][(thdGoSize+1)/2]!=0) {//again!
    			thdGoInstancesOfSize[i][(thdGoSize+1)/2]-=(thdGoSize+1)/2;
    			thdDoubles.get((thdGoSize+1)/2).add(i);
    		}
    	}
    	thdDoubles.get(1).add(mid);
    	
    	
    	
    	//first double-ifier
    	for (int i=0;i<=secGoSize;i++)
    		instancesOfSize[first][i+1]--;
    	List<List<Integer>> fstDoubles = new ArrayList<>();
    	for (int i=0;i<n+1;i++) fstDoubles.add(new ArrayList<>());
    	for (int i=0;i<=(n+1)/2;i++) fstDoubles.add(new ArrayList<>());
    	for (int i=2;i<=(n+1)/2;i++) {
    		for (int j=0;j<26;j++) {
    			//if (j==1) System.out.println(instancesOfSize[j][i]+" "+i);
    			if (instancesOfSize[j][i]%i!=0) {
    				//out.println((char)(j+'a')+" "+i+" "+instancesOfSize[j][i]);
    				fstDoubles.get(i-1).add(j);
    				for (int k=0;k<=n;k++) instancesOfSize[j][k]-=(i-1);
    			}
    			if (instancesOfSize[j][i]%i!=0) { //again! for doubles
    				//out.println(j+"XX"+i);
    				fstDoubles.get(i-1).add(j);
    				for (int k=0;k<=n;k++) instancesOfSize[j][k]-=(i-1);
    			}
    		}
    	}
    	for (int i=0;i<26;i++) {
    		if (instancesOfSize[i][(n+1)/2]!=0) {
    			instancesOfSize[i][(n+1)/2]-=(n+1)/2;
    			fstDoubles.get((n+1)/2).add(i);
    		}
    		if (instancesOfSize[i][(n+1)/2]!=0) {//again!
    			instancesOfSize[i][(n+1)/2]-=(n+1)/2;
    			fstDoubles.get((n+1)/2).add(i);
    		}
    	}
    	//for (int i=0;i<fstDoubles.get((n+1)/2).size();i++) System.out.println(fstDoubles.get((n+1)/2).get(i));
    	
    	//WE DID ITTT
    	/*System.out.println("hh");
    	for (int i=0;i<fstDoubles.size();i++) {
    		if (fstDoubles.get(i).size()>0) System.out.print(i+" ");
    		for (int j=0;j<fstDoubles.get(i).size();j++) System.out.print(fstDoubles.get(i).get(j)+" ");
    		if (fstDoubles.get(i).size()>0) System.out.println();
    	}
    	System.out.println();
    	for (int i=0;i<secDoubles.size();i++) {
    		if (secDoubles.get(i).size()>0) System.out.print(i+" ");
    		for (int j=0;j<secDoubles.get(i).size();j++) System.out.print(secDoubles.get(i).get(j)+" ");
    		if (secDoubles.get(i).size()>0) System.out.println();
    	}
    	System.out.println();
    	for (int i=0;i<thdDoubles.size();i++) {
    		if (thdDoubles.get(i).size()>0) System.out.print(i+" ");
    		for (int j=0;j<thdDoubles.get(i).size();j++) System.out.print(thdDoubles.get(i).get(j)+" ");
    		if (thdDoubles.get(i).size()>0) System.out.println();
    	}
    	System.out.println();*/
    	//System.out.println(answered);
    	//System.out.println(thdDoubles.get(2).size());
    	int count=0;
    	while (answered<n) {
    		
    		for (int i=1;i<=(n+1)/2;i++) {
    			/*count++;
        		if (count<1000) {
        		for (int j=0;j<n;j++) System.out.print((char)(answer[j]+'a')+" ");
        		System.out.println();}*/
    			if (fstDoubles.get(i).size()==1) {
    				//System.out.println(fstDoubles.get(i).get(0));
    				answered++;
    				int j = fstDoubles.get(i).get(0);
    				fstDoubles.get(i).remove(0);
    				if (answer[i-1]==-1) {
    					answer[i-1]=j;
    					int x = Math.min(i,secGoSize+1-i);
    					if (secDoubles.get(x).contains(j)) secDoubles.get(x).remove(secDoubles.get(x).indexOf(j));
    				}
    				else {
    					answer[n-i]=j;
    					int x = Math.min(n-i+1-secGoSize+1,thdGoSize+1-(n-i+1-secGoSize+1));
    					if (thdDoubles.get(x).contains(j)) thdDoubles.get(x).remove(thdDoubles.get(x).indexOf(j));
    				}
    			}
    			
    			if (secDoubles.get(i).size()==1) {
    				answered++;
    				//System.out.println("zzz");
    				int j = secDoubles.get(i).get(0);
    				secDoubles.get(i).remove(0);
    				if (answer[i-1]==-1) {
    					answer[i-1]=j;
    					if (fstDoubles.get(i).contains(j)) fstDoubles.get(i).remove(fstDoubles.get(i).indexOf(j));
    				}
    				else {
    					answer[secGoSize-i]=j;
    					int x = Math.min(secGoSize-i+1, n+1-(secGoSize-i+1));
    					if (fstDoubles.get(x).contains(j)) fstDoubles.get(x).remove(fstDoubles.get(x).indexOf(j));
    					if (i==1)
    						if (thdDoubles.get(1).contains(j)) thdDoubles.get(1).remove(thdDoubles.get(1).indexOf(j));
    				}
    			}
    			
    			if (thdDoubles.get(i).size()==1) {
    				answered++;
    				int j = thdDoubles.get(i).get(0);
    				thdDoubles.get(i).remove(0);
    				if (answer[secGoSize+i-1-1]==-1) {
        				//System.out.println("j");
    					answer[secGoSize+i-1-1]=j;
    					if (fstDoubles.get(n-(secGoSize+i-1)+1).contains(j)) fstDoubles.get(n-(secGoSize+i-1)+1).remove(fstDoubles.get(n-(secGoSize+i-1)+1).indexOf(j));
    					if (i==1) {
    						//System.out.println(i+" "+j);
    						if (secDoubles.get(1).contains(j)) secDoubles.get(1).remove(secDoubles.get(1).indexOf(j));
    					}
    				}
    				else {
    					answer[n-1-i+1]=j;
    					if (fstDoubles.get(i).contains(j)) fstDoubles.get(i).remove(fstDoubles.get(i).indexOf(j));
    				}
    			}
    		}
    	}
    	out.print("! ");
    	for (int i=0;i<n;i++) out.print((char)(answer[i]+'a'));
    	out.println();
    	out.flush();
    	} else {
    		String s = "";
    		for (int i=0;i<n;i++) {
    			out.println("? "+(i+1)+" "+(i+1));
    			out.flush();
    			s+=reader.readLine();
    		}
    		out.println("! "+s);
    		out.flush();
    	}
        reader.close();
        out.close();
    }
}