## https://yukicoder.me/problems/no/1958 MOD = 998244353 def main(): N, X, Y = map(int, input().split()) A = list(map(int, input().split())) B = list(map(int, input().split())) answer = 0 max_k = 19 for k in range(max_k + 1): a_array = [0, 0] b_array = [0, 0] for a in A: if a & (1 << k) > 0: a_array[1] += 1 else: a_array[0] += 1 for b in B: if b & (1 << k) > 0: b_array[1] += 1 else: b_array[0] += 1 p = [1, 0] for _ in range(N): new_p = [0, 0] new_p[0] = (p[0] * a_array[0]) % MOD new_p[1] = (p[0] * a_array[1]) % MOD new_p[1] += (p[1] * a_array[1]) % MOD new_p[1] %= MOD new_p[1] += (p[1] * a_array[0]) % MOD new_p[1] %= MOD p = new_p new_p = [0, 0] new_p[0] = (p[0] * b_array[0]) % MOD new_p[0] += (p[0] * b_array[1]) % MOD new_p[0] %= MOD new_p[0] += (p[1] * b_array[0]) % MOD new_p[0] %= MOD new_p[1] = (p[1] * b_array[1]) % MOD p = new_p answer += (p[1] * (1 << k)) % MOD answer %= MOD print(answer) if __name__ == "__main__": main()