#include <bits/stdc++.h>
using namespace std;
int a[105];
int n, m;
int s[105], h[105];
int v[105];
int b[105];
vector<int> ans;
bool test(int x) {
  ans.clear();
  for (int i = 1; i <= n; i++) b[i] = a[i];
  for (int i = 1; i <= m; i++) v[i] = 0;
  for (int i = 0; i < m; i++) {
    bool can2 = false;
    for (int j = 1; j <= m; j++) {
      if (v[j]) continue;
      int H = h[j];
      bool can = true;
      if (s[j] <= x) {
        for (int k = s[j]; k <= x; k++) {
          H += b[k];
          if (H < 0) {
            can = false;
            break;
          }
        }
      } else {
        for (int k = s[j]; k >= x; k--) {
          H += b[k];
          if (H < 0) {
            can = false;
            break;
          }
        }
      }
      if (can) {
        if (s[j] <= x) {
          for (int k = s[j]; k <= x; k++) {
            b[k] = 0;
          }
        } else {
          for (int k = s[j]; k >= x; k--) {
            b[k] = 0;
          }
        }
        can2 = true;
        v[j] = 1;
        ans.push_back(j);
        break;
      }
    }
    if (!can2) return false;
  }
  return true;
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= m; i++) {
    scanf("%d%d", &s[i], &h[i]);
  }
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
  }
  for (int i = 1; i <= n; i++) {
    if (test(i)) {
      printf("%d\n", i);
      for (auto x : ans) {
        printf("%d ", x);
      }
      return 0;
    }
  }
  printf("-1\n");
}
