atcoder#ABC304F. [ABC304F] Shift Table

[ABC304F] Shift Table

Score : 525525 points

Problem Statement

Takahashi and Aoki will work part-time for the next NN days. Takahashi's shift schedule is given by the string SS, where the ii-th character of SS is # if he works on the ii-th day, and . if he is absent on the ii-th day. Based on this, Aoki created his shift schedule as follows.

  • First, take a positive divisor MM of NN that is not equal to NN.
  • Next, decide the attendance for the first MM days.
  • Finally, for i=1,2,,NMi = 1, 2, \ldots, N - M in this order, decide the attendance for the (M+i)(M + i)-th day so that it matches the attendance for the ii-th day.

Note that different values of MM may lead to the same final shift schedule.

Find the number of possible shift schedules for Aoki such that at least one of Takahashi and Aoki works on each of the NN days, modulo 998244353998244353.

Constraints

  • NN is an integer between 22 and 10510^5, inclusive.
  • SS is a string of length NN consisting of # and ..

Input

The input is given from Standard Input in the following format:

NN

SS

Output

Print the answer.

6
##.#.#
3

Takahashi works on days 11, 22, 44, and 66. Let TT be the string representing Aoki's shift schedule, where the ii-th character of TT is # if he works on the ii-th day, and . if he is absent on the ii-th day. There are three possible strings for TT: ######, #.#.#., and .##.##.

The first shift schedule can be realized by choosing M=1M = 1 or 22 or 33, the second by choosing M=2M = 2, and the third by choosing M=3M = 3.

7
...####
1
12
####.####.##
19