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 <vector>
#include <utility>
#include <unordered_set>
#include <chrono>
using namespace std;
typedef pair<int,int> ii;

struct custom_hash {
    typedef long long ll;
    typedef unsigned long long ull;
    const ull FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
    static ull splitmix64(ull x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(ll x) const {
        return splitmix64(x + FIXED_RANDOM);
    }
    size_t operator()(const pair<int,int> &i)const{
        return splitmix64((((ll)i.first)^(((ll)i.second)<<32))+FIXED_RANDOM);
    }
};


struct ufds{
    int p[2005];
    
    ufds(){
        for (int x=0;x<2005;x++){
            p[x]=x;
        }
    }
    
    int parent(int i){return (p[i]==i)?i:p[i]=parent(p[i]);}
} dsu=*new ufds();

int n,k;
vector<int> al[2005];
int parent[2005];
int depth[2005];
vector<int> edges[2005];
int deg[2005];

ii path[2005];

vector<int> proc;

unordered_set<int,custom_hash> s;

void dfs(int i,int p){
    if (p!=-1) proc.push_back(i);
    for (auto &it:al[i]){
        if (it==p) continue;
        parent[it]=i;
        depth[it]=depth[i]+1;
        dfs(it,i);
    }
}

void process(int i,int j,int k){
    if (depth[i]<depth[j]) swap(i,j);
    
    while (depth[i]!=depth[j]){
        edges[i].push_back(k);
        i=parent[i];
    }
    
    while (i!=j){
        edges[i].push_back(k);
        i=parent[i];
        edges[j].push_back(k);
        j=parent[j];
    }
}

bool dir(int __i,int __j){
    unordered_set<ii,custom_hash> dir;
    
    int i=path[__i].first,j=path[__i].second;
    
    while (depth[i]>depth[j]){
        dir.insert(ii(i,parent[i]));
        i=parent[i];
    }
    
    while (depth[i]<depth[j]){
        dir.insert(ii(parent[j],j));
        j=parent[j];
    }
    
    while (i!=j){
        dir.insert(ii(i,parent[i]));
        i=parent[i];
        dir.insert(ii(parent[j],j));
        j=parent[j];
    }
    
    i=path[__j].first,j=path[__j].second;
    while (depth[i]>depth[j]){
        if (dir.count(ii(i,parent[i]))) return true;
        i=parent[i];
    }
    
    while (depth[i]<depth[j]){
        if (dir.count(ii(parent[j],j))) return true;
        j=parent[j];
    }
    
    while (i!=j){
        if (dir.count(ii(i,parent[i]))) return true;
        i=parent[i];
        if (dir.count(ii(parent[j],j))) return true;
        j=parent[j];
    }
    
    return false;
}

vector<int> al2[2005];
bool state[2005];
bool visited[2005];

void dfs(int i){ 
    visited[i]=true;
    for (auto &it:al2[i]){
        if (visited[it]) continue;
        state[it]=state[i]^dir(i,it);
        dfs(it);
    }
}

int main(){
    scanf("%d%d",&n,&k);
    
    int a,b;
    for (int x=1;x<n;x++){
        scanf("%d%d",&a,&b);
        al[a].push_back(b);
        al[b].push_back(a);
    }
    
    dfs(1,-1);
    
    for (int x=0;x<k;x++){
        scanf("%d%d",&path[x].first,&path[x].second);
        process(path[x].first,path[x].second,x);
    }
    
    int __ans=0;
    
    int node;
    while (!proc.empty()){
        node=proc.back(),proc.pop_back();
        if (edges[node].size()==1){
            __ans++;
        }
        else if (edges[node].size()>=2){
            __ans+=2;
            s.clear();
            for (auto &it:edges[node]){
                s.insert(dsu.parent(it));
            }
            
            if (s.size()==edges[node].size()){
               int temp=edges[node][0],temp2=edges[node][1];
               dsu.p[temp]=temp2;   
               al2[temp].push_back(temp2);
               al2[temp2].push_back(temp);
               
               //printf("%d %d %d\n",temp,temp2,dir(temp,temp2));
            }
        }
    }
    
            
    printf("%d\n",__ans);    
    for (int x=0;x<k;x++){
        if (!visited[x]) dfs(x);
        if (state[x]) printf("%d %d\n",path[x].first,path[x].second);
        else printf("%d %d\n",path[x].second,path[x].first);
    }
}