{"raw_statement":[{"iden":"statement","content":"For a permutation _P_\\[1... _N_\\] of integers from 1 to _N_, function _f_ is defined as follows:\n\nLet _g_(_i_) be the minimum positive integer _j_ such that _f_(_i_, _j_) = _i_. We can show such _j_ always exists.\n\nFor given _N_, _A_, _B_, find a permutation _P_ of integers from 1 to _N_ such that for 1 ≤ _i_ ≤ _N_, _g_(_i_) equals either _A_ or _B_."},{"iden":"input","content":"The only line contains three integers _N_, _A_, _B_ (1 ≤ _N_ ≤ 106, 1 ≤ _A_, _B_ ≤ _N_)."},{"iden":"output","content":"If no such permutation exists, output _\\-1_. Otherwise, output a permutation of integers from 1 to _N_."},{"iden":"examples","content":"Input\n\n9 2 5\n\nOutput\n\n6 5 8 3 4 1 9 2 7\n\nInput\n\n3 2 1\n\nOutput\n\n1 2 3"},{"iden":"note","content":"In the first example, _g_(1) = _g_(6) = _g_(7) = _g_(9) = 2 and _g_(2) = _g_(3) = _g_(4) = _g_(5) = _g_(8) = 5\n\nIn the second example, _g_(1) = _g_(2) = _g_(3) = 1"}],"translated_statement":[{"iden":"statement","content":"对于整数 $1$ 到 $N$ 的一个排列 $P[1... N]$，函数 $f$ 定义如下：\n\n令 $g(i)$ 为满足 $f(i, j) = i$ 的最小正整数 $j$。我们可以证明这样的 $j$ 总是存在。\n\n给定 $N, A, B$，请找出一个 $1$ 到 $N$ 的排列 $P$，使得对所有 $1 ≤ i ≤ N$，$g(i)$ 等于 $A$ 或 $B$ 之一。\n\n输入仅一行，包含三个整数 $N, A, B$（$1 ≤ N ≤ 10^6, 1 ≤ A, B ≤ N$）。\n\n如果不存在这样的排列，请输出 _-1_。否则，请输出一个 $1$ 到 $N$ 的排列。\n\n在第一个例子中，$g(1) = g(6) = g(7) = g(9) = 2$ 且 $g(2) = g(3) = g(4) = g(5) = g(8) = 5$。\n\n在第二个例子中，$g(1) = g(2) = g(3) = 1$。\n\n"},{"iden":"input","content":"输入仅一行，包含三个整数 $N, A, B$（$1 ≤ N ≤ 10^6, 1 ≤ A, B ≤ N$）。"},{"iden":"output","content":"如果不存在这样的排列，请输出 _-1_。否则，请输出一个 $1$ 到 $N$ 的排列。"},{"iden":"examples","content":"输入\n9 2 5\n输出\n6 5 8 3 4 1 9 2 7\n\n输入\n3 2 1\n输出\n1 2 3 "},{"iden":"note","content":"在第一个例子中，$g(1) = g(6) = g(7) = g(9) = 2$ 且 $g(2) = g(3) = g(4) = g(5) = g(8) = 5$。在第二个例子中，$g(1) = g(2) = g(3) = 1$。"}],"sample_group":[],"show_order":[],"formal_statement":"**Definitions**  \nLet $ N, A, B \\in \\mathbb{Z}^+ $ with $ 1 \\leq N \\leq 10^6 $, $ 1 \\leq A, B \\leq N $.  \nLet $ P = (P[1], P[2], \\dots, P[N]) $ be a permutation of $ \\{1, 2, \\dots, N\\} $.  \nDefine $ f(i, j) $ as the result of applying the permutation $ P $ iteratively $ j $ times starting from $ i $:  \n$$ f(i, 1) = P[i], \\quad f(i, j) = P[f(i, j-1)] \\text{ for } j > 1. $$  \nDefine $ g(i) $ as the smallest positive integer $ j $ such that $ f(i, j) = i $ — i.e., the cycle length containing $ i $ in the functional graph of $ P $.\n\n**Constraints**  \nFor all $ i \\in \\{1, 2, \\dots, N\\} $, $ g(i) \\in \\{A, B\\} $.\n\n**Objective**  \nFind a permutation $ P $ such that every element lies in a cycle of length either $ A $ or $ B $.  \nIf no such permutation exists, output $-1$.  \nOtherwise, output any such permutation $ P $.","simple_statement":null,"has_page_source":false}