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>
long long a[101000];
int t[101000], c[101000], ori[101000];
long long d[101000];
int tempa[101000], tempb[101000], tempd[101000];
long long tempc[101000];
void mergesort(int *a, int *b, long long *c, int *d, int n1, int n2);
double he[101000];
int he2[101000];
int zzz[101000];
int pt[101000], pc[101000], pori[101000];
long long pd[101000];
int main(void) {
  int k, n, m, n2, nnn, i, j, i2, i3;
  double dd, tempd1, tempd2;
  int nh;
  int p;
  int nans;
  int oo;
  while (scanf("%d %d %d", &k, &n, &m) != EOF) {
    nnn = n;
    for (i = 1; i <= k; i++) {
      scanf("%I64d", &a[i]);
    }
    for (i = 1; i <= n; i++) {
      scanf("%d %d %I64d", &t[i], &c[i], &d[i]);
      pt[i] = t[i];
      pc[i] = c[i];
      pd[i] = d[i];
      ori[i] = i;
      pori[i] = i;
    }
    mergesort(c, t, d, ori, 1, n);
    n2 = 0;
    for (i = 1; i <= n;) {
      if (t[i] == 1) {
        for (i2 = i + 1; i2 <= n; i2++) {
          if (t[i2] != 1 || c[i2] != c[i]) {
            break;
          }
        }
        if (d[i] > a[c[i]]) {
          n2++;
          t[n2] = 2;
          c[n2] = c[i];
          d[n2] = d[i] - a[c[i]];
          ori[n2] = ori[i];
        }
        i = i2;
      } else {
        n2++;
        t[n2] = t[i];
        c[n2] = c[i];
        d[n2] = d[i];
        ori[n2] = ori[i];
        i++;
      }
    }
    n = n2;
    if (n < m) {
      m = n;
    }
    nh = 0;
    for (i = 1; i <= n;) {
      for (i2 = i + 1; i2 <= n; i2++) {
        if (t[i2] != t[i] || c[i2] != c[i]) {
          break;
        }
      }
      if (t[i] == 2) {
        dd = d[i];
        oo = ori[i];
        for (i3 = i + 1; i3 < i2; i3++) {
          if (dd < d[i3]) {
            d[i3 - 1] = d[i3];
            ori[i3 - 1] = ori[i3];
          } else {
            break;
          }
        }
        d[i3 - 1] = dd;
        ori[i3 - 1] = oo;
        tempd1 = a[c[i]];
        for (i3 = i; i3 < i2; i3++) {
          tempd2 = tempd1 + d[i3];
          dd = tempd2 / tempd1;
          p = ++nh;
          while (p > 1) {
            if (dd > he[p >> 1]) {
              he[p] = he[p >> 1];
              he2[p] = he2[p >> 1];
              p >>= 1;
            } else {
              break;
            }
          }
          he[p] = dd;
          he2[p] = ori[i3];
          tempd1 = tempd2;
        }
      } else {
        for (i3 = i; i3 < i2; i3++) {
          dd = d[i3];
          p = ++nh;
          while (p > 1) {
            if (dd > he[p >> 1]) {
              he[p] = he[p >> 1];
              he2[p] = he2[p >> 1];
              p >>= 1;
            } else {
              break;
            }
          }
          he[p] = dd;
          he2[p] = ori[i3];
        }
      }
      i = i2;
    }
    for (i = 1; i <= nnn; i++) {
      zzz[i] = 0;
    }
    for (i = 1; i <= m; i++) {
      zzz[he2[1]] = 1;
      dd = he[nh];
      oo = he2[nh];
      nh--;
      p = 1;
      while (p + p + 1 <= nh) {
        if (he[p + p] >= he[p + p + 1] && he[p + p] > dd) {
          he[p] = he[p + p];
          he2[p] = he2[p + p];
          p = p + p;
        } else if (he[p + p] < he[p + p + 1] && he[p + p + 1] > dd) {
          he[p] = he[p + p + 1];
          he2[p] = he2[p + p + 1];
          p = p + p + 1;
        } else {
          break;
        }
      }
      if (p + p <= nh && he[p + p] > dd) {
        he[p] = he[p + p];
        he2[p] = he2[p + p];
        p = p + p;
      }
      he[p] = dd;
      he2[p] = oo;
    }
    mergesort(pc, pt, pd, pori, 1, nnn);
    printf("%d\n", m);
    for (i = 1; i <= nnn; i++) {
      if (zzz[pori[i]]) {
        printf("%d ", pori[i]);
      }
    }
    printf("\n");
  }
  return 0;
}
void mergesort(int *a, int *b, long long *c, int *d, int n1, int n2) {
  int a1, a2, n12;
  int i, j;
  if (n1 < n2) {
    n12 = (n1 + n2) / 2;
    mergesort(a, b, c, d, n1, n12);
    mergesort(a, b, c, d, n12 + 1, n2);
    for (i = n1; i <= n2; i++) {
      tempa[i] = a[i];
      tempb[i] = b[i];
      tempc[i] = c[i];
      tempd[i] = d[i];
    }
    a1 = n1;
    a2 = n12 + 1;
    for (i = n1; (a1 <= n12 && a2 <= n2); i++) {
      if (tempa[a1] < tempa[a2] ||
          (tempa[a1] == tempa[a2] && tempb[a1] < tempb[a2]) ||
          (tempa[a1] == tempa[a2] && tempb[a1] == tempb[a2] &&
           tempc[a1] >= tempc[a2])) {
        a[i] = tempa[a1];
        b[i] = tempb[a1];
        c[i] = tempc[a1];
        d[i] = tempd[a1];
        a1++;
      } else {
        a[i] = tempa[a2];
        b[i] = tempb[a2];
        c[i] = tempc[a2];
        d[i] = tempd[a2];
        a2++;
      }
    }
    if (a1 > n12) {
      for (j = a2; j <= n2; j++, i++) {
        a[i] = tempa[j];
        b[i] = tempb[j];
        c[i] = tempc[j];
        d[i] = tempd[j];
      }
    } else {
      for (j = a1; j <= n12; j++, i++) {
        a[i] = tempa[j];
        b[i] = tempb[j];
        c[i] = tempc[j];
        d[i] = tempd[j];
      }
    }
  }
}