#include <bits/stdc++.h>
using namespace std;
const int N = 100;
long long pos[N + 5];
long long hp[N + 5];
long long item[N + 5];
long long copyy[N + 5];
bool cmp1(pair<long long, long long> a, pair<long long, long long> b) {
  return pos[a.first] < pos[b.first];
}
bool cmp2(pair<long long, long long> a, pair<long long, long long> b) {
  return pos[a.first] > pos[b.first];
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n, m;
  cin >> n >> m;
  for (int i = 1; i <= m; ++i) cin >> pos[i] >> hp[i];
  for (int i = 1; i <= n; ++i) cin >> item[i];
  for (int j = 1; j <= n; ++j) copyy[j] = item[j];
  vector<long long> ans;
  long long id = -1;
  for (int i = 1; i <= n; ++i) {
    vector<pair<long long, long long> > ki, ka;
    for (int j = 1; j <= m; ++j) {
      if (pos[j] <= i)
        ki.push_back(pair<long long, long long>(j, hp[j]));
      else
        ka.push_back(pair<long long, long long>(j, hp[j]));
    }
    for (int j = 1; j <= n; ++j) item[j] = copyy[j];
    sort(ki.begin(), ki.end(), cmp1);
    sort(ka.begin(), ka.end(), cmp2);
    stack<int> tm1, tm2;
    bool ok = true;
    int cur, p, h;
    if (!ki.empty()) {
      cur = 0;
      p = pos[ki[cur].first];
      h = hp[ki[cur].first];
      for (int i = 1; i < ki.size() && ok; ++i) {
        while (p < pos[ki[i].first] && ok) {
          h += item[++p];
          item[p] = 0;
          if (h < 0) ok = false;
        }
        if (!ok) break;
        if (h > hp[ki[i].first]) {
          tm1.push(ki[i].first);
        } else {
          tm1.push(ki[cur].first);
          cur = i;
          h = hp[ki[i].first];
        }
      }
      while (p < i && ok) {
        h += item[++p];
        item[p] = 0;
        if (h < 0) ok = false;
      }
      tm1.push(ki[cur].first);
      if (!ok) continue;
    }
    if (!ka.empty()) {
      cur = 0;
      p = pos[ka[cur].first];
      h = hp[ka[cur].first];
      for (int i = 1; i < ka.size() && ok; ++i) {
        while (p > pos[ka[i].first] && ok) {
          h += item[--p];
          item[p] = 0;
          if (h < 0) ok = false;
        }
        if (!ok) break;
        if (h > hp[ka[i].first]) {
          tm2.push(ka[i].first);
        } else {
          tm2.push(ka[cur].first);
          cur = i;
          h = hp[ka[i].first];
        }
      }
      while (p > i && ok) {
        h += item[--p];
        item[p] = 0;
        if (h < 0) ok = false;
      }
      tm2.push(ka[cur].first);
      if (!ok) continue;
    }
    if (!ok) continue;
    while (!tm1.empty()) ans.push_back(tm1.top()), tm1.pop();
    while (!tm2.empty()) ans.push_back(tm2.top()), tm2.pop();
    id = i;
    break;
  }
  for (int i = 1; i <= n && id == -1; ++i) {
    vector<pair<long long, long long> > ki, ka;
    for (int j = 1; j <= m; ++j) {
      if (pos[j] < i)
        ki.push_back(pair<long long, long long>(j, hp[j]));
      else
        ka.push_back(pair<long long, long long>(j, hp[j]));
    }
    for (int j = 1; j <= n; ++j) item[j] = copyy[j];
    sort(ki.begin(), ki.end(), cmp1);
    sort(ka.begin(), ka.end(), cmp2);
    stack<int> tm1, tm2;
    bool ok = true;
    int cur, p, h;
    if (!ka.empty()) {
      cur = 0;
      p = pos[ka[cur].first];
      h = hp[ka[cur].first];
      for (int i = 1; i < ka.size() && ok; ++i) {
        while (p > pos[ka[i].first] && ok) {
          h += item[--p];
          item[p] = 0;
          if (h < 0) ok = false;
        }
        if (!ok) break;
        if (h > hp[ka[i].first]) {
          tm2.push(ka[i].first);
        } else {
          tm2.push(ka[cur].first);
          cur = i;
          h = hp[ka[i].first];
        }
      }
      while (p > i && ok) {
        h += item[--p];
        item[p] = 0;
        if (h < 0) ok = false;
      }
      tm2.push(ka[cur].first);
      if (!ok) continue;
    }
    if (!ki.empty()) {
      cur = 0;
      p = pos[ki[cur].first];
      h = hp[ki[cur].first];
      for (int i = 1; i < ki.size() && ok; ++i) {
        while (p < pos[ki[i].first] && ok) {
          h += item[++p];
          item[p] = 0;
          if (h < 0) ok = false;
        }
        if (!ok) break;
        if (h > hp[ki[i].first]) {
          tm1.push(ki[i].first);
        } else {
          tm1.push(ki[cur].first);
          cur = i;
          h = hp[ki[i].first];
        }
      }
      while (p < i - 1 && ok) {
        h += item[++p];
        item[p] = 0;
        if (h < 0) ok = false;
      }
      tm1.push(ki[cur].first);
      if (!ok) continue;
    }
    if (!ok) continue;
    while (!tm2.empty()) ans.push_back(tm2.top()), tm2.pop();
    while (!tm1.empty()) ans.push_back(tm1.top()), tm1.pop();
    id = i;
    break;
  }
  cout << id << endl;
  if (ans.size() > 0) {
    for (int i = 0; i < ans.size(); ++i) {
      if (i) cout << " ";
      cout << ans[i];
    }
    cout << endl;
  }
}
