import java.util.Scanner; public class Q1 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); String[]s = new String[n]; String[]t = new String[n]; int[]p = new int[n]; for (int i = 0; i < n; i++) { s[i] = sc.next(); } for (int i = 0; i < n; i++) { p[i] = sc.nextInt(); } for (int i = 0; i < n; i++) { int f = p[i]; int f2 = p[i]-1; for (int j = p[i]-1; j > 0 ; j--) { f = f*(j); } for (int j = p[i]-2; j > 0 ; j--) { f2 = f2*(j); } int pf; if (f2!=0 && f !=0){ pf = f/f2; } else { pf = f; } t[i] = s[pf-1]; } } }