import java.util.*; public class Run { final static int M = 1000000007; public static void main (String arg[]) { Scanner scan = new Scanner(System.in); int N = scan.nextInt(); String C, D; int c ,d; long ans = 0; for (int i = 0; i < N; i++) { c = d = 0; C = scan.next(); D = scan.next(); for (int j = 0; j < C.length(); j++) c = (c*10 + Integer.valueOf(C.substring(j, j+1))) % M; for (int j = 0; j < D.length(); j++) d = (d*10 + Integer.valueOf(D.substring(j, j+1))) % M; c = (c + 1)/2; ans += (c * d) % M; } System.out.println(ans); } }