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.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.*;


public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        solve(in, out);
        out.close();
    }

    static String reverse(String s) {
        return (new StringBuilder(s)).reverse().toString();
    }

    static void sieveOfEratosthenes(int n, ArrayList<Integer> ar) 
    { 
        boolean prime[] = new boolean[n+1]; 
        for(int i=0;i<n;i++) 
            prime[i] = true; 
          
        for(int p = 2; p*p <=n; p++) 
        { 
            // If prime[p] is not changed, then it is a prime 
            if(prime[p] == true) 
            { 
                // Update all multiples of p 
                for(int i = p*p; i <= n; i += p) 
                    prime[i] = false; 
            } 
        } 
        // Print all prime numbers 
        for(int i = 2; i <= n; i++) 
        { 
            if(prime[i] == true) 
                ar.add(i);
        } 
    }

    static void sort(int ar[]) {
        int n = ar.length;
        ArrayList<Integer> a = new ArrayList<>();
        for (int i = 0; i < n; i++)
            a.add(ar[i]);
        Collections.sort(a);
        for (int i = 0; i < n; i++)
            ar[i] = a.get(i);
    }

    static long ncr(long n, long r, long mod) {
        if (r == 0)
            return 1;
        long val = ncr(n - 1, r - 1, mod);
        val = (n * val) % mod;
        val = (val * modInverse(r, mod)) % mod;
        return val;
    }

    

    public static void solve(InputReader sc, PrintWriter pw) {
        int i, j = 0;
        int t = 1;  
        // int t = sc.nextInt();
        u: while (t-- > 0) {
            int n=sc.nextInt();
            int m=sc.nextInt();
            int a[]=new int[n];
            int b[]=new int[m];
            for(i=0;i<n;i++){
                a[i]=sc.nextInt();
            }
            for(j=0;j<m;j++){
                b[j]=sc.nextInt();
            }
            if(m>n){
                pw.println(0);
                continue u;
            }
            int y[]=new int[n];
            int z[]=new int[n];
            for(i=0;i<n;i++){
                int val=a[i];
                int ans=-1,l=0,r=m-1;
                while(l<=r){
                    int mid=(l+r)/2;
                    if(val>=b[mid]){
                        ans=mid;
                        l=mid+1;
                    }
                    else{
                        r=mid-1;
                    }
                }
                if(ans==-1){
                    pw.println(0);
                    continue u;
                }
                y[i]=ans;
            }
            for(i=n-2;i>=0;i--){
                y[i]=Math.min(y[i],y[i+1]);
            }
            int x[]=new int[m];
            int min[]=new int[m];
            for(i=0;i<m;i++){
                min[i]=-1;
            }
            for(i=0;i<n-1;i++){
                // pw.println(y[i]);
                x[y[i]]=i+1;
                if(a[i]==b[y[i]])
                    min[y[i]]=Math.max(min[y[i]],i);
            }
            i=n-1;
            x[y[i]]=i+1;
            if(a[i]==b[y[i]])
                min[y[i]]=Math.max(min[y[i]],i);
            for(i=0;i<m;i++){
                if(x[i]==0){
                    // pw.println("Here1");
                    pw.println(0);
                    continue u;
                }
            }
            if(min[0]==-1){
                pw.println(0);
                continue u;
            }
            long tot=1L;
            long mod=998244353;
            for(i=1;i<m;i++){
                if(min[i]==-1){
                    // pw.println("Here");
                    pw.println(0);
                    continue u;
                }
                tot=tot*(min[i]-x[i-1]+1)%mod;
            }
            pw.println(tot);
        }
    }

    static class Pair implements Comparable<Pair> {
        int a;
        int b;
        int c;
        
        Pair(int a, int b, int c) {
            this.a = a;
            this.b = b;
            this.c = c;
        }

        public int compareTo(Pair p) {
            if (c != p.c)
                return -1*(c - p.c);
            return (a - p.a);
        }
    }

    static boolean isPrime(long n) {
        if (n <= 1)
            return false;
        if (n <= 3)
            return true;
        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;
    }

    static long gcd(long a, long b) {
        if (b == 0)
            return a;
        return gcd(b, a % b);
    }

    static long fast_pow(long base, long n, long M) {
        if (n == 0)
            return 1;
        if (n == 1)
            return base % M;
        long halfn = fast_pow(base, n / 2, M);
        if (n % 2 == 0)
            return (halfn * halfn) % M;
        else
            return (((halfn * halfn) % M) * base) % M;
    }

    static long modInverse(long n, long M) {
        return fast_pow(n, M - 2, M);
    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

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

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

