#include <bits/stdc++.h>
using namespace std;
template <class T>
int getbit(T s, int i) {
  return (s >> i) & 1;
}
template <class T>
T onbit(T s, int i) {
  return s | (T(1) << i);
}
template <class T>
T offbit(T s, int i) {
  return s & (~(T(1) << i));
}
template <class T>
int cntbit(T s) {
  return __builtin_popcounll(s);
}
template <class T>
T gcd(T a, T b) {
  T r;
  while (b != 0) {
    r = a % b;
    a = b;
    b = r;
  }
  return a;
}
template <class T>
T lcm(T a, T b) {
  return a / gcd(a, b) * b;
}
int k, n, m;
int a[200005], b[200005];
vector<pair<int, int> > V[200005];
vector<pair<int, int> > VV;
int M[200005], vt[200005];
vector<pair<long double, int> > T[200005];
vector<pair<long double, int> > TT;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  memset(M, -1, sizeof(M));
  memset(vt, -1, sizeof(vt));
  cin >> k >> n >> m;
  for (int i = (1); i <= (k); ++i) {
    cin >> a[i];
  }
  for (int run = 0; run < (n); ++run) {
    int id, u, v;
    cin >> id >> u >> v;
    b[run + 1] = id;
    if (id == 1) {
      if (M[u] < v) {
        M[u] = v;
        vt[u] = run + 1;
      }
    } else if (id == 2) {
      V[u].push_back(make_pair(v, run + 1));
    } else {
      VV.push_back(make_pair(v, run + 1));
    }
  }
  sort((VV).begin(), (VV).end());
  priority_queue<pair<pair<long double, int>, pair<int, int> > > que;
  for (int i = (1); i <= (k); ++i) {
    if (M[i] > a[i]) {
      V[i].push_back(make_pair(M[i] - a[i], vt[i]));
    }
    sort((V[i]).begin(), (V[i]).end());
    long long run = a[i], temp;
    for (int j = ((int)(V[i]).size()) - 1; j >= 0; j--) {
      temp = run + V[i][j].first;
      T[i].push_back(make_pair(log(temp) - log(run), V[i][j].second));
      run = temp;
    }
    if (((int)(V[i]).size())) {
      que.push(
          make_pair(make_pair(T[i][0].first, T[i][0].second), make_pair(i, 0)));
    }
  }
  long double RR = 0;
  while (!que.empty()) {
    pair<long double, int> PP = que.top().first;
    long double x = PP.first;
    int t = PP.second;
    pair<int, int> P = que.top().second;
    int u = P.first, v = P.second;
    que.pop();
    if (((int)(T[u]).size()) >= v + 2) {
      que.push(make_pair(make_pair(T[u][v + 1].first, T[u][v + 1].second),
                         make_pair(u, v + 1)));
    }
    RR += x;
    TT.push_back(make_pair(RR, t));
  }
  RR = 0;
  long double MAX = -1;
  int vt = -1;
  for (int i = 0; i <= ((int)(VV).size()); i++) {
    if (i > m) break;
    int u = min(m - i, ((int)(TT).size()));
    u--;
    long double x;
    if (u >= 0)
      x = TT[u].first;
    else
      x = 0;
    if (MAX < x + RR) {
      MAX = x + RR;
      vt = i;
    }
    if (i < ((int)(VV).size())) RR += log(VV[((int)(VV).size()) - i - 1].first);
  }
  int u = min(m - vt, ((int)(TT).size()));
  cout << u + vt << endl;
  vector<pair<int, int> > res;
  for (int i = 1; i <= vt; i++)
    res.push_back(make_pair(b[VV[((int)(VV).size()) - i].second],
                            VV[((int)(VV).size()) - i].second));
  for (int i = 0; i < u; i++)
    res.push_back(make_pair(b[TT[i].second], TT[i].second));
  sort((res).begin(), (res).end());
  for (int i = 0; i < (((int)(res).size())); ++i) cout << res[i].second << " ";
  return 0;
}
