----------------------------------------------------------------------------------------
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <cmath>
#include <vector>
#include <string>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#define MAX(a,b) ((a)>=(b)?(a):(b))
#define MIN(a,b) ((a)<=(b)?(a):(b))
#define OO 0x0fffffff
typedef long long LL;
using namespace std;
const int N = 100100;
const int M = 1024;
int A[N],B[N];
int K[M],P[M];
int table[16][M];
int dp[M];
int main(){
int n,m;
int a,b;
while(scanf("%d%d",&n,&m)!=EOF){
for(int i=0;i<n;i++) scanf("%d%d",A+i,B+i);
for(int i=0;i<m;i++) scanf("%d%d",K+i,P+i);
memset(table,127,sizeof(table));
for(int defend=0;defend<=10;defend++){
int *dp = table[defend];
dp[0] = 0;
for(int id=0;id<m;id++){
int value = P[id] - defend;
if(value<=0) continue;
for(int life=0;life<=1000;life++){
int base = ((life-value)>=0)?(dp[life-value]):0;
dp[life] = MIN(dp[life],base+K[id]);
}
}
}
LL ans = 0;
bool flag = true;
for(int i=0;i<n;i++) {
int tmp = table[B[i]][A[i]];
if(tmp==2139062143) {flag=false;break;}
ans += tmp;
}
if(flag) printf("%lld\n",ans);
else puts("-1");
}
return 0;
}