#include <bits/stdc++.h>
using namespace std;
vector<int> vec;
int hero[105], en[105];
bool possible(vector<int> &vec, int from, int to, int cur) {
  if (from <= to) {
    for (int i = from; i <= to; i++) {
      cur += vec[i];
      if (cur < 0) return 0;
    }
  } else {
    for (int i = from; i >= to; i--) {
      cur += vec[i];
      if (cur < 0) return 0;
    }
  }
  return 1;
}
inline void fix(vector<int> &vec, int from, int to) {
  if (from > to) swap(from, to);
  for (int i = from; i <= to; i++) vec[i] = 0;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  vec.push_back(0);
  for (int i = 1; i <= m; i++) cin >> hero[i] >> en[i];
  for (int i = 1; i <= n; i++) {
    int a;
    cin >> a;
    vec.push_back(a);
  }
  int rally = -1;
  vector<int> ans;
  for (int i = 1; i <= n; i++) {
    int can = 0;
    vector<bool> flag(n + 1, 0);
    vector<int> st;
    st = vec;
    vector<int> pos;
    for (int j = 1; j <= m; j++) {
      if (can == m) break;
      int left = n + 1, right = -1;
      for (int k = 1; k <= m; k++) {
        if (flag[hero[k]] == 0 && possible(st, hero[k], i, en[k])) {
          if (hero[k] < left && hero[k] <= i) left = hero[k];
          if (hero[k] > right && hero[k] > i) right = hero[k];
        }
      }
      if (left != n + 1) {
        flag[left] = 1;
        can++;
        fix(st, left, i);
        pos.push_back(left);
      }
      if (right != -1) {
        flag[right] = 1;
        can++;
        fix(st, right, i);
        pos.push_back(right);
      }
    }
    if (can == m) {
      rally = i;
      ans = pos;
      break;
    }
  }
  cout << rally << endl;
  for (int i = 0; i < ans.size(); i++) {
    for (int j = 1; j <= m; j++) {
      if (ans[i] == hero[j]) cout << j << " ";
    }
  }
  cout << endl;
  return 0;
}
