#include<iostream>
#include<memory.h>
#include<cstdlib>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<cstdlib>
#include<iomanip>
#include<algorithm>
typedef long long LL;
using namespace std;
const int maxn = 500 + 10, INF = 0x3f3f3f3f;
int N, M, S, D;
//val用于存人数,dis存到S的最短距离,map存图,cntp存当前点最短路径条数
//num存到当前点最多召集的人数,path存当前点的前驱用于最后输出路径
int val[maxn], dis[maxn], map[maxn][maxn], cntp[maxn], num[maxn], path[maxn];
bool vis[maxn];
void dijstra(int s) {
//初始化
for (int i = 0; i < N; i++) {
dis[i] = INF;
}
for (int i = 0; i < N; i++) {
path[i] = i;
}
memset(cntp, 0, sizeof(cntp));
memset(num, 0, sizeof(num));
memset(vis, false, sizeof(vis));
dis[s] = 0;
cntp[s] = 1;
num[s] = val[s];
for (int i = 0; i < N; i++) {
if (i != s) {
dis[i] = map[s][i];
if (map[s][i] != INF) {
cntp[i] = 1;
num[i] = val[i] + num[s];
path[i] = s;
}
}
}
vis[s] = true;
//初始化完毕
for (int t = 0; t < N - 1; t++) {
int minn = INF, index = s;
for (int i = 0; i < N; i++) {
if (!vis[i] && minn > dis[i]) { //注意!vis[i]
minn = dis[i];
index = i;
}
}
vis[index] = true;
for (int i = 0; i < N; i++) {
if (!vis[i] && map[index][i] < INF) { //debug add !vis[i]
//不判断vis[i]去重的话会使下一句dis[index] + map[index][i] == dis[i]即
//dis[index] + 0 == dis[i] (i == index时) 为真,重复计算
if (dis[index] + map[index][i] == dis[i]) {
cntp[i] += cntp[index]; //debug 不是简单的cntp[i]++,index之前可能连接着多条路径
if (num[index] + val[i] > num[i]) {
num[i] = val[i] + num[index];
path[i] = index;
}
}
//此处没判不判断!vis[i]无所谓,是因为即使index == i时,dis[index] < dis[i]肯定不成立
else if (dis[index] + map[index][i] < dis[i])
{
cntp[i] = cntp[index]; //debug 重新计算最短路径数
dis[i] = dis[index] + map[index][i];
num[i] = val[i] + num[index];
path[i] = index;
}
}
}
}
}
int main()
{
scanf("%d%d%d%d", &N, &M, &S, &D);
for (int i = 0; i < N; i++) {
scanf("%d", &val[i]);
}
for (int i = 0; i < N; i++) {
for (int j = 0; j < N; j++) {
map[i][j] = (i == j ? 0 : INF);
}
}
for (int i = 0; i < M; i++) {
int u, v, w;
scanf("%d%d%d", &u, &v, &w);
map[u][v] = map[v][u] = w;
}
dijstra(S);
printf("%d %d\n", cntp[D], num[D]);
int pre[maxn], i, len; //用pre相当于一个栈的作用,根据path输出最后结果
i = D; len = 0;
while (i != S) {
pre[len++] = i;
i = path[i];
}
pre[len++] = i;
for (int j = len - 1; j >= 0; j--) {
printf(j == len - 1 ? "%d" : " %d", pre[j]);
}
puts("");
return 0;
}