#include <bits/stdc++.h>
using namespace std;
const int N = 110, inf = 2e9;
int n, m, rd, flag, mini, maxx;
int num[N], hel[N], val[N], outp[N], mark[N];
bool able(int pos) {
  int noww = 0, pts = 0, ok = 0;
  for (int i = maxx; i > pos; i--) {
    if (noww < hel[num[i]]) outp[++pts] = num[i], noww = hel[num[i]];
    noww += val[i];
    if (noww < 0) return false;
  }
  ok |= (noww + val[pos] >= 0), noww = 0;
  for (int i = mini; i < pos; i++) {
    if (noww < hel[num[i]]) outp[++pts] = num[i], noww = hel[num[i]];
    noww += val[i];
    if (noww < 0) return false;
  }
  ok |= (noww + val[pos] >= 0);
  if (!ok) return false;
  printf("%d\n", pos);
  while (pts) printf("%d ", outp[pts]), mark[outp[pts--]] = true;
  for (int i = 1; i <= m; i++)
    if (!mark[i]) printf("%d ", i);
  return true;
}
int main() {
  scanf("%d%d", &n, &m);
  hel[0] = -inf, mini = inf, maxx = -inf;
  for (int i = 1; i <= m; i++) {
    scanf("%d%d", &rd, &hel[i]), num[rd] = i;
    mini = min(mini, rd), maxx = max(maxx, rd);
  }
  for (int i = 1; i <= n; i++) scanf("%d", &val[i]);
  for (int i = 1; i <= n; i++)
    if (able(i)) return 0;
  printf("-1");
  return 0;
}
