AT_abc422_g [ABC422G] Balls and Boxes

Description

You are given positive integers $ A, B, C, N $ . Solve Problems $ 1 $ and $ 2 $ . (The differences between the problems are indicated in bold.)

Input Format

The input is given from Standard Input in the following format: > $ N $ $ A $ $ B $ $ C $

Output Format

Output two lines. On the $ i $ -th line, output the answer to Problem $ i $ .

Explanation/Hint

### Problem 1 There are $ N $ balls. **The balls are indistinguishable from each other.** Also, there are boxes $ 1 $ , $ 2 $ , and $ 3 $ . Find the number, modulo $ 998244353 $ , of ways to put all balls into the boxes satisfying the following conditions. - The number of balls in box $ 1 $ is a multiple of $ A $ . - The number of balls in box $ 2 $ is a multiple of $ B $ . - The number of balls in box $ 3 $ is a multiple of $ C $ . Here, two ways of putting balls are counted separately **when there exists a box where the number of balls differs between the two ways**. ### Problem 2 There are $ N $ balls **numbered from $ 1 $ to $ N $** . **The balls are distinguishable from each other.** Also, there are boxes $ 1 $ , $ 2 $ , and $ 3 $ . Find the number, modulo $ 998244353 $ , of ways to put all balls into the boxes satisfying the following conditions. - The number of balls in box $ 1 $ is a multiple of $ A $ . - The number of balls in box $ 2 $ is a multiple of $ B $ . - The number of balls in box $ 3 $ is a multiple of $ C $ . Here, two ways of putting balls are counted separately **when there exists a ball whose box differs between the two ways**. ### Sample Explanation 1 In Problem $ 1 $ , the ways of putting balls that satisfy the condition are the following three ways: - Put $ 3 $ balls in box $ 1 $ . - Put $ 1 $ ball in box $ 1 $ and $ 2 $ balls in box $ 2 $ . - Put $ 3 $ balls in box $ 3 $ . In Problem $ 2 $ , the ways of putting balls that satisfy the condition are the following five ways: - Put balls $ 1,2,3 $ in box $ 1 $ . - Put ball $ 1 $ in box $ 1 $ and balls $ 2,3 $ in box $ 2 $ . - Put ball $ 2 $ in box $ 1 $ and balls $ 1,3 $ in box $ 2 $ . - Put ball $ 3 $ in box $ 1 $ and balls $ 1,2 $ in box $ 2 $ . - Put balls $ 1,2,3 $ in box $ 3 $ . ### Constraints - $ 1 \leq N \leq 3 \times 10^5 $ - $ 1 \leq A \leq 3 \times 10^5 $ - $ 1 \leq B \leq 3 \times 10^5 $ - $ 1 \leq C \leq 3 \times 10^5 $ - All input values are integers.