#include <bits/stdc++.h>
using namespace std;
long long MOD = 998244853;
long long mpow(long long a, long long b) {
  if (b == 0) return 1;
  long long t1 = mpow(a, b / 2);
  t1 *= t1;
  t1 %= MOD;
  if (b % 2) t1 *= a;
  t1 %= MOD;
  return t1;
}
long long mpow(long long a, long long b, long long p) {
  if (b == 0) return 1;
  long long t1 = mpow(a, b / 2);
  t1 *= t1;
  t1 %= p;
  if (b % 2) t1 *= a;
  t1 %= p;
  return t1;
}
long long modinverse(long long a, long long m) {
  long long m0 = m;
  long long y = 0, x = 1;
  if (m == 1) return 0;
  while (a > 1) {
    long long q = a / m;
    long long t = m;
    m = a % m, a = t;
    t = y;
    y = x - q * y;
    x = t;
  }
  if (x < 0) x += m0;
  return x;
}
long long range(long long l, long long r) { return l + rand() % (r - l + 1); }
void solve() {
  long long n, m;
  cin >> n >> m;
  vector<pair<long long, long long> > s;
  long long st = n + 1, en = 0;
  for (long long i = 0; i < m; i++) {
    pair<long long, long long> temp;
    cin >> temp.first >> temp.second;
    s.push_back(temp);
    st = min(st, temp.first);
    en = max(en, temp.first);
  }
  st--;
  en--;
  long long b[n];
  for (long long i = 0; i < n; i++) cin >> b[i];
  for (long long i = st; i < en + 1; i++) {
    bool bo = 1;
    pair<long long, long long> h[n];
    for (long long i = 0; i < n; i++)
      h[i] = make_pair((long long)-1, (long long)-1);
    long long name = 1;
    for (auto it : s) {
      h[it.first - 1] = make_pair(it.second, name++);
    }
    for (long long j = st; j < i + 1; j++) {
      pair<long long, long long> temp =
          ((j == 0) ? make_pair((long long)0, (long long)0)
                    : make_pair(h[j - 1].first + b[j], h[j - 1].second));
      h[j] = max(h[j], temp);
      if (h[j].first < 0) bo = 0;
    }
    for (long long j = en; j >= i; j--) {
      pair<long long, long long> temp =
          ((j == n - 1) ? make_pair((long long)0, (long long)0)
                        : make_pair(h[j + 1].first + b[j], h[j + 1].second));
      h[j] = max(h[j], temp);
      if (h[j].first < 0) bo = 0;
    }
    if (!bo) continue;
    cout << i + 1 << "\n";
    bool vis[m];
    for (long long i = 0; i < m; i++) vis[i] = 0;
    for (long long j = i; j >= st; j--) {
      if (vis[h[j].second - 1] == 0) {
        cout << h[j].second << " ";
        vis[h[j].second - 1] = 1;
      }
    }
    for (long long j = i; j < en + 1; j++) {
      if (vis[h[j].second - 1] == 0) {
        cout << h[j].second << " ";
        vis[h[j].second - 1] = 1;
      }
    }
    for (long long j = 0; j < m; j++) {
      if (vis[j] == 0) {
        cout << j + 1 << " ";
        vis[j] = 1;
      }
    }
    cout << "\n";
    return;
  }
  cout << -1 << "\n";
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long t = 1;
  for (long long i = 0; i < t; i++) {
    solve();
  }
  return 0;
}
