#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using ll = long long;
using ld = long double;

const int MOD = 998244353;
const int INFi = 1e9;
const ll INF = 1e18;
const int N = 1e6 + 10;

using namespace __gnu_pbds;
using namespace std;

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

vector<vector<int>> g;
vector<int> dep, pred;

int bin_pow(int x, int y) {
    int res = 1;
    while (y) {
        if (y & 1) {
            res = res * 1ll * x % MOD;
        }
        y >>= 1;
        x = x * 1ll * x % MOD;
    }
    return res;
}

int fact[N], rfact[N];

int C(int n, int k) {
    return ((fact[n] * 1ll * rfact[k]) % MOD) * rfact[n - k] % MOD;
}

void dfs(int x, int p, int d) {
    dep[x] = d;
    pred[x] = p;
    for (auto to : g[x]) {
        if (to == p) {
            continue;
        }
        dfs(to, x, d + 1);
    }
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    fact[0] = 1;
    rfact[0] = 1;
    for (int i = 1; i < N; i++) {
        fact[i] = fact[i - 1] * 1ll * i % MOD;
        rfact[i] = bin_pow(fact[i], MOD - 2);
    }

    int n, m;
    cin >> m >> n;
    vector<int> x(m);
    for (int i = 0; i < m; i++) {
        cin >> x[i];
        x[i]--;
    }
    g.resize(n);
    dep.resize(n);
    pred.resize(n);
    for (int i = 0; i < n - 1; i++) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    /*int ans = 1, last = 0;
    vector<int> v;
    for (int i = 0; i < m; i++) {
        v.push_back(x[i] - last);
        last = x[i];
    }
    int ans = 1;
    int len = 0;
    for (int i = m - 1; i >= 0; i--) {
        len++;

    }*/
    dfs(0, 0, 0);
    cout << bin_pow(2, dep[x[0]]) << '\n';
}
