Problem: You are given a directed weighted graph with n nodes and 2n - 2 edges. The nodes are labeled from 1 to n, while the edges are labeled from 1 to 2n - 2. The graph's edges can be split into two parts.

  * The first n - 1 edges will form a rooted spanning tree, with node 1 as the root. All these edges will point away from the root. 
  * The last n - 1 edges will be from node i to node 1, for all 2 ≤ i ≤ n. 



You are given q queries. There are two types of queries

  * 1 i w: Change the weight of the i-th edge to w
  * 2 u v: Print the length of the shortest path between nodes u to v



Given these queries, print the shortest path lengths.

Input

The first line of input will contain two integers n, q (2 ≤ n, q ≤ 200 000), the number of nodes, and the number of queries, respectively.

The next 2n - 2 integers will contain 3 integers ai, bi, ci, denoting a directed edge from node ai to node bi with weight ci.

The first n - 1 of these lines will describe a rooted spanning tree pointing away from node 1, while the last n - 1 of these lines will have bi = 1.

More specifically, 

  * The edges (a1, b1), (a2, b2), ... (an - 1, bn - 1) will describe a rooted spanning tree pointing away from node 1. 
  * bj = 1 for n ≤ j ≤ 2n - 2. 
  * an, an + 1, ..., a2n - 2 will be distinct and between 2 and n. 



The next q lines will contain 3 integers, describing a query in the format described in the statement.

All edge weights will be between 1 and 106.

Output

For each type 2 query, print the length of the shortest path in its own line.

Example

Input

5 9
1 3 1
3 2 2
1 4 3
3 5 4
5 1 5
3 1 6
2 1 7
4 1 8
2 1 1
2 1 3
2 3 5
2 5 2
1 1 100
2 1 3
1 8 30
2 4 2
2 2 4


Output

0
1
4
8
100
132
10

Solution (in JAVA):

Solution:

/**
 * DA-IICT
 * Author : Savaliya Sagar
 */
import java.io.*;
import java.math.*;
import java.util.*;

import static java.util.Arrays.fill;
import static java.lang.Math.*;
import static java.util.Arrays.sort;
import static java.util.Collections.sort;

public class B838 {
	InputStream is;
	PrintWriter out;
	String INPUT = "";
	ArrayList<Integer> a[];
	int uu[], vv[];
	long c[], w[];
	int s[], e[];
	int time = 0;
	int n;

	void solve() {
		n = ni();
		int q = ni();
		a = new ArrayList[n + 1];
		for (int i = 1; i <= n; i++)
			a[i] = new ArrayList<>();
		uu = new int[2 * n - 2];
		vv = new int[2 * n - 2];
		w = new long[n + 1];
		c = new long[n + 1];
		s = new int[n + 1];
		e = new int[n + 1];
		for (int i = 0; i < n + n - 2; i++) {
			uu[i] = ni();
			vv[i] = ni();
			int ww = ni();
			if (vv[i] == 1)
				c[uu[i]] = ww;
			else {
				w[vv[i]] = ww;
				a[uu[i]].add(vv[i]);
			}
		}
		init(n);
		dfs(1, 0);
		while (q-- > 0) {
			int t = ni();
			if (t == 1) {
				int i = ni() - 1;
				long val = ni();
				if (i < n - 1) {
					updateRange(1, 1, n, s[vv[i]], e[vv[i]], val - w[vv[i]]);
					w[vv[i]] = val;
				}else{
					updateRange(1,1,n,s[uu[i]],s[uu[i]],val-c[uu[i]]);
					c[uu[i]] = val;
				}
			} else {
				int u = ni();
				int v = ni();
				long ans;
				if (s[u] <= s[v] && e[v] <= e[u])
					ans = queryRange(1, 1, n, s[v], s[v]) - c[v] - queryRange(1, 1, n, s[u], s[u]) + c[u];
				else {
					ans = queryRange(1, 1, n, s[u], e[u]) - queryRange(1, 1, n, s[u], s[u]) + c[u];
					ans += queryRange(1, 1, n, s[v], s[v]) - c[v];
				}
				out.println(ans);
			}
		}

	}

	void dfs(int u, long sum) {
		time++;
		s[u] = time;
		updateRange(1, 1, n, time, time, sum + c[u]);
		for (int k : a[u]) {
			dfs(k, sum + w[k]);
		}
		e[u] = time;
	}

	long tree[];
	long lazy[];

	public void init(int n) {
		tree = new long[4 * n];
		lazy = new long[4 * n];
	}

	void updateRange(int node, int start, int end, int l, int r, long val) {
		if (lazy[node] != 0) {
			tree[node] += lazy[node];
			if (start != end) {
				lazy[node * 2] += lazy[node];
				lazy[node * 2 + 1] += lazy[node];
			}
			lazy[node] = 0;
		}
		if (start > end || start > r || end < l)
			return;
		if (start >= l && end <= r) {
			tree[node] += val;
			if (start != end) {
				lazy[node * 2] += val;
				lazy[node * 2 + 1] += val;
			}
			return;
		}
		int mid = (start + end) / 2;
		updateRange(node * 2, start, mid, l, r, val);
		updateRange(node * 2 + 1, mid + 1, end, l, r, val);
		tree[node] = min(tree[node * 2], tree[node * 2 + 1]);
	}

	long queryRange(int node, int start, int end, int l, int r) {
		if (start > end || start > r || end < l)
			return Long.MAX_VALUE;
		if (lazy[node] != 0) {
			tree[node] += lazy[node];
			if (start != end) {
				lazy[node * 2] += lazy[node];
				lazy[node * 2 + 1] += lazy[node];
			}
			lazy[node] = 0;
		}
		if (start >= l && end <= r)
			return tree[node];
		int mid = (start + end) / 2;
		long p1 = queryRange(node * 2, start, mid, l, r);
		long p2 = queryRange(node * 2 + 1, mid + 1, end, l, r);
		return min(p1, p2);
	}

	void run() throws Exception {
		is = INPUT.isEmpty() ? System.in : new ByteArrayInputStream(INPUT.getBytes());
		out = new PrintWriter(System.out);

		long s = System.currentTimeMillis();
		solve();
		out.flush();
		if (!INPUT.isEmpty())
			tr(System.currentTimeMillis() - s + "ms");
	}

	public static void main(String[] args) throws Exception {
		new Thread(null, new Runnable() {
			public void run() {
				try {
					new B838().run();
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		}, "1", 1 << 26).start();
	}

	private byte[] inbuf = new byte[1024];
	public int lenbuf = 0, ptrbuf = 0;

	private int readByte() {
		if (lenbuf == -1)
			throw new InputMismatchException();
		if (ptrbuf >= lenbuf) {
			ptrbuf = 0;
			try {
				lenbuf = is.read(inbuf);
			} catch (IOException e) {
				throw new InputMismatchException();
			}
			if (lenbuf <= 0)
				return -1;
		}
		return inbuf[ptrbuf++];
	}

	private boolean isSpaceChar(int c) {
		return !(c >= 33 && c <= 126);
	}

	private int skip() {
		int b;
		while ((b = readByte()) != -1 && isSpaceChar(b))
			;
		return b;
	}

	private double nd() {
		return Double.parseDouble(ns());
	}

	private char nc() {
		return (char) skip();
	}

	private String ns() {
		int b = skip();
		StringBuilder sb = new StringBuilder();
		while (!(isSpaceChar(b))) { // when nextLine, (isSpaceChar(b) && b !=
									// ' ')
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	private char[] ns(int n) {
		char[] buf = new char[n];
		int b = skip(), p = 0;
		while (p < n && !(isSpaceChar(b))) {
			buf[p++] = (char) b;
			b = readByte();
		}
		return n == p ? buf : Arrays.copyOf(buf, p);
	}

	private char[][] nm(int n, int m) {
		char[][] map = new char[n][];
		for (int i = 0; i < n; i++)
			map[i] = ns(m);
		return map;
	}

	private int[] na(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = ni();
		return a;
	}

	private int ni() {
		int num = 0, b;
		boolean minus = false;
		while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'))
			;
		if (b == '-') {
			minus = true;
			b = readByte();
		}

		while (true) {
			if (b >= '0' && b <= '9') {
				num = num * 10 + (b - '0');
			} else {
				return minus ? -num : num;
			}
			b = readByte();
		}
	}

	private long nl() {
		long num = 0;
		int b;
		boolean minus = false;
		while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'))
			;
		if (b == '-') {
			minus = true;
			b = readByte();
		}

		while (true) {
			if (b >= '0' && b <= '9') {
				num = num * 10 + (b - '0');
			} else {
				return minus ? -num : num;
			}
			b = readByte();
		}
	}

	private void tr(Object... o) {
		System.out.println(Arrays.deepToString(o));
	}
}