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>
using namespace std;
const long long INF = 1e18;
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);
const int MAX = 1e6 + 10;
int pos, qnext[MAX], qhead[MAX], qv[MAX];
int main() {
  int n, m, queries;
  n = readInt();
  m = readInt();
  queries = readInt();
  int head[n], next[m], to[m], w[m];
  memset(head, -1, sizeof(head));
  for (int i = 0; i < (int)(m); i++) {
    int a = readInt();
    int b = readInt();
    int c = readInt();
    a--, b--;
    w[i] = c, to[i] = b, next[i] = head[a], head[a] = i;
  }
  long long d[n];
  auto Dijkstra = [&]() {
    set<pair<int, int> > s;
    fill(d, d + n, INF);
    s.insert(pair<int, int>(d[0] = 0, 0));
    while (s.size()) {
      int v = s.begin()->second;
      s.erase(s.begin());
      for (int i = head[v]; i != -1; i = next[i]) {
        if (d[to[i]] > d[v] + w[i]) {
          s.erase(pair<int, int>(d[to[i]], to[i]));
          s.insert(pair<int, int>(d[to[i]] = d[v] + w[i], to[i]));
        }
      }
    }
  };
  Dijkstra();
  int k = 0, res[n];
  auto bfs = [&]() {
    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 < (int)(k + 1); 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 = next[i]) {
          int tmp;
          if (res[to[i]] > (tmp = d[v] + res[v] + w[i] - d[to[i]])) {
            if (tmp > k) continue;
            res[to[i]] = tmp, addq(tmp, to[i]);
          }
        }
      }
    for (int i = 0; i < (int)(n); i++)
      if (d[i] != INF) d[i] += res[i];
  };
  while (queries--) {
    int type;
    type = readInt();
    if (type == 1) {
      int v = readInt();
      if (d[v - 1] == INF)
        puts("-1");
      else {
        if (k > 0) bfs(), k = 0;
        printf("%lld\n", d[v - 1]);
      }
    } else {
      int cnt, i;
      cnt = readInt();
      for (int _ = 0; _ < (int)(cnt); _++) {
        i = readInt() - 1;
        w[i]++;
      }
      k += cnt;
    }
  }
}
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;