import java.util.*; class Main{ static Scanner s=new Scanner(System.in); static int gInt(){ return Integer.parseInt(s.next()); } public static void main(String[] A){ Mapmap=new HashMap<>(); int[]reward=new int[5]; for(int i=0;i<5;++i) { map.put(s.next(),i); reward[i]=gInt(); } long[]len=new long[3]; long[][]count=new long[3][5]; for(int i=0;i<3;++i) for(long j=len[i]=gInt();j>0;--j) count[i][map.get(s.next())]++; long prob=0; for(int i=0;i<5;++i) prob+=count[0][i]*count[1][i]*count[2][i]*reward[i]; System.out.println(prob*5.0/(len[0]*len[1]*len[2])); for(int i=0;i<5;++i) System.out.println(count[0][i]*count[1][i]*count[2][i]*5);; } }