Problem: Takahashi decided to go sightseeing in New York with Apple. Takahashi didn't have any particular hope for sightseeing, but due to Sachika-chan's enthusiastic invitation, he decided to go sightseeing in the "hosonogai place" as shown in the map below.

<image> Google Maps-(C) 2012 Google

This "horizontal place" is very elongated and can be regarded as a straight line. In addition, there is a start point at one end and a goal point at the other end, and several tourist carriages are running from the start point to the goal point. This carriage operates according to the following rules.

* There are n carriages, and all carriages start from the starting point and proceed to the goal point.
* The size of the carriage can be ignored in all of the following cases:
* Since it is difficult to change the speed on the way, all carriages travel at a constant speed of Si (Si is an integer of 1 or more) per 1 km.
* The carriages have a set departure order, and you must follow this order. However, there is no particular rule regarding the order in which you will arrive at the goal point.
* Multiple carriages cannot depart from the starting point at the same time, and if one carriage departs, there must be at least one minute before the next carriage departs.
* The goal point is wide enough that any number of carriages can arrive at the same time. Also, the carriage that arrives at the goal point stops there and stays at the goal point all the time.
* Since the "Hoso Nagai" is very long and narrow, basically two carriages cannot be lined up in the same place. However, there are special "slightly wide areas" in m, where up to two can be lined up, allowing one carriage to overtake another.



In addition, the following restrictions are satisfied for the above-mentioned "horizontal place" and "slightly wide place".

* There is a straight line from the start point to the goal point, and the distance is (dist) km (dist is an integer greater than or equal to 1).
* There are m "slightly wide areas" somewhere from the start point to the goal point, none of which overlap the start point and goal point. Also, each "slightly wide area" is exactly (Di) km (Di is an integer greater than or equal to 1) from the starting point.



Upon hearing this, Mr. Takahashi adjusted the departure time of the carriage while observing the rules of carriage operation described above, so that the time required from the departure of the first carriage to the arrival of all the carriages was reduced. I found out that I could make it smaller. In order to know the result of Mr. Takahashi, the number of carriages n, the parameter Si regarding the speed of each carriage, the total number of "slightly wide places" existing on the "horizontal place" m, each "slightly wide place" Given the distance Di from the starting point, it's your job to write a program that finds the minimum amount of time it takes for all carriages to arrive after the first carriage departs. In addition, Sachika-chan fully enjoyed sightseeing in "Hosonagai-ko", but Takahashi-kun only muttered "It was hospitable ..." after this sightseeing.

Constraints

> 1 ≤ dist ≤ 100000000 (108)
> 1 ≤ n ≤ 5
> 0 ≤ m ≤ 5
> 1 ≤ Si ≤ 100
> 0 <Di <dist
> If i ≠ j then Di ≠ Dj
> All numbers appearing in the input are integers.
>

* If i <j, the i-th carriage must depart at least 1 minute earlier than the j-th carriage

Input

The input format is as follows.

> dist
> n
> S1
> S2
> ..
> Sn
> m
> D1
> D2
> ..
> Dm
>

* dist represents the distance (km) from the start point to the goal point
* n represents the number of carriages departing from the starting point
* Si represents the speed of the carriage, and the i-th departing carriage represents 1 km in (Si) minutes.
* m represents the total number of "slightly wide areas"
* Di represents the distance (km) from the starting point to each "slightly wide area".

Output

Output the minimum time it takes for all carriages to arrive in one line after the first carriage departs. The unit is minutes.

Examples

Input

100
2
1
2
0


Output

201


Input

100
2
2
1
0


Output

200


Input

100
3
2
1
1
1
50


Output

200


Input

100
4
3
1
1
3
2
40
60


Output

421

Solution (in CPP):

Solution:
#include<cstdlib>
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<queue>
#include<set>
#include<cstring>
#include<map>
using namespace std;
const int MAXN = (int) 105;
const int INF = (int) 0x3f3f3f3f;
typedef long long LL;

int dist;
int M,N;
int S[MAXN];
int D[MAXN];
LL ans;
LL out_time[MAXN];
map<LL,set<int> > mp;
struct permutation{
    int a[10];
}per;
int percnt;
vector<permutation> P;

bool is_judge(){
    mp.clear();
    for(int i=2;i<=N;i++)if(out_time[i]<=out_time[i-1]) return false;
    for(int i=1;i<N;i++){
        for(int j=i+1;j<=N;j++){
            if(S[i]<=S[j]) continue;
            if((out_time[j]-out_time[i])/(S[i]-S[j])>=dist) continue;
            if((out_time[j]-out_time[i])%(S[i]-S[j])!=0) return false;
            int tmpD=(out_time[j]-out_time[i])/(S[i]-S[j]);
            int ok=0;
            for(int k=1;k<=M;k++){
                if(D[k]==tmpD) ok=1;
            }
            if(!ok) return false;
            if(mp.count(tmpD)){
                if(mp[tmpD].count(i)) return false;
                if(mp[tmpD].count(j)) return false;
            }
            mp[tmpD].insert(i);
            mp[tmpD].insert(j);
        }
    }
    return true;
}

void update(){
    for(int i=N;i>=1;i--) out_time[i]-=out_time[1];
    if(!is_judge()) return;
    LL tmpans=0;
    for(int i=1;i<=N;i++){
        LL tmp=out_time[i]+(LL)dist*S[i];
        tmpans=max(tmpans,tmp);
    }
    ans=min(ans,tmpans);
}

int mark[MAXN];
void DFS1(int cur){
    if(cur>N){
        per.a[0]=1;
        P.push_back(per);
        return;
    }
    for(int i=1;i<=N;i++)if(!mark[i]){
        per.a[++percnt]=i;
        mark[i]=1;
        DFS1(cur+1);
        percnt--;
        mark[i]=0;
    }
}

void DFS2(int curid,const permutation& now){
    if(curid>N){
        update();
        return;
    }
    int cur=now.a[curid];
    if(curid==1){
        out_time[cur]=0;
        DFS2(curid+1,now);
        return;
    }

    for(int t=1;t<curid;t++){
        int pre=now.a[t];
        if(cur<pre){
            out_time[cur]=out_time[pre]-1;
            DFS2(curid+1,now);
            for(int i=1;i<=M;i++){
                LL dt=D[i];
                out_time[cur]=out_time[pre]-dt*(S[cur]-S[pre]);
    //            printf("%d-%d : %lld->%lld\n",pre,cur,out_time[pre],out_time[cur]);
                DFS2(curid+1,now);
            }
        }
        if(cur>pre){
            out_time[cur]=out_time[pre]+1;
            DFS2(curid+1,now);
            for(int i=1;i<=M;i++){
                LL dt=D[i];
                out_time[cur]=out_time[pre]+dt*(S[pre]-S[cur]);
                DFS2(curid+1,now);
            }
        }
    }
}

void solve(){
    for(int perid=0;perid<P.size();perid++){
        DFS2(1,P[perid]);
    }
}

void work(){
    scanf("%d%d",&dist,&N);
    for(int i=1;i<=N;i++) scanf("%d",&S[i]);
    scanf("%d",&M);
    for(int i=1;i<=M;i++) scanf("%d",&D[i]);
    D[++M]=dist;
    ans=(LL)INF*INF;
    DFS1(1);
    solve();
    printf("%lld\n",ans);
}

int main(){
#ifdef NNever
//freopen("data.in","r",stdin);
///freopen("out.txt","w",stdout);
#endif // NNever
    work();
    return 0;
}

/*
input
60516263
5
45
16
94
71
91
4
20586550
54017689
36941264
49153094

output
6577480535
*/