#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll (i) = 0; (i) < (n); (i)++)
#define rep1(i, n) for(ll (i) = 1; (i) <= (n); (i)++)
#define rrep(i, n) for(ll (i) = (n) - 1; (i) >= 0; (i)--)
#define rrep1(i, n) for(ll (i) = (n); (i) >= 1; (i)--)
const ll INF = 1145141919;
const ll MOD = 1000000007;
template<class T> void chmax(T &a, const T &b){if(a < b){a = b;}}
template<class T> void chmin(T &a, const T &b){if(a > b){a = b;}}

vector<ll>path[101010];
ll flg[101010][2];
ll A, B, C;
ll A_cnt, B_cnt;

int main(){

    ll N, M;
    cin >> N >> M;
    rep(i, M){
        ll x, y;
        cin >> x >> y;
        path[x].push_back(y);
        path[y].push_back(x);
    }
    rep1(i, N){
        if(flg[i][0] || flg[i][1])continue;
        if(path[i].empty()){
            C++;
            continue;
        }
        flg[i][0] = 1;
        queue<P>Q;
        Q.push(P(i, 0));
        while(!Q.empty()){
            ll idx = Q.front().first;
            ll v = Q.front().second;
            Q.pop();
            rep(j, path[idx].size()){
                ll to = path[idx][j];
                if(flg[to][v ^ 1])continue;
                flg[to][v ^ 1] = 1;
                Q.push(P(to, v ^ 1));
            }
        }
        if(flg[i][1])B++;
        else A++;
    }
    rep1(i, N){
        if(flg[i][0] && flg[i][1])A_cnt++;
        else if(flg[i][0] || flg[i][1])B_cnt++;
    }

    cout << B * B + 2 * A * B + 2 * A * A + 2 * B_cnt * C + 2 * A_cnt * C + C * C << endl;

    return 0;
}
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n-1; i >= 0; i--)
#define ALL(x) x.begin(), x.end()
using vi = vector<int>;
using pii = pair<int, int>;
#define fir first
#define sec second

template<class T> inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

int main() {
    // input
    int d, g;
    cin >> d >> g;
    vector<int> p(d), c(d);
    rep(i, d) {
        cin >> p[i] >> c[i];
    }
    // solve
    int min_c = 1000;
    rep(bit, 1<<d) {
        int cnt = 0, scr = 0;
        rep(i, d) {
            if (bit & 1<<i) {
                scr += 100 * (i+1) * p[i] + c[i];
                cnt += p[i];
            }
        }
        if (scr >= g) chmin(min_c, cnt);
        else {
            repr(i, d) {
                if (~bit & 1<<i) {
                    rep(j, p[i]-1) {
                        scr += 100 * (i+1);
                        cnt++;
                        if (scr >= g) break;
                    }
                }
                if (scr >= g) break;
            }
            if (scr >= g) chmin(min_c, cnt);
        }
    }
    // output
    cout << min_c << endl;
}