from math import gcd mod = 10 ** 9 + 7 N = int(input()) M = int(input()) A = list(map(int, input().split())) B = list(map(int, input().split())) ans = 0 for b in B: for a in A: ans += a * (b + 1) % mod ans -= b - gcd(a, b) ans %= mod print(ans)