// Arup Guha
// 2/26/2023
// Solution to 2022 SER D1/D2 Problem: Family Visits

import java.util.*;

public class familyvisits {

	public static int n;
	public static int k;
	
	public static int[] mess;
	public static int[] clean;
	public static ArrayList<Integer> visit;
	
	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=visit.size()-1; i>0; i--) {
			int tmp = solve(visit.get(i), visit.get(i-1)+1);
			if (tmp == -1) {
				res = -1; break;
			}
			res += tmp;
		}
		
		// Ta da!
		System.out.println(res);
	}
	
	// Solves the subcase days[highIdx..lowIdx].
	public static int solve(int highIdx, int lowIdx) {
	
		// 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=highIdx, j=0; i>=lowIdx; i--,j++) {
			m[j] = mess[i];
			c[j] = clean[i];
		}
		
		// dp[i][j] is the highest "cleaning" surplus I can accrue with the last i days of mess cleaning exactly j of those days.
		Integer[][] dp = new Integer[sz+1][sz+1];
		for (int i=0; i<=sz; i++) Arrays.fill(dp[i], null);
		
		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++) {
			
				// Build off previous state by cleaning today.
				if (j > 0 && dp[i-1][j-1] != null) {
					int newV = dp[i-1][j-1] + c[i-1] - m[i-1];
					if (newV >= 0)  dp[i][j] = newV;
				}
				
				// Don't clean today...if that's possible.
				if (dp[i-1][j] != null) {
					int cleanFromNo = dp[i-1][j] - m[i-1];
					if (cleanFromNo >= 0 && (dp[i][j] == null || cleanFromNo > dp[i][j])) dp[i][j] = cleanFromNo;
				}
			}
		}
		
		// See the fewest days with which we could clean.
		for (int i=0; i<=sz; i++)
			if (dp[sz][i] != null)
				return i;
				
		// If we get here, we couldn't do it.
		return -1;
	}

}