import java.util.*;

public class quiz12 {

  static int[][] graph = new int[300][300];
  static int     INF   = 12345;

  public static void main(String[] args) {
    int n, a, b, c, d, u, v, w;

    Scanner in = new Scanner(System.in);
    int nc = in.nextInt();
    for(int cs = 0; cs < nc; cs++) {
      n = in.nextInt();
      a = in.nextInt();
      b = in.nextInt();
      c = in.nextInt();
      d = in.nextInt();

      // read in graph
      for(int[] row : graph) Arrays.fill(row, INF);
      for(int i = 0; i < n; i++) graph[i][i] = 0;

      while(in.hasNextInt()) {
        u = in.nextInt();
        v = in.nextInt();
        w = in.nextInt();
        if (u == -1 && v == -1 && w == -1) break;
        graph[u][v] = graph[v][u] = w;
      }

      // run Floyd
      for(int k = 0; k < n; k++)
      for(int i = 0; i < n; i++)
      for(int j = 0; j < n; j++)
        graph[i][j] = Math.min(graph[i][j], graph[i][k] + graph[k][j]);

      // check if there are good nodes
      boolean good = false;
      for(int i = 0; i < n && !good; i++)
        if (graph[a][b] == graph[a][i] + graph[i][b])
          if (graph[c][d] == graph[c][i] + graph[i][d])
            good = true;

      if (good) System.out.println("YES");
      else      System.out.println("NO");
    }
  }
}
