#include <bits/stdc++.h>
using namespace std;
const int maxn = 200;
int mn[maxn << 2], lazy[maxn << 2], gs[maxn << 2];
void push(int rt) {
  if (lazy[rt] == 1000000000) return;
  lazy[rt << 1] = lazy[rt << 1 | 1] = lazy[rt];
  mn[rt << 1] = mn[rt << 1 | 1] = lazy[rt];
  gs[rt << 1] = gs[rt << 1 | 1] = lazy[rt];
  lazy[rt] = 1000000000;
}
void update(int l, int r, int rt, int ql, int qr, int v) {
  if (ql <= l && qr >= r)
    lazy[rt] = v, mn[rt] = gs[rt] = v;
  else {
    push(rt);
    int mid = l + r >> 1;
    if (ql <= mid) update(l, mid, rt << 1, ql, qr, v);
    if (qr > mid) update(mid + 1, r, rt << 1 | 1, ql, qr, v);
    mn[rt] = min(mn[rt << 1], mn[rt << 1 | 1]);
  }
}
int query(int l, int r, int rt, int ql, int qr) {
  if (ql <= l && qr >= r) return mn[rt];
  push(rt);
  int mid = l + r >> 1, ret = 1e9;
  if (ql <= mid) ret = query(l, mid, rt << 1, ql, qr);
  if (qr > mid) ret = min(ret, query(mid + 1, r, rt << 1 | 1, ql, qr));
  return ret;
}
int Pv(int l, int r, int rt, int p) {
  if (l == r) return gs[rt];
  push(rt);
  int mid = l + r >> 1;
  if (p <= mid)
    return Pv(l, mid, rt << 1, p);
  else
    return Pv(mid + 1, r, rt << 1 | 1, p);
}
int sum[maxn], a[maxn];
void build(int l, int r, int rt) {
  lazy[rt] = 1000000000;
  if (l == r)
    mn[rt] = gs[rt] = sum[l];
  else {
    int mid = l + r >> 1;
    build(l, mid, rt << 1);
    build(mid + 1, r, rt << 1 | 1);
    mn[rt] = min(mn[rt << 1], mn[rt << 1 | 1]);
  }
}
int vis[maxn];
using pii = pair<int, int>;
pii her[maxn];
vector<int> ans;
int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 1; i <= m; ++i) cin >> her[i].first >> her[i].second;
  for (int i = 1; i <= n; ++i) cin >> a[i];
  int pos = -1;
  for (int i = 1; i <= n; ++i) {
    sum[0] = 0;
    sum[n + 1] = 0;
    int tp = a[i];
    for (int i = 1; i <= n; ++i) vis[i] = 0;
    for (int j = 1; j < i; ++j) sum[j] = sum[j - 1] + a[j];
    for (int j = n; j > i; --j) sum[j] = sum[j + 1] + a[j];
    sum[i] = 0;
    build(1, n, 1);
    while (true) {
      int cnt = 0;
      for (int j = 1; j <= m; ++j) {
        if (vis[j]) continue;
        auto h = her[j];
        int S = 0, ps = Pv(1, n, 1, h.first);
        if (h.first <= i - 1) S = query(1, n, 1, h.first, i - 1) - ps;
        if (h.first >= i + 1) S = query(1, n, 1, i + 1, h.first) - ps;
        if (h.second + S >= 0) {
          if (h.first <= i - 1) S = Pv(1, n, 1, i - 1) - ps;
          if (h.first >= i + 1) S = Pv(1, n, 1, i + 1) - ps;
          if (h.second + S + a[i] >= 0) {
            a[i] = 0;
            vis[j] = 1;
            cnt++;
            ans.push_back(j);
            if (h.first <= i - 1) update(1, n, 1, h.first, i - 1, ps);
            if (h.first >= i + 1) update(1, n, 1, i + 1, h.first, ps);
          }
        }
      }
      if (!cnt) break;
    }
    if (ans.size() == m) {
      pos = i;
      break;
    }
    a[i] = tp;
    ans.clear();
  }
  cout << pos << endl;
  for (auto &u : ans) cout << u << " ";
  puts("");
  return 0;
}
