let MOD = pown 10 9 |> (+)7 |> int64 let (|ODD|EVE|) x = if x%2L=0L then EVE else ODD let R() = stdin.ReadLine() let solve cs ds = let rec f score cs ds = match cs, ds with | [], _ | _, [] -> score | c::cs, d::ds -> match c with | EVE -> f ((score+(c%MOD/2L)*d%MOD)%MOD) cs ds | ODD -> f ((score+(c%MOD/2L+1L)*d%MOD)%MOD) cs ds f 0L cs ds let N = R() |> int let C, D = let t = List.init N (fun _ -> let t = R().Split() int64 t.[0], int64 t.[1]) let c = t |> List.map fst let d = t |> List.map snd c, d solve C D |> stdout.WriteLine