#include <bits/stdc++.h>
using namespace std;
long long INF = 1e18;
int main(){
    long long d, g;
    cin >> d >> g;
    vector<long long> p(d), c(d), score(d);
    for(int i = 0; i < d; i++) {
        cin >> p[i] >> c[i];
        score[i] = (i + 1) * 100;
    }
    long long ans = INF;
    for(int bit = 0; bit < (1 << d); bit++){
        long long G = g;
        long long res = 0;
        vector<int> flag(d, 1);
        for(int i = 0; i < d; i++){
            if(bit & (1 << i)) {
                G -= p[i]*score[i] + c[i];
                flag[i] = 0;
                res += p[i];
            }
        }
        int t = -1;
        for(int j = 0; j < d; j++){
            if(flag[j] == 1) t = j;
        }
        if(G > 0 && G <= p[t] * score[t] + c[t]){
            res += min(p[t], (G + score[t] - 1) / score[t]);
            ans = min(res, ans);
        }
        else if(G <= 0) ans = min(res, ans);
    }
    cout << ans << endl;
}

/**
*    author:  souzai32
*    created: 01.08.2020 23:22:01
**/

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;

int main() {   

    int n,m;
    cin >> n >> m;
    vector<tuple<int,int>> con(m);
    int s,c;
    rep(i,m){
        cin >> s >> c;
        con.at(i)=make_tuple(s,c);
    }
    sort(con.begin(),con.end());

    vector<int> num(4,-1);
    bool a=true;
    int ans=0;

    rep(i,m){
        if(num.at(get<0>(con.at(i)))!=-1 && num.at(get<0>(con.at(i)))!=get<1>(con.at(i))) a=false;
        if(get<0>(con.at(i))==1&&get<1>(con.at(i))==0&&n!=1) a=false;
        num.at(get<0>(con.at(i)))=get<1>(con.at(i));
    }

    int t=1;
    rep(i,n) t*=10;

    if(a){
        for(int i=1; i<=n; i++){
            t/=10;
            if(num.at(i)==-1){
                if(i==1 && n!=1) num.at(i)=1;
                else num.at(i)=0;
            }
            ans+=num.at(i)*t;
        }
        cout << ans << endl;
    }
    else cout << -1 << endl;

    return 0;
}