eolymp
bolt
Try our new interface for solving problems
Problems

Dictionary of Obscene Words

Dictionary of Obscene Words

Given a dictionary of obscene words \textbf{S_1} , \textbf{S_2} , ..., \textbf{S_n} and text \textbf{T}, find if text contains one of obscene words as subsequence. If it does, find smallest prefix of \textbf{T} that contains such subsequence. \InputFile First line of input contains one integer \textbf{n} - number of words in dictionary. Following n lines contain words from dictionary, one per line. Each word consists of ASCII characters with codes from \textbf{32} to \textbf{127}, inclusive. Next line contains text \textbf{T}, consisting of the same set of characters. Total length of all words in dictionary doesn't exceed \textbf{100} KiB (\textbf{100} x \textbf{2^10} \textit{bytes}). Total size of input file doesn't exceed \textbf{1} MiB (\textbf{2^20} \textit{bytes}). \OutputFile Output \textbf{NO} if there is no obscene subsequence in the text. Otherwise output \textbf{YES} <\textbf{X}>, where \textbf{X} is the length of smallest prefix of \textbf{T} that contains some obscene subsequence.
Time limit 1 second
Memory limit 64 MiB
Input example #1
2
jsss
bracd
abracadabra
Output example #1
YES 7