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 <map>
#include <set>
#include <ctime>
#include <queue>
#include <stack>
#include <cmath>
#include <vector>
#include <bitset>
#include <cstdio>
#include <cctype>
#include <string>
#include <numeric>
#include <cstring>
#include <cassert>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <functional>
using namespace std ;
#define rep(i, a, b) for (register int i = (a); i <= (b); ++i)
#define per(i, a, b) for (register int i = (a); i >= (b); --i)
#define loop(it, v) for (auto it = v.begin(); it != v.end(); it++)
#define cont(i, x) for (register int i = head[x]; i; i = edge[i].nex)
#define clr(a) memset(a, 0, sizeof(a))
#define ass(a, cnt) memset(a, cnt, sizeof(a))
#define cop(a, b) memcpy(a, b, sizeof(a))
#define lowbit(x) (x & -x)
#define all(x) x.begin(), x.end()
#define SC(t, x) static_cast <t> (x)
#define ub upper_bound
#define lb lower_bound
#define pqueue priority_queue
#define mp make_pair
#define pb push_back
#define pof pop_front
#define pob pop_back
#define fi first
#define se second
#define y1 y1_
#define Pi acos(-1.0)
#define iv inline void
#define enter putchar('\n')
#define siz(x) ((int)x.size())
#define file(x) freopen(x".in", "r", stdin),freopen(x".out", "w", stdout)
typedef double db ;
typedef long long ll ;
typedef unsigned long long ull ;
typedef pair <int, int> pii ;
typedef vector <int> vi ;
typedef vector <pii> vii ;
typedef queue <int> qi ;
typedef queue <pii> qii ;
typedef set <int> si ;
typedef map <int, int> mii ;
typedef map <string, int> msi ;
const int maxn = 5e3 + 5 ;
const int inf = 0x3f3f3f3f ;
const int iinf = 1 << 30 ;
const ll linf = 2e18 ;
const ll mod = 1e9 + 7 ;
const double eps = 1e-7 ;
template <class T = int> T read()
{
	T f = 1, a = 0;
	char ch = getchar() ;
	while (!isdigit(ch)) { if (ch == '-') f = -1 ; ch = getchar() ; }
	while (isdigit(ch)) { a =  (a << 3) + (a << 1) + ch - '0' ; ch = getchar() ; }
	return a * f ;
}

int n, m, maxx;

vi edge[maxn];

int dep[maxn], fa[maxn], b[maxn][maxn], ans[maxn], g[maxn][2];

pii query[maxn];

bool vis[maxn];

vii s[maxn], lim[maxn];

void dfs(int now, int father)
{
	dep[now] = dep[father] + 1;
	fa[now] = father;
	for(int to : edge[now])
	{
		if(to == father) continue;
		dfs(to, now);
	}
}

void solve(int now)
{
	int cnt = 0;
	for(int to : edge[now])
	{
		if(to == fa[now]) continue;
		solve(to);
		rep(i, 1, m) if(b[now][i] == -1) b[now][i] = b[to][i];
	}
	for(pii i : s[now]) b[now][i.fi] = i.se;
	rep(i, 1, m) cnt += b[now][i] != -1;
	if(cnt < 2) return (void)(maxx += cnt);
	maxx += 2;
	for(int to : edge[now])
	{
		if(to == fa[now]) continue;
		if((~ b[now][g[to][0]]) && (~ b[now][g[to][1]]))
		{
			g[now][0] = g[to][0], g[now][1] = g[to][1];
			break;
		}
	}
	if(g[now][0] != -1) return ;
	int x = 0, y = 0;
	rep(i, 1, m)
	{
		if(b[now][i] == -1) continue;
		if(!x) x = i;
		else
		{
			y = i;
			break;
		}
	}
	g[now][0] = x, g[now][1] = y;
	lim[x].pb(mp(y, b[now][x] ^ b[now][y] ^ 1)), lim[y].pb(mp(x, b[now][x] ^ b[now][y] ^ 1));
}

void paint(int now)
{
	vis[now] = 1;
	for(pii to : lim[now])
	{
		if(vis[to.fi]) continue;
		ans[to.fi] = ans[now] ^ to.se;
		paint(to.fi);
	}
}


signed main()
{
	scanf("%d %d", &n, &m);
	rep(i, 1, n - 1)
	{
		int u, v;
		scanf("%d %d", &u, &v);
		edge[u].pb(v), edge[v].pb(u);
	}
	dfs(1, 0);
	rep(i, 1, m)
	{
		int u, v;
		scanf("%d %d", &u, &v);
		query[i] = mp(u, v);
		while(u != v)
		{
			if(dep[u] < dep[v]) swap(u, v);
			u = fa[u];
		}
		if(query[i].fi != u) s[query[i].fi].pb(mp(i, 0));
		if(query[i].se != u) s[query[i].se].pb(mp(i, 1));
		s[u].pb(mp(i, -1));
	}
	ass(b, -1), ass(g, -1);
	solve(1);
	rep(i, 1, m) if(!vis[i]) paint(i);
	printf("%d\n", maxx);
	rep(i, 1, m) if(ans[i]) printf("%d %d\n", query[i].se, query[i].fi); else printf("%d %d\n", query[i].fi, query[i].se);
	return 0;
}