You are given m sets of integers A_1, A_2, …, A_m; elements of these sets are integers between 1 and n, inclusive.

There are two arrays of positive integers a_1, a_2, …, a_m and b_1, b_2, …, b_n. 

In one operation you can delete an element j from the set A_i and pay a_i + b_j coins for that.

You can make several (maybe none) operations (some sets can become empty).

After that, you will make an edge-colored undirected graph consisting of n vertices. For each set A_i you will add an edge (x, y) with color i for all x, y ∈ A_i and x < y. Some pairs of vertices can be connected with more than one edge, but such edges have different colors.

You call a cycle i_1 → e_1 → i_2 → e_2 → … → i_k → e_k → i_1 (e_j is some edge connecting vertices i_j and i_{j+1} in this graph) rainbow if all edges on it have different colors.

Find the minimum number of coins you should pay to get a graph without rainbow cycles.

Input

The first line contains two integers m and n (1 ≤ m, n ≤ 10^5), the number of sets and the number of vertices in the graph.

The second line contains m integers a_1, a_2, …, a_m (1 ≤ a_i ≤ 10^9).

The third line contains n integers b_1, b_2, …, b_n (1 ≤ b_i ≤ 10^9).

In the each of the next of m lines there are descriptions of sets. In the i-th line the first integer s_i (1 ≤ s_i ≤ n) is equal to the size of A_i. Then s_i integers follow: the elements of the set A_i. These integers are from 1 to n and distinct.

It is guaranteed that the sum of s_i for all 1 ≤ i ≤ m does not exceed 2 ⋅ 10^5.

Output

Print one integer: the minimum number of coins you should pay for operations to avoid rainbow cycles in the obtained graph.

Examples

Input


3 2
1 2 3
4 5
2 1 2
2 1 2
2 1 2


Output


11


Input


7 8
3 6 7 9 10 7 239
8 1 9 7 10 2 6 239
3 2 1 3
2 4 1
3 1 3 7
2 4 3
5 3 4 5 6 7
2 5 7
1 8


Output


66

Note

In the first test, you can make such operations:

  * Delete element 1 from set 1. You should pay a_1 + b_1 = 5 coins for that. 
  * Delete element 1 from set 2. You should pay a_2 + b_1 = 6 coins for that. 



You pay 11 coins in total. After these operations, the first and the second sets will be equal to \{2\} and the third set will be equal to \{1, 2\}.

So, the graph will consist of one edge (1, 2) of color 3.

In the second test, you can make such operations:

  * Delete element 1 from set 1. You should pay a_1 + b_1 = 11 coins for that. 
  * Delete element 4 from set 2. You should pay a_2 + b_4 = 13 coins for that. 
  * Delete element 7 from set 3. You should pay a_3 + b_7 = 13 coins for that. 
  * Delete element 4 from set 4. You should pay a_4 + b_4 = 16 coins for that. 
  * Delete element 7 from set 6. You should pay a_6 + b_7 = 13 coins for that. 



You pay 66 coins in total.

After these operations, the sets will be:

  * \{2, 3\}; 
  * \{1\}; 
  * \{1, 3\}; 
  * \{3\}; 
  * \{3, 4, 5, 6, 7\}; 
  * \{5\}; 
  * \{8\}. 



We will get the graph:

<image>

There are no rainbow cycles in it.
import sun.security.krb5.internal.PAData;

import java.io.*;
import java.util.*;

public class Main {

    public static void main(String[] args) throws Exception {
        MyReader reader = new MyReader(System.in);
//        MyReader reader = new MyReader(new FileInputStream("input.txt"));
        MyWriter writer = new MyWriter(System.out);
        new Main().run(reader, writer);
        writer.close();
    }

    private void run(MyReader reader, MyWriter writer) throws Exception {
        int m = reader.nextInt();
        int n = reader.nextInt();
        int[] a = reader.nextIntArray(m);
        int[] b = reader.nextIntArray(n);
        Graph graph = new Graph();
        graph.initNodes(m + n);
        long sum = 0;
        for (int i = 0; i < m; i++) {
            int s = reader.nextInt();
            for (int j = 0; j < s; j++) {
                int v = reader.nextInt() - 1;
                sum += a[i] + b[v];
                graph.addEdge(i, m + v, -(a[i] + b[v]), false);
            }
        }
        long w = graph.mst();
        writer.println(sum + w);
    }

    class Pair<T> extends Pair2<T, T> {

        public Pair(T x, T y) {
            super(x, y);
        }
    }

    class Pair2<T, U> {

        T x;
        U y;

        public Pair2(T x, U y) {
            this.x = x;
            this.y = y;
        }
    }

    public class DSU {

        int n;
        int[] p;
        int[] r;

        DSU(int n) {
            this.n = n;
            p = new int[n];
            for (int i = 0; i < n; i++) {
                p[i] = i;
            }
            r = new int[n];
        }

        int get(int x) {
            if (p[x] != x) {
                p[x] = get(p[x]);
            }
            return p[x];
        }

        void union(int x, int y) {
            x = get(x);
            y = get(y);
            if (x == y) {
                return;
            }
            if (r[x] == r[y]) {
                r[x]++;
            }
            if (r[x] < r[y]) {
                p[x] = y;
            } else {
                p[y] = x;
            }
        }
    }

    public class Graph<T> {

        int counter = 0;
        List<Node> nodes = new ArrayList<>();
        List<Long> dist;

        void initNodes(int n) {
            for (int i = 0; i < n; i++) {
                nodes.add(new Node());
            }
        }

        void addNode(T obj) {
            nodes.add(new Node(obj));
        }

        void addEdge(int i, int j, boolean oriented) {
            addEdge(i, j, 0, oriented);
        }

        void addEdge(int i, int j, long w, boolean oriented) {
            Node from = nodes.get(i);
            Node to = nodes.get(j);
            addEdge(from, to, w, oriented);
        }

        void addEdge(Node from, Node to, boolean oriented) {
            addEdge(from, to, 0, oriented);
        }

        void addEdge(Node from, Node to, long w, boolean oriented) {
            Edge edge = new Edge(from, to, w);
            from.edges.add(edge);
            if (!oriented) {
                Edge rev = new Edge(to, from, w);
                to.edges.add(rev);
            }
        }

        long mst() {
            List<Edge> list = new ArrayList<>();
            for (Node node : nodes) {
                list.addAll(node.edges);
            }
            list.sort((e1, e2) -> (int) (e1.w - e2.w));
            DSU dsu = new DSU(nodes.size());
            long weight = 0;
            for (Edge edge : list) {
                if (dsu.get(edge.from.i) != dsu.get(edge.to.i)) {
                    weight += edge.w;
                    dsu.union(edge.from.i, edge.to.i);
                }
            }
            return weight;
        }

//    void dijkstra() {
//        PriorityQueue<Main.Pair2<Node, Long>> queue = new PriorityQueue<>((o1, o2) -> (int) (o1.y - o2.y));
//        queue.add(new Main.Pair2<>(nodes.get(0), 0L));
//        while (!queue.isEmpty()) {
//            Main.Pair2<Node, Long> p = queue.poll();
//            Node n = p.x;
//            long d = p.y;
//            if (n.dist != -1) {
//                continue;
//            }
//            n.dist = d;
//            for (Edge edge : n.edges) {
//                queue.add(new Main.Pair2<>(edge.to, d + edge.w));
//            }
//        }
//    }

        class Node {

            int i;
            T obj;
            List<Edge> edges = new ArrayList<>();
            long dist = -1;

            public Node() {
                this(null);
            }

            public Node(T obj) {
                this.i = counter++;
                this.obj = obj;
            }
        }

        class Edge {

            long w;
            Node from;
            Node to;

            public Edge(Node from, Node to) {
                this(from, to, 0);
            }

            public Edge(Node from, Node to, long w) {
                this.from = from;
                this.to = to;
                this.w = w;
            }
        }
    }


    public static class MyReader {

        final BufferedInputStream in;
        final int bufSize = 1 << 16;
        final byte[] buf = new byte[bufSize];
        int i = bufSize;
        int k = bufSize;
        boolean end = false;
        final StringBuilder str = new StringBuilder();

        MyReader(InputStream in) {
            this.in = new BufferedInputStream(in, bufSize);
        }

        int nextInt() throws IOException {
            return (int) nextLong();
        }

        int[] nextIntArray(int n) throws IOException {
            int[] m = new int[n];
            for (int i = 0; i < n; i++) {
                m[i] = nextInt();
            }
            return m;
        }

        int[][] nextIntMatrix(int n, int m) throws IOException {
            int[][] a = new int[n][0];
            for (int j = 0; j < n; j++) {
                a[j] = nextIntArray(m);
            }
            return a;
        }

        long nextLong() throws IOException {
            int c;
            long x = 0;
            int sign = 1;
            while ((c = nextChar()) <= 32) ;
            if (c == '-') {
                sign = -1;
                c = nextChar();
            }
            if (c == '+') {
                c = nextChar();
            }
            while (c >= '0') {
                x = x * 10 + (c - '0');
                c = nextChar();
            }
            return sign * x;
        }

        long[] nextLongArray(int n) throws IOException {
            long[] m = new long[n];
            for (int i = 0; i < n; i++) {
                m[i] = nextLong();
            }
            return m;
        }

        int nextChar() throws IOException {
            if (i == k) {
                k = in.read(buf, 0, bufSize);
                i = 0;
            }
            return i >= k ? -1 : buf[i++];
        }

        String nextString() throws IOException {
            if (end) {
                return null;
            }
            str.setLength(0);
            int c;
            while ((c = nextChar()) <= 32 && c != -1) ;
            if (c == -1) {
                end = true;
                return null;
            }
            while (c > 32) {
                str.append((char) c);
                c = nextChar();
            }
            return str.toString();
        }

        String nextLine() throws IOException {
            if (end) {
                return null;
            }
            str.setLength(0);
            int c = nextChar();
            while (c != '\n' && c != '\r' && c != -1) {
                str.append((char) c);
                c = nextChar();
            }
            if (c == -1) {
                end = true;
                if (str.length() == 0) {
                    return null;
                }
            }
            if (c == '\r') {
                nextChar();
            }
            return str.toString();
        }

        char[] nextCharArray() throws IOException {
            return nextString().toCharArray();
        }

        char[][] nextCharMatrix(int n) throws IOException {
            char[][] a = new char[n][0];
            for (int i = 0; i < n; i++) {
                a[i] = nextCharArray();
            }
            return a;
        }
    }

    public static class MyWriter {

        final BufferedOutputStream out;
        final int bufSize = 1 << 16;
        final byte buf[] = new byte[bufSize];
        int i = 0;
        final byte c[] = new byte[30];
        static final String newLine = System.getProperty("line.separator");

        MyWriter(OutputStream out) {
            this.out = new BufferedOutputStream(out, bufSize);
        }

        void print(long x) throws IOException {
            int j = 0;
            if (i + 30 >= bufSize) {
                flush();
            }
            if (x < 0) {
                buf[i++] = (byte) ('-');
                x = -x;
            }
            do {
                c[j++] = (byte) (x % 10 + '0');
                x /= 10;
            } while (x != 0);
            while (--j >= 0) {
                buf[i++] = c[j];
            }
        }

        void println(long x) throws IOException {
            print(x);
            println();
        }

        void print(int[] m) throws IOException {
            for (int a : m) {
                print(a);
                print(' ');
            }
        }

        void print(long[] m) throws IOException {
            for (long a : m) {
                print(a);
                print(' ');
            }
        }

        void print(String s) throws IOException {
            for (int i = 0; i < s.length(); i++) {
                print(s.charAt(i));
            }
        }

        void print(char x) throws IOException {
            if (i == bufSize) {
                flush();
            }
            buf[i++] = (byte) x;
        }

        void print(char[] m) throws IOException {
            for (char c : m) {
                print(c);
            }
        }

        void println(String s) throws IOException {
            print(s);
            println();
        }

        void println() throws IOException {
            print(newLine);
        }

        void flush() throws IOException {
            out.write(buf, 0, i);
            out.flush();
            i = 0;
        }

        void close() throws IOException {
            flush();
            out.close();
        }
    }
}