Problem2254--First Grid

2254: First Grid

[Creator : ]
Time Limit : 1.000 sec  Memory Limit : 128 MB

Description

Time Limit: 2 sec / Memory Limit: 1024 MB

Score : 100100 points

Problem Statement

We have a grid with 22 horizontal rows and 22 vertical columns.
Each of the squares is black or white, and there are at least 22 black squares.
The colors of the squares are given to you as strings S_1S1 and S_2S2, as follows.
  • If the jj-th character of S_iSi is #, the square at the ii-th row from the top and jj-th column from the left is black.
  • If the jj-th character of S_iSi is ., the square at the ii-th row from the top and jj-th column from the left is white.
You can travel between two different black squares if and only if they share a side.
Determine whether it is possible to travel from every black square to every black square (directly or indirectly) by only passing black squares.

Constraints

  • Each of S_1S1 and S_2S2 is a string with two characters consisting of # and ..
  • S_1S1 and S_2S2 have two or more #s in total.

Input

Input is given from Standard Input in the following format:
S_1S1S_2S2

Output

If it is possible to travel from every black square to every black square, print Yes; otherwise, print No.

Input



Sample Input Copy

##
.#

Sample Output Copy

Yes

HINT

It is possible to directly travel between the top-left and top-right black squares and between top-right and bottom-right squares.
These two moves enable us to travel from every black square to every black square, so the answer is Yes.

Source/Category