You are given two arrays a_1, a_2, ... , a_n and b_1, b_2, ... , b_m. Array b is sorted in ascending order (b_i < b_{i + 1} for each i from 1 to m - 1).

You have to divide the array a into m consecutive subarrays so that, for each i from 1 to m, the minimum on the i-th subarray is equal to b_i. Note that each element belongs to exactly one subarray, and they are formed in such a way: the first several elements of a compose the first subarray, the next several elements of a compose the second subarray, and so on.

For example, if a = [12, 10, 20, 20, 25, 30] and b = [10, 20, 30] then there are two good partitions of array a: 

  1. [12, 10, 20], [20, 25], [30]; 
  2. [12, 10], [20, 20, 25], [30]. 



You have to calculate the number of ways to divide the array a. Since the number can be pretty large print it modulo 998244353.

Input

The first line contains two integers n and m (1 ≤ n, m ≤ 2 ⋅ 10^5) — the length of arrays a and b respectively.

The second line contains n integers a_1, a_2, ... , a_n (1 ≤ a_i ≤ 10^9) — the array a.

The third line contains m integers b_1, b_2, ... , b_m (1 ≤ b_i ≤ 10^9; b_i < b_{i+1}) — the array b.

Output

In only line print one integer — the number of ways to divide the array a modulo 998244353.

Examples

Input


6 3
12 10 20 20 25 30
10 20 30


Output


2


Input


4 2
1 3 3 7
3 7


Output


0


Input


8 2
1 2 2 2 2 2 2 2
1 2


Output


7

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

public class e
{
    public static void print(String str,int val){
        System.out.println(str+"  "+val);
    }



    public static void debug(long[][] arr){
        int len = arr.length;
        for(int i=0;i<len;i++){
            System.out.println(Arrays.toString(arr[i]));
        }
    }
    public static void debug(int[][] arr){
        int len = arr.length;
        for(int i=0;i<len;i++){
            System.out.println(Arrays.toString(arr[i]));
        }
    }
    public static void debug(String[] arr){
        int len = arr.length;
        for(int i=0;i<len;i++){
            System.out.println(arr[i]);
        }
    }

    public static void print(int[] arr){
        int len = arr.length;
        for(int i=0;i<len;i++){
            System.out.print(arr[i]+" ");
        }
        System.out.print('\n');
    }
    public static void print(String[] arr){
        int len = arr.length;
        for(int i=0;i<len;i++){
            System.out.print(arr[i]+" ");
        }
        System.out.print('\n');
    }
    public static void print(long[] arr){
        int len = arr.length;
        for(int i=0;i<len;i++){
            System.out.print(arr[i]+" ");
        }
        System.out.print('\n');
    }

    static class FastReader
    {
        BufferedReader br;
        StringTokenizer st;

        public FastReader()
        {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next()
        {
            while (st == null || !st.hasMoreElements())
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException  e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt()
        {
            return Integer.parseInt(next());
        }

        long nextLong()
        {
            return Long.parseLong(next());
        }

        double nextDouble()
        {
            return Double.parseDouble(next());
        }

        String nextLine()
        {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }

    static int M = 998244353;
    public static void main(String[] args)
    {
        FastReader s=new FastReader();
        int n = s.nextInt();
        int m = s.nextInt();
        int[] a = new int[n];
        int[] b = new int[m];
        for(int i=0;i<n;i++){
            a[i] = s.nextInt();
        }
        for(int i=0;i<m;i++){
            b[i] = s.nextInt();
        }
        System.out.println(solve(n,m,a,b));
    }

    public static long mul(long a,int b){
        return (a*1L*b)%M;
    }

    public static long solve(int n,int m,int[] a,int[] b){
        //store positions of every last bi
        HashMap<Integer,Integer> tm = new HashMap<>();
        for(int i=0;i<n;i++){
            tm.putIfAbsent(a[i],i);
            tm.replace(a[i],i);
        }

        if(n<m){
            return 0;
        }
        long answer =1;
        int index_b =0;
        int start =0;
        while (true){
            if(!tm.containsKey(b[index_b])){
                return 0;
            }
            int las_pos =  tm.get(b[index_b]);
            if(start>=n){
                return 0;
            }
            //now check whether this has any min<b
            int min_pref =Integer.MAX_VALUE;
            for(int i=start;i<las_pos;i++){
                min_pref = Math.min(a[i],min_pref);
            }
            if(min_pref<b[index_b]){
                return 0;
            }
            if(index_b==m-1){
                for(int i=las_pos;i<n;i++){
                    if(a[i]<b[index_b]){
                        return 0;
                    }
                }

                    return answer;
            }
            //now get next position
            if(!tm.containsKey(b[index_b+1])){
                return 0;
            }
            int get_next = tm.get(b[index_b+1]);
            if(get_next<las_pos){
                return 0;
            }
            //now check for break point at which it is less than b2 and greater than b1
            int min_pos =las_pos;
            for(int i=get_next;i>las_pos;i--){
                if(a[i]<b[index_b+1] && min_pos==las_pos){
                    min_pos = i;
                }
                //check whether all elements are greater than b[index_b]
                if(a[i]<b[index_b]){
                    return 0;
                }
            }
            answer = mul(answer,get_next-min_pos);
            //now update values
            start = min_pos+1;
            index_b++;

        }
    }





//    OutputStream out = new BufferedOutputStream( System.out );
//        for(int i=1;i<n;i++){
//    out.write((arr[i]+" ").getBytes());
//}
//        out.flush();

    //  long start = System.currentTimeMillis();
//  long end = System.currentTimeMillis();
//  System.out.println((end - start) + "ms");



}
