#include <bits/stdc++.h>
using LL = long long;
const int N = 100000 + 5;
int K, n, m;
LL A[N];
std::priority_queue<std::pair<int, int>> op[3][N];
struct OP {
  LL coefa, coefb;
  int oid, id, kind;
  bool operator<(const OP& rhs) const {
    return (LL)coefa * rhs.coefb < (LL)rhs.coefa * coefb;
  }
};
void work() {
  for (int i = 0; i < K; ++i) {
    if (op[0][i].empty()) continue;
    LL val = op[0][i].top().first;
    int oid = op[0][i].top().second;
    op[0][i].pop();
    if (val < A[i]) continue;
    op[1][i].push({val - A[i], -oid});
  }
  std::priority_queue<OP> que;
  for (int i = 0; i < K; ++i) {
    if (op[1][i].empty()) continue;
    LL val = op[1][i].top().first;
    int oid = op[1][i].top().second;
    op[1][i].pop();
    int kind = 2;
    if (oid < 0) {
      kind = 1;
      oid *= -1;
    }
    que.push({val + A[i], A[i], oid, i, kind});
  }
  for (int i = 0; i < K; ++i) {
    if (op[2][i].empty()) continue;
    LL val = op[2][i].top().first;
    int oid = op[2][i].top().second;
    op[2][i].pop();
    int kind = 3;
    que.push({val, 1, oid, i, kind});
  }
  std::vector<std::pair<int, int>> answer;
  for (int I = 0; I < m; ++I) {
    if (que.empty()) break;
    OP e = que.top();
    que.pop();
    answer.push_back({e.kind, e.oid});
    if (e.kind != 3) {
      A[e.id] = e.coefa;
      if (!op[1][e.id].empty()) {
        LL val = op[1][e.id].top().first;
        int oid = op[1][e.id].top().second;
        op[1][e.id].pop();
        int kind = 2;
        if (oid < 0) {
          kind = 1;
          oid *= -1;
        }
        que.push({val + A[e.id], A[e.id], oid, e.id, kind});
      }
    } else {
      if (!op[2][e.id].empty()) {
        LL val = op[2][e.id].top().first;
        int oid = op[2][e.id].top().second;
        op[2][e.id].pop();
        int kind = 3;
        que.push({val, 1ll, oid, e.id, kind});
      }
    }
  }
  std::sort(answer.begin(), answer.end());
  printf("%d\n", answer.size());
  for (auto t : answer) {
    printf("%d ", t.second);
  }
  puts("");
}
int main() {
  scanf("%d%d%d", &K, &n, &m);
  for (int i = 0; i < K; ++i) {
    scanf("%I64d", A + i);
  }
  for (int i = 0; i < n; ++i) {
    int a, b, c;
    scanf("%d%d%d", &a, &b, &c);
    b--;
    op[a - 1][b].push({c, i + 1});
  }
  work();
}
