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 ll = long long;

// リファクタリング兼とき直し

const int N = 2000;
vector<pair<int, int>> g[N];
vector<pair<int, int>> ng[N];
int n, m;
int ecas[N], qina[N];
vector<pair<int, int>> noel[N];
vector<int> tap[N];

int u[N], v[N];
int did[N], edgeUsed[N];

int dfs(int i, int p, int to, int id) {
  if(i == to) return 1;
  int f = 0;
  for(auto e : g[i]) {
    int j, ei; tie(j, ei) = e;
    if(j == p) continue;
    int t = dfs(j, i, to, id);
    f += t;
    if(t) {
      tap[ei].emplace_back(id);
    }
  }
  return f;
}
int dfs2(int i, int p, int to0, int to1) {
  int f = (i == to0) + (i == to1);
  for(auto e : g[i]) {
    int j, ei; tie(j, ei) = e;
    if(j == p) continue;
    int t = dfs2(j, i, to0, to1);
    f += t;
    if(t == 2) {
      edgeUsed[ei] = 1;
    }
  }
  return f;
}

int used[N];
int ans[N];
void dfs3(int i) {
  used[i] = 1;
  for(auto e : ng[i]) {
    int j, usi; tie(j, usi) = e;
    if(used[j]) continue;
    ans[j] = ans[i] ^ usi;
    dfs3(j);
  }
}

int main() {
  ios::sync_with_stdio(false), cin.tie(0);
  cin >> n >> m;
  for(int i = 0; i < n - 1; i++) {
    int a, b; cin >> a >> b;
    a--; b--;
    g[a].emplace_back(b, i);
    g[b].emplace_back(a, i);
  }
  for(int i = 0; i < m; i++) {
    cin >> u[i] >> v[i];
    u[i]--; v[i]--;
    dfs(u[i], -1, v[i], i);
    ecas[i] = u[i];
    qina[i] = v[i];
    noel[u[i]].emplace_back(i, 0);
    noel[v[i]].emplace_back(i, 1);
  }
  ll val = 0;
  for(int i = 0; i < n - 1; i++) val += min((int) tap[i].size(), 2);

  queue<int> q;
  for(int i = 0; i < n; i++) if(g[i].size() == 1) q.emplace(i);
  while(q.size()) {
    int i = q.front();
    did[i] = 1;
    q.pop();
    for(auto e : g[i]) {
      int j, ei; tie(j, ei) = e;
      if(did[j]) continue;
      int cnt = 0;
      for(auto e2 : g[j]) if(!did[e2.first]) cnt++;
      if(cnt == 1) q.emplace(j);
      vector<pair<int, int>> filt;
      for(auto el : noel[i]) if(ecas[el.first] != qina[el.first]) filt.emplace_back(el);
      noel[i] = filt;
      if(noel[i].size() >= 2 && !edgeUsed[ei]) {
        int to0 = noel[i][0].second ? ecas[noel[i][0].first] : qina[noel[i][0].first];
        int to1 = noel[i][1].second ? ecas[noel[i][1].first] : qina[noel[i][1].first];
        dfs2(i, -1, to0, to1);
        ng[noel[i][0].first].emplace_back(noel[i][1].first, noel[i][0].second == noel[i][1].second);
        ng[noel[i][1].first].emplace_back(noel[i][0].first, noel[i][0].second == noel[i][1].second);
        noel[to1].erase(find(begin(noel[to1]), end(noel[to1]), make_pair(noel[i][1].first, int(!noel[i][1].second))));
        noel[to1].emplace_back(noel[i][0]);
        (!noel[i][0].second ? ecas : qina) [noel[i][0].first] = to1;
        noel[i].erase(begin(noel[i]), begin(noel[i]) + 2);
      }
      for(auto el : noel[i]) {
        (!el.second ? ecas : qina) [el.first] = j;
        noel[j].emplace_back(el);
      }
      noel[i].clear();
    }
  }

  for(int i = 0; i < m; i++) if(!used[i]) dfs3(i);
  cout << val << endl;
  for(int i = 0; i < m; i++) {
    if(ans[i]) swap(u[i], v[i]);
    cout << u[i] + 1 << " " << v[i] + 1 << endl;
  }
}