#include <bits/stdc++.h>
using namespace std;
int main(){
set<pair<long long int, long long int>, greater<pair<long long int, long long int>>> s;
long long int a, b, sum=0;
while(cin >> a >> b){
s.insert(make_pair(a, b));
sum+=a*b;
}
for(auto p : s){
cout << p.first << "元鈔票共有" << p.second << "張" << endl;
}
cout << "總共有" << sum << "元";
return 0;
}