import sequtils,strutils,algorithm,math,sugar,macros,strformat import sets,tables,intsets,queues,heapqueue,bitops template `max=`*(x,y) = x = max(x,y) template `min=`*(x,y) = x = min(x,y) proc getchar_unlocked():char {. importc:"getchar_unlocked",header: "" .} proc scan(): int = while true: let k = getchar_unlocked() if k < '0': break result = 10 * result + k.ord - '0'.ord let n = scan() let K = newSeqWith(n,scan()) type Win = tuple[a,b,c:int,win:bool] proc isWin(K:seq[int]):Win = if K.len < 3 : return (0,0,0,false) var results = newSeq[Win]() for a in 0.. K[c]) or (K[a] > K[b] and K[b] < K[c])) : continue let K2 = K[0..