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 <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <set>
#include <queue>
#define PB push_back
#define MP make_pair
#define PII pair<int,int>
#define FIR first
#define SEC second
#define ll long long
using namespace std;
template <class T>
inline void rd(T &x) {
	x=0; char c=getchar(); int f=1;
	while(!isdigit(c)) { if(c=='-') f=-1; c=getchar(); }
	while(isdigit(c)) x=x*10-'0'+c,c=getchar(); x*=f;
}

const int N=2010;
struct ED {
	int x,y;
	int ty,id;
}E[N*N];
int res[N*N];
int n,m,head[N],ecnt,mcnt;
struct ed { int to,next; }e[N<<1];
void ad(int x,int  y) {
	e[++ecnt]=(ed){y,head[x]}; head[x]=ecnt;
	e[++ecnt]=(ed){x,head[y]}; head[y]=ecnt;
}
int vis1[N],vis2[N];
int fa[N],dep[N],deg[N];
vector<int> son[N];
void dfs(int u,int last) {
	fa[u]=last,dep[u]=dep[last]+1;
	for(int k=head[u];k;k=e[k].next) {
		int v=e[k].to; if(v==last) continue;
		son[u].PB(v),dfs(v,u);
	}
	deg[u]=son[u].size();
}
void go_mark(int x,int y) {
	if(dep[x]<dep[y]) swap(x,y);
	while(dep[x]>dep[y]) vis2[x]=1,x=fa[x];
	while(x!=y) vis2[x]=vis2[y]=1,x=fa[x],y=fa[y];
}
int LCA(int x,int y) {
	if(dep[x]<dep[y]) swap(x,y);
	while(dep[x]>dep[y]) x=fa[x];
	while(x!=y) x=fa[x],y=fa[y];
	return x;
}
int get_max_dep(int x,int y) { return dep[x]>dep[y] ? x : y; }

set<int> P[N];
queue<int> que;
int main() {
//	freopen("in.txt","r",stdin);
	rd(n),rd(m);
	for(int i=1,x,y;i<n;++i) rd(x),rd(y),ad(x,y);
	dfs(1,0);
	for(int i=1;i<=m;++i) {
		rd(E[i].x),rd(E[i].y);
		E[i].ty=0,E[i].id=i;
		P[E[i].x].insert(i),P[E[i].y].insert(i);
	}
	mcnt=m;
	for(int i=2;i<=n;++i) if(!deg[i]) que.push(i);
	int ans=0;
	while(!que.empty()) {
		int u=que.front(); que.pop();
		if(!vis2[u] && P[u].size()>1) {
			int x=*P[u].begin(); P[u].erase(P[u].begin());
			int y=*P[u].begin(); P[u].erase(P[u].begin());
			int a=E[x].x^E[x].y^u;
			int b=E[y].x^E[y].y^u;
			if(a==b) {
				res[x]=E[x].x!=a,res[y]=E[y].y!=b;
				go_mark(u,a);
				P[a].erase(x),P[b].erase(y);
			}
			else {
				int L=get_max_dep(LCA(u,a),get_max_dep(LCA(u,b),LCA(a,b)));
				go_mark(u,L);
				int k=++mcnt;
				E[k].x=a,E[k].y=b,E[k].ty=0,E[k].id=k;
				E[x].ty=E[k].x!=E[x].x;
				E[y].ty=E[k].y!=E[y].y;
				E[x].id=E[y].id=k;
				P[a].erase(x),P[a].insert(k);
				P[b].erase(y),P[b].insert(k);
			}
		}
		if(vis2[u]) ans+=2;
		else if(!P[u].empty()) ans++;
		while(!P[u].empty()) {
			int x=*P[u].begin(); P[u].erase(P[u].begin());
			int v=E[x].x^E[x].y^u;
//			cerr<<"delete : "<<v<<' '<<u<<endl;
			P[v].erase(x);
			if(v!=fa[u]) {
				int y=++mcnt;
				E[y].x=fa[u],E[y].y=v,E[y].ty=0,E[y].id=y;
				E[x].ty=E[y].y!=E[x].y,E[x].id=y;
				P[v].insert(y),P[fa[u]].insert(y);
			}
		}
		deg[fa[u]]--;
		if(!deg[fa[u]]&&fa[u]!=1) que.push(fa[u]);

//		cout<<"solved : "<<u<<endl;
//		for(int i=1;i<=mcnt;++i) printf("(%d,%d,%d,%d) ",E[i].x,E[i].y,E[i].ty,E[i].id); cout<<endl;
//		for(int i=1;i<=mcnt;++i) cout<<res[i]<<' '; cout<<endl;
				
	}
	printf("%d\n",ans);
	for(int i=mcnt;i>=1;--i) if(E[i].id!=i) res[i]=res[E[i].id]^E[i].ty;
	for(int i=1;i<=m;++i)
		if(res[i]) printf("%d %d\n",E[i].y,E[i].x);
		else printf("%d %d\n",E[i].x,E[i].y);
	return 0;
}