n,x,y = map(int,input().split()) A = list(map(int,input().split())) B = list(map(int,input().split())) mod = 998244353 ans = 0 for i in range(18): nA = [0,0] nB = [0,0] for a in A: if a >> i & 1: nA[1] += 1 else: nA[0] += 1 for b in B: if b >> i & 1: nB[1] += 1 else: nB[0] += 1 dp = [1,0] for j in range(n): ndp = [0,0] ndp[0] = dp[0]*nA[0]%mod ndp[1] = (dp[0]*nA[1] + dp[1]*x)%mod dp = ndp ndp = [0,0] ndp[0] = (dp[0]*y + dp[1]*nB[0])%mod ndp[1] = dp[1]*nB[1]%mod dp = ndp ans += (1<