#include <bits/stdc++.h>
using namespace std;
const int N = 110;
pair<int, int> hero[N];
int bak_a[N], a[N];
bool done[N];
void solve(int p, int n, int m);
int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 1; i <= m; ++i) {
    int s, h;
    cin >> s >> h;
    hero[i] = {s, h};
  }
  for (int i = 1; i <= n; ++i) {
    cin >> bak_a[i];
  }
  for (int i = 1; i <= n; ++i) {
    solve(i, n, m);
  }
  cout << -1 << endl;
}
void solve(int p, int n, int m) {
  memset(done, 0, sizeof(done));
  for (int i = 1; i <= n; ++i) {
    a[i] = bak_a[i];
  }
  vector<int> ans;
  for (int i = 0; i < m; ++i) {
    bool ok = false;
    for (int j = 1; j <= m; ++j) {
      if (!done[j]) {
        ok = true;
        int h = hero[j].second, s = hero[j].first;
        while (true) {
          if (s < p) {
            ++s;
          } else if (s > p) {
            --s;
          }
          if (a[s] < 0) {
            int m = -a[s];
            if (m > h) {
              ok = false;
              break;
            } else {
              h -= m;
            }
          } else if (a[s] > 0) {
            h += a[s];
          }
          if (s == p) {
            break;
          }
        }
        if (ok) {
          int s = hero[j].first;
          while (true) {
            if (s < p) {
              ++s;
            } else if (s > p) {
              --s;
            }
            a[s] = 0;
            if (s == p) {
              break;
            }
          }
          ans.push_back(j);
          done[j] = true;
          break;
        }
      }
    }
    if (!ok) {
      return;
    }
  }
  cout << p << endl;
  for (auto& i : ans) {
    cout << i << ' ';
  }
  cout << endl;
  exit(0);
}
