#include <bits/stdc++.h>
using namespace std;
const int N = 105;
int n, m;
int a[N], b[N], pos[N];
bool avail[N];
pair<int, int> p[N];
void Read_Input() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= m; i++) {
    scanf("%d%d", &p[i].first, &p[i].second);
    pos[p[i].first] = i;
  }
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  sort(p + 1, p + 1 + m);
}
void Solve() {
  for (int x = 1; x <= n; x++) {
    int cnt = m;
    vector<int> ans;
    for (int i = 1; i <= n; i++) b[i] = a[i];
    for (int i = 1; i <= m; i++) avail[i] = 1;
    while (cnt > 0) {
      bool check = false;
      for (int i = 1; i <= m; i++)
        if (avail[i] && p[i].first <= x) {
          bool flag = true;
          int cur = p[i].second;
          for (int j = p[i].first; j <= x; j++) {
            cur += b[j];
            if (cur < 0) flag = false;
          }
          if (!flag) continue;
          for (int j = p[i].first; j <= x; j++) b[j] = 0;
          ans.push_back(pos[p[i].first]);
          avail[i] = 0;
          cnt--;
          check = true;
        }
      for (int i = m; i >= 1; i--)
        if (avail[i] && p[i].first >= x) {
          bool flag = true;
          int cur = p[i].second;
          for (int j = p[i].first; j >= x; j--) {
            cur += b[j];
            if (cur < 0) flag = false;
          }
          if (!flag) continue;
          for (int j = p[i].first; j >= x; j--) b[j] = 0;
          ans.push_back(pos[p[i].first]);
          avail[i] = 0;
          cnt--;
          check = true;
        }
      if (!check) break;
    }
    if (cnt == 0) {
      printf("%d\n", x);
      for (int i = 0; i < ans.size(); i++) printf("%d ", ans[i]);
      return;
    }
  }
  puts("-1");
}
int main() {
  Read_Input();
  Solve();
  return 0;
}
