package hackerrank;

/**
 * https://www.hackerrank.com/challenges/the-quickest-way-up
 */
public class SnakesAndLadders {
    public static void main(String[] args) {

    }
}

package hackerrank;

import java.util.Scanner;

/**
 * https://www.hackerrank.com/challenges/the-quickest-way-up
 */
public class SnakesAndLadders {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int testCases = in.nextInt();
        for (int t = 0; t < testCases; t++) {
            int n = in.nextInt();
            for (int i = 0; i < n; i++) {
                int from = in.nextInt();
                int to = in.nextInt();
            }
            int m = in.nextInt();
            for (int i = 0; i < m; i++) {
                int from = in.nextInt();
                int to = in.nextInt();
            }
        }
    }
}

Update Snakes and Ladders