#include <bits/stdc++.h>
using namespace std;
int n, m;
int a[120], b[120], c[120], d[120];
map<int, int> mp;
vector<int> ans;
int main() {
  memset(b, -1, sizeof(b));
  scanf("%d %d", &n, &m);
  for (int i = 1; i <= m; i++) {
    int x, y;
    scanf("%d %d", &x, &y);
    b[x] = y;
    mp[x] = i;
  }
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
  }
  for (int i = 1; i <= n; i++) {
    ans.clear();
    memcpy(c, a, sizeof(c));
    memcpy(d, b, sizeof(d));
    for (int q = 1; q <= m; q++) {
      int choose = -1, hp = 2000000000;
      for (int j = 1; j <= n; j++) {
        if (d[j] == -1) continue;
        int tmp = d[j], ok = 1;
        if (j <= i) {
          for (int k = j; k <= i; k++) {
            tmp += c[k];
            if (tmp < 0) {
              ok = 0;
              break;
            }
          }
        } else {
          for (int k = j; k >= i; k--) {
            tmp += c[k];
            if (tmp < 0) {
              ok = 0;
              break;
            }
          }
        }
        if (!ok) continue;
        if (tmp < hp) {
          choose = j;
          hp = tmp;
        }
      }
      if (choose == -1) break;
      for (int j = min(i, choose); j <= max(i, choose); j++) c[j] = 0;
      d[choose] = -1;
      ans.push_back(choose);
    }
    if (ans.size() == m) {
      printf("%d\n", i);
      for (int j = 0; j < ans.size(); j++) printf("%d ", mp[ans[j]]);
      return 0;
    }
  }
  printf("-1");
  return 0;
}
