#include <bits/stdc++.h>
using namespace std;
int n, m, a[110], b[110];
int s[110], h[110];
bool use[110];
int ap, ans[110], acnt;
inline void update(int l, int r) {
  memset(b + l, 0, sizeof(b[0]) * (r - l + 1));
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= m; ++i) scanf("%d%d", s + i, h + i);
  for (int i = 1; i <= n; ++i) scanf("%d", a + i);
  for (int rp = 1; rp <= n; ++rp) {
    acnt = 0;
    memcpy(b, a, sizeof(a));
    memset(use, 0, sizeof(use));
    while (1) {
      bool flag = 0;
      for (int i = 1; i <= m; ++i) {
        if (use[i]) continue;
        if (s[i] <= rp) {
          int th = h[i], j = s[i];
          for (; j <= rp; ++j) {
            th += b[j];
            if (th < 0) break;
          }
          if (j > rp) {
            ans[++acnt] = i;
            update(s[i], rp);
            flag = 1;
            use[i] = 1;
          }
        } else {
          int th = h[i], j = s[i];
          for (; j >= rp; --j) {
            th += b[j];
            if (th < 0) break;
          }
          if (j < rp) {
            ans[++acnt] = i;
            update(rp, s[i]);
            flag = 1;
            use[i] = 1;
          }
        }
      }
      if (!flag || acnt == m) break;
    }
    if (acnt == m) {
      ap = rp;
      break;
    }
  }
  if (acnt == m) {
    printf("%d\n", ap);
    for (int i = 1; i <= acnt; ++i) printf("%d%c", ans[i], " \n"[i == acnt]);
  } else
    puts("-1");
  return 0;
}
