People in BubbleLand like to drink beer. Little do you know, beer here is so good and strong that every time you drink it your speed goes 10 times slower than before you drank it.

Birko lives in city Beergrade, but wants to go to city Beerburg. You are given a road map of BubbleLand and you need to find the fastest way for him. When he starts his journey in Beergrade his speed is 1. When he comes to a new city he always tries a glass of local beer, which divides his speed by 10. 

The question here is what the minimal time for him to reach Beerburg is. If there are several paths with the same minimal time, pick the one that has least roads on it. If there is still more than one path, pick any.

It is guaranteed that there will be at least one path from Beergrade to Beerburg.

Input

The first line of input contains integer N — the number of cities in Bubbleland and integer M — the number of roads in this country. Cities are enumerated from 0 to N - 1, with city 0 being Beergrade, and city N - 1 being Beerburg. Each of the following M lines contains three integers a, b (a ≠ b) and len. These numbers indicate that there is a bidirectional road between cities a and b with length len. 

  * 2 ≤ N ≤ 105
  * 1 ≤ M ≤ 105
  * 0 ≤ len ≤ 9
  * There is at most one road between two cities 

Output

The first line of output should contain minimal time needed to go from Beergrade to Beerburg.

The second line of the output should contain the number of cities on the path from Beergrade to Beerburg that takes minimal time. 

The third line of output should contain the numbers of cities on this path in the order they are visited, separated by spaces.

Examples

Input

8 10
0 1 1
1 2 5
2 7 6
0 3 2
3 7 3
0 4 0
4 5 0
5 7 2
0 6 0
6 7 7


Output

32
3
0 3 7
#include <bits/stdc++.h>
using namespace std;
vector<int> e[100001], w[100001], sv[100001];
int dis[100001], diss[100001], dl[100001], fr[100001], ff[100001], nt[100001],
    rr[100001], vis[100001], rk[100001];
int ed, n, m, dd, x, y, z;
inline bool cmp(int x, int y) {
  if (rk[x] != rk[y])
    return rk[x] < rk[y];
  else
    return diss[x] < diss[y];
}
inline void bfs1() {
  for (int i = (1); i <= (n - 1); i++) dis[i] = 1000000000;
  int s = 1, t = 1;
  vis[0] = 1;
  for (; s <= t; s++) {
    int ss = dl[s], sz = e[ss].size() - 1;
    for (int i = (0); i <= (sz); i++) {
      int tt = e[ss][i];
      if (dis[ss] + 1 < dis[tt]) {
        dis[tt] = dis[ss] + 1;
        vis[tt] = 1, dl[++t] = tt;
      }
    }
  }
}
inline void bfs2() {
  for (int i = (0); i <= (n - 2); i++) diss[i] = 1000000000;
  for (int i = (0); i <= (n - 1); i++) vis[i] = 0;
  int s = 1, t = 1;
  vis[n - 1] = 1;
  dl[1] = n - 1;
  for (; s <= t; s++) {
    int ss = dl[s], sz = e[ss].size() - 1;
    for (int i = (0); i <= (sz); i++) {
      int tt = e[ss][i];
      if (!w[ss][i] && diss[ss] + 1 < diss[tt]) {
        diss[tt] = diss[ss] + 1;
        nt[tt] = ss;
        vis[tt] = 1, dl[++t] = tt;
      }
    }
  }
}
void prf(int x) {
  if (x) prf(fr[x]);
  printf("%d ", x);
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = (1); i <= (m); i++) {
    scanf("%d%d%d", &x, &y, &z);
    e[x].push_back(y);
    w[x].push_back(z);
    e[y].push_back(x);
    w[y].push_back(z);
  }
  bfs1();
  bfs2();
  ed = n - 1;
  for (int i = (0); i <= (n - 1); i++)
    if (dis[i] != 1000000000) {
      sv[dis[i]].push_back(i);
      if (dis[i] > dd) dd = dis[i];
    }
  for (int i = (1); i <= (dd); i++) {
    int nm = sv[i].size() - 1;
    int lsm = sv[i - 1].size();
    for (int j = (0); j <= (nm); j++) {
      x = sv[i][j];
      rk[x] = lsm * 10;
      int sz = e[x].size() - 1;
      for (int ii = (0); ii <= (sz); ii++) {
        int frm = e[x][ii];
        if (dis[frm] + 1 == dis[x]) {
          int ww = w[x][ii] * lsm + rk[frm];
          if (ww < rk[x]) rk[x] = ww, fr[x] = frm, ff[x] = w[x][ii];
        }
      }
      rr[j] = x;
    }
    sort(rr, rr + nm + 1, cmp);
    for (int j = (0); j <= (nm); j++) rk[rr[j]] = j;
  }
  for (int i = (0); i <= (n - 2); i++)
    if (vis[i]) {
      if (dis[i] == dis[ed] && rk[i] == rk[ed] && diss[i] < diss[ed]) ed = i;
      if (dis[i] == dis[ed] && rk[i] < rk[ed]) ed = i;
      if (dis[i] < dis[ed]) ed = i;
    }
  for (x = ed; x; x = fr[x]) printf("%d", ff[x]);
  if (!ed) printf("0");
  printf("\n%d\n", dis[ed] + diss[ed] + 1);
  prf(ed);
  for (x = nt[ed]; x; x = nt[x]) printf("%d ", x);
}
