A Good Contest

Given a partially hidden scoreboard with known solve counts and a staircase visibility pattern, decide whether the hidden entries can be filled so every contestant solves at least one problem, every problem is solved, and nobody solves all problems.

Medium6GreedyBrute forceImplementationCombinatoricsNo attempts yetTime limit1sMemory limit512 MB

Problem

Running a contest means weighing a great many factors. Hyeonjeong is famous for making contests that are bad in every sense. Her problem sets have never once met the standard of a good contest either. The good contest Hyeonjeong wants to make is a contest that meets all three of the following conditions.

  1. Every contestant must solve at least one problem.
  2. Every problem must be solved by at least one contestant.
  3. No contestant may solve every problem.

After many such experiences, Hyeonjeong gave everything she had to make a good contest this time. She seems to have given too much, because she collapsed before the contest ended. When she woke up, the first thing she wanted was to look at the results and find out whether this contest had been a good one.

She hurried to the contest website and found the scoreboard with the results. But the top right corner of her laptop screen is broken in a triangular shape, so she could not see the whole scoreboard.

On the scoreboard, a contestant who solved more problems ranks higher, and the rows are sorted by rank with first place at the top. Because Hyeonjeong's screen is broken in a ◥ shape, the part of the scoreboard she can see satisfies all of the following rules.

  • If she can see the result of problem xx for the contestant in place ii, she can also see the result of problem xx for the contestants in places i+1i+1 to NN.
  • If she cannot see the result of problem xx for the contestant in place ii, she also cannot see the result of problem xx for the contestants in places 11 to i1i-1.
  • If she can see the result of problem xx for the contestant in place ii, she can also see that contestant's results for problems 11 to xx.
  • If she cannot see the result of problem xx for the contestant in place ii, she also cannot see that contestant's results for problems xx to MM.

Hyeonjeong knows how many problems each contestant solved, and she has partial information about which problems they solved. She starts daydreaming. She wants to fill in the hidden part of the scoreboard however she likes, so that she can believe the contest was a good one. Each hidden result is filled in as either solved or unsolved. Of course, she cannot change the number of problems each contestant solved or any result she can already see. Given the scoreboard visible on the broken screen, determine whether this contest can be a good contest.

Input

The first line contains the number of contestants NN (1N1001 \le N \le 100) and the number of problems MM (1M101 \le M \le 10). Each of the next NN lines describes one contestant, in order from first place to place NN. The line for the contestant in place ii contains the number of problems that contestant solved, KiK_i (0KiM0 \le K_i \le M), followed by MM results for problems 11 to MM. A result is 1 if the problem was solved, 0 if it was not solved, and -1 if it is hidden by the broken screen.

The given scoreboard is part of a real contest result. That is, KiK_i never increases from first place downward, and the visible results satisfy the four rules above and do not contradict KiK_i.

Output

Print YES if the contest can be a good contest, and NO otherwise.

Hint

Below is one of several ways to fill in the hidden results of the first example so that the contest is a good contest.

1 1 0 1 1
1 0 1 0 1
1 0 1 0 0
1 0 0 0 0