#include <bits/stdc++.h>
using namespace std;
struct Frac {
  long long up;
  long long dw;
  Frac() {
    up = 0;
    dw = 1;
  }
  Frac(long long up_, long long dw_) {
    up = up_;
    dw = dw_;
  }
  bool operator<(const Frac &other) const {
    __int128 f = (__int128)up * other.dw;
    __int128 s = (__int128)other.up * dw;
    return f < s;
  }
};
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  long long k, n, m;
  cin >> k >> n >> m;
  vector<vector<pair<long long, long long>>> muls(k);
  vector<vector<pair<long long, long long>>> adds(k);
  vector<pair<long long, long long>> mx(k, {-1, -1});
  vector<long long> a(k);
  for (auto &t : a) {
    cin >> t;
  }
  vector<long long> types(n);
  for (long long i = 0; i < n; i++) {
    long long t, who, b;
    cin >> t >> who >> b;
    who--;
    types[i] = t;
    if (t == 1) {
      mx[who] = max(mx[who], make_pair(b, i));
    } else if (t == 2) {
      adds[who].push_back({b, i});
    } else {
      muls[who].push_back({b, i});
    }
  }
  for (long long i = 0; i < k; i++) {
    if (mx[i].first > a[i]) {
      adds[i].push_back({mx[i].first - a[i], mx[i].second});
    }
  }
  vector<pair<Frac, long long>> all;
  for (long long i = 0; i < k; i++) {
    sort(adds[i].rbegin(), adds[i].rend());
    long long c = a[i];
    for (auto t : adds[i]) {
      all.push_back(make_pair(Frac(c + t.first, c), t.second));
      c += t.first;
    }
    for (auto t : muls[i]) {
      all.push_back(make_pair(Frac(t.first, 1), t.second));
    }
  }
  sort(all.rbegin(), all.rend());
  vector<long long> tk;
  for (long long i = 0; i < (long long)all.size() && i < m; i++) {
    tk.push_back(all[i].second);
  }
  sort(tk.begin(), tk.end(),
       [&](long long i, long long j) { return types[i] < types[j]; });
  cout << tk.size() << endl;
  for (auto i : tk) {
    cout << i + 1 << ' ';
  }
  cout << endl;
}
