/*
 * 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 wintadd;

import java.util.HashMap;
import java.util.Scanner;

/**
 *
 * @author olesnanik2
 */
public class Lunch {
    public static HashMap<Integer, Long> array = new HashMap<Integer, Long>();
    
    public static void addComb(int price, long n) {
        if(array.containsKey(price)) {
            array.put(price, n+array.get(price));
        } else {
            array.put(price, n);
        }
    }
    
    public static void main(String [] arguments) {
        Scanner scanner = new Scanner(System.in);
        
        while(true) {
            int totalPrice = scanner.nextInt(), soups = scanner.nextInt(), mains = scanner.nextInt(), deserts = scanner.nextInt(), drinks = scanner.nextInt();
            if (totalPrice == 0 && soups == 0 && mains == 0 && deserts == 0 && drinks == 0) {
                break;
            }
            for(int soup=0; soup<soups; soup++) {
                int price = scanner.nextInt();
                if (price <= totalPrice) {
                    addComb(price, 1);
                }
            }
            HashMap<Integer, Long> oldArray = new HashMap<>(array);
            array.clear();
            for(int main=0; main<mains; main++) {
                int mainPrice = scanner.nextInt();
                for(Integer price : oldArray.keySet()) {
                    int newPrice = mainPrice + price;
                    long originalComb = oldArray.get(price);
                    
                    if (newPrice <= totalPrice) {
                        addComb(newPrice, originalComb);
                    }
                }
            }
            oldArray = new HashMap<>(array);
            array.clear();
            for(int desert=0; desert<deserts; desert++) {
                int mainPrice = scanner.nextInt();
                for(Integer price : oldArray.keySet()) {
                    int newPrice = mainPrice + price;
                    long originalComb = oldArray.get(price);
                    
                    if (newPrice <= totalPrice) {
                        addComb(newPrice, originalComb);
                    }
                }
            }
            oldArray = new HashMap<>(array);
            array.clear();
            for(int drink=0; drink<drinks; drink++) {
                int mainPrice = scanner.nextInt();
                for(Integer price : oldArray.keySet()) {
                    int newPrice = mainPrice + price;
                    long originalComb = oldArray.get(price);
                    
                    if (newPrice <= totalPrice) {
                        addComb(newPrice, originalComb);
                    }
                }
            }
            
            long result = 0L;
            for(Long c : array.values()) {
                result += c;
            }
            
            System.out.println(result);
            
            array.clear();
        }
    }
}