import java.util.Scanner; // 一维DP的优化 public class Main { static int MOD = (int)(1e9 + 7); public static void main(String[] args) { Scanner in = new Scanner(System.in); // 注意 hasNext 和 hasNextLine 的区别 int l1 = in.nextInt(); int l2 = in.nextInt(); int[] nums1 = new int[l1]; int[] nums2 = new int[l2]; int aim = in.nextInt(); for (int i = 0; i < l1; i++){ nums1[i] = in.nextInt(); } for (int i = 0; i < l2; i++){ nums2[i] = in.nextInt(); } long res = 0; if (l1 == 0 && l2 == 0){ res = aim == 0 ? 1:0; System.out.print(res); } long[] dp1 = allBagFunc(nums1, aim); long[] dp2 = zeroOneBagFunc(nums2, aim); for ( int i = 0; i <= aim; i++){ res += dp1[i] * dp2[aim-i]; res %= MOD; } System.out.print(res); } public static long[] allBagFunc(int[] arr, int aim){ long[] dp = new long[aim+1]; dp[0] = 1; for (int num: arr){ for (int i = num; i <= aim; i++){ dp[i] += dp[i-num]; dp[i] %= MOD; } } return dp; } public static long[] zeroOneBagFunc(int[] arr, int aim){ long[] dp = new long[aim+1]; dp[0] = 1; for (int num: arr){ for (int i = aim; i >= num; i--){ dp[i] += dp[i-num]; dp[i] %= MOD; } } return dp; } }