using namespace std;
#include <iostream>
#include <iomanip>
#include <vector>
#include <cstdio>
#include <set>
#include <cctype>
#include <map>
#include <cmath>
#include <queue>
#include <algorithm>
#include <stack>
#include <cctype>
#include <cstring>
#include <string>
#include <bitset>
#define MAX 610
#define MOD 1000000007
#define PI 3.1415926535897932384
#define F first
#define S second
#define pb push_back
#define mp make_pair
typedef long long ll;
int n, k, p;
int cost[MAX];
int dp[MAX][MAX][3]; // DP[ current_gum ][ num_teeth ][ val /prev_col /cont_teeth_for_this_gum ]
vector<pair<int, int> > gum[MAX];
vector<int> res;
void solve(){
// Initial state of DP
memset(dp, -1, sizeof(dp));
dp[0][0][0] = 0;
for(int i = 1;i <= k;i++){
int acm = cost[i]; // Initial cost of anesthesia
for(int l = -1;l < (int)gum[i].size();l++){
if(l != -1) acm += gum[i][l].F; // Cost of curing teeh[0, l] in gum[i]
// Num holds the number of cured teeth
for(int num = 0;num <= n;num++){
if(dp[i-1][num][0] == -1) continue;
if(l == -1){
dp[i][num][0] = dp[i-1][num][0];
dp[i][num][1] = num;
dp[i][num][2] = 0;
continue;
}
if(dp[i][num+l+1][0] == -1 || dp[i][num+l+1][0] > dp[i-1][num][0]+acm){
dp[i][num+l+1][0] = dp[i-1][num][0]+acm;
dp[i][num+l+1][1] = num;
dp[i][num+l+1][2] = l+1;
}
}
}
}
int cur; // Cur is the number of cured teeth untill gum[i], initially i == k
for(int i = n;i >= 0;i--){
if(dp[k][i][0] != -1 && dp[k][i][0] <= p){ cur = i; break; }
}
for(int i = k;i > 0;i--){
for(int j = 0;j < dp[i][cur][2];j++) res.pb(gum[i][j].S); // Values on answer
// Cur receives number of teeth cured untill gum[i-1]
cur = dp[i][cur][1];
}
// Print answer
cout << res.size() << endl;
for(int i = 0;i < res.size();i++) cout << res[i] << " \n"[i == res.size()-1];
}
int main(){
//freopen("in", "r", stdin);
//freopen("out", "w", stdout);
// ______________Read input:
cin >> n >> k >> p;
for(int i = 1;i <= k;i++) cin >> cost[i];
for(int x, y, i = 1;i <= n;i++){
cin >> x >> y;
gum[y].pb(mp(x, i));
}
//_________________________
// Sort values for each gum
for(int i = 1;i <= n;i++) sort(gum[i].begin(), gum[i].end());
solve();
return 0;
}
dXNpbmcgbmFtZXNwYWNlIHN0ZDsKI2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8aW9tYW5pcD4KI2luY2x1ZGUgPHZlY3Rvcj4KI2luY2x1ZGUgPGNzdGRpbz4KI2luY2x1ZGUgPHNldD4KI2luY2x1ZGUgPGNjdHlwZT4KI2luY2x1ZGUgPG1hcD4KI2luY2x1ZGUgPGNtYXRoPgojaW5jbHVkZSA8cXVldWU+CiNpbmNsdWRlIDxhbGdvcml0aG0+CiNpbmNsdWRlIDxzdGFjaz4KI2luY2x1ZGUgPGNjdHlwZT4KI2luY2x1ZGUgPGNzdHJpbmc+CiNpbmNsdWRlIDxzdHJpbmc+CiNpbmNsdWRlIDxiaXRzZXQ+CgojZGVmaW5lIE1BWCA2MTAKI2RlZmluZSBNT0QgMTAwMDAwMDAwNwojZGVmaW5lIFBJIDMuMTQxNTkyNjUzNTg5NzkzMjM4NAojZGVmaW5lIEYgZmlyc3QKI2RlZmluZSBTIHNlY29uZAojZGVmaW5lIHBiIHB1c2hfYmFjawojZGVmaW5lIG1wIG1ha2VfcGFpcgp0eXBlZGVmIGxvbmcgbG9uZyBsbDsKCmludCBuLCBrLCBwOwppbnQgY29zdFtNQVhdOwppbnQgZHBbTUFYXVtNQVhdWzNdOyAvLyBEUFsgY3VycmVudF9ndW0gXVsgbnVtX3RlZXRoIF1bIHZhbCAvcHJldl9jb2wgL2NvbnRfdGVldGhfZm9yX3RoaXNfZ3VtIF0KdmVjdG9yPHBhaXI8aW50LCBpbnQ+ID4gZ3VtW01BWF07CnZlY3RvcjxpbnQ+IHJlczsKCnZvaWQgc29sdmUoKXsKCiAgICAvLyBJbml0aWFsIHN0YXRlIG9mIERQCiAgICBtZW1zZXQoZHAsIC0xLCBzaXplb2YoZHApKTsKICAgIGRwWzBdWzBdWzBdID0gMDsKCiAgICBmb3IoaW50IGkgPSAxO2kgPD0gaztpKyspewogICAgICAgIGludCBhY20gPSBjb3N0W2ldOyAvLyBJbml0aWFsIGNvc3Qgb2YgYW5lc3RoZXNpYQoKICAgICAgICBmb3IoaW50IGwgPSAtMTtsIDwgKGludClndW1baV0uc2l6ZSgpO2wrKyl7CiAgICAgICAgICAgIGlmKGwgIT0gLTEpIGFjbSArPSBndW1baV1bbF0uRjsgLy8gQ29zdCBvZiBjdXJpbmcgdGVlaFswLCBsXSBpbiBndW1baV0KCiAgICAgICAgICAgIC8vIE51bSBob2xkcyB0aGUgbnVtYmVyIG9mIGN1cmVkIHRlZXRoCiAgICAgICAgICAgIGZvcihpbnQgbnVtID0gMDtudW0gPD0gbjtudW0rKyl7CiAgICAgICAgICAgICAgICBpZihkcFtpLTFdW251bV1bMF0gPT0gLTEpIGNvbnRpbnVlOwoKICAgICAgICAgICAgICAgIGlmKGwgPT0gLTEpewogICAgICAgICAgICAgICAgICAgIGRwW2ldW251bV1bMF0gPSBkcFtpLTFdW251bV1bMF07CiAgICAgICAgICAgICAgICAgICAgZHBbaV1bbnVtXVsxXSA9IG51bTsKICAgICAgICAgICAgICAgICAgICBkcFtpXVtudW1dWzJdID0gMDsKICAgICAgICAgICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgICAgICAgIH0KCiAgICAgICAgICAgICAgICBpZihkcFtpXVtudW0rbCsxXVswXSA9PSAtMSB8fCBkcFtpXVtudW0rbCsxXVswXSA+IGRwW2ktMV1bbnVtXVswXSthY20pewogICAgICAgICAgICAgICAgICAgIGRwW2ldW251bStsKzFdWzBdID0gZHBbaS0xXVtudW1dWzBdK2FjbTsKICAgICAgICAgICAgICAgICAgICBkcFtpXVtudW0rbCsxXVsxXSA9IG51bTsKICAgICAgICAgICAgICAgICAgICBkcFtpXVtudW0rbCsxXVsyXSA9IGwrMTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgfQogICAgIC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