#include <bits/stdc++.h>
using namespace std;
const unsigned long long hashConst = 123;
struct Hero {
  int hp;
  int pos;
  int i;
};
int main() {
  int nb, nh;
  cin >> nb >> nh;
  vector<int> b(nb);
  vector<Hero> h(nh);
  for (int i = 0; i < nh; i++) {
    Hero hero;
    cin >> hero.pos >> hero.hp;
    hero.i = i + 1;
    hero.pos -= 1;
    h[i] = hero;
  }
  for (int i = 0; i < nb; i++) cin >> b[i];
  bool isFound = false;
  vector<Hero> res;
  int resPos = -1;
  for (int pos = 0; pos < nb && !isFound; pos++) {
    auto board = b;
    auto heroes = h;
    auto curHeroes = heroes;
    res.clear();
    auto curBoard = board;
    while (true) {
      int curHeroesCount = curHeroes.size();
      for (int ih = 0; ih < curHeroes.size(); ih++) {
        auto heroBoard = curBoard;
        Hero hero = curHeroes[ih];
        int dir = hero.pos != pos ? (pos - hero.pos) / abs(pos - hero.pos) : 0;
        bool isPos = true;
        for (int ib = hero.pos; hero.pos != pos; ib += dir) {
          hero.hp += heroBoard[ib];
          heroBoard[ib] = 0;
          hero.pos = ib;
          if (hero.hp < 0) {
            isPos = false;
            break;
          }
        }
        if (isPos) {
          curBoard = heroBoard;
          res.push_back(curHeroes[ih]);
          curHeroes.erase(curHeroes.begin() + ih);
        }
      }
      if (curHeroes.size() == 0) {
        isFound = true;
        resPos = pos;
        break;
      }
      if (curHeroes.size() == curHeroesCount) {
        break;
      }
    }
  }
  if (isFound) {
    cout << resPos + 1 << endl;
    for (int ih = 0; ih < res.size(); ih++) {
      cout << res[ih].i << " ";
    }
    cout << endl;
  } else
    cout << "-1" << endl;
  return 0;
}
