#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

int main()
{
    while ( true )
    {
        int n, a, s, g;
        cin >> n >> a >> s >> g;
        if ( n == 0  &&  a == 0  &&  s == 0  &&  g == 0 )
            break;

        vector<int> x( a );
        vector<int> y( a );
        vector<string> lab( a );
        for ( int i=0; i<a; i++ )
            cin >> x[i] >> y[i] >> lab[i];

        int     N = 6*(n-1);    //  ツδ仰ーツプツつオツづ按つ「ツ偲エツ閉カツづ個催妥・ツ陳キ
        string  inf( N, 'z' );  //  "zzzzzz..."

        vector<vector<string> > spell( n, vector<string>( 2*N+1, inf ) );
        spell[s][0] = "";

        for ( int l=0; l<2*N; l++ )
        for ( int i=0; i<n; i++ )
        if ( spell[i][l] != inf )
        {
            for ( int j=0; j<a; j++ )
            if ( x[j] == i )
            {
                string sp = spell[i][l] + lab[j];
                int len = (int)sp.length();

                if ( len <= 2*N )
                    spell[y[j]][len] = min( spell[y[j]][len], sp );
            }
        }

        string ans = *min_element( spell[g].begin(), spell[g].end() );

        if ( ans != inf  &&
             (int)ans.length() <= N )
            cout << ans << endl;
        else
            cout << "NO" << endl;
    }
}