def ris() gets.split.map &:to_i end def ri() gets.to_i end MOD = 1_000_000_007 # 998_244_353 s = 0 ri.times{ c,d=ris s+=(c+1)/2*d } p s % MOD