Aligned Typesetting

Interview

Time limit2sMemory limit512 MB

Summary
Given an equal number of spaces between every pair of consecutive words, decide whether one such aligned typesetting has total length exactly L.
Level

Easy3 of 10

Topics
String, Math, Implementation
Solved
No attempts yet

Problem

In this problem, a sentence with nn words is a sequence of nn non-empty strings [w1,w2,…,wn][w_1, w_2, \ldots, w_n]. Given a sentence, a valid typesetting of length LL is a string of length exactly LL formed by concatenating all the words in the sentence in order and inserting a positive number of spaces between each adjacent pair of words.

An aligned typesetting is a valid typesetting in which the number of spaces between each adjacent pair of words is the same.

For example, given the sentence [harry,ron,hermione][\text{harry}, \text{ron}, \text{hermione}] and using _ to indicate a space:

  • the string __harry_ronhermione is not a valid typesetting;
  • the string harry_ron_____hermione is a valid typesetting of length 22, but it is not an aligned typesetting;
  • the string harry___ron___hermione is an aligned typesetting of length 22.

Darcy was given a sentence of nn words and the desired length of typesetting LL. Can you help him figure out whether an aligned typesetting of the desired length exists?

Input

The first line contains two integers nn (1≤n≤1061 \le n \le 10^6), the number of words, and LL (0≤L≤1060 \le L \le 10^6), the desired length of typesetting.

The next nn lines describe the words. Each of these lines contains a single string wiw_i, the ii-th word in the sentence. The word contains only lowercase letters and has length between 1 and 10610^6.

The total length of all the words in the sentence is at most 10610^6.

Output

Display whether the sentence has an aligned typesetting of the given length LL.

Examples3

  1. Example 1

    Input
    3 8
    harry
    j
    p
    
    Expected output
    No
    
  2. Example 2

    Input
    1 5
    harry
    
    Expected output
    Yes
    
  3. Example 3

    Input
    3 22
    harry
    ron
    hermione
    
    Expected output
    Yes