#include <bits/stdc++.h>
using namespace std;

int main() {
	int n;
	cin >> n;
	
	int m;
	cin >> m;
	
	vector<int> Graph[n+5];
	
	for(int i=0; i<m; i++) {
		int x, y;
		
		cin >> x >> y;
		
		Graph[x].push_back(y);
		Graph[y].push_back(x);
	}
	
	int src = 1;
	int vis[n+5] = {0};
	int level[n+5] = {0};
	
	queue<int> q;
	
	q.push(src);
	vis[src] = 1;
	level[src] = 0;
	
	while(!q.empty()) {
		int removed = q.front();
		
		cout << "Removed: " << removed << " Level: " << level[removed] << endl;

		q.pop();
		
		for(auto u : Graph[removed]) {
			if(vis[u] == 0) {
				q.push(u);
				vis[u] = 1;
				level[u] = level[removed] + 1;
			}
		}
	}
	
	return 0;
}