Under construction

Still being built. Things may change

Royal Garden

Time limit2sMemory limit1024 MB

Summary
Given an a by b grid of letters, decide whether deleting one full row or column leaves only cells with the same letter.
Level

Easy2 of 10

Topics
Brute force, Implementation
Solved
No attempts yet

Problem

The royal park is widely known for its collection of rare trees. It consists of aa rows of bb trees each. One day the king developed an unknown allergy. That same evening the royal gardener was ordered to cut down some of the trees so that only trees of one type remained, and he had until morning. Since he had never cut down a tree in his life (he is a gardener, not a lumberjack), he asked a wizard he knew for help. The wizard agreed to help and cut down one arbitrary row of trees.

The gardener has a plan showing the park as an a×ba \times b rectangle of cells, each recording which tree grows there. He must point the wizard to one vertical or horizontal row on the plan, and the wizard cuts down every tree in that row. After the cutting, all remaining trees in the park must be identical.

Your task is to determine whether the wizard can help the gardener or not.

Input

The first line of the input contains two integers aa and bb (1≤a,b≤101 \le a, b \le 10), the size of the park. Each of the next aa lines describes one row of the park. Each line contains exactly bb lowercase Latin letters, the tree species in that row.

Output

Print "Yes" if the gardener can choose a row in the required way, and "No" otherwise.

Examples3

  1. Example 1

    Input
    3 2
    aa
    ba
    ca
    
    Expected output
    Yes
    
  2. Example 2

    Input
    2 4
    wwww
    this
    
    Expected output
    Yes
    
  3. Example 3

    Input
    3 3
    www
    wrw
    wwt
    
    Expected output
    No