import java.util.*;
import static java.lang.Math.*;

public class quiz13 {

  static int n;                             // number of nodes
  static ArrayList<ArrayList<Integer>> adj; // my adjacency list
  static int[] nodeCost;
  static int[] dist;

  static int u;
  static int s, t;
  static String line;

  public static void main(String[] arg) throws Exception {
    Scanner in = new Scanner(System.in);
    int nc = in.nextInt();
    for(int cs = 0; cs < nc; cs++) {
      n = in.nextInt();
      s = in.nextInt();
      t = in.nextInt();
      adj = new ArrayList<ArrayList<Integer>>();
      nodeCost = new int[n];
      dist= new int[n];
      in.nextLine(); // get rid of junk \n


      // read in graph
      for(int i = 0; i < n; i++) {
        line = in.nextLine();
        Scanner scan= new Scanner(line);
        u = scan.nextInt();
        if (u != i) throw new Exception("what the heck..");
        nodeCost[i] = scan.nextInt();

        ArrayList<Integer> curr = new ArrayList<Integer>();
        while(scan.hasNextInt())
          curr.add(scan.nextInt());

        adj.add(curr);
      }


      

      // now run belmon ford
      Arrays.fill(dist, Integer.MAX_VALUE/100);
      dist[s] = 0;

      for(int pass = 0; pass < n-1; pass++) {
        // relax all edges
        for(int i = 0; i < n; i++)
          for(int j : adj.get(i))
            if (dist[i] != Integer.MAX_VALUE/100)
              dist[j] = min(dist[j], dist[i] + nodeCost[j]);
      }

      // one more round to detect negative cycle
      boolean negativeCycle = false;
flag: for(int i = 0; i < n; i++)
        for(int j : adj.get(i))
          if (dist[j] > dist[i] + nodeCost[j]) { negativeCycle = true; break flag;}


      if (negativeCycle) System.out.println("Negative Infinity");
      else               System.out.println(dist[t]+nodeCost[s]);

      /*
      int edges = 0;
      for(ArrayList<Integer> a:adj) edges += a.size();
      System.out.println("m = " + edges);
      */
    }
  }
}
