    #include <bits/stdc++.h>
    using namespace std;
    #include <math.h>
    #include <iomanip>
    #include <cstdint>
    #include <string>
    #include <sstream>
    template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
    template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
    #define rep(i,n) for (int i = 0; i < (n); ++i)
    typedef long long ll;
    using P=pair<ll,ll>;
    const ll INF=1e18;
    const int mod=1e9+7;
    
    struct edge{
      int to;
      ll w,k;
      edge(int to,ll w,ll k):to(to),w(w),k(k){}
    };
    using Graph=vector<vector<edge>>;

    ll n,m,x,y;
    
    void dijkstra(int s,Graph G,vector<ll>& dist){
      dist.resize(n,INF);
      dist[s]=0;
      priority_queue<pair<ll,int>,vector<pair<ll,int>>,greater<pair<ll,int>>>q;
      q.push({dist[s],s});
      while(!q.empty()){
        int v=q.top().second;
        ll d=q.top().first;
        q.pop();
        if(d>dist[v]){continue;}
        for(auto e:G[v]){
          if(chmin(dist[e.to],dist[v]+e.w)){
            q.push({dist[e.to],e.to});
          }
        }
      }
    }
    int main() {
      cin>>n>>m>>x>>y;
      x--;y--;
      Graph G(n);
      rep(i,m){
        ll a,b,t,k,c;cin>>a>>b>>t>>c;
        a--;b--;
        G[a].push_back(edge(b,t,c));
        G[b].push_back(edge(a,t,c));
      }
      vector<ll>dist(n,INF);
      dist[x]=0;
      priority_queue<pair<ll,int>,vector<pair<ll,int>>,greater<pair<ll,int>>>q;
      q.push({0ll,x});
      while(!q.empty()){
        int v=q.top().second,d=q.top().first;q.pop();
        if(d>dist[v]){continue;}
        for(auto e:G[v]){
          ll cost=(e.k-dist[v]%e.k)%e.k+e.w;
          if(chmin(dist[e.to],dist[v]+cost)){q.push({dist[e.to],e.to});}
        }
      }
      cout<<(dist[y]==INF?-1:dist[y])<<endl;
      return 0;
    }
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("inline")
#include<bits/stdc++.h>
using namespace std;
inline int my_getchar_unlocked(){
  static char buf[1048576];
  static int s = 1048576;
  static int e = 1048576;
  if(s == e && e == 1048576){
    e = fread_unlocked(buf, 1, 1048576, stdin);
    s = 0;
  }
  if(s == e){
    return EOF;
  }
  return buf[s++];
}
inline void rd(int &x){
  int k;
  int m=0;
  x=0;
  for(;;){
    k = my_getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = my_getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void rd(long long &x){
  int k;
  int m=0;
  x=0;
  for(;;){
    k = my_getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = my_getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
struct MY_WRITER{
  char buf[1048576];
  int s;
  int e;
  MY_WRITER(){
    s = 0;
    e = 1048576;
  }
  ~MY_WRITER(){
    if(s){
      fwrite_unlocked(buf, 1, s, stdout);
    }
  }
}
;
MY_WRITER MY_WRITER_VAR;
void my_putchar_unlocked(int a){
  if(MY_WRITER_VAR.s == MY_WRITER_VAR.e){
    fwrite_unlocked(MY_WRITER_VAR.buf, 1, MY_WRITER_VAR.s, stdout);
    MY_WRITER_VAR.s = 0;
  }
  MY_WRITER_VAR.buf[MY_WRITER_VAR.s++] = a;
}
inline void wt_L(char a){
  my_putchar_unlocked(a);
}
inline void wt_L(const char c[]){
  int i=0;
  for(i=0;c[i]!='\0';i++){
    my_putchar_unlocked(c[i]);
  }
}
int A;
int B;
long long K;
long long c[61][61];
int main(){
  int WYIGIcGE, ao_dF3pO, i;
  for(i=(0);i<(61);i++){
    c[i][0] = 1;
  }
  for(i=(1);i<(61);i++){
    int j;
    for(j=(1);j<(61);j++){
      c[i][j] = c[i-1][j-1] + c[i-1][j];
    }
  }
  rd(A);
  rd(B);
  rd(K);K += (-1);
  while(A && B){
    if(K < c[A+B-1][A-1]){
      wt_L('a');
      A--;
    }
    else{
      K -= c[A+B-1][A-1];
      wt_L('b');
      B--;
    }
  }
  for(WYIGIcGE=(0);WYIGIcGE<(A);WYIGIcGE++){
    wt_L('a');
  }
  for(ao_dF3pO=(0);ao_dF3pO<(B);ao_dF3pO++){
    wt_L('b');
  }
  wt_L("");
  wt_L('\n');
  return 0;
}
// cLay version 20210524-1

// --- original code ---
// int A, B; ll K;
// ll c[61][61];
// {
//   rep(i,61) c[i][0] = 1;
//   rep(i,1,61) rep(j,1,61) c[i][j] = c[i-1][j-1] + c[i-1][j];
//   rd(A,B,K--);
//   while(A && B){
//     if(K < c[A+B-1][A-1]){
//       wtN('a');
//       A--;
//     } else {
//       K -= c[A+B-1][A-1];
//       wtN('b');
//       B--;
//     }
//   }
//   rep(A) wtN('a');
//   rep(B) wtN('b');
//   wt("");
// }
