import math, sequtils, strscans, sugar let input = stdin.lines.toseq xs = newSeq.collect: for i, str in input: if i == 0: continue let (_, a, b) = str.scanTuple"$i $i" a + b * 4 max = max xs xs2 = xs.mapIt(max.pred it) sum = xs2.sum echo: if xs2.allIt (it mod 2) == 0: sum div 2 else: -1