#include using namespace std; //* ATCODER #include using namespace atcoder; typedef modint998244353 mint; //*/ /* BOOST MULTIPRECISION #include using namespace boost::multiprecision; //*/ typedef long long ll; #define rep(i, s, n) for (int i = (int)(s); i < (int)(n); i++) #define rrep(i, s, n) for (int i = (int)(n)-1; i >= (int)(s); i--) template bool chmin(T &a, const T &b) { if (a <= b) return false; a = b; return true; } template bool chmax(T &a, const T &b) { if (a >= b) return false; a = b; return true; } template T max(vector &a){ assert(!a.empty()); T ret = a[0]; for (int i=0; i<(int)a.size(); i++) chmax(ret, a[i]); return ret; } template T min(vector &a){ assert(!a.empty()); T ret = a[0]; for (int i=0; i<(int)a.size(); i++) chmin(ret, a[i]); return ret; } template T sum(vector &a){ T ret = 0; for (int i=0; i<(int)a.size(); i++) ret += a[i]; return ret; } ll op(ll a, ll b) {return a + b;} ll e(){return 0;} int main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); int n, m, k; cin >> n >> m >> k; vector d(n, vector(n, 1e18)); vector s(k+1); rep(i,0,k+1){ cin >> s[i]; s[i]--; } rep(i,0,m){ int a, b; cin >> a >> b; a--; b--; ll c; cin >> c; chmin(d[a][b], c); chmin(d[b][a], c); } rep(r,0,n){ rep(i,0,n){ rep(j,0,n){ chmin(d[i][j], d[i][r] + d[r][j]); } } } segtree seg(k); rep(i,0,k){ seg.set(i, d[s[i]][s[i+1]]); } int q; cin >> q; while(q--){ int t; cin >> t; int x, y; cin >> x >> y; if (t == 1){ s[x] = y-1; if (x-1 >= 0){ seg.set(x-1, d[s[x-1]][s[x]]); } if (x < k){ seg.set(x, d[s[x]][s[x+1]]); } }else{ cout << seg.prod(x, y) << '\n'; } } }