Problem: Vasya plays one very well-known and extremely popular MMORPG game. His game character has k skill; currently the i-th of them equals to ai. Also this game has a common rating table in which the participants are ranked according to the product of all the skills of a hero in the descending order.

Vasya decided to 'upgrade' his character via the game store. This store offers n possible ways to improve the hero's skills; Each of these ways belongs to one of three types:

  1. assign the i-th skill to b; 
  2. add b to the i-th skill; 
  3. multiply the i-th skill by b. 



Unfortunately, a) every improvement can only be used once; b) the money on Vasya's card is enough only to purchase not more than m of the n improvements. Help Vasya to reach the highest ranking in the game. To do this tell Vasya which of improvements he has to purchase and in what order he should use them to make his rating become as high as possible. If there are several ways to achieve it, print any of them.

Input

The first line contains three numbers — k, n, m (1 ≤ k ≤ 105, 0 ≤ m ≤ n ≤ 105) — the number of skills, the number of improvements on sale and the number of them Vasya can afford.

The second line contains k space-separated numbers ai (1 ≤ ai ≤ 106), the initial values of skills.

Next n lines contain 3 space-separated numbers tj, ij, bj (1 ≤ tj ≤ 3, 1 ≤ ij ≤ k, 1 ≤ bj ≤ 106) — the type of the j-th improvement (1 for assigning, 2 for adding, 3 for multiplying), the skill to which it can be applied and the value of b for this improvement.

Output

The first line should contain a number l (0 ≤ l ≤ m) — the number of improvements you should use.

The second line should contain l distinct space-separated numbers vi (1 ≤ vi ≤ n) — the indices of improvements in the order in which they should be applied. The improvements are numbered starting from 1, in the order in which they appear in the input. 

Examples

Input

2 4 3
13 20
1 1 14
1 2 30
2 1 6
3 2 2


Output

3
2 3 4

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
struct impr_t {
  int type, skill, value, idx;
  long double contribution;
};
impr_t I[100010];
int V[100010];
vector<int> imps[100010];
int best_assn[100010];
bool by_value(const int& i, const int& j) {
  int iv = (i >= 0 ? I[i].value : 0);
  int jv = (j >= 0 ? I[j].value : 0);
  return (iv == jv ? (i < j) : (iv < jv));
}
bool by_contribution(const int& i, const int& j) {
  long double iv = (i >= 0 ? I[i].contribution : 0);
  long double jv = (j >= 0 ? I[j].contribution : 0);
  return iv < jv;
}
vector<int> muls;
vector<int> adds;
int main() {
  int K, N, M, tpe, skl, val;
  scanf("%d%d%d", &K, &N, &M);
  for (int i = 0; i < (K); ++i) scanf("%d", &V[i]);
  for (int i = 0; i < (K); ++i) best_assn[i] = -1;
  for (int j = 0; j < (N); ++j) {
    scanf("%d%d%d", &tpe, &skl, &val);
    skl--;
    I[j] = (struct impr_t){tpe, skl, val, j, 0};
    if (tpe == 1)
      best_assn[skl] = max(best_assn[skl], j, by_value);
    else if (tpe == 2)
      imps[skl].push_back(j);
    else if (tpe == 3)
      muls.push_back(j);
    else
      assert(false);
  }
  sort(muls.begin(), muls.end(), by_value);
  reverse(muls.begin(), muls.end());
  for (int i = 0; i < (K); ++i)
    if (best_assn[i] >= 0) {
      int idx = best_assn[i];
      if (I[idx].value > V[i]) {
        I[idx].value = I[idx].value - V[i];
        imps[i].push_back(idx);
      }
    }
  for (int i = 0; i < (K); ++i) {
    sort(imps[i].begin(), imps[i].end(), by_value);
    reverse(imps[i].begin(), imps[i].end());
    long long sum = V[i];
    int numImps = imps[i].size();
    for (int x = 0; x < (numImps); ++x) {
      impr_t& imp = I[imps[i][x]];
      long long new_sum = sum + imp.value;
      imp.contribution = logl(new_sum) - logl(sum);
      sum = new_sum;
      adds.push_back(imps[i][x]);
    }
  }
  sort(adds.begin(), adds.end(), by_contribution);
  reverse(adds.begin(), adds.end());
  for (const auto& idx : muls) {
    I[idx].contribution = logl(I[idx].value);
  }
  int A = muls.size(), B = adds.size();
  vector<long double> sum_muls(muls.size(), 0);
  vector<long double> sum_adds(adds.size(), 0);
  for (int i = 0; i < (A); ++i)
    sum_muls[i] = I[muls[i]].contribution + (i ? sum_muls[i - 1] : 0);
  for (int i = 0; i < (B); ++i)
    sum_adds[i] = I[adds[i]].contribution + (i ? sum_adds[i - 1] : 0);
  int best_num_muls = 0;
  int best_num_adds = 0;
  long double best_contrib = 0;
  int max_muls = min(A, M);
  for (int num_muls = 0; num_muls <= max_muls; ++num_muls) {
    int num_adds = min(M - num_muls, B);
    long double contrib = (num_muls ? sum_muls[num_muls - 1] : 0) +
                          (num_adds ? sum_adds[num_adds - 1] : 0);
    if (contrib > best_contrib) {
      best_contrib = contrib;
      best_num_muls = num_muls;
      best_num_adds = num_adds;
    }
  }
  vector<int> ans;
  ans.insert(ans.end(), adds.begin(), adds.begin() + best_num_adds);
  ans.insert(ans.end(), muls.begin(), muls.begin() + best_num_muls);
  int cur = 0;
  for (int i = 0; i < (int)ans.size(); ++i) {
    if (I[ans[i]].type == 1) {
      swap(ans[i], ans[cur]);
      cur++;
    }
  }
  printf("%d\n", (int)ans.size());
  bool sp = false;
  for (const auto& x : ans) {
    if (sp) printf(" ");
    sp = true;
    printf("%d", x + 1);
  }
  printf("\n");
}