#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef pair<ll, ll> p_ll;

template<class T>
void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; }
#define repr(i,from,to) for (ll i=(ll)from; i<(ll)to; i++)
#define all(vec) vec.begin(), vec.end()
#define rep(i,N) repr(i,0,N)
#define per(i,N) for (ll i=(ll)N-1; i>=0; i--)
#define popcount __builtin_popcount

const ll LLINF = pow(2,61)-1;
const ll INF = pow(2,30)-1;

ll gcd(ll a, ll b) { if (a<b) swap(a,b); return b==0 ? a : gcd(b, a%b); }
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; }

// ----------------------------------------------------------------------
// ----------------------------------------------------------------------

struct dijkstra {

  ll N;
  struct edge {
    ll to, C, D;
    ll f(ll x) { return C+D/(x+1); }
    ll cost(ll d) { 
      ll sqd = sqrt(D);
      ll result = d+f(d);
      repr(i,sqd-2,sqd+3) if (i>=d) result = min(result,i+f(i));
      return result;
    }
  };
  vector<vector<edge>> adj;
  vector<ll> minlen;

  dijkstra(ll n) { N = n; adj.resize(N); minlen.assign(N,LLINF); }
  ll operator[](const ll &x) const { return minlen[x]; }

  void add_edge(ll from, ll to, ll C, ll D){
    adj[from].push_back({to, C, D});
  }
  vector<ll> calc(ll n=0) {
    minlen.assign(N,LLINF);
    auto c = [](const p_ll &x, const p_ll &y){return x.second>y.second;};
    priority_queue<p_ll, vector<p_ll>, decltype(c)> q(c);
    minlen[n] = 0; q.push(make_pair(n,0));
    while(q.size()) {
      p_ll now = q.top(); q.pop();
      ll np = now.first, nd = now.second;
      if (nd>minlen[np]) continue;
      for (auto x: adj[np]) {
        if (minlen[x.to]<=x.cost(minlen[np])) continue;
        q.push(make_pair(x.to, x.cost(minlen[np])));
        minlen[x.to] = x.cost(minlen[np]);
      }
    }
    return minlen;
  }

};

// ----------------------------------------------------------------------
// ----------------------------------------------------------------------
int main() {
  ll N, M; cin >> N >> M;
  ll A[M], B[M], C[M], D[M]; rep(i,M) { cin >> A[i] >> B[i] >> C[i] >> D[i]; A[i]--; B[i]--; }
  dijkstra ds(N);
  rep(i,M) {
    ds.add_edge(A[i],B[i],C[i],D[i]);
    ds.add_edge(B[i],A[i],C[i],D[i]);
  }
  vector<ll> d = ds.calc();
  // debug(all(d));
  ll result = d[N-1]!=LLINF ? d[N-1] : -1;
  cout << result << endl;
  return 0;
}
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define IFOR(i, m, n) for (ll i = n - 1; i >= m; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define FOREACH(x, a) for (auto&(x) : (a))
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

int main() {
  ll t, n;
  cin >> t >> n;
  set<ll> st;
  FOR(r, 1, 100 + 1) {
    ll p = (100 + t) * r / 100;
    st.insert(p);
  }
  ll maxi = *st.rbegin();
  vector<ll> a;

  FOR(x, 1, maxi + 1) {
    if (st.find(x) == st.end()) {
      a.push_back(x);
    }
  }
  ll s = SZ(a), l = 100 + t;
  n--;
  ll ans = a[n % s] + l * (n / s);
  cout << ans << endl;
}