import java.util.*;
import java.io.*;

public class gifts {
    public static void main(String[] args) throws Exception {
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        int S = Integer.parseInt(in.readLine());
        for (int scen=1; scen <= S; ++scen) {
            System.out.println("Scenario #"+scen+":");
            String[] tokens = in.readLine().split(" +");
            int u = Integer.parseInt(tokens[0]);
            int v = Integer.parseInt(tokens[1]);
            assert(1<=u && u <= 1000);
            assert(1<=v && v <= 1000);
            int n = Integer.parseInt(in.readLine());
            assert(2<=n && n <= 1000);
            tokens = in.readLine().split(" +");
            assert(tokens.length == n-1);
            int[] boss = new int[n];
            for (int i=1; i < n; ++i) {
              boss[i] = Integer.parseInt(tokens[i-1]);
            }
            int color[] = new int[n];
            color[0] = 1;
            int k = 0;
            for (int i=1; i < n; ++i) {
              if (colorize(boss,color,i) == 2) ++k;
            }
            System.out.println(Math.min(k*u+(n-k)*v,
                                        k*v+(n-k)*u));
            System.out.println();
        }
    }

  static int colorize(int[] boss,int[] color,int u) {
    if (color[u] != 0) return color[u];
    return color[u] = 3-colorize(boss,color,boss[u]);
  }
}
