/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package lunch;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;

/**
 *
 * @author cteam034
 */
public class Lunch {

    static int l, s, m, d, b,  cprice;
    static long combs, curcombs;
    static int[] sp, mp, dp, bp;
    static int[] smp;

    static int search(int index) {
        if (smp[index] <= cprice) {
            for (int i = index + 1; i < smp.length; i++) {
                if (smp[i] >cprice) {
                    return i;
                }
            }
        } else {
            if (index > 0) {
                index /= 2;
                return search(index);
            } else {
                return -1;
            }
        }
        return -1;

    }

    public static void main(String[] args) throws IOException {

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st;
        while (true) {
            combs = 0;
            st = new StringTokenizer(br.readLine());
            l = Integer.parseInt(st.nextToken());
            s = Integer.parseInt(st.nextToken());
            m = Integer.parseInt(st.nextToken());
            d = Integer.parseInt(st.nextToken());
            b = Integer.parseInt(st.nextToken());
            if (l == 0 && s == 0 && m == 0 && d == 0 && b == 0) {
                break;
            }
            sp = new int[s];
            mp = new int[m];
            dp = new int[d];
            bp = new int[b];

            st = new StringTokenizer(br.readLine());
            for (int i = 0; i < sp.length; i++) {
                sp[i] = Integer.parseInt(st.nextToken());
            }
            st = new StringTokenizer(br.readLine());
            for (int i = 0; i < mp.length; i++) {
                mp[i] = Integer.parseInt(st.nextToken());
            }
            st = new StringTokenizer(br.readLine());
            for (int i = 0; i < dp.length; i++) {
                dp[i] = Integer.parseInt(st.nextToken());
            }
            st = new StringTokenizer(br.readLine());
            for (int i = 0; i < bp.length; i++) {
                bp[i] = Integer.parseInt(st.nextToken());
            }
            br.readLine();

            smp = new int[s * m];
            int index = 0;
            for (int i = 0; i < s; i++) {
                for (int j = 0; j < m; j++) {
                    smp[index++] = sp[i] + mp[j];
                }
            }

            Arrays.sort(smp);
            for (int i = 0; i < d; i++) {
                for (int j = 0; j < b; j++) {
                    cprice = l-(dp[i] + bp[j]);
                    curcombs = search(smp.length
                            / 2);
                    combs += curcombs != -1 ? curcombs : 0;
                }

            }
            System.out.println(combs);
        }
    }

}

/*
 11 3 1 1 1
 4 5 6
 3
 2
 1

 10 4 5 4 2
 3 2 5 7
 1 1 8 4 2
 3 5 2 1
 2 3

 0 0 0 0 0

 */