#include <iostream>
#include <vector>

int main(int argc, char** argv) {
	std::vector<std::string> strings = {"onion", "bbaaccaadd", "alfalfa", "weugweougewoiheew", "pneumonoultramicroscopicsilicovolcanoconiosis"};
		
	for (auto& str : strings) {
		std::string lowestRot = str;
		unsigned int sizeOfRot = 0;
	
		for (auto it = str.begin(); it != str.end(); it++) {
			std::string rotated {it, str.end()};

			rotated += std::string {str.begin(), it};
			if (rotated < lowestRot) {
				lowestRot = rotated;
				sizeOfRot = std::distance(str.begin(), it);
			}
		}

		std::cout << sizeOfRot << " " << lowestRot << std::endl;

	}
}