Олимпиадный тренинг

Задача 38275. Tom and Jerry


Задача

Темы:
In this problem, we again return to the younger group of the Teletubbies kindergarten. To finally calm the children down, the teacher decided to turn on a cartoon about Tom and Jerry for them. The series the kids are watching right now is pretty straightforward — in it, Jerry hung anvils on ropes from the ceiling of the room. When Tom is under another anvil, Jerry cuts the rope. The anvil falls on Tom, Tom is hurt, everyone else is having fun, the children are laughing. All in all, quite a normal series.

And you need to determine from the frame from this episode whether the anvil will fall on Tom if Jerry cuts the rope.

Input
You are given an ASCII art picture, that is, a picture drawn with characters. It has an anvil tied to the ceiling with a rope, and Tom the cat. The first line contains numbers N, M (4≤N≤100, 1≤M≤100 ). The next N lines consist of M characters each and represent the picture itself. The picture is set up like this:
  • The first K1 lines in the same X1 position contain the character «|», the rest — space. This is a rope.
  • The next K2 lines in the same positions from X2 to X3 contain the symbol "#", in the rest — space. This is an anvil.
  • 2×X1=X2+X3, i.e. the anvil is suspended from the middle.
  • The following K3 lines contain only spaces. This is the void between the anvil and the cat.
  • Next N − K1 − K2 − K3 lines contain arbitrary characters. Any character other than a space — part of a cat. There is at least one non-whitespace character.
The numbers K1, K2, K3 and N − K1 − K2 − K3  nonzero.
Imprint
Print "YES" if the anvil hits Tom when it falls, otherwise print "NO".
 
Examples
# Input Output
1 13 29
          |
          |
          |
    #############
    #############
    #############
                             
                             
            /\_/\
            >^.^<.---.
           _'-`-' )\
          (6--\ |--\ (`.`-.
              --' --' ``-' 
YES
2 16 30
    |
 #######
 #######
 #######
 #######
                              
            ,
           \)\_
          / '. .---._
        =P ^ ` '.
         `--. / \
         .-'( \ |
        (.-' )-..__> , ;
        (_.--`` (__.-/ /
                .-.__.-'.'
                 '-...-' 
NO