#include <bits/stdc++.h>
using namespace std;
inline int Read() {
  int x = 0;
  char y;
  bool z = false;
  do y = getchar(), z |= y == '-';
  while (y < '0' || y > '9');
  do x = x * 10 + y - '0', y = getchar();
  while (y >= '0' && y <= '9');
  return z ? -x : x;
}
int n, m, v[105], id[105][2];
int Ans[105];
bool vis[105];
bool Check(int x) {
  memset(vis, false, sizeof vis);
  int pre = 0, least = 0, ri = 0;
  bool flag = false;
  for (int i = x; i; i--)
    if (v[i]) {
      least += v[i];
      least = min(0, least);
    } else if (id[i][1]) {
      if (id[i][0] < -least) {
        flag = true;
        continue;
      }
      flag = false;
      Ans[++ri] = id[i][1];
      vis[id[i][1]] = true;
      pre = 0;
      least = 0;
    }
  if (flag) return false;
  for (int i = x; i; i--)
    if (!vis[id[i][1]] && id[i][1]) Ans[++ri] = id[i][1];
  bool Add = ri > 0;
  pre = 0;
  least = 0;
  for (int i = x + 1; i <= n; i++)
    if (v[i]) {
      least += v[i];
      least = min(0, least);
    } else if (id[i][1]) {
      if (id[i][0] < -least) {
        flag = true;
        continue;
      }
      flag = false;
      Ans[++ri] = id[i][1];
      vis[id[i][1]] = true;
      pre = 0;
      least = 0;
    }
  if (flag) return false;
  for (int i = x + 1; i <= n; i++)
    if (!vis[id[i][1]] && id[i][1]) Ans[++ri] = id[i][1];
  int pos = Add ? x : x + 1;
  cout << pos << endl;
  for (int i = 1; i <= m; i++) printf("%d ", Ans[i]);
  puts("");
  return true;
}
int main() {
  n = Read();
  m = Read();
  for (int i = 1; i <= m; i++) {
    int k = Read(), l = Read();
    id[k][0] = l;
    id[k][1] = i;
  }
  for (int i = 1; i <= n; i++) v[i] = Read();
  for (int i = 0; i <= n; i++)
    if (Check(i)) return 0;
  puts("-1");
  return 0;
}
