Problem: Takahashi loves walking on a tree. The tree where Takahashi walks has N vertices numbered 1 through N. The i-th of the N-1 edges connects Vertex a_i and Vertex b_i.

Takahashi has scheduled M walks. The i-th walk is done as follows:

* The walk involves two vertices u_i and v_i that are fixed beforehand.
* Takahashi will walk from u_i to v_i or from v_i to u_i along the shortest path.



The happiness gained from the i-th walk is defined as follows:

* The happiness gained is the number of the edges traversed during the i-th walk that satisfies one of the following conditions:
* In the previous walks, the edge has never been traversed.
* In the previous walks, the edge has only been traversed in the direction opposite to the direction taken in the i-th walk.



Takahashi would like to decide the direction of each walk so that the total happiness gained from the M walks is maximized. Find the maximum total happiness that can be gained, and one specific way to choose the directions of the walks that maximizes the total happiness.

Constraints

* 1 ≤ N,M ≤ 2000
* 1 ≤ a_i , b_i ≤ N
* 1 ≤ u_i , v_i ≤ N
* a_i \neq b_i
* u_i \neq v_i
* The graph given as input is a tree.

Input

Input is given from Standard Input in the following format:


N M
a_1 b_1
:
a_{N-1} b_{N-1}
u_1 v_1
:
u_M v_M


Output

Print the maximum total happiness T that can be gained, and one specific way to choose the directions of the walks that maximizes the total happiness, in the following format:


T
u^'_1 v^'_1
:
u^'_M v^'_M


where (u^'_i,v^'_i) is either (u_i,v_i) or (v_i,u_i), which means that the i-th walk is from vertex u^'_i to v^'_i.

Examples

Input

4 3
2 1
3 1
4 1
2 3
3 4
4 2


Output

6
2 3
3 4
4 2


Input

5 3
1 2
1 3
3 4
3 5
2 4
3 5
1 5


Output

6
2 4
3 5
5 1


Input

6 4
1 2
2 3
1 4
4 5
4 6
2 4
3 6
5 6
4 5


Output

9
2 4
6 3
5 6
4 5

Solution (in CPP):

Solution:
#include <bits/stdc++.h>

const int N = 2005;

int n, m, head[N], tot, dep[N], f[N];
struct edge { int to, nxt; } e[N << 1];

void link(int x, int y) {
	e[++tot] = (edge) { y, head[x] }, head[x] = tot;
	e[++tot] = (edge) { x, head[y] }, head[y] = tot;
}

int dfn[N], idx;

void dfs0(int x) {
	dep[x] = dep[f[x]] + 1, dfn[++idx] = x;
	for (int i = head[x]; i; i = e[i].nxt)
		if (e[i].to != f[x]) f[e[i].to] = x, dfs0(e[i].to);
}

int lca[N][N], cnt[N];

void dfs1(int x, int start, int min = 0, int f = 0) {
	if (dep[x] < dep[min]) min = x;
	lca[start][x] = min;
	for (int i = head[x]; i; i = e[i].nxt) if (e[i].to != f)
		dfs1(e[i].to, start, min, x);
}

std::vector<bool> solve(int dep, std::vector<std::pair<int, int>> paths) {
	if (dep > n) return {};
	int x = dfn[n - dep + 1], m = paths.size();
	std::vector<bool> rev(m, 0);
	std::vector<int> depend(m, -1);
	std::vector<std::pair<int, int>> nxt;
	int A = -1, B = -1;
	for (int i = 0; i < m; ++i) {
		if ((paths[i].first == x) ^ (paths[i].second == x))	(~A ? B : A) = i;
		if (B != -1) {
			if (paths[A].first == x)
				rev[A] = !rev[A], std::swap(paths[A].first, paths[A].second);
			if (paths[B].second == x)
				rev[B] = !rev[B], std::swap(paths[B].first, paths[B].second);
			int y = paths[A].first, z = paths[B].second, l = lca[y][z], L = lca[l][x];
			for (int i = x; i != L; i = f[i]) cnt[i] -= 2;
			for (int i = l; i != L; i = f[i]) cnt[i] -= 2;
			depend[A] = depend[B] = nxt.size();
			nxt.emplace_back(y, z);
			A = B = -1;
		}
	}
	for (int i = 0; i < m; ++i) {
		if (depend[i] == -1 && paths[i].first != paths[i].second) {
			auto p = paths[i];
			if (p.first == x) p.first = f[x];
			if (p.second == x) p.second = f[x];
			depend[i] = nxt.size();
			nxt.emplace_back(p);
		}
	}
	auto ret = solve(dep + 1, nxt);
	std::vector<bool> ans(m, 0);
	for (int i = 0; i < m; ++i) {
		if (depend[i] != -1) ans[i] = ret[depend[i]];
		if (rev[i]) ans[i] = !ans[i];
	}
	return ans;
}

int main() {
	std::ios::sync_with_stdio(0), std::cin.tie(0);
	std::cin >> n >> m;
	for (int i = 1, x, y; i < n; ++i)
		std::cin >> x >> y, link(x, y);
	dfs0(1), dep[0] = 0x3f3f3f3f;
	for (int i = 1; i <= n; ++i) dfs1(i, i);
	std::vector<std::pair<int, int>> paths;
	for (int i = 0; i < m; ++i) {
		int x, y, l;
		std::cin >> x >> y, l = lca[x][y];
		for (int i = x; i != l; i = f[i]) ++cnt[i];
		for (int i = y; i != l; i = f[i]) ++cnt[i];
		paths.emplace_back(x, y);
	}
	int ans = 0;
	for (int i = 2; i <= n; ++i)
		ans += std::min(2, cnt[i]);
	auto ret = solve(1, paths);
	for (int i = 0; i < m; ++i) if (ret[i]) std::swap(paths[i].first, paths[i].second);
	std::cout << ans << '\n';
	for (auto i : paths) std::cout << i.first << ' ' << i.second << '\n';
	return 0;
}