#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;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8c3RyaW5nPgojaW5jbHVkZSA8dmVjdG9yPgojaW5jbHVkZSA8c3RkZXhjZXB0PgojaW5jbHVkZSA8YWxnb3JpdGhtPgpzdGQ6OnZlY3RvcjxzdGQ6OnN0cmluZz4gc3BsaXQoY29uc3Qgc3RkOjpzdHJpbmcgJnN0ciwgY2hhciBkZWxpbSkgewoJc3RkOjp2ZWN0b3I8c3RkOjpzdHJpbmc+IHJlczsKCXNpemVfdCBjdXJyZW50ID0gMCwgZm91bmQ7Cgl3aGlsZSAoc3RkOjpzdHJpbmc6Om5wb3MgIT0gKGZvdW5kID0gc3RyLmZpbmRfZmlyc3Rfb2YoZGVsaW0sIGN1cnJlbnQpKSkgewoJCXJlcy5wdXNoX2JhY2soc3RkOjpzdHJpbmcoc3RyLCBjdXJyZW50LCBmb3VuZCAtIGN1cnJlbnQpKTsKCQljdXJyZW50ID0gZm91bmQgKyAxOwoJfQoJcmVzLnB1c2hfYmFjayhzdGQ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