
#include <algorithm>
#include <array>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

int
main2()
{
#if 0
	// index = > groupId
	std::map<int, int> groups;

	int a, b;

	while (std::cin >> a && a != 0 && std::cin >> b)
	{
		int groupId;
		if (groups.find(a) == groups.end())
		{
			groups[a] = a;
		}
		if (groups.find(b) == groups.end())
		{
			groups[b] = b;
		}
		if (groups[a] == groups[b])
			continue;
		auto temp = groups[b];

		for (auto& elem : groups)
		{
			if (elem.second == temp)
				elem.second = groups[a];
		}

	}

	std::set<int> uniqueGroups;
	std::for_each(groups.begin(), groups.end(), [&uniqueGroups](auto p) { uniqueGroups.insert(p.second); });


	std::cout << "We have " << uniqueGroups.size() << " unique groups" << std::endl;
#else

#endif

	return 0;
}

int
main()
{
	using state = std::array<int, 9>;

	std::queue<state> open;
	std::map<state, std::string> history;

	state initState;
	for (unsigned i = 0; i < 9; ++i) {
		std::cin >> initState[i];
	}

	open.push(initState);
	history[initState] = "";

	std::set<state> visited;
	while (!open.empty()) {
		state current = open.front();
		open.pop();

		if (visited.count(current)) {
			continue;
		}

		visited.emplace(current);
		bool inGoalState = true;
		for (size_t i = 0; i < 9; i++) {
			if (current[i] != (i == 8 ? 0 : (i + 1))) {
				inGoalState = false;
			}
		}

		if (inGoalState) {
			std::cout << "Victory!" << std::endl;
			std::cout << history[current] << std::endl;
			break;
		}

		auto currentZeroIndex =
		  std::distance(current.begin(),
		                std::find(current.begin(), current.end(), 0));

		if (currentZeroIndex >= 3) {
			// move 0 up
			state newstate = current;
			std::swap(newstate[currentZeroIndex],
			          newstate[currentZeroIndex - 3]);
			open.push(newstate);
			if (!history.count(newstate))
				history[newstate] = history[current] + "d";
		}

		if (currentZeroIndex <= 5) {
			// move 0 down
			state newstate = current;
			std::swap(newstate[currentZeroIndex],
			          newstate[currentZeroIndex + 3]);
			open.push(newstate);
			if (!history.count(newstate))
				history[newstate] = history[current] + "u";
		}

		if (currentZeroIndex % 3 != 0) {
			// move 0 left
			state newstate = current;
			std::swap(newstate[currentZeroIndex],
			          newstate[currentZeroIndex - 1]);
			open.push(newstate);
			if (!history.count(newstate))
				history[newstate] = history[current] + "r";
		}

		if (currentZeroIndex % 3 != 2) {
			// move 0 right
			state newstate = current;
			std::swap(newstate[currentZeroIndex],
			          newstate[currentZeroIndex + 1]);
			open.push(newstate);
			if (!history.count(newstate))
				history[newstate] = history[current] + "l";
		}
	}
}
