#include <bits/stdc++.h>
using namespace std;
const int nn = 101;
int n, m, key, pass[nn], s[nn], h[nn], a[nn], aa[nn], ans[nn];
void mov(int i) {
  pass[i] = key;
  i = s[i];
  if (i < key)
    while (i < key) aa[++i] = 0;
  else if (i > key)
    while (i > key) aa[--i] = 0;
}
bool movable(int i) {
  int hp = h[i];
  i = s[i];
  if (i < key)
    while (i < key) {
      hp += aa[++i];
      if (hp < 0) return false;
    }
  else if (i > key)
    while (i >= key) {
      hp += aa[--i];
      if (hp < 0) return false;
    }
  return true;
}
void check() {
  bool ok = true;
  int cnt = 0;
  for (int i = 1; i <= n; ++i) aa[i] = a[i];
  while (ok) {
    ok = false;
    for (int i = 1; i <= m; ++i)
      if (pass[i] != key && movable(i)) {
        mov(i);
        ok = true;
        ans[++cnt] = i;
      }
  }
  if (cnt == m) {
    cout << key << "\n";
    for (int i = 1; i <= m; ++i) cout << ans[i] << " ";
    exit(0);
  }
}
int main() {
  cin >> n >> m;
  for (int i = 1; i <= m; ++i) cin >> s[i] >> h[i];
  for (int i = 1; i <= n; ++i) cin >> a[i];
  for (key = 1; key <= n; ++key) check();
  cout << -1;
}
