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;
using Int = long long;
//INSERT ABOVE HERE
signed main(){
  Int n,m;
  cin>>n>>m;
  vector<vector<Int> > G(n);
  for(Int i=1;i<n;i++){
    Int a,b;
    cin>>a>>b;
    a--;b--;
    G[a].emplace_back(b);
    G[b].emplace_back(a);
  }
  auto GG(G);
  vector<Int> a(m),b(m);
  for(Int i=0;i<m;i++) cin>>a[i]>>b[i];
  
  vector<vector<Int> > H(n);
  for(Int i=0;i<m;i++){
    a[i]--;b[i]--;
    H[a[i]].emplace_back(i);
    H[b[i]].emplace_back(i);
  }
  
  Int ans=0;
  vector<vector<Int> > C(n*m+114514);
  auto sw=
    [&](Int x){
      queue<Int> q({x});
      while(!q.empty()){
	x=q.front();q.pop();
	swap(a[x],b[x]);
	for(Int y:C[x]) q.emplace(y);
      }
    };

  vector<Int> used(n*m+114514,0);
  while(1){
    Int idx=-1;
    for(Int i=0;i<n;i++)
      if(G[i].size()==1u) idx=i;
    if(idx<0) break;
      
    H[idx].erase(remove_if(H[idx].begin(),H[idx].end(),
			   [&](Int v){return used[v];}),
		 H[idx].end());      
      
    Int x=-1,y=-1;
    if(H[idx].size()>1u){
      x=H[idx].back();
      H[idx].pop_back();
      y=H[idx].back();
      H[idx].pop_back();

      Int u=a[x]!=idx?a[x]:b[x];
      Int v=a[y]!=idx?a[y]:b[y];
	
      if(u!=a[x]) sw(x);
      if(v!=b[y]) sw(y);

      used[x]=used[y]=1;
      if(u!=v){
	H[u].emplace_back(a.size());
	H[v].emplace_back(b.size());
	  
	C[a.size()].emplace_back(x);
	C[b.size()].emplace_back(y);
	  
	a.emplace_back(u);
	b.emplace_back(v);
      }
      ans+=2;
    }else ans+=H[idx].size();

	  
    Int k=G[idx][0];
    G[idx].clear();
    G[k].erase(remove_if(G[k].begin(),G[k].end(),
			 [&](Int v){return v==idx;}),
	       G[k].end());
      
    vector<Int> tmp(H[idx]);
    H[idx].clear();
    for(Int z:tmp){
      if(used[z]) continue;
      used[z]=1;
      Int u=(a[z]==idx?k:a[z]);
      Int v=(b[z]==idx?k:b[z]);
      if(u==v) continue;
      
      H[u].emplace_back(a.size());
      H[v].emplace_back(b.size());
      
      C[a.size()].emplace_back(z);
      
      a.emplace_back(u);
      b.emplace_back(v);
    }
  };
  {
    vector<Int> ps(n);
    function<void(Int, Int)> dfs=
      [&](Int v,Int p){
	ps[v]=p;
	for(Int u:GG[v])
	  if(u!=p) dfs(u,v);
      };
    using P = pair<Int, Int>;
    set<P> sp;
    for(Int i=0;i<m;i++){
      dfs(b[i],-1);
      Int v=a[i];
      while(v!=b[i]){
	sp.emplace(v,ps[v]);
	v=ps[v];
      }
    }
    Int res=sp.size();
    //cout<<res<<" "<<ans<<endl;
    ans=res;
    //assert(res==ans);
  }
  cout<<ans<<endl;
  for(Int i=0;i<m;i++) cout<<++a[i]<<" "<<++b[i]<<endl;
  return 0;
}