// Arup Guha
// 2/26/2023
// Solution to 2022 SER D1/D2 Problem: Family Visits
// Edited on 1/25/2026 for NAPC-O lecture

import java.util.*;

public class familyvisits2 {

	public static int n;
	public static int k;
	public static int[] mess;
	public static int[] clean;
	public static ArrayList<Integer> visit;
	
	final public static int NOSOL = 1000000000;
	
	public static void main(String[] args) {
	
		// Get mess, clean.
		Scanner stdin = new Scanner(System.in);
		n = stdin.nextInt();
		k = stdin.nextInt();
		mess = new int[n];
		clean = new int[n];
		for (int i=0; i<n; i++) {
			mess[i] = stdin.nextInt();
			clean[i] = stdin.nextInt();
		}
		
		// Visit days...
		visit = new ArrayList<Integer>();
		visit.add(-1);
		for (int i=0; i<k; i++) visit.add(stdin.nextInt()-1);
		
		// Solve each "set" of days until a visit, and add results.
		int res = 0;
		for (int i=0; i<k; i++) {
			int tmp = solve(visit.get(i)+1, visit.get(i+1));
			if (tmp == -1) {
				res = -1; break;
			}
			res += tmp;
		}
		
		// Ta da!
		System.out.println(res);
	}
	
	// Solves the subcase days[lowIdx...highIdx].
	public static int solve(int lowIdx, int highIdx) {
	
		// Just solve this DP.
		int sz = highIdx-lowIdx+1;
		int[] m = new int[sz];
		int[] c = new int[sz];
		
		// Reverse them so it's easier for me to think about.
		for (int i=lowIdx; i<=highIdx; i++) {
			m[i-lowIdx] = mess[i];
			c[i-lowIdx] = clean[i];
		}
		
		// dp[i][j] is the minimum mess I can make after day i cleaning exactly j days.
		int[][] dp = new int[sz+1][sz+1];
		for (int i=0; i<=sz; i++) Arrays.fill(dp[i], NOSOL);
		
		// This is clear.
		dp[0][0] = 0;
		
		// i represents the number of days we've gone through.
		for (int i=1; i<=sz; i++) {
		
			// j represents the number of days we've cleaned.
			for (int j=0; j<=i; j++) {
				
				// Don't clean...
				dp[i][j] = Math.min(NOSOL, dp[i-1][j] + m[i-1]);
				
				// We do clean this day.
				if (j > 0) 
					dp[i][j] = Math.min( dp[i][j], Math.max(0, dp[i-1][j-1] + m[i-1] - c[i-1]) );
			}
		}
		
		// See the fewest days with which we could clean.
		for (int i=0; i<=sz; i++)
			if (dp[sz][i] == 0)
				return i;
				
		// If we get here, we couldn't do it.
		return -1;
	}
}