#include <iostream>
#include <string>
#include <vector>
#include <stdexcept>
#include <algorithm>
std::vector<std::string> split(const std::string &str, char delim) {
	std::vector<std::string> res;
	size_t current = 0, found;
	while (std::string::npos != (found = str.find_first_of(delim, current))) {
		res.push_back(std::string(str, current, found - current));
		current = found + 1;
	}
	res.push_back(std::string(str, current, str.size() - current));
	return res;
}
std::pair<std::string, int> convert_from_input(const std::string & line) {
	const auto vec = split(line, ' ');
	if (2 != vec.size()) throw std::runtime_error("unknown input");;
	std::pair<std::string, int> re(vec.at(0), std::stoi(vec.at(1)));
	return re;
}
int main() {
	std::vector<std::pair<std::string, int>> shouhin;
	std::string buf;
	//input
	for (std::size_t i = 0; getline(std::cin, buf); i++) {
		try {
			shouhin.push_back(convert_from_input(buf));
		}
		catch (std::exception er) {
			std::cerr << er.what() << std::endl;
		}
	}
	//swap data
	std::reverse(shouhin.begin(), shouhin.end());

	//print data
	for (auto& i : shouhin) {//Range-base for(C++11)
		std::cout << i.first << " " << i.second << std::endl;
	}
	return 0;
}