#include<bits/stdc++.h>
using namespace std;
int main(){
vector<pair<int, int>> money;
int a, b;
while(cin >> a >> b) {
money.push_back({a, b});
}
sort(money.begin(), money.end(), greater<pair<int, int>>());
long long total = 0;
for(auto& m : money) {
cout << m.first << "元鈔票共有" << m.second << "張" << endl;
total += (long long)m.first * m.second;
}
cout << "總共有" << total << "元" << endl;
return 0;
}