#include<bits/stdc++.h>
#define x first
#define y second
#define int long long
using namespace std;
typedef long long ll;
typedef pair<int ,int> PII;
const int N=2e5+10;
const int MOD =1e9+7;
const int M =N*2;
int h[N], e[M], ne[M], w[M], idx;
void add(int a, int b, int c)
{
e[idx] = b, w[idx] = c, ne[idx] = h[a], h[a] = idx ++;
}
int n,m,s,t;
int sums[N];//每个点最短路情况下 最多的人数 max~
int total[N];//每个点最短路径的条数。sum~
int pre[N];//路径记录 //链表形式
int dist[N];
int a[N];
int st[N];
void print(int u)
{
if (u == s)
{
cout << u;
return;
}
else{
print(pre[u]);
cout << " " << u;
}
}
void dijkstra()
{
priority_queue<PII,vector<PII>,greater<PII> > heap;
memset(dist,0x3f,sizeof dist);
dist[s]=0;
heap.push({0,s});
sums[s]=a[s];
total[s] = 1;
while(heap.size())
{
auto t=heap.top();
heap.pop();
int ver =t.second;
if(st[ver]) continue;
st[ver]= true;
for(int i=h[ver];~i;i=ne[i])
{
int j=e[i];
if (dist[j] > dist[ver] + w[i])
{
dist[j] = dist[ver] + w[i];
total[j] = total[ver];//最短路数量更新
sums[j] = sums[ver] + a[j];//!不用回溯~因为上一点已经最短
heap.push({dist[j],j});
pre[j] = ver;
}
else if (dist[j] == dist[ver] + w[i])
{
total[j] += total[ver];
if (sums[ver] + a[j] > sums[j])
{
pre[j] = ver;
sums[j] = sums[ver] + a[j];
}
}
}
}
}
signed main()
{
cin>>n>>m>>s>>t;
memset(h,-1,sizeof h);
for(int i=0;i<n;i++) cin>>a[i];
for(int i=1;i<=m;i++)
{
int a,b,c;
cin>>a>>b>>c;
add(a,b,c);
add(b,a,c);
}
dijkstra();
cout << total[t] << " " << sums[t] << endl;
print(t);
return 0;
}