#include <bits/stdc++.h>
using namespace std;
const int INF = 1000000001;
const long double EPS = 1e-9;
const int MOD = 1000000007;
const long long LLINF = 1000000000000000001;
const int maxn = 101;
int n, m;
int za[maxn];
pair<int, int> heroes[maxn];
pair<pair<int, int>, int> heroesind[maxn];
int a[maxn];
bool done[maxn];
void concent(int c) {
  for (int i = 1; i <= n; i++) {
    a[i] = za[i];
    done[i] = false;
  }
  vector<int> ans;
  for (int run = 1; run <= 2; run++) {
    for (int i = 1; i <= m; i++) {
      if (heroes[i].first > c && !done[i]) {
        int hp = heroes[i].second;
        bool alive = true;
        for (int j = heroes[i].first; j >= c; j--) {
          hp += a[j];
          if (hp < 0) alive = false;
        }
        if (alive) {
          done[i] = true;
          ans.push_back(i);
          for (int j = heroes[i].first; j >= c; j--) a[j] = 0;
        } else if (run == 2 && i == m) {
          return;
        }
      }
    }
    for (int i = m; i >= 1; i--) {
      if (heroes[i].first < c && !done[i]) {
        int hp = heroes[i].second;
        bool alive = true;
        for (int j = heroes[i].first; j <= c; j++) {
          hp += a[j];
          if (hp < 0) alive = false;
        }
        if (alive) {
          done[i] = true;
          ans.push_back(i);
          for (int j = heroes[i].first; j <= c; j++) a[j] = 0;
        } else if (run == 2 && i == 1) {
          return;
        }
      }
    }
  }
  for (int i = 1; i <= m; i++)
    if (!done[i]) ans.push_back(i);
  cout << c << '\n';
  for (auto i : ans) cout << heroesind[i].second << ' ';
  cout << '\n';
  exit(0);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> m;
  for (int i = 1; i <= m; i++) {
    cin >> heroesind[i].first.first >> heroesind[i].first.second;
    heroesind[i].second = i;
  }
  for (int i = 1; i <= n; i++) cin >> za[i];
  sort(heroesind + 1, heroesind + 1 + m);
  for (int i = 1; i <= m; i++) heroes[i] = heroesind[i].first;
  for (int i = 1; i <= n; i++) concent(i);
  cout << "-1\n";
}
