#include <bits/stdc++.h>

#ifdef DEBUG
#define debug(...) fprintf(stderr, __VA_ARGS__)
#else
#define debug(...)
#endif

#ifdef __WIN32
#define LLFORMAT "I64"
#define Rand() ((rand() << 15) + rand())
#else
#define LLFORMAT "ll"
#define Rand() (rand())
#endif

using namespace std;

const int maxn = 2010;

vector<int> g[maxn], has[maxn];
vector<pair<int, int> > fuck;
int cnt[maxn], ans, par[maxn], dep[maxn], dfn[maxn], id[maxn], n, m;

void dfs0(int u = 1, int p = 0) {
	static int clk = 0;
	id[dfn[u] = ++clk] = u;
	dep[u] = dep[par[u] = p] + 1;
	for (int &v: g[u]) {
		if(v != p) {
			dfs0(v, u);
		}
	}
	return;
}

void solve(int n, vector<pair<int, int> > &fuck) {
#ifdef DEBUG
	debug("solve(%d, \n", id[n]);
	for (auto t: fuck) {
		//debug("\t%d %d\n", t.first, t.second);
	}
	debug(")\n");
#endif
	auto FUCK = fuck;
	if(n == 1) {
		return;
	}
	for (int i = 1; i <= n; ++i) {
		has[id[i]].clear();
	}
	for (int i = 0; i < fuck.size(); ++i) {
		if(fuck[i].first != fuck[i].second && dfn[fuck[i].first] <= n && dfn[fuck[i].second] <= n) {
			has[fuck[i].first].push_back(i);
			has[fuck[i].second].push_back(i);
		}
	}
	int u = id[n];
	if(!has[u].size()) {
		return solve(n - 1, fuck);
	}
	int i = has[u][0];
	auto t = fuck[i];
	if(t.first != u) {
		swap(t.first, t.second);
	}
	if(has[u].size() == 1) {
		t.first = par[u];
		fuck[i] = t;
		solve(n - 1, fuck);
		if(fuck[i].first == t.second) {
			fuck[i].second = u;
		}
		else {
			fuck[i].first = u;
		}
#ifdef DEBUG
		debug("ret(%d, \n", id[n]);
		for (auto t: fuck) {
			//debug("\t%d %d\n", t.first, t.second);
		}
		debug(")\n");
#endif
		for (int i = 0; i < fuck.size(); ++i) {
			assert(fuck[i].first == FUCK[i].first && fuck[i].second == FUCK[i].second || fuck[i].first == FUCK[i].second && fuck[i].second == FUCK[i].first);
		}
		return;
	}
	int j = has[u][1], p = par[u];
	auto s = fuck[j];
	if(s.first != u) {
		swap(s.first, s.second);
	}
	if(t.second == s.second) {
		swap(s.first, s.second);
		vector<int> v;
		for (int k = 0; k < fuck.size(); ++k) {
			if(k == i) {
				fuck[k] = t;
			}
			else {
				if(k == j) {
					fuck[k] = s;
				}
				else {
					if(fuck[k].first != fuck[k].second && dfn[fuck[k].first] <= n && dfn[fuck[k].second] <= n) {
						if(fuck[k].first == u) {
							v.push_back(k);
							fuck[k].first = p;
						}
						if(fuck[k].second == u) {
							v.push_back(k);
							fuck[k].second = p;
						}
					}
				}
			}
		}
		solve(n - 1, fuck);
		for (int i: v) {
			if(fuck[i].first == p) {
				fuck[i].first = u;
			}
			else if(fuck[i].second == p) {
				fuck[i].second = u;
			}
		}
#ifdef DEBUG
		debug("ret(%d, \n", id[n]);
		for (auto t: fuck) {
			//debug("\t%d %d\n", t.first, t.second);
		}
		debug(")\n");
#endif
		for (int i = 0; i < fuck.size(); ++i) {
			assert(fuck[i].first == FUCK[i].first && fuck[i].second == FUCK[i].second || fuck[i].first == FUCK[i].second && fuck[i].second == FUCK[i].first);
		}
		return;
	}
	vector<int> v;
	for (int k = 0; k < fuck.size(); ++k) {
		if(k == i) {
			fuck[k] = make_pair(u, u);
		}
		else {
			if(k == j) {
				fuck[k] = make_pair(t.second, s.second);
			}
			else {
				if(fuck[k].first != fuck[k].second && dfn[fuck[k].first] <= n && dfn[fuck[k].second] <= n) {
					if(fuck[k].first == u) {
						v.push_back(k);
						fuck[k].first = p;
					}
					if(fuck[k].second == u) {
						v.push_back(k);
						fuck[k].second = p;
					}
				}
			}
		}
	}
	solve(n - 1, fuck);
	for (int i: v) {
		if(fuck[i].first == p) {
			fuck[i].first = u;
		}
		else if(fuck[i].second == p) {
			fuck[i].second = u;
		}
	}
	if(fuck[j].first == t.second) {
		fuck[i] = make_pair(t.second, u);
		fuck[j] = make_pair(u, s.second);
	}
	else {
		fuck[i] = make_pair(u, t.second);
		fuck[j] = make_pair(s.second, u);
	}
#ifdef DEBUG
	debug("ret(%d, \n", id[n]);
	for (auto t: fuck) {
		//debug("\t%d %d\n", t.first, t.second);
	}
	debug(")\n");
#endif
	for (int i = 0; i < fuck.size(); ++i) {
		assert(fuck[i].first == FUCK[i].first && fuck[i].second == FUCK[i].second || fuck[i].first == FUCK[i].second && fuck[i].second == FUCK[i].first);
	}
	return;
}

int main() {
	scanf("%d%d", &n, &m);
	for (int i = 1; i < n; ++i) {
		int u, v;
#ifdef DEBUG
		u = i + 1;
		v = rand() % i + 1;
		debug("%d %d\n", u, v);
#else
		scanf("%d%d", &u, &v);
#endif
		g[u].push_back(v);
		g[v].push_back(u);
	}
	dfs0();
	for (int i = 1; i <= m; ++i) {
		int u, v;
#ifdef DEBUG
		u = rand() % n + 1;
		v = rand() % n + 1;
		debug("%d %d\n", u, v);
#else
		scanf("%d%d", &u, &v);
#endif
		fuck.push_back(make_pair(u, v));
		while(u != v) {
			if(dep[u] < dep[v]) {
				swap(u, v);
			}
			++cnt[u];
			u = par[u];
		}
	}
	for (int i = 1; i <= n; ++i) {
		ans += min(cnt[i], 2);
	}
	printf("%d\n", ans);
	solve(n, fuck);
	for (auto t: fuck) {
		printf("%d %d\n", t.first, t.second);
	}
	return 0;
}


Measured memory_bytes: 32384