#include <bits/stdc++.h>
using namespace std;
const long long nax = 105;
struct pt {
  long long idx, x;
  pt() {
    idx = 0;
    x = 0;
  }
  pt(long long a, long long b) {
    idx = a;
    x = b;
  }
  bool operator<(const pt &other) const { return x < other.x; }
};
long long n, m, a[nax], s[nax], h[nax];
inline void Clear(long long mn, long long mx, vector<long long> &cur) {
  for (long long i = mn; i <= mx; ++i) cur[i] = 0;
}
bool check(long long c, long long pos, vector<long long> &cur,
           long long health) {
  if (c <= pos) {
    for (long long i = c; i <= pos; ++i) {
      health += cur[i];
      if (health < 0) return false;
    }
  } else {
    for (long long i = c; i >= pos; --i) {
      health += cur[i];
      if (health < 0) return false;
    }
  }
  return true;
}
bool chk(long long x) {
  vector<pt> vec(m + 1);
  vector<long long> cur(n + 1);
  for (long long i = 1; i <= n; ++i) cur[i] = a[i];
  for (long long i = 1; i <= m; ++i) {
    vec[i].idx = i;
    vec[i].x = abs(x - s[i]);
  }
  sort(vec.begin() + 1, vec.begin() + m + 1);
  vector<bool> ok(m + 1, false);
  vector<long long> steps;
  for (long long i = 1; i <= m; ++i) {
    long long idx = vec[i].idx;
    if (check(s[idx], x, cur, h[idx])) {
      Clear(min(x, s[idx]), max(x, s[idx]), cur);
      steps.push_back(idx);
      ok[idx] = true;
    }
  }
  for (long long i = 1; i <= m; ++i) {
    long long idx = vec[i].idx;
    if (!ok[idx]) {
      if (!check(s[idx], x, cur, h[idx]))
        return false;
      else {
        ok[idx] = true;
        steps.push_back(idx);
        Clear(min(x, s[idx]), max(x, s[idx]), cur);
      }
    }
  }
  cout << x << '\n';
  for (auto &c : steps) cout << c << ' ';
  return true;
}
void solve() {
  cin >> n >> m;
  for (long long i = 1; i <= m; ++i) cin >> s[i] >> h[i];
  for (long long i = 1; i <= n; ++i) cin >> a[i];
  for (long long i = 1; i <= n; ++i)
    if (chk(i)) {
      return;
    }
  cout << -1;
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  long long t = 1;
  while (t--) solve();
  return 0;
}
