############################################################# import sys sys.setrecursionlimit(10**7) from heapq import heappop,heappush from collections import deque,defaultdict,Counter from bisect import bisect_left, bisect_right from itertools import product,combinations,permutations ipt = sys.stdin.readline def iin(): return int(ipt()) def lmin(): return list(map(int,ipt().split())) def prime_factorize(n): d = defaultdict(int) while n % 2 == 0: d[2] += 1 n //= 2 f = 3 while f * f <= n: if n % f == 0: d[f] += 1 n //= f else: f += 2 if n != 1: d[n] += 1 return d MOD = 998244353 ############################################################# N,M = lmin() A = lmin() D = [prime_factorize(a) for a in A] S = set() for d in D: for k in d.keys(): S.add(k) G = [[] for _ in range(N)] for _ in range(M): u,v = lmin() u,v = u-1,v-1 G[u].append(v) G[v].append(u) cost = defaultdict(list) for s in S: tmp_cost = [MOD]*N tmp_cost[0] = D[0][s] hq = [(tmp_cost[0],0)] while hq: c1,cur = heappop(hq) if tmp_cost[cur] < c1: continue tmp_cost[cur] = c1 for nxt in G[cur]: c2 = D[nxt][s] v = max(c1,c2) if v < tmp_cost[nxt]: tmp_cost[nxt] = v heappush(hq,(v,nxt)) cost[s] = tmp_cost #print(cost) for i in range(N): ans = 1 for s in S: ans *= pow(s,cost[s][i],MOD) ans %= MOD print(ans)