#include <bits/stdc++.h>
using namespace std;
int n, m, s[103], h[103], b[103], a[103];
bool sudah[103];
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 (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) b[j] = a[j];
    memset(sudah, false, sizeof sudah);
    bool yo = true;
    vector<int> ve;
    for (int cnt = 1; cnt <= m; cnt++) {
      int mana = 1e9, si;
      for (int j = 1; j <= m; j++) {
        if (s[j] > i || sudah[j]) continue;
        int darah = h[j];
        bool ya = true;
        for (int k = s[j]; k <= i; k++) {
          darah += b[k];
          if (darah < 0) {
            ya = false;
            break;
          }
        }
        if (ya) {
          if (mana > s[j]) {
            mana = s[j];
            si = j;
          }
        }
      }
      if (mana != 1e9) {
        ve.push_back(si);
        sudah[si] = true;
        for (int k = s[si]; k <= i; k++) {
          b[k] = 0;
        }
        continue;
      }
      mana = -1;
      for (int j = 1; j <= m; j++) {
        if (s[j] <= i || sudah[j]) continue;
        int darah = h[j];
        bool ya = true;
        for (int k = s[j]; k >= i; k--) {
          darah += b[k];
          if (darah < 0) {
            ya = false;
            break;
          }
        }
        if (ya) {
          if (mana < s[j]) {
            mana = s[j];
            si = j;
          }
        }
      }
      if (mana != -1) {
        ve.push_back(si);
        sudah[si] = true;
        for (int k = s[si]; k >= i; k--) {
          b[k] = 0;
        }
        continue;
      }
      yo = false;
      break;
    }
    if (yo) {
      cout << i << endl;
      for (int j : ve) cout << j << ' ';
      cout << endl;
      return 0;
    }
  }
  cout << -1 << endl;
  return 0;
}
