#include <bits/stdc++.h>
using namespace std;
vector<pair<int, int> > hero;
vector<int> ans;
int grid[105];
int back_up[105];
bool can_go(int heroidx, int des) {
  int sou = hero[heroidx].first;
  int hp = hero[heroidx].second;
  if (des < sou) {
    for (int i = sou; i >= des; i--) {
      hp += grid[i];
      if (hp < 0) return 0;
    }
    for (int i = sou; i >= des; i--) grid[i] = 0;
  } else {
    for (int i = sou; i <= des; i++) {
      hp += grid[i];
      if (hp < 0) return 0;
    }
    for (int i = sou; i <= des; i++) grid[i] = 0;
  }
  return 1;
}
bool ok_point(int des) {
  ans.clear();
  vector<pair<int, int> > dd;
  for (int i = 0; i < hero.size(); i++)
    dd.push_back({abs(des - hero[i].first), i});
  while (1) {
    bool ok = 0;
    vector<pair<int, int> > newdd;
    for (int i = 0; i < dd.size(); i++)
      if (can_go(dd[i].second, des)) {
        ok = 1;
        ans.push_back(dd[i].second);
      } else
        newdd.push_back(dd[i]);
    if (!ok) return 0;
    dd = newdd;
    if (dd.empty()) break;
  }
  return 1;
}
int main() {
  int n, m, a, b;
  scanf("%d %d", &n, &m);
  for (int i = 1; i < m + 1; i++) {
    scanf("%d %d", &a, &b);
    hero.push_back({a, b});
  }
  for (int i = 1; i < n + 1; i++) scanf("%d", &grid[i]);
  for (int i = 1; i < n + 1; i++) {
    for (int i = 0; i < 102; i++) back_up[i] = grid[i];
    if (ok_point(i)) {
      printf("%d\n", i);
      for (int i = 0; i < ans.size(); i++) printf("%d ", ans[i] + 1);
      return 0;
    }
    for (int i = 0; i < 102; i++) grid[i] = back_up[i];
  }
  puts("-1");
  return 0;
}
