All Submissions


The Problem

In the coming week ACM is organizing Workshop on Cryptography. Many Professors have been called to take workshop on separate days.
Each Professor having their own teaching style take their sessions on different topics in different sequence.
Saurabh unwilling to do any classes decides that he would attend the workshop session in a particular sequence of topics and atleast a session from each professor.

Each topic is represented by a letter of English alphabet.
Saurabh can decide to take more than a session on a topic as well as professor can also take more than a session on the topic.

For Example :
In a workshop taken by two professors A and B
Professor A takes sessions as : abcdefghi
Professor B takes sessions as : defghiabc

and Saurabh decides to take the session as : ACAC.
The no of ways Saurabh will be able to take classes would be: thats what you need to find

Input

The input file consists of multiple test cases, each one in a separate line. Each line begins with the sequence of the topics Saurabh would like to cover in the Workshop
(uppercase letters only) then the space separated sequence of the topics each Professor would take class of on separate days. Saurabh would take atleast one class
and as obvious there would always be a professor taking class in the workshop. No input line would contain more than 200 characters. However there is no restriction
on the topics being covered by the professors in any order.

Output

For Each test Case output the number of ways Saurabh can take the clases if possible in the given below format.
Saurabh can do classes in i ways
or
Saurabh cant take the classes in the desired sequence.

where i is the no of ways Saurabh can take classes.

Sample Input


ACAC abcdefghi defghiabc
REMZBERITSSQBQYUVREFC nrrrgcwwqrcrnrjel eeueu wmnmwmslzsmmul
CAD ccbeccbccbbcbbcccccccecbb eacaac b beabbbedeabd daad
CCAC ccccbbccbcbcbc ccbccbbcc caccaaabbbcbcc cbcbbcbcccbb


Sample Output


Saurabh can do classes in 1 ways
Saurabh cant take the classes in the desired sequence.
Saurabh cant take the classes in the desired sequence.
Saurabh can do classes in 1296 ways


Problem by: Vivek Keshri

Languages: C,C++,Java

Time Limit: 1 Second(s)
Score: 100 Point(s)
Input File Limit: 50000 Bytes

Submit

Login to post clarification.

No Clarifications.

Contest

Mode Judge

Passive

Online

Overall Rankings

RankNameScore
1xyz0
2Ams0
3TIP0
4team420
5xyzz0
6asdasdasd0
7abcd0
8khankhan0
9Gabriel0
10gigel0