#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 102;
int n, m, hero[MAX_N], cell[MAX_N], tmp[MAX_N], id[MAX_N];
int first_hero, last_hero;
bool visited[MAX_N];
vector<int> res;
void enter() {
  cin >> n >> m;
  first_hero = n + 1;
  last_hero = 0;
  for (int i = 1; i <= m; ++i) {
    int s, hp;
    cin >> s >> hp;
    hero[s] = hp;
    first_hero = min(first_hero, s);
    last_hero = max(last_hero, s);
    id[s] = i;
  }
  for (int i = 1; i <= n; ++i) {
    cin >> cell[i];
  }
}
bool check(int l, int r, int delta) {
  int cnt = 0;
  memset(visited, false, sizeof(visited));
  for (int i = l; i - delta != r; i += delta) {
    cnt += (hero[i] != 0);
  }
  for (int i = 1; i <= n; ++i) {
    tmp[i] = cell[i];
  }
  while (cnt > 0) {
    int pos = 0;
    for (int i = r; i + delta != l; i -= delta) {
      if (hero[i] && !visited[i]) {
        int64_t s = hero[i];
        bool ok = true;
        for (int j = i; j + delta != l; j -= delta) {
          s += tmp[j];
          if (s < 0) {
            ok = false;
            break;
          }
        }
        if (ok) {
          pos = i;
          break;
        }
      }
    }
    if (!pos) return false;
    visited[pos] = true;
    for (int i = pos; i + delta != l; i -= delta) tmp[i] = 0;
    res.push_back(id[pos]);
    --cnt;
  }
  return true;
}
void solve() {
  int pos = 0;
  for (int i = 1; i <= n; ++i) {
    res.clear();
    if (first_hero <= i && check(i, 1, -1) && check(i + 1, n, 1)) {
      pos = i;
      break;
    }
    res.clear();
    if (last_hero >= i && check(i, n, 1) && check(i - 1, 1, -1)) {
      pos = i;
      break;
    }
  }
  if (!pos) {
    cout << -1;
  } else {
    cout << pos << '\n';
    for (int i = 0; i < res.size(); ++i) cout << res[i] << ' ';
  }
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  enter();
  solve();
}
