#include <iostream>
#include <sstream>
#include <vector>
#include <string>
#include <map>
using namespace std;


#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v.begin(), v.end())
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }



template<class Abel> struct UnionFind {
    vector<int> par;
    vector<int> rank;
    vector<Abel> diff_weight;
    
    UnionFind(int n = 1, Abel SUM_UNITY = 0) {
        init(n, SUM_UNITY);
    }
    
    void init(int n = 1, Abel SUM_UNITY = 0) {
        par.resize(n); rank.resize(n); diff_weight.resize(n);
        for (int i = 0; i < n; ++i) par[i] = i, rank[i] = 0, diff_weight[i] = SUM_UNITY;
    }
    
    int root(int x) {
        if (par[x] == x) {
            return x;
        }
        else {
            int r = root(par[x]);
            diff_weight[x] += diff_weight[par[x]];
            return par[x] = r;
        }
    }
    
    Abel weight(int x) {
        root(x);
        return diff_weight[x];
    }
    
    bool issame(int x, int y) {
        return root(x) == root(y);
    }
    
    bool merge(int x, int y, Abel w) {
        w += weight(x); w -= weight(y);
        x = root(x); y = root(y);
        if (x == y) return false;
        if (rank[x] < rank[y]) swap(x, y), w = -w;
        if (rank[x] == rank[y]) ++rank[x];
        par[y] = x;
        diff_weight[y] = w;
        return true;
    }
    
    Abel diff(int x, int y) {
        return weight(y) - weight(x);
    }
    
    friend ostream& operator << (ostream& s, UnionFind uf) {
        map<int, vector<int> > res;
        for (int i = 0; i < uf.par.size(); ++i) {
            int r = uf.root(i);
            res[r].push_back(i);
        }
        for (map<int, vector<int> >::iterator it = res.begin(); it != res.end(); ++it) {
            s << endl;
            for (int j = 0; j < (int)it->second.size(); ++j) {
                s << it->second[j] << "(" << uf.weight(it->second[j]) << "), ";
            }
        }
        return s << endl;
    }
};

typedef pair<int,int> pint;

long long dist;
int n, m;
long long S[11], D[11];

const long long INF = 1LL<<60;
long long res = INF; // 答えを更新していく

// 各馬車が「どこですれ違うか」
void check(vector<long long> diffs) {
    UnionFind<long long> uf(n);
    int iter = 0;
    for (int i = 0; i < n; ++i) {
        for (int j = i + 1; j < n; ++j) {
            long long diff = diffs[iter++];
            if (diff == -1) continue;
            
            if (uf.issame(i, j)) {
                long long curdiff = uf.diff(i, j);
                if (diff != curdiff) return;
            }
            else {
                uf.merge(i, j, diff);
            }
        }
    }

    // 暫定回を求める
    long long start = 0, goal = 0;
    for (int i = 0; i < n; ++i) {
        long long start_i = start + uf.diff(0, i);
        long long goal_i = start_i + S[i] * dist;
        if (start > start_i) start = start_i;
        if (goal < goal_i) goal = goal_i;
    }
    
    // 整合性を確認
    for (int i = 0; i < n; ++i) {
        for (int j = i + 1; j < n; ++j) {
            if (!uf.issame(i, j)) return; // 繋がっていない箇所があったら明らかに最適でないので return
            if (uf.diff(i, j) < 1) return; // j が i の 1分後よりも早く出ていたらダメ
            
            // 追い越している場合はどこで追い越してるか
            long long start_i = uf.diff(0, i);
            long long goal_i = start_i + S[i] * dist;
            long long start_j = uf.diff(0, j);
            long long goal_j = start_j + S[j] * dist;
            if (goal_j < goal_i) {
                int pl = -1;
                for (int k = 0; k < m; ++k) {
                    long long it = start_i + S[i] * D[k];
                    long long jt = start_j + S[j] * D[k];
                    if (it == jt) {
                        pl = k;
                    }
                }
                if (pl == -1) return; // 「少し広いところ以外で交わったらダメ
            }
        }
    }
    
    // 本当に m 箇所それぞれについて、3 個以上の馬車が交わることがないか確認
    for (int i = 0; i < m; ++i) {
        map<long long,int> ma;
        for (int j = 0; j < n; ++j) {
            long long t = uf.diff(0, j) + S[j] * D[i];
            ma[t]++;
        }
        for (map<long long,int>::iterator it = ma.begin(); it != ma.end(); ++it) {
            if (it->second >= 3) return;
        }
    }
    
    /*
    COUT("--------------");
    COUT(diffs);
    COUT(uf);
    COUT(start);
    COUT(goal);
    */
    
    // 確認を終えたら OK
    if (res > goal - start) res = goal - start;
}

void dfs(vector<long long> diffs, int i, int j) {
    if (i == n-1) {
        check(diffs);
        return;
    }
    
    // 馬車 i, j が何分でゴールするか
    long long total_i = S[i] * dist;
    long long total_j = S[j] * dist;
    
    // 次の index
    int ni = i;
    int nj = j+1;
    if (nj == n) {
        ++ni;
        nj = ni+1;
    }
    
    // weight(j) - weight(i) = 1 (j が i より 1 分遅れスタートで、途中で抜かさない場合
    if (total_j >= total_i - 1) {
        diffs.push_back(1);
        dfs(diffs, ni, nj);
        diffs.pop_back();
    }
    
    // ゴールでピッタリ
    {
        long long diff = total_i - total_j;
        if (diff >= 1) {
            diffs.push_back(diff);
            dfs(diffs, ni, nj);
            diffs.pop_back();
        }
    }
    
    // m 箇所それぞれ
    if (S[i] != S[j]) {
        for (int k = 0; k < m; ++k) {
            long long diff = (S[i] - S[j]) * D[k];
            if (diff >= 1) {
                diffs.push_back(diff);
                dfs(diffs, ni, nj);
                diffs.pop_back();
            }
        }
    }
    
    // それ以外
    diffs.push_back(-1);
    dfs(diffs, ni, nj);
    diffs.pop_back();
}

int main() {
    while (cin >> dist) {
        cin >> n;
        for (int i = 0; i < n; ++i) cin >> S[i];
        cin >> m;
        for (int i = 0; i < m; ++i) cin >> D[i];
        
        vector<long long> diffs;
        dfs(diffs, 0, 1);
        
        cout << res << endl;
    }
}


Measured memory_bytes: 3176