func_code_string: #include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     int n, m;     cin >> n >> m;     vector<bool> hero(n);     vector<long long> v(n);     vector<int> pos_num(n);     for (int i = 0; i < m; i++) {       int s, h;       cin >> s >> h;       hero[--s] = 1;       pos_num[s] = i;       v[s] = h;     }     for (int i = 0; i < n; i++) {       int x;       cin >> x;       if (!hero[i]) v[i] = x;     }     for (int cell = 0; cell < n; cell++) {       vector<int> order;       vector<long long> v_;       vector<bool> hero_;       for (bool x : hero) hero_.push_back(x);       for (long long x : v) v_.push_back(x);       for (int dum = 0; dum < m; dum++) {         vector<bool> can(n);         for (int i = 0; i < n; i++)           if (hero_[i]) {             int inc = i <= cell ? 1 : -1;             long long sum = 0;             int idx = i;             bool ok = 1;             while (1) {               if (idx == i || !hero_[idx]) sum += v_[idx];               if (sum < 0) ok = 0;               if (idx == cell) break;               idx += inc;             }             if (ok) can[i] = 1;           }         int idx = -1;         for (int i = 0; i < cell + 1; i++) {           if (can[i]) {             idx = i;             break;           }         }         for (int i = n - 1; i >= cell; i--)           if (can[i]) {             idx = i;             break;           }         if (idx == -1) break;         int inc = idx <= cell ? 1 : -1;         order.push_back(pos_num[idx]);         hero_[idx] = 0;         while (1) {           v_[idx] = 0;           if (idx == cell) break;           idx += inc;         }       }       if (order.size() == m) {         cout << cell + 1 <<   n ;         for (int i = 0; i < m; i++) {           if (i) cout <<    ;           cout << order[i] + 1;         }         cout <<   n ;         return 0;       }     }     cout << -1 <<   n ;   }   