#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <string>
#define oo 987654321
#define PAIR std::pair<int, std::pair<int, std::string> >

int v, e, dap = oo;
struct EDGE{ int to, w; };
std::vector<EDGE> GL[10010];
std::queue<int> s_path;

PAIR dist(int a, int b, int st, int ed)
{
    int chk[10010] = {0}; char tt[100];
    std::priority_queue< PAIR, std::vector< PAIR >, std::greater< PAIR > > Q;
    PAIR temp;
    for(int i = 0 ; i < GL[a].size() ; i++ )
    {
        if( a == st && GL[a][i].to == ed ) continue;
        Q.push(std::make_pair(GL[a][i].w, std::make_pair(GL[a][i].to, "1-")));
    }
    while(!Q.empty())
    {
        temp = Q.top(); Q.pop();
        std::string path = temp.second.second;
        if( chk[temp.second.first] ) continue;
        chk[temp.second.first] = 1;
        sprintf(tt, "%d-", temp.second.first);
        path = path.append(tt);
        if( temp.second.first == b ) return temp;
        for(int i = 0 ; i < GL[temp.second.first].size() ; i++ )
        {
            if( temp.second.first == st && GL[temp.second.first][i].to == ed ) continue;
            Q.push(std::make_pair((temp.first+GL[temp.second.first][i].w), std::make_pair(GL[temp.second.first][i].to, path)));
        }
    }
    return std::make_pair(oo, std::make_pair(0,""));
}

int main()
{
    freopen(".10.in","r",stdin);
    freopen(".10.out","w",stdout);
    scanf("%d%d",&v,&e);
    for(int i = 0 ; i < e ; i++ )
    {
        int a, b, w;
        scanf("%d%d%d", &a, &b, &w);
        GL[a].push_back({b, w}), GL[b].push_back({a,w});
    }
    PAIR ans = dist(1, v, 0, 0);
    if( ans.first < oo ) printf("%d!\n", ans.first);
    ans.second.second.append("");
    if( ans.first >= oo ) puts("Impossible");
    else
    {
        char path[101001];
        sprintf(path, "%s%d", ans.second.second.c_str(), v);
        for(int i = 0 ; path[i] ; i++ )
        {
            int value = 0;
            while( path[i] != '-' )
            {
                if( path[i] == 0 ) break;
                value *= 10;
                value += path[i]-'0';
                i++;
            }
            s_path.push(value);
        }
        int st, ed = s_path.front();
        while(!s_path.empty())
        {
            int aa;
            s_path.pop();
            if( s_path.empty() ) break;
            st = ed; ed = s_path.front();
            dap = std::min(dap, aa = dist(1, v, st, ed).first);
            //printf("%d-%d %d!!\n", st, ed, aa);
            if( aa >= oo )
            {
                puts("Success");
                return 0;
            }
        }
        printf("%d", dap);
    }
}

/*
6 8
1 2 1
1 3 1
1 4 1
1 5 1
2 6 2
3 6 3
4 6 3
5 6 2
6 7 1
*/
