#include <bits/stdc++.h>

using namespace std;

typedef long long int ll;
typedef pair<ll, ll> pll;

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

ll calc(ll &m, ll p) {
    ll ret = 1;
    m += p;
    if (m >= 10) {
        ret++;
        m = (m / 10) + (m % 10);
    }
    return ret;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll M;
    cin >> M;
    ll ans = 0;
    vector<ll> v(M);
    REP(i, M) {
        ll d, c;
        cin >> d >> c;

        vector<ll> u;
        while (c > 1) {
            if (c % 2 == 1)
                u.push_back(d);
            c /= 2;
            ans += c;
            d = d + d;
            if (d >= 10) {
                d = (d / 10) + (d % 10);
                ans += c;
            }
        }
        u.push_back(d);
        ll n = u[0];
        REP(j, u.size() - 1) {
            ans += calc(n, u[j + 1]);
        }
        v[i] = n;
    }

    ll m = v[0];
    REP(i, M - 1) {
        ans += calc(m, v[i + 1]);
    }
    cout << ans << endl;
    return 0;
}
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i) 
#define rrep(i, a, b) for (int i = (a); i < (b); ++i)
#define PI acos(-1)
#define pcnt __builtin_popcountll
#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#define sz(x) (int)(x).size()
#define v(T) vector<T>
#define vv(T) v(v(T))
#define fi first
#define se second

using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using LP = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;

template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) {if (a > b) { a = b; return true; } return false; }

ll INF = 1001001001;
ll LINF = 1001001001001001001ll;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);

    ll m; cin>>m;
    vector<LP> dc(m); cin>>dc;

    ll d = 0;
    rep(i, m) d += dc[i].se;

    ll s = 0;
    rep(i, m) s += dc[i].fi * dc[i].se;

    ll ans = d - 1 + (s - 1) / 9;
    cout<<ans<<endl;
}