#include <bits/stdc++.h>
using namespace std;
int ar[109], b[109];
bool mark[109];
int h[109];
int ind[109];
bool ok[109];
vector<int> res;
int main() {
  int n, m, i, j;
  int smm;
  scanf("%d %d", &n, &m);
  int x, y;
  for (i = 0; i < m; i++) {
    scanf("%d %d", &x, &y);
    mark[x] = true;
    h[x] = y;
    ind[x] = i + 1;
  }
  for (i = 1; i <= n; i++) scanf("%d", &ar[i]);
  int k;
  for (k = 1; k <= n; k++) {
    memset(ok, false, sizeof(ok));
    res.clear();
    for (i = 1; i <= n; i++) b[i] = ar[i];
    bool fl;
    while (1) {
      fl = false;
      for (i = 1; i <= k; i++) {
        if (!mark[i] || ok[i]) continue;
        for (j = i, smm = h[i]; j <= k; j++) {
          smm += b[j];
          if (smm < 0) {
            break;
          }
        }
        if (j > k) {
          fl = true;
          ok[i] = true;
          res.push_back(i);
          for (j = i; j <= k; j++) b[j] = 0;
        }
      }
      for (i = n; i >= k; i--) {
        if (!mark[i] || ok[i]) continue;
        for (j = i, smm = h[i]; j >= k; j--) {
          smm += b[j];
          if (smm < 0) {
            break;
          }
        }
        if (j < k) {
          fl = true;
          ok[i] = true;
          res.push_back(i);
          for (j = i; j >= k; j--) b[j] = 0;
        }
      }
      if (!fl || res.size() == m) break;
    }
    if (res.size() == m) {
      printf("%d\n", k);
      for (i = 0; i < res.size(); i++) {
        if (i) printf(" ");
        printf("%d", ind[res[i]]);
      }
      puts("");
      return 0;
    }
  }
  puts("-1");
  return 0;
}
