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>
using namespace std;
const int maxn = 200000 + 10;

int n, m, h[maxn], ecnt, acnt;
struct enode{
	int v, n;
	enode() {}
	enode(int _v, int _n):v(_v), n(_n) {}
}e[maxn << 1];
struct anode{
	int x, y;
	anode() {}
	anode(int _x, int _y):x(_x), y(_y) {}
}a[maxn];

inline void addedge(int u, int v) { ecnt ++; e[ecnt] = enode(v,h[u]); h[u] = ecnt; }

int pre[maxn], dep[maxn], dfn[maxn], lst[maxn], tim;
void predfs(int u, int fa) {
	tim ++; dfn[u] = tim;
  pre[u] = fa; dep[u] = dep[fa] + 1;
	for(int i = h[u];~ i;i = e[i].n) {
		int v = e[i].v;
		if(v == fa) continue;
		predfs(v,u);
	}
	lst[u] = tim;
}

vector<int> lis[maxn];
int sfa[maxn], used[maxn], d[maxn], ch[maxn][2];

int findfa(int u) { return (sfa[u] == u) ? (u) : (sfa[u] = findfa(sfa[u])); }

inline void work(int u, int v, int id) {
	if(dep[u] < dep[v]) swap(u,v);
	while(dep[u] > dep[v]) {
		lis[u].push_back(id);
		u = pre[u];
	}
	if(u == v) return;
	while(pre[u] != pre[v]) {
		lis[u].push_back(id);
		lis[v].push_back(id);
		u = pre[u], v = pre[v];
	}
	lis[u].push_back(id);
	lis[v].push_back(id);
}

int col[maxn];

inline void addcol(int u, int v, int c) {
	if(dep[u] < dep[v]) swap(u,v);
	while(dep[u] > dep[v]) {
		col[u] |= c;
		u = pre[u];
	}
	if(u == v) {
		col[u] |= c;
		return;
	}
  while(pre[u] != pre[v]) {
		col[u] |= c;
		col[v] |= c;
		u = pre[u], v = pre[v];
	}
	col[u] |= c;
	col[v] |= c;
	col[pre[u]] |= c;
}

inline void calc(int x, int y, int u) {
	memset(col,0,sizeof(col));
	addcol(a[x].x,a[x].y,1);
	addcol(a[y].x,a[y].y,2);
	while(col[pre[u]] == 3) {
		used[u] = 1;
		u = pre[u];
	}
}

int Ans = 0;
void dfs1(int u, int fa) {
  for(int i = h[u];~ i;i = e[i].n) {
		int v = e[i].v;
		if(v == fa) continue;
		dfs1(v,u);
	}
	Ans += min((int)lis[u].size(),2);
}

void dfs2(int u, int fa) {
	for(int i = h[u];~ i;i = e[i].n) {
		int v = e[i].v;
		if(v == fa) continue;
		dfs2(v,u);
	}
	int Sz = lis[u].size();
	int x = -1, y = -1;
	for(int i = 0;i < Sz;i ++) {
		int v = findfa(lis[u][i]);
		if(x == -1) x = v;
		else {
			if(x == v) continue;
			y = v;
			break;
		}
	}
	if(y == -1 || used[u]) return;
//	cout << u << endl;
  calc(x,y,u);
	if(dfn[u] <= dfn[a[x].x] && dfn[a[x].x] <= lst[u]) swap(a[x].x,a[x].y);
	if(dfn[u] <= dfn[a[y].y] && dfn[a[y].y] <= lst[u]) swap(a[y].x,a[y].y);
	int p = ++ acnt;
	a[p] = anode(a[x].x,a[y].y);
	ch[p][0] = x; ch[p][1] = y;
//	d[x] ++; d[y] ++;
	sfa[x] = sfa[y] = sfa[p] = p;
}

void dfs3(int u) {
	int ls = ch[u][0], rs = ch[u][1];
	if(!ls && !rs) return;
	if(a[u].x != a[ls].x) swap(a[ls].x,a[ls].y), swap(a[rs].x,a[rs].y);
	dfs3(ls);
	dfs3(rs);
}

int val[maxn];

inline void Check_add(int u, int v) {
	while(dep[u] > dep[v]) {
		val[u] |= 1;
		u = pre[u];
	}
	while(dep[u] < dep[v]) {
		val[v] |= 2;
		v = pre[v];
	}
	if(u == v) return;
	while(pre[u] != pre[v]) {
		val[u] |= 1;
		val[v] |= 2;
		u = pre[u], v = pre[v];
	}
	val[u] |= 1, val[v] |= 2;
}

int res;

inline int calc_sum(int x) {
	if(x == 0) return 0;
	if(x == 1 || x == 2) return 1;
	if(x == 3) return 2;
}

void dfs_ch(int u, int fa) {
  res += min(2,calc_sum(val[u]));
	for(int i = h[u];~ i;i = e[i].n) {
		int v = e[i].v;
		if(v == fa) continue;
		dfs_ch(v,u);
	}
}

inline void Check() {
  memset(val,0,sizeof(val));
	for(int i = 1;i <= m;i ++) {
    Check_add(a[i].x,a[i].y);
	}
	res = 0;
	dfs_ch(1,0);
	if(res == Ans) puts("Yes");
	else puts("No");
}

int main() {
	scanf("%d%d", &n, &m); ecnt = 0;
	memset(h,-1,sizeof(h));
	for(int i = 1;i < n;i ++) {
		int u, v;
		scanf("%d%d", &u, &v);
		addedge(u,v);
		addedge(v,u);
	}
	tim = dfn[0] = 0;
	predfs(1,0);
	for(int i = 1;i <= m;i ++) {
		int u, v;
		scanf("%d%d", &u, &v);
		a[i] = anode(u,v);
		work(u,v,i);
		sfa[i] = i;
	}
	acnt = m;
	dfs1(1,0);
	dfs2(1,0);
	for(int i = 1;i <= acnt;i ++) {
		if(sfa[i] != i) continue;
		dfs3(i);
	}
	printf("%d\n", Ans);
//  Check();
//	/*
	for(int i = 1;i <= m;i ++) {
		printf("%d %d\n", a[i].x, a[i].y);
	}
//	*/
	return 0;
}