#{{{ header import algorithm, sequtils, tables, macros, math, sets, strutils, deques when defined(MYDEBUG): import header import deques var cin = initDeque[string]() proc get(cin:var Deque[string]):string = while cin.len == 0: for s in stdin.readLine.split(' '): if s.len > 0: cin.addLast(s) return cin.popFirst proc nextInt(cin:var Deque[string]):int = cin.get.parseInt proc nextFloat(cin:var Deque[string]):float = cin.get.parseFloat proc nextString(cin:var Deque[string]):string = cin.get template `max=`*(x,y:typed):void = x = max(x,y) template `min=`*(x,y:typed):void = x = min(x,y) template infty(T): untyped = ((T(1) shl T(sizeof(T)*8-2)) - 1) #}}} proc test(x,y:int):int = echo "? ",x," ",y let ans = cin.nextInt() return ans proc main() = let N = cin.nextInt() var v = initDeque[(int,seq[int])]() for i in 1..N: v.addLast((i,@[])) while v.len > 1: var v2 = initDeque[(int,seq[int])]() while v.len > 0: if v.len == 1: v2.addLast(v.popLast) else: var s,t = v.popLast let r = test(s[0],t[0]) if r == s[0]: s[1].add(t[0]) v2.addLast(s) else: t[1].add(s[0]) v2.addLast(t) v = v2 var w = v.popFirst[1] var cur = w[0] for i in 1..