CF999B.Reversing Encryption

传统题 时间 2000 ms 内存 256 MiB 4 尝试 1 已通过 1 标签

Reversing Encryption

A string ss of length nn can be encrypted by the following algorithm:

  • iterate over all divisors of nn in decreasing order (i.e. from nn to 11),
  • for each divisor dd, reverse the substring s[1d]s[1 \dots d] (i.e. the substring which starts at position 11 and ends at position dd).

For example, the above algorithm applied to the string ss="codeforces" leads to the following changes: "codeforces" \to "secrofedoc" \to "orcesfedoc" \to "rocesfedoc" \to "rocesfedoc" (obviously, the last reverse operation doesn't change the string because d=1d=1).

You are given the encrypted string tt. Your task is to decrypt this string, i.e., to find a string ss such that the above algorithm results in string tt. It can be proven that this string ss always exists and is unique.

Input

The first line of input consists of a single integer nn (1n1001 \le n \le 100) — the length of the string tt. The second line of input consists of the string tt. The length of tt is nn, and it consists only of lowercase Latin letters.

Output

Print a string ss such that the above algorithm results in tt.

Note

The first example is described in the problem statement.

Samples

10
rocesfedoc
codeforces
16
plmaetwoxesisiht
thisisexampletwo
1
z
z

在线编程 IDE

建议全屏模式获得最佳体验