Problem: You are given a weighted directed graph, consisting of n vertices and m edges. You should answer q queries of two types:

  * 1 v — find the length of shortest path from vertex 1 to vertex v. 
  * 2 c l1 l2 ... lc — add 1 to weights of edges with indices l1, l2, ..., lc. 

Input

The first line of input data contains integers n, m, q (1 ≤ n, m ≤ 105, 1 ≤ q ≤ 2000) — the number of vertices and edges in the graph, and the number of requests correspondingly.

Next m lines of input data contain the descriptions of edges: i-th of them contains description of edge with index i — three integers ai, bi, ci (1 ≤ ai, bi ≤ n, 0 ≤ ci ≤ 109) — the beginning and the end of edge, and its initial weight correspondingly.

Next q lines of input data contain the description of edges in the format described above (1 ≤ v ≤ n, 1 ≤ lj ≤ m). It's guaranteed that inside single query all lj are distinct. Also, it's guaranteed that a total number of edges in all requests of the second type does not exceed 106.

Output

For each query of first type print the length of the shortest path from 1 to v in a separate line. Print -1, if such path does not exists.

Examples

Input

3 2 9
1 2 0
2 3 0
2 1 2
1 3
1 2
2 1 1
1 3
1 2
2 2 1 2
1 3
1 2


Output

1
0
2
1
4
2


Input

5 4 9
2 3 1
2 4 1
3 4 1
1 2 0
1 5
1 4
2 1 2
2 1 2
1 4
2 2 1 3
1 4
2 1 4
1 4


Output

-1
1
2
3
4

Note

The description of changes of the graph in the first sample case:

<image>

The description of changes of the graph in the second sample case:

<image>

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
#pragma GCC optimize "-O3"
using namespace std;
template <typename T1, typename T2>
inline void chkmin(T1 &x, T2 y) {
  if (x > y) x = y;
}
template <typename T1, typename T2>
inline void chkmax(T1 &x, T2 y) {
  if (x < y) x = y;
}
inline int readChar();
template <class T = int>
inline T readInt();
template <class T>
inline void writeInt(T x, char end = 0);
inline void writeChar(int x);
inline void writeWord(const char *s);
static const int buf_size = 4096;
inline int getChar() {
  static char buf[buf_size];
  static int len = 0, pos = 0;
  if (pos == len) {
    pos = 0, len = fread(buf, 1, buf_size, stdin);
  }
  if (pos == len) {
    return -1;
  }
  return buf[pos++];
}
inline int readChar() {
  int c = getChar();
  while (c <= 32) {
    c = getChar();
  }
  return c;
}
template <class T>
inline T readInt() {
  int s = 1, c = readChar();
  T x = 0;
  if (c == '-') s = -1, c = getChar();
  while ('0' <= c && c <= '9') x = x * 10 + c - '0', c = getChar();
  return s == 1 ? x : -x;
}
static int write_pos = 0;
static char write_buf[buf_size];
inline void writeChar(int x) {
  if (write_pos == buf_size)
    fwrite(write_buf, 1, buf_size, stdout), write_pos = 0;
  write_buf[write_pos++] = x;
}
template <class T>
inline void writeInt(T x, char end) {
  if (x < 0) writeChar('-'), x = -x;
  char s[24];
  int n = 0;
  while (x || !n) s[n++] = '0' + x % 10, x /= 10;
  while (n--) writeChar(s[n]);
  if (end) writeChar(end);
}
inline void writeWord(const char *s) {
  while (*s) writeChar(*s++);
}
struct Flusher {
  ~Flusher() {
    if (write_pos) fwrite(write_buf, 1, write_pos, stdout), write_pos = 0;
  }
} flusher;
const long long INF = 1e18;
const int MAXN = 1000228;
int pos, qnext[MAXN], qhead[MAXN], qv[MAXN];
int main() {
  int n = readInt(), m = readInt(), q = readInt();
  int head[n], next228[m], to[m], w[m];
  memset(head, -1, sizeof(head));
  for (int i = 0; i < m; i++) {
    int a = readInt();
    int b = readInt();
    int c = readInt();
    a--, b--;
    w[i] = c;
    to[i] = b;
    next228[i] = head[a];
    head[a] = i;
  }
  long long d[n];
  set<pair<int, int> > s;
  fill(d, d + n, INF);
  s.insert(make_pair(d[0] = 0, 0));
  while ((int)(s).size()) {
    int v = s.begin()->second;
    s.erase(s.begin());
    for (int i = head[v]; i != -1; i = next228[i]) {
      if (d[to[i]] > d[v] + w[i]) {
        s.erase(make_pair(d[to[i]], to[i]));
        s.insert(make_pair(d[to[i]] = d[v] + w[i], to[i]));
      }
    }
  }
  int k = 0, res[n];
  for (int it = 0; it < q; it++) {
    int type = readInt();
    if (type == 1) {
      int v = readInt();
      if (d[v - 1] == INF) {
        puts("-1");
      } else {
        if (k > 0) {
          memset(qhead, -1, sizeof(qhead[0]) * (k + 1));
          pos = 0;
          fill(res, res + n, 1e9);
          res[0] = 0;
          auto addq = [&](int i, int v) {
            qnext[pos] = qhead[i], qv[pos] = v, qhead[i] = pos++;
          };
          addq(0, 0);
          for (int dist = 0; dist <= k; dist++) {
            while (qhead[dist] != -1) {
              int p = qhead[dist];
              int v = qv[p];
              qhead[dist] = qnext[p];
              if (res[v] != dist) {
                continue;
              }
              for (int i = head[v]; i != -1; i = next228[i]) {
                long long ndist = d[v] + res[v] + w[i] - d[to[i]];
                if (res[to[i]] > ndist) {
                  if (ndist > k) {
                    continue;
                  }
                  res[to[i]] = ndist, addq(ndist, to[i]);
                }
              }
            }
          }
          for (int i = 0; i < n; i++) {
            if (d[i] != INF) {
              d[i] += res[i];
            }
          }
          k = 0;
        }
        printf("%lld\n", d[v - 1]);
      }
    } else {
      int cnt = readInt();
      for (int it = 0; it < cnt; it++) {
        int i = readInt() - 1;
        w[i]++;
      }
      k += cnt;
    }
  }
  return 0;
}