# 先頭から長さ4の部分文字列を確定させることを考える # 他の部分は固定して、先頭だけaaaaからzzzzまで26通り試すことで先頭4文字に含まれる英子文字がわかる(順番はまだわからない) # ↑でわかった英子文字でつくれる候補を全通り(4文字の場合、4種なら4!、3種なら3×(4!/2)、2種なら2×(4!/3!)+2×(4!/2!2!)、1種なら1)調べれば位置もわかる # これを末尾まで繰り返すことで最大でも(26+36)*(100/4)クエリでできそう import collections import itertools def count_match(s1, s2="gga"): cnt = 0 for i in range(len(s1)): if s1[i]==s2[i]: cnt += 1 return cnt N = int(input()) abc = [chr(ord("a")+i) for i in range(26)] s = "x"*N for i in range((N+3)//4): if N%4!=0 and i==(N+3)//4-1: chnum = N%4 else: chnum = 4 r1 = {} for ch in abc: s = s[:4*i] + ch*chnum + s[4*(i+1):] print("? "+s) r1[ch] = int(input()) #r1[ch] = count_match(s) matched = collections.Counter(r1.values()).most_common() cands = [] for c in matched[1:]: for k, v in r1.items(): if c[0]==v: cands.append(k) if len(cands)==4: perm = ["".join(p) for p in list(itertools.permutations(cands))] elif len(cands)==3: perm = [] if chnum==4: for c in cands: perm += list(set(["".join(p) for p in list(itertools.permutations(list(cands)+[c,]))])) else: perm = ["".join(p) for p in list(itertools.permutations(cands))] elif len(cands)==2: perm = [] if chnum==4: for c in cands: perm += list(set(["".join(p) for p in list(itertools.permutations(list(cands)+[c,c,]))])) perm += list(set(["".join(p) for p in list(itertools.permutations(list(cands)+list(cands)))])) elif chnum==3: for c in cands: perm += list(set(["".join(p) for p in list(itertools.permutations(list(cands)+[c,]))])) else: perm = ["".join(p) for p in list(itertools.permutations(cands))] else: perm = [cands[0]*chnum] ans = "" max_match = 0 for p in perm: print("? "+s[:4*i] + p + s[4*(i+1):]) matched = int(input()) #matched = count_match(s[:4*i] + p + s[4*(i+1):]) if matched > max_match: ans = p max_match = matched s = s[:4*i] + ans + s[4*(i+1):] print("! "+s)