#include <iostream> #include <algorithm> #include <vector> #include <string> #include <sstream> #include <set> using namespace std; int count_steps(vector<int> &nums) { int totalSteps = 0; vector<int> line; for (int i = 1; i < nums.size(); i++) { int num = nums[i]; for (int j = 0; j < line.size(); j++) { if (line[j] > num) { totalSteps++; } } line.push_back(num); } return totalSteps; } // numbers int main() { std::string tmp; std::getline(std::cin, tmp); while(std::getline(std::cin, tmp)) { std::vector<int> nums; std::stringstream ss(tmp); int ti; while(ss >> ti) nums.push_back(ti); int steps = count_steps(nums); cout << nums[0] << " " << steps << endl; } return 0; }