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 <iostream>
#include <vector>
#include <set>

using namespace std;

const int MAX_N = 2e3 + 5;

namespace dsu {
  int root [MAX_N];
  int rank [MAX_N];
  int sgn [MAX_N];

  pair<int, int> find (int u) {
    if (root[u] != u) {
      auto pr = find(root[u]);
      return make_pair(pr.first, sgn[u] * pr.second);
    } else {
      return make_pair(root[u], sgn[u]);
    }
  }

  void merge (int u, int v, int s) {
    //  cerr << " merge " << u << " " << v << endl;
    auto up = find(u);
    auto vp = find(v);
    u = up.first;
    v = vp.first;
    s *= up.second * vp.second;

    if (u == v) {
      return;
    }

    if (rank[u] < rank[v]) {
      swap(u, v);
    }

    root[v] = u;
    sgn[v] = s;
    if (rank[u] == rank[v]) {
      rank[u]++;
    }
  }
}

vector<int> adj [MAX_N];
int par [MAX_N];
int lvl [MAX_N];

void dfs (int u, int p) {
  par[u] = p;
  lvl[u] = lvl[p] + 1;

  for (int nxt : adj[u]) {
    if (nxt != p) {
      dfs(nxt, u);
    }
  }
}

struct PathFrag {
  int idx, sgn;

  PathFrag (int _idx = 0, int _sgn = 0) :
    idx(_idx), sgn(_sgn) {}
};

vector<PathFrag> covers [MAX_N];

bool doubly_covered (int u, int v) {
  if (lvl[u] < lvl[v]) {
    swap(u, v);
  }

  while (lvl[u] > lvl[v]) {
    if ((int) covers[u].size() < 2) return false;
    u = par[u];
  }

  while (u != v) {
    if ((int) covers[u].size() < 2) return false;
    u = par[u];

    if ((int) covers[v].size() < 2) return false;
    v = par[v];
  }
  
  return true;
}

void add_path (int u, int v, int idx) {
  int sgn = 1;
  
  if (lvl[u] < lvl[v]) {
    swap(u, v);
    sgn = -1;
  }

  while (lvl[u] > lvl[v]) {
    covers[u].push_back(PathFrag(idx, sgn));
    u = par[u];
  }

  while (u != v) {
    covers[u].push_back(PathFrag(idx, sgn));
    u = par[u];

    covers[v].push_back(PathFrag(idx, -sgn));
    v = par[v];
  }
}

int main () {
  int n, m;
  cin >> n >> m;

  for (int i = 0; i < n - 1; i++) {
    int u, v;
    cin >> u >> v;

    adj[u].push_back(v);
    adj[v].push_back(u);
  }

  dfs(1, 0);

  vector<pair<int, int>> paths;
  for (int i = 0; i < m; i++) {
    dsu::root[i] = i;
    dsu::sgn[i] = 1;

    int u, v;
    cin >> u >> v;

    if (!doubly_covered(u, v)) {
      add_path(u, v, i);
    }
    paths.push_back(make_pair(u, v));
  }

  int ans = 0;
  for (int i = 1; i <= n; i++) {
    ans += min(2, (int) covers[i].size());
    if ((int) covers[i].size() == 2) {
      dsu::merge(covers[i][0].idx, covers[i][1].idx,
                 -covers[i][0].sgn * covers[i][1].sgn);
    }
  }

  for (int i = 1; i <= n; i++) {
    if ((int) covers[i].size() >= 3) {
      // check if a path-group already has both sides covered here
      bool need = true;
      set<pair<int, int>> ps;
      for (PathFrag pf : covers[i]) {
        pair<int, int> fp = dsu::find(pf.idx);
        fp.second *= pf.sgn;

        fp.second *= -1;
        if (ps.count(fp)) {
          need = false;
        }
        fp.second *= -1;

        ps.insert(fp);
      }

      if (need) {
        pair<int, int> fp = dsu::find(covers[i][0].idx);
        fp.second *= covers[i][0].sgn;
      
        for (int j = 1; j < (int) covers[i].size(); j++) {
          pair<int, int> cp = dsu::find(covers[i][j].idx);
          cp.second *= covers[i][j].sgn;

          if (fp.first != cp.first) {
            dsu::merge(covers[i][0].idx, covers[i][j].idx,
                       -covers[i][0].sgn * covers[i][j].sgn);
            break;
          } else if (fp.second != cp.second) {
            break;
          }

          if (j == (int) covers[i].size() - 1) {
            cerr << " === URROR === " << endl;
          }
        }
      }
    }
  }

  cout << ans << '\n';
  for (int i = 0; i < m; i++) {
    if (dsu::find(i).second < 0) {
      swap(paths[i].first, paths[i].second);
    }

    cout << paths[i].first << " " << paths[i].second << '\n';
  }
}