#include <iostream>

using namespace std;

int main() {
	int m; cin >> m;
	long long sum = 0, ans = -1;
	for (int i = 0; i < m; ++i) {
		long long d, c; cin >> d >> c;
		sum += d * c;
		ans += c;
	}
	long long tmp = sum;
	while (tmp > 9) {
		ans += tmp / 10;
		tmp = tmp / 10 + tmp % 10;
	}
	cout << ans << endl;

	return 0;
}