Problem: Vasya, like many others, likes to participate in a variety of sweepstakes and lotteries. Now he collects wrappings from a famous chocolate bar "Jupiter". According to the sweepstake rules, each wrapping has an integer written on it — the number of points that the participant adds to his score as he buys the bar. After a participant earns a certain number of points, he can come to the prize distribution center and exchange the points for prizes. When somebody takes a prize, the prize's cost is simply subtracted from the number of his points.

Vasya didn't only bought the bars, he also kept a record of how many points each wrapping cost. Also, he remembers that he always stucks to the greedy strategy — as soon as he could take at least one prize, he went to the prize distribution centre and exchanged the points for prizes. Moreover, if he could choose between multiple prizes, he chose the most expensive one. If after an exchange Vasya had enough points left to get at least one more prize, then he continued to exchange points.

The sweepstake has the following prizes (the prizes are sorted by increasing of their cost): 

  * a mug (costs a points), 
  * a towel (costs b points), 
  * a bag (costs c points), 
  * a bicycle (costs d points), 
  * a car (costs e points). 



Now Vasya wants to recollect what prizes he has received. You know sequence p1, p2, ..., pn, where pi is the number of points Vasya got for the i-th bar. The sequence of points is given in the chronological order. You also know numbers a, b, c, d, e. Your task is to find, how many prizes Vasya received, what prizes they are and how many points he's got left after all operations are completed.

Input

The first line contains a single integer n (1 ≤ n ≤ 50) — the number of chocolate bar wrappings that brought points to Vasya. The second line contains space-separated integers p1, p2, ..., pn (1 ≤ pi ≤ 109). The third line contains 5 integers a, b, c, d, e (1 ≤ a < b < c < d < e ≤ 109) — the prizes' costs.

Output

Print on the first line 5 integers, separated by a space — the number of mugs, towels, bags, bicycles and cars that Vasya has got, respectively. On the second line print a single integer — the number of points Vasya will have left after all operations of exchange are completed.

Please, do not use the %lld specifier to read or write 64-bit integers in С++. It is preferred to use the cin, cout streams or the %I64d specifier.

Examples

Input

3
3 10 4
2 4 10 15 20


Output

1 1 1 0 0 
1


Input

4
10 4 39 2
3 5 10 11 12


Output

3 0 1 0 3 
0

Note

In the first sample Vasya gets 3 points after eating the first chocolate bar. Then he exchanges 2 points and gets a mug. Vasya wins a bag after eating the second chocolate bar. Then he wins a towel after eating the third chocolate bar. After all chocolate bars 3 - 2 + 10 - 10 + 4 - 4 = 1 points remains.

Solution (in JAVA):

Solution:


import java.awt.List;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.Map.Entry;
import java.util.Queue;
import java.util.Scanner;
import java.util.Set;
import java.util.Stack;
import java.util.*;


 
 
public class ck {

	private static InputStream stream;
	private static PrintWriter pw;
	
	
	
//	static int a;
//	static int b;
//	static int f = 0;
	static int n;
	static int m;
	static int arr[];
//	static char[][] arr;
	
	static int Arr[];
	static int size[];
	
	static int time = 0;
	
//	static int[][] dir = {{-1,0},{0,1},{1,0},{0,-1}};

	static int visited[];
	static Stack<Integer> stack;
	
//	static ArrayList<Integer> ans;

//	static int arr[][];
//	static int arr[];
//	static char[][] arr;
//	static int[][] visited;
//  static int c;
//	static int d[];
//	static int arr[][];
	static ArrayList<Integer> adj[];
//	static ArrayList<Integer> ans;
//	static int f;
	static int parent[];
	static int state[];
//	static ArrayList<Integer> comp[];
	
	static int count = 0;
	static int ap = 0;
	static int arrap[];
	
	static int disc[];
	static int low[];
	
	public static void main(String[] args) throws NumberFormatException, IOException{
		//InputReader(System.in);
		//pw = new PrintWriter(System.out);
		
		Scanner in = new Scanner(System.in);
		
		int n = in.nextInt();
		in.nextLine();
		
		long arr[] = new long[n];
		
		for(int i = 0 ;i<n;i++){
			arr[i] = in.nextInt();
		}
		
		long pr[] = new long[5];
		
		for(int i = 0;i<5;i++){
			pr[i] = in.nextLong();
		}
		
		long ans = 0;
		
		long count[] = new long[5];
		
		for(int i = 0;i<n;i++){
			long a = ans + arr[i];
			
			int j = 4;
			//System.out.println(a);
			while(j >= 0){
				if(pr[j] > a){
					j--;
				}else{
					count[j] += (long)(a/pr[j]);
					a = a - (long)(a/pr[j])*pr[j];
				}
			}
			//System.out.println(a);
			ans = a;
			
		}
		
		for(int i = 0;i<5;i++){
			System.out.print(count[i] + " ");
		}
		System.out.println();
		System.out.println(ans);
		
	}
	
	public static void AP(int i){
		
		state[i] = 1;
		int c = 0;
		
		// System.out.println(i + " sdf");
		disc[i] = low[i] = ++time;
		 
        // Go through all vertices aadjacent to this
        Iterator<Integer> it = adj[i].iterator();
        while (it.hasNext())
        {
        	
            int v = it.next();  // v is current adjacent of u
          
            // If v is not visited yet, then make it a child of u
            // in DFS tree and recur for it
            if (state[v] == 0)
            {
                c++;
                parent[v] = i;
                AP(v);
 
                // Check if the subtree rooted with v has a connection to
                // one of the ancestors of u
                low[i]  = Math.min(low[i], low[v]);
 
                // u is an articulation point in following cases
 
                // (1) u is root of DFS tree and has two or more chilren.
                if (parent[i] == -1 && c > 1){
                	
                	if(arrap[i] == 0){
                		ap++;
                		arrap[i] = 1;
                	}
                }
                   
 
                // (2) If u is not root and low value of one of its child
                // is more than discovery value of u.
                if (parent[i] != -1 && low[v] >= disc[i]){
                	if(arrap[i] == 0){
                		ap++;
                		arrap[i] = 1;
                	}
                }
                    
            }
 
            // Update low value of u for parent function calls.
            else if (v != parent[i])
                low[i]  = Math.min(low[i], disc[v]);
        }
	
	}
	
	public static void dfs(int i){
		if(visited[i] == 1 || state[i] == 1){
			return;
		}
		
		count++;
		
		for(int j = 0;j<adj[i].size();j++){
			dfs(adj[i].get(j));
		}
		
	}

	public static void bfs(int i){
		
		Queue<Integer> q=new LinkedList<Integer>();
    	q.add(i);
    	
    	visited[i] = 1;
    	count = 1;
    	while(!q.isEmpty()){
    		int top=q.poll();
    		
    		Iterator<Integer> it= adj[top].listIterator();
    		while(it.hasNext()){
    			int next =it.next();
    			
    			if(visited[next] == 0){
    				count++;
    				visited[next] = 1;
    				q.add(next);
    			}
    		
    		}
    	}
		
	}
	
	public static int prev(int i,boolean[] arr){
		
		while(arr[i]){
			if(i == 0){
				if(arr[i]){
					return -1;
				}else{
					return 0;
				}
				
				
			}
			
			
			i--;
			
		}
		
		return i;
		
		
	}
	
	
	public static int next(int i,boolean[] arr){
		
		
		while(arr[i]){
			if(i == arr.length-1){
				if(arr[i]){
					return -1;
				}else{
					return 0;
				}
			}
			
			i++;
		}
		
		
		return i;
	}
	

	
	private static Map<String, Integer> sortByValue(Map<String, Integer> unsortMap) {

        // 1. Convert Map to List of Map
        LinkedList<Entry<String, Integer>> list =
                new LinkedList<Map.Entry<String, Integer>>(unsortMap.entrySet());

        // 2. Sort list with Collections.sort(), provide a custom Comparator
        //    Try switch the o1 o2 position for a different order
        Collections.sort(list, new Comparator<Map.Entry<String, Integer>>() {
            public int compare(Map.Entry<String, Integer> o1,
                               Map.Entry<String, Integer> o2) {
                return (o1.getValue()).compareTo(o2.getValue());
            }
        });

        // 3. Loop the sorted list and put it into a new insertion order Map LinkedHashMap
        Map<String, Integer> sortedMap = new LinkedHashMap<String, Integer>();
        for (Map.Entry<String, Integer> entry : list) {
            sortedMap.put(entry.getKey(), entry.getValue());
        }

        /*
        //classic iterator example
        for (Iterator<Map.Entry<String, Integer>> it = list.iterator(); it.hasNext(); ) {
            Map.Entry<String, Integer> entry = it.next();
            sortedMap.put(entry.getKey(), entry.getValue());
        }*/


        return sortedMap;
    }

	
	public static ArrayList<Integer> Range(int[] numbers, int target) {
	  

	    int low = 0, high = numbers.length - 1;
	    // get the start index of target number
	    int startIndex = -1;
	    while (low <= high) {
	        int mid = (high - low) / 2 + low;
	        if (numbers[mid] > target) {
	            high = mid - 1;
	        } else if (numbers[mid] == target) {
	            startIndex = mid;
	            high = mid - 1;
	        } else
	            low = mid + 1;
	    }

	    // get the end index of target number
	    int endIndex = -1;
	    low = 0;
	    high = numbers.length - 1;
	    while (low <= high) {
	        int mid = (high - low) / 2 + low;
	        if (numbers[mid] > target) {
	            high = mid - 1;
	        } else if (numbers[mid] == target) {
	            endIndex = mid;
	            low = mid + 1;
	        } else
	            low = mid + 1;
	    }

	    ArrayList<Integer> list = new ArrayList<Integer>();
	    int c = 0;
	    if (startIndex != -1 && endIndex != -1){
	        for(int i = startIndex;i<=endIndex;i++){
	        	list.add(i);
	        }
	    }
	    
	    
	    return list;
	    
	    
	}

	
	
	 private static int root(int Arr[],int i)
	    {
	        while(Arr[ i ] != i)           //chase parent of current element until it reaches root
	        {
	            Arr[ i ] = Arr[ Arr[ i ] ] ; 
	            i = Arr[ i ];
	        }
	        return i;
	    }
	 
	 private static void union(int Arr[],int size[],int A,int B)
	    {
	        int root_A = root(Arr,A);
	        int root_B = root(Arr,B);
	     
	       System.out.println(root_A + " " + root_B);
	        if(root_A != root_B){
	        	 if(size[root_A] < size[root_B ])
	 	        {
	        		 Arr[ root_A ] = Arr[root_B];
	        		 size[root_B] += size[root_A];	 	
	 	        }
	 	        else
	 	        {   	
	 	        	Arr[ root_B ] = Arr[root_A];
	 	        	size[root_A] += size[root_B];	 	   
	 	        }	
	        }
	    }
	 
	 private static boolean find(int A,int B)
	    {
	        if( root(Arr,A)==root(Arr,B) )       //if A and B have the same root, it means that they are connected.
	        return true;
	        else
	        return false;
	    }
	 
	
	


//	
//	public static void bfs(int i){
//		
//		Queue<Integer> q=new LinkedList<Integer>();
//    	q.add(i);
//    	
//    	visited[i] = 1;
//    	c++;
//    	nodes++;
//    	while(!q.isEmpty()){
//    		int top=q.poll();
//    		
//    		Iterator<Integer> it= arr[top].listIterator();
//    		while(it.hasNext()){
//    			int next =it.next();
//    			
//    			if(visited[next] == 0){
//    				nodes++;
//    				visited[next] = 1;
//    				q.add(next);
//    			}
//    		
//    		}
//    	}
//		
//	}
	
	
	
//	public static void dfs(int i){
//		
//		
//		if(visited[i] == 1){
//			return;
//		}
//		
//		visited[i] = 1;
//		con[c].add(i);
//		//System.out.print(i + " ");
//		for(int j = 0;j<arr[i].size();j++){
//			dfs(arr[i].get(j));
//		}
//		
//	}
//	
//	
//	public static void dfss(int i){
//		if(visited[i] == 1){
//			return;
//		}
//		
//		visited[i] = 1;
//		
//		for(int j = 0;j<arr[i].size();j++){
//			dfss(arr[i].get(j));
//		}
//	//	System.out.println(i);
//		stack.push(i);
//	}
//	
//	public static void reverse(){
//		ArrayList[] temp = new ArrayList[n];
//		
//		for(int i = 0;i<n;i++){
//			temp[i] = new ArrayList();
//		}
//		
//		for(int i = 0;i<n;i++){
//			for(int j = 0;j<arr[i].size();j++){
//				temp[arr[i].get(j)].add(i);
//			}
//		}
//		
//		arr = temp;
//		
//	}
//	
//	
	
	
	
	
	
	
	public static boolean isPrime(int n) {
		// Corner cases
		if (n <= 1)
			return false;
		if (n <= 3)
			return true;
 
		// This is checked so that we can skip 
		// middle five numbers in below loop
		if (n % 2 == 0 || n % 3 == 0)
			return false;
 
		for (int i = 5; i * i <= n; i = i + 6)
			if (n % i == 0 || n % (i + 2) == 0)
				return false;
 
		return true;
	}
	
		 
	 // union code starts	
	
	
	 
	 // union code ends
	
	
	 
//	 // Segment tree code begins
//	 
//	 
//	 static void build(int node,int start,int end)
//	 {
//	 if(start==end)
//	 tree[node]=a[start];
//	 else
//	 {
//	 int mid=(start+end)/2;
//	 build(2*node,start,mid);
//	 build(2*node+1,mid+1,end);
//	 if(tree[2*node]<tree[2*node+1])
//	 tree[node]=tree[2*node];
//	 else
//	 tree[node]=tree[2*node+1];
//	 }
//	 }
//	 
//	 
//	 static void update(int node,int start,int end,int idx,int val)
//	 {
//	 if(start==end)
//	 {
//	 a[idx]=val;
//	 tree[node]=val;
//	 }
//	 else
//	 {
//	 int mid=(start+end)/2;
//	 if(idx>=start&&idx<=mid)
//	 update(2*node,start,mid,idx,val);
//	 else
//	 update(2*node+1,mid+1,end,idx,val);
//	 if(tree[2*node]<tree[2*node+1])
//	 tree[node]=tree[2*node];
//	 else
//	 tree[node]=tree[2*node+1];
//	 }
//	 }
//	 
//	 static int query(int node,int start,int end,int l,int r)
//	 {
//	 if(l>end||start>r)
//	 return 100005;
//	 if(l<=start&&r>=end)
//	 return tree[node];
//	 int p1,p2;
//	 int mid=(start+end)/2;
//	 p1=query(2*node,start,mid,l,r);
//	 p2=query(2*node+1,mid+1,end,l,r);
//	 if(p1<p2)
//	 return p1;
//	 else
//	 return p2;
//	 }
//	 
//	 
//	 
//}

}

class Node{
	int i;
	long a;
	long b;
}


class MyComp2 implements Comparator<Node>{
    
	@Override
	public int compare(Node o1, Node o2) {
		if(o1.a>o2.a){
			return 1;
		}else if(o1.a<o2.a){
			return -1;
		}else{
			if(o1.b>o2.b){
				return 1;
				
			}else{
				return -1;
			}
			
			
		}
		
		
	}
}


class Card implements Comparable<Card>
{
	int a,b;
	public Card(int w,int h)
	{
		this.a=w;
		this.b=h;
		
	}
	public int compareTo(Card that)
	{
		return this.a-that.a;
	}
}