#include <bits/stdc++.h>
#pragma gcc optimize("O3, unroll-loops")
using namespace std;
template <typename It>
ostream& outIt(ostream& out, It b, It e) {
  for (It i = b; i != e; i++) out << (i == b ? "" : " ") << *i;
  return out;
}
template <typename T>
ostream& operator<<(ostream& out, vector<T>& v) {
  return outIt(out << '[', (v).begin(), (v).end()) << ']';
}
template <typename T1, typename T2>
ostream& operator<<(ostream& out, pair<T1, T2> p) {
  return out << '(' << p.first << ", " << p.second << ')';
}
template <typename T1, typename T2>
istream& operator>>(istream& in, pair<T1, T2>& p) {
  return in >> p.first >> p.second;
}
vector<pair<int, int> > v;
vector<int> game, cg, used, ans;
signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    a--;
    v.push_back({a, b});
  }
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    game.push_back(x);
  }
  cg.resize(n);
  used.resize(m);
  for (int r = 0; r < n; r++) {
    copy((game).begin(), (game).end(), cg.begin());
    int maxd = INT_MIN, maxi, mind = INT_MAX, mini;
    ans.resize(0);
    fill((used).begin(), (used).end(), 0);
    while (ans.size() < m) {
      bool flg = 1;
      for (int i = 0; i < m; i++) {
        if (used[i]) continue;
        int cur = v[i].second;
        if (v[i].first > r)
          for (int k = v[i].first; k >= r; k--)
            if ((cur += cg[k]) < 0) goto no;
        if (v[i].first < r)
          for (int k = v[i].first; k <= r; k++)
            if ((cur += cg[k]) < 0) goto no;
        ans.push_back(i);
        flg = 0;
        used[i] = true;
        for (int k = min(v[i].first, r); k <= max(v[i].first, r); k++)
          cg[k] = 0;
      no:;
      }
      if (flg) break;
    }
    if (ans.size() == m) {
      cout << r + 1 << endl;
      for (auto i : ans) cout << i + 1 << " ";
      cout << endl;
      return 0;
    }
  }
  cout << -1 << endl;
}
