import java.util.*; import java.io.*; import static java.util.Arrays.*; import static java.lang.Math.*; public class No160 { static final InputStream in = System.in; static final PrintWriter out = new PrintWriter(System.out,false); static void solve(){ int n = nextInt(); int m = nextInt(); int s = nextInt(); int g = nextInt(); int[] n1 = new int[m]; int[] n2 = new int[m]; int[] cost = new int[m]; for (int i=0; i list = new ArrayList(); list.add(s); int cur = s; while (cur != g) { int next = Integer.MAX_VALUE/2; for (int[] to : graph[cur]) if (d[cur] == d[to[0]] + to[1]) next = min(next,to[0]); list.add(next); cur = next; } for (int i=0; i que = new TreeSet(new Comparator(){ public int compare(Integer a, Integer b){ if (d[a]-d[b] != 0) return d[a] - d[b]; return a - b; } }); que.add(from); d[from] = 0; while (!que.isEmpty()) { int cur = que.pollFirst(); for (int i=0; i