namespace AtCoder; #nullable enable using System.Numerics; static class Extensions { public static T[] Repeat(this int time, Func F) => Enumerable.Range(0, time).Select(_ => F()).ToArray(); } abstract class SegmentTree { public interface IOperator { TMonoid IdentityElement { get; } TMonoid Operation(TMonoid x, TMonoid y); } public interface IBinarySearchOperator { bool F(TMonoid value); } public class Body where TOperator : struct, IOperator { public int BaseSize { get; init; } protected int Height { get; init; } protected TOperator Op { get; init; } protected TMonoid[] Values { get; init; } public Body(TMonoid[] initial, TOperator op = default) { Op = op; (BaseSize, Height) = (1, 0); while (BaseSize < initial.Length) (BaseSize, Height) = (BaseSize << 1, Height + 1); var size = BaseSize << 1; Values = new TMonoid[size]; for (var i = 0; i < size; i++) Values[i] = op.IdentityElement; for (var i = 0; i < initial.Length; i++) Values[i + BaseSize] = initial[i]; for (var i = BaseSize - 1; i > 0; i--) Update(i); } public TMonoid Product(int l, int r) { (l, r) = (l + BaseSize, r + BaseSize); var (resL, resR) = (Op.IdentityElement, Op.IdentityElement); while (l < r) { if ((l & 1) == 1) resL = Op.Operation(resL, Values[l++]); if ((r & 1) == 1) resR = Op.Operation(Values[--r], resR); (l, r) = (l >> 1, r >> 1); } return Op.Operation(resL, resR); } public void Set(int index, TMonoid value) { var j = index + BaseSize; Values[j] = value; for (var i = 1; i <= Height; i++) Update(j >> i); } // the result might be greater than n public int MinIndex(TMinIndexOperator op = default) where TMinIndexOperator : struct, IBinarySearchOperator { if (!op.F(Values[1])) return BaseSize + 1; var product = Op.IdentityElement; var (res, w, i) = (0, BaseSize, 1); while (w > 0) { var p = Op.Operation(product, Values[i]); if (!op.F(p)) { res += w; i++; product = p; } w >>= 1; i <<= 1; } return res + 1; } protected void Update(int k) { Values[k] = Op.Operation(Values[k << 1], Values[(k << 1) + 1]); } } } struct Op : SegmentTree.IOperator { public long IdentityElement => 0; public long Operation(long x, long y) => x + y; } class AtCoder { object? Solve() { var n = Int(); var m = Int(); var k = Int(); var sz = (k + 1).Repeat(() => Int() - 1); var g = new long[n, n]; var max = long.MaxValue / 8; for (var i = 0; i < n; i++) for (var j = 0; j < n; j++) if (i != j) g[i, j] = max; for (var i = 0; i < m; i++) { var a = Int() - 1; var b = Int() - 1; var c = Int(); g[a, b] = c; g[b, a] = c; } for (var v = 0; v < n; v++) for (var i = 0; i < n; i++) for (var j = 0; j < n; j++) { g[i, j] = Math.Min(g[i, j], g[i, v] + g[v, j]); } var init = new long[k]; for (var i = 0; i < k; i++) init[i] = g[sz[i], sz[i + 1]]; var tree = new SegmentTree.Body(init); var q = Int(); var ans = new List(); for (var i = 0; i < q; i++) { var t = Int(); var x = Int(); var y = Int(); if (t == 1) { y--; sz[x] = y; if (x > 0) tree.Set(x - 1, g[sz[x - 1], y]); if (x < k) tree.Set(x, g[y, sz[x + 1]]); } else { ans.Add(tree.Product(x, y)); } } Out(ans); return null; } public static void Main() => new AtCoder().Run(); public void Run() { var res = Solve(); if (res != null) { if (res is bool yes) res = yes ? "Yes" : "No"; sw.WriteLine(res); } sw.Flush(); } string[] input = Array.Empty(); int iter = 0; readonly StreamWriter sw = new(Console.OpenStandardOutput()) { AutoFlush = false }; #pragma warning disable IDE0051 string String() { while (iter >= input.Length) (input, iter) = (Console.ReadLine()!.Split(' '), 0); return input[iter++]; } T Input() where T : IParsable => T.Parse(String(), null); int Int() => Input(); void Out(object? x, string? separator = null) { separator ??= Environment.NewLine; if (x is System.Collections.IEnumerable obj and not string) { var firstLine = true; foreach (var item in obj) { if (!firstLine) sw.Write(separator); firstLine = false; sw.Write(item); } } else sw.Write(x); sw.WriteLine(); } #pragma warning restore IDE0051 }