#include <bits/stdc++.h>
#pragma g++ optimize("Ofast")
#pragma loop_opt(on)
using namespace std;
const int N = 125;
pair<int, int> h[N];
int v[N], n, m, id[N];
int sum(int l, int r) { return v[r] - v[l - 1]; }
bool dp[N][N], taken[N], valid[N][N];
pair<int, int> fr[N][N];
signed main() {
  ios_base::sync_with_stdio(0), cin.tie(0);
  cin >> n >> m;
  for (int i = 0; i < m; i++)
    cin >> h[i].first >> h[i].second, id[h[i].first] = i;
  for (int i = 1; i <= n; i++) cin >> v[i];
  for (int i = 0; i < m; i++) {
    {
      bool ok = true;
      int hp = h[i].second;
      for (int j = h[i].first; j >= 1; j--) {
        hp += v[j];
        if (hp < 0) ok = false;
        valid[h[i].first][j] = ok;
      }
    }
    {
      bool ok = true;
      int hp = h[i].second;
      for (int j = h[i].first; j <= n; j++) {
        hp += v[j];
        if (hp < 0) ok = false;
        valid[h[i].first][j] = ok;
      }
    }
  }
  for (int l = 1; l <= n; l++)
    for (int r = l; r <= n; r++) {
      if (valid[l][r]) dp[l][r] = true, fr[l][r] = {r, r};
      if (valid[r][l]) dp[l][r] = true, fr[l][r] = {l, l};
    }
  for (int l = n + 1; l >= 1; l--)
    for (int r = l - 1; r <= n; r++)
      if (dp[l][r]) {
        for (int x = 1; x < l; x++) {
          if (valid[x][l - 1]) dp[x][r] = true, fr[x][r] = {l, r};
        }
        for (int x = r + 1; x <= n; x++) {
          if (valid[x][r + 1]) dp[l][x] = true, fr[l][x] = {l, r};
        }
      }
  int l = 1e9, r = 0;
  for (int i = 0; i < m; i++) l = min(l, h[i].first), r = max(r, h[i].first);
  if (dp[l][r]) {
    vector<int> ans;
    while (l < r) {
      auto [L, R] = fr[l][r];
      if (l == L)
        ans.emplace_back(r);
      else
        ans.emplace_back(l);
      l = L, r = R;
    }
    cout << l << '\n';
    reverse(begin(ans), end(ans));
    for (int x : ans) cout << id[x] + 1 << ' ', taken[id[x]] = true;
    for (int i = 0; i < m; i++)
      if (!taken[i]) cout << i + 1 << ' ';
    cout << '\n';
  } else {
    cout << -1 << '\n';
  }
}
