import sequtils,algorithm,tables,strutils template `^`(n:int) : int = (1 shl n) proc getchar_unlocked():char {. importc:"getchar_unlocked",header: "" .} proc scan(): int = while true: let k = getchar_unlocked() if k < '0': return result = 10 * result + k.ord - '0'.ord proc build(P:seq[int],carry:int = 1) : Table[int,seq[string]] = result = initTable[int,seq[string]]() for x in 0 ..< ^P.len: var total = 0 var pair = "" for j in 0.. 0 : total += P[j] pair &= $(j+carry) & " " if total notin result: result[total] = @[] result[total] &= pair let n = scan() let s = scan() let P = newSeqWith(n,scan()) if n == 1: quit "1",0 let P1 = P[0..