#include <bits/stdc++.h>
using namespace std;
int ara[102], tmp[102];
pair<int, int> hero[102], t_hero[102];
vector<int> ans;
int tree[502];
bool query(int x, int y, int p, int l) {
  int ret = p;
  if (l)
    for (int i = x; i <= y; i++) {
      ret += tmp[i];
      if (ret < 0) return false;
    }
  else
    for (int i = y; i >= x; i--) {
      ret += tmp[i];
      if (ret < 0) return false;
    }
  return true;
}
void update(int x, int y) {
  for (int i = x; i <= y; i++) tmp[i] = 0;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n, m;
  cin >> n >> m;
  int x, y;
  for (int i = 0; i < 102; i++) hero[i] = {0, 0};
  for (int i = 1; i <= m; i++) {
    cin >> x >> y;
    hero[x] = {y, i};
  }
  for (int i = 1; i <= n; i++) cin >> ara[i];
  for (int rally = 1; rally <= n; rally++) {
    int l_h = 0, r_h = 0;
    ans.clear();
    for (int i = 1; i <= n; i++) t_hero[i] = hero[i], tmp[i] = ara[i];
    for (int i = 1; i <= rally; i++)
      if (t_hero[i].first != 0) l_h++;
    for (int i = rally + 1; i <= n; i++)
      if (t_hero[i].first != 0) r_h++;
    for (int i = 1; i <= rally and l_h; i++) {
      for (int j = 1; j <= rally; j++) {
        if (t_hero[j].first != 0) {
          int p = t_hero[j].first;
          if (query(j, rally, p, 1)) {
            ans.push_back(t_hero[j].second);
            t_hero[j] = {0, 0};
            update(j, rally);
            l_h--;
          }
        }
      }
    }
    if (l_h) continue;
    for (int i = rally + 1; i <= n and r_h; i++) {
      for (int j = rally + 1; j <= n; j++) {
        if (t_hero[j].first != 0) {
          int p = t_hero[j].first;
          if (query(rally, j, p, 0)) {
            ans.push_back(t_hero[j].second);
            t_hero[j] = {0, 0};
            update(rally + 1, j);
            r_h--;
          }
        }
      }
    }
    if (r_h) continue;
    cout << rally << endl;
    for (int i = 0; i < m; i++) {
      if (i) cout << " ";
      cout << ans[i];
    }
    cout << endl;
    return 0;
  }
  cout << "-1" << endl;
  return 0;
}
