Word Break

medium
1. You are given n space-separated strings, which represents a dictionary of words.
2. You are given another string that represents a sentence.
3. You have to determine if this sentence can be segmented into a space-separated sequence of one or more dictionary words.

Input Format

A number n n strings representing words A string representing a sentence

Output Format

Check the sample ouput and question video.

Constraints

1 <= number of words <= 10
1 <= length of each word <= 15
1 <= length of sentence <= 1000

Example

Input
2
pep coding
pepcoding
Output
true
Previous
Print In Range - Bst
Next
4 Key Keyboard

Related Questions