#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> PII;
const int N = 510, INF = 0x3f3f3f3f;
struct node
{
int to, cost;
};
vector<node> v[N];
/**
* a[]:每个点救援队人数
* dis[]:到每个顶点的最短路径
* num[]:到每个顶点的最短路径的条数
* w[]:到每个顶点的最短路径的救援队总数
* q[]:路径,存前驱
* */
int a[N], w[N], dis[N], num[N], q[N];
int n, m, s, d;
void dfs(int x)
{
if (q[x] == x)
{
cout << x;
return;
}
dfs(q[x]);
cout << ' ' << x;
}
void Dijkstra(int s)
{
memset(dis, INF, sizeof dis);
// 初始化起点的所有参数
dis[s] = 0, num[s] = 1, w[s] = a[s], q[s] = s;
priority_queue<PII, vector<PII>, greater<PII>> que;
que.push({0, s});
while (que.size())
{
auto t = que.top();
int u = t.second, e = t.first;
que.pop();
if (e > dis[u]) continue;
for (auto c : v[u])
{
if (dis[u] + c.cost < dis[c.to])
{
dis[c.to] = dis[u] + c.cost;
que.push({dis[c.to], c.to});
num[c.to] = num[u];
w[c.to] = w[u] + a[c.to];
q[c.to] = u;
}
else if (dis[u] + c.cost == dis[c.to])
{
num[c.to] += num[u];
if (w[u] + a[c.to] > w[c.to])
{
w[c.to] = w[u] + a[c.to];
q[c.to] = u;
}
}
}
}
}
int main()
{
cin >> n >> m >> s >> d;
for (int i = 0; i < n; i++) cin >> a[i];
while (m--)
{
int a, b, c;
cin >> a >> b >> c;
v[a].push_back({b, c});
v[b].push_back({a, c});
}
Dijkstra(s);
cout << num[d] << ' ' << w[d] << endl;
dfs(d);
return 0;
}