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 <fstream>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <string>
#include <cmath>
#include <cassert>
#include <ctime>
#include <algorithm>
#include <sstream>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <cstdlib>
#include <cstdio>
#include <iterator>
#include <functional>
#include <bitset>

#ifdef LOCAL
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
clock_t __my_start_clock = clock();
#else
#define eprintf(...)
#endif

#define TIMESTAMP(x) eprintf("["#x"] Time : %.3lf s.\n", (clock() - __my_start_clock)*1.0/CLOCKS_PER_SEC)
#define TIMESTAMPf(x,...) eprintf("[" x "] Time : %.3lf s.\n", __VA_ARGS__, (clock() - __my_start_clock)*1.0/CLOCKS_PER_SEC)

using namespace std;

#ifdef LOCAL
static struct __timestamper {
  string what;
  __timestamper(const char* what) : what(what){};
  __timestamper(const string& what) : what(what){};
  ~__timestamper(){
    TIMESTAMPf("%s", what.data());
	}
} __TIMESTAMPER("end");
#else 
struct __timestamper {};
#endif

typedef long long ll;
typedef long double ld;

const int MAXN = 2100;

vector<int> g[MAXN];
int pp[MAXN];
vector<int> segs[MAXN];

void dfs(int v, int p) {
  pp[v] = p;
  for (int u : g[v]) {
    if (u != p) {
      dfs(u, v);
    }
  }
}


bool dfs2(int v, int p, int to, int id) {
  if (v == to) {
    return true;
  }
  for (int u : g[v]) {
    if (u != p) {
      if (dfs2(u, v, to, id)) {
        if (pp[v] == u) {
          segs[v].push_back(2 * id);
        } else {
          assert(pp[u] == v);
          segs[u].push_back(2 * id + 1);
        }
        return true;
      }
    }
  }
  return false;
}

int main() {
#ifdef LOCAL
  freopen("e.in", "r", stdin);
  freopen("e.out", "w", stdout);
#endif

  int n, m;
  while (scanf("%d%d", &n, &m) == 2) {
    for (int i = 0; i < n; i++) {
      g[i].clear();
      segs[i].clear();
    }

    for (int i = 1; i < n; i++) {
      int a, b;
      scanf("%d%d", &a, &b);
      --a, --b;
      g[a].push_back(b);
      g[b].push_back(a);
    }
    dfs(0, -1);

    vector<pair<int, int>> ps;

    for (int i = 0; i < m; i++) {
      int u, v;
      scanf("%d%d", &u, &v);
      --u, --v;
      dfs2(u, -1, v, i);
      ps.push_back({u, v});
    }

    int ans = 0;

    for (int i = 0; i < n; i++) {
      if (segs[i].size() == 1) {
        ans++;
        segs[i].clear();
      }
      if (segs[i].size()) {
        ans += 2;
      }
    }

    vector<bool> have[2];
    have[0] = have[1] = vector<bool>(n);
    vector<int> cnt(n);
    vector<vector<int>> rsegs(m);
    for (int i = 0; i < n; i++) {
      for (int u : segs[i]) {
        rsegs[u / 2].push_back(2 * i + (u % 2));
      }
    }

    for (int i = 0; i < n; i++) {
      cnt[i] = segs[i].size();
    }

    vector<int> val(m, -1);

    for (int it = 0; it < m; it++) {
      int only = -1;
      for (int i = 0; i < n; i++) {
        if (cnt[i] == 1) {
          only = i;
        }
      }

      int id = -1;
      if (only != -1) {
        for (int x : segs[only]) {
          if (val[x / 2] == -1) {
            assert(id == -1);
            id = x;
          }
        }
        assert(have[0][only] || have[1][only]);
        if (have[0][only]) {
          id ^= 1;
        }
        val[id / 2] = id % 2;
      } else {
        for (int i = 0; i < m; i++) {
          if (val[i] == -1) {
            id = 2 * i;
            val[i] = 0;
            break;
          }
        }
      }


      assert(id != -1);

//      eprintf("id = %d, set %d to %d\n", id, id / 2, val[id / 2]);

      for (int s : rsegs[id / 2]) {
        if (have[0][s / 2] && have[1][s / 2]) {
          continue;
        }
        int v = (s % 2) ^(id % 2);
        have[v][s / 2] = 1;
        if (have[0][s / 2] && have[1][s / 2]) {
          cnt[s / 2] = 0;
          continue;
        }
        cnt[s / 2]--;
        assert(cnt[s / 2] != 0);
      }

    }

    printf("%d\n", ans);

    for (int i = 0; i < m; i++) {
      if (val[i]) {
        printf("%d %d\n", ps[i].second + 1, ps[i].first + 1);
      } else {
        printf("%d %d\n", ps[i].first + 1, ps[i].second + 1);
      }
    }
  }

  return 0;
}