#include #include #include #include #include #include #include #include #include #include #include using namespace std; typedef long long ll; typedef pair PII; typedef pair PLL; #define fs first #define sc second #define INF 1000000000 #define MOD 1000000007 #define EPS 0.00000001 int main() { int N; cin >> N; vector V(N); for(string &S:V){ string a, b; cin >> a >> b; a += " "; a += b; S = a; } sort(V.begin(), V.end()); for(string &S:V) cout << S << endl; return 0; }