In this problem, the alphabet contains
only the first 
lowercase Latin letters, that is, the alphabet contains
only the characters from
a to
r.
In this problem, the string index starts from

.

has a string

. She thinks a string

of
distinct letters is a beautiful string if
any of the following conditions are met:
-
appears in the string
and
is lexicographically strictly greater than
for
. - All characters in the string
appear in the string
.
)
means the

-th character in the string

.
Now

wants you to calculate the number of beautiful string

.