#include <bits/stdc++.h>
using namespace std;
struct Node {
  int val;
  int cor;
  int num;
} hero[105];
int a[105], l[105], r[105];
int n, m, lh, rh;
bool cmp(const Node &x, const Node &y) { return x.cor < y.cor; }
int passed;
bool workleft(int x, int &num, int flag) {
  num = m;
  for (int i = 1; i <= m; i++) {
    if (hero[i].cor >= x) {
      num = i - 1;
      break;
    }
  }
  if (num == 0) return true;
  int val = 0;
  for (int i = 1; i <= num; i++) {
    if (hero[i].val > val) {
      l[i] = hero[i].num;
      val = hero[i].val;
    } else
      l[i] = l[i - 1];
    int ed = min(hero[i + 1].cor, x + flag);
    for (int j = hero[i].cor + 1; j <= ed; j++) {
      val += a[j];
      if (val < 0) return false;
    }
  }
  passed = 1;
  return true;
}
bool workright(int x, int &num, int flag) {
  num = 1;
  for (int i = m; i >= 1; i--) {
    if (hero[i].cor < x) {
      num = i + 1;
      break;
    }
  }
  if (num == m + 1) return true;
  int val = 0;
  for (int i = m; i >= num; i--) {
    if (hero[i].val > val) {
      r[i] = hero[i].num;
      val = hero[i].val;
    } else
      r[i] = r[i + 1];
    int ed = max(hero[i - 1].cor, x + flag);
    for (int j = hero[i].cor - 1; j >= ed; j--) {
      val += a[j];
      if (val < 0) return false;
    }
  }
  passed = 1;
  return true;
}
bool lef[105];
void print_ans(int numl, int numr, int flag) {
  memset(lef, 0, sizeof(lef));
  if (!flag) {
    for (int i = numl; i >= 1; i--) {
      if (!lef[l[i]]) {
        printf("%d ", l[i]);
        lef[l[i]] = true;
      }
    }
    for (int i = numr; i <= m; i++) {
      if (!lef[r[i]]) {
        printf("%d ", r[i]);
        lef[r[i]] = true;
      }
    }
  } else {
    for (int i = numr; i <= m; i++) {
      if (!lef[r[i]]) {
        printf("%d ", r[i]);
        lef[r[i]] = true;
      }
    }
    for (int i = numl; i >= 1; i--) {
      if (!lef[l[i]]) {
        printf("%d ", l[i]);
        lef[l[i]] = true;
      }
    }
  }
  for (int i = 1; i <= m; i++) {
    if (!lef[i]) {
      printf("%d ", i);
    }
  }
}
void work() {
  if (m == 1) {
    printf("%d\n%d\n", hero[1].cor, 1);
    return;
  }
  for (int x = 1; x <= n; x++) {
    memset(l, 0, sizeof(l));
    int numl, numr;
    passed = 0;
    if (workleft(x, numl, 0) && workright(x, numr, passed)) {
      printf("%d\n", x);
      print_ans(numl, numr, 0);
      return;
    } else {
      passed = 0;
      if (workright(x, numr, 0) && workleft(x, numl, -passed)) {
        printf("%d\n", x);
        print_ans(numl, numr, 1);
        return;
      }
    }
  }
  printf("-1\n");
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= m; i++) {
    scanf("%d%d", &hero[i].cor, &hero[i].val);
    hero[i].num = i;
  }
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  sort(hero + 1, hero + 1 + m, cmp);
  work();
  return 0;
}
