346. Word Segmentation

0

Medium

Given a string s and a dictionary of strings wordDict, determine if s can be divided into a sequence of one or more words from wordDict, where words can be repeated.

Input Format

The first line contains an integer N, which represents the size of wordDict.
The second line consists of space-separated words that are present in the wordDict dictionary.
The third line contains a string S.

Output Format

Print "True" or "False"

Example

Input

2 Coding Blocks CodingBlocks

Output

True

Constraints

1 <= N <= 300
1 <= wordDict.length <= 500
1 <= wordDict[i].length <= 20
Loading...

View Submissions

Console