#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e2 + 10;
const int mod = 1e9 + 7;
struct bkn {
  int h, s, p;
  bool friend operator<(bkn a, bkn b) { return a.s < b.s; }
} a[maxn];
int n, m;
int vis[maxn], b[maxn], v[maxn], ans[maxn];
bool op1(int i) {
  int tot = 0;
  for (int j = 1; j <= m; j++) vis[j] = 0;
  int now = n + 1;
  int ok = 1;
  while (now != a[1].s) {
    int tl = 1;
    if (a[tl].s > i) break;
    do {
      ok = 1;
      int h = a[tl].h;
      for (int j = a[tl].s; j <= now && j <= i; j++) {
        h += v[j];
        if (h < 0) {
          ok = 0;
          break;
        }
      }
      if (ok) {
        ans[++tot] = a[tl].p;
        vis[a[tl].p] = 1;
        now = a[tl].s;
        break;
      }
      tl++;
      if (now == a[tl].s || a[tl].s > i) break;
    } while (1);
    if (!ok) break;
  }
  if (!ok) return 0;
  now = 0;
  while (now != a[m].s) {
    int tl = m;
    if (a[tl].s <= i) break;
    do {
      ok = 1;
      int h = a[tl].h;
      for (int j = a[tl].s; j >= now && j > i; j--) {
        h += v[j];
        if (h < 0) {
          ok = 0;
          break;
        }
      }
      if (ok) {
        now = a[tl].s;
        ans[++tot] = a[tl].p;
        vis[a[tl].p] = 1;
        break;
      }
      tl--;
      if (now == a[tl].s || a[tl].s <= i) break;
    } while (1);
    if (!ok) break;
  }
  if (ok) {
    printf("%d\n", i);
    for (int j = 1; j <= tot; j++) {
      printf("%d ", ans[j]);
    }
    for (int j = 1; j <= m; j++) {
      if (!vis[j]) printf("%d ", j);
    }
    printf("\n");
    return 1;
  }
  return 0;
}
bool op2(int i) {
  int tot = 0;
  for (int j = 1; j <= m; j++) vis[j] = 0;
  int now = n + 1;
  int ok = 1;
  while (now != a[1].s) {
    int tl = 1;
    if (a[tl].s >= i) break;
    do {
      ok = 1;
      int h = a[tl].h;
      for (int j = a[tl].s; j <= now && j < i; j++) {
        h += v[j];
        if (h < 0) {
          ok = 0;
          break;
        }
      }
      if (ok) {
        ans[++tot] = a[tl].p;
        vis[a[tl].p] = 1;
        now = a[tl].s;
        break;
      }
      tl++;
      if (now == a[tl].s || a[tl].s >= i) break;
    } while (1);
    if (!ok) break;
  }
  if (!ok) return 0;
  now = 0;
  while (now != a[m].s) {
    int tl = m;
    if (a[tl].s < i) break;
    do {
      ok = 1;
      int h = a[tl].h;
      for (int j = a[tl].s; j >= now && j >= i; j--) {
        h += v[j];
        if (h < 0) {
          ok = 0;
          break;
        }
      }
      if (ok) {
        now = a[tl].s;
        ans[++tot] = a[tl].p;
        vis[a[tl].p] = 1;
        break;
      }
      tl--;
      if (now == a[tl].s || a[tl].s < i) break;
    } while (1);
    if (!ok) break;
  }
  if (ok) {
    printf("%d\n", i);
    for (int j = 1; j <= tot; j++) {
      printf("%d ", ans[j]);
    }
    for (int j = 1; j <= m; j++) {
      if (!vis[j]) printf("%d ", j);
    }
    printf("\n");
    return 1;
  }
  return 0;
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= m; i++) {
    scanf("%d%d", &a[i].s, &a[i].h);
    a[i].p = i;
  }
  sort(a + 1, a + 1 + m);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &v[i]);
  }
  for (int i = 1; i <= n; i++) {
    if (a[1].s <= i && op1(i)) return 0;
    if (a[m].s >= i && op2(i)) return 0;
  }
  printf("-1\n");
}
