require "big" MOD = 998244353i64 n, p, q = read_line.split.map(&.to_i) a = Array.new(n) { |i| i } a_orig = a.dup a[...p] = a[...p].reverse a[-q..] = a[-q..].reverse ans = BigInt.new(1) visited = Array.new(n, false) n.times do |i| next if visited[i] cur = i len = 0 while !visited[cur] visited[cur] = true len += 1 cur = a[cur] end ans = ans.lcm(BigInt.new(len)) end puts ans * 2 % MOD