import sequtils,algorithm template times*(n:int,body) = (for _ in 0.." .} proc scan(): int = while true: let k = getchar_unlocked() if k < '0': break result = 10 * result + k.ord - '0'.ord template useRollingHash() = type RollingHash = object A,B: seq[int] AP,BP: seq[int] modA,modB : int baseA,baseB : int proc initRollingHash( S:string, baseA:int=17, baseB:int=19, modA:int=1_0000_0000_7.int, modB:int=1_0000_0000_9.int) : RollingHash = result.baseA = baseA result.baseB = baseB result.modA = modA result.modB = modB result.A = newSeq[int](S.len + 1) # baseA 進数表示した時の値 result.B = newSeq[int](S.len + 1) result.AP = newSeq[int](S.len + 1) # base^n result.BP = newSeq[int](S.len + 1) result.AP[0] = 1 result.BP[0] = 1 for i in 0..