First Grid

AtCoder
IDabc229_a
Time2000ms
Memory256MB
Difficulty
We have a grid with $2$ horizontal rows and $2$ vertical columns. Each of the squares is black or white, and there are at least $2$ black squares. The colors of the squares are given to you as strings $S_1$ and $S_2$, as follows. * If the $j$\-th character of $S_i$ is `#`, the square at the $i$\-th row from the top and $j$\-th column from the left is black. * If the $j$\-th character of $S_i$ is `.`, the square at the $i$\-th row from the top and $j$\-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_1$ and $S_2$ is a string with two characters consisting of `#` and `.`. * $S_1$ and $S_2$ have two or more `#`s in total. ## Input Input is given from Standard Input in the following format: $S_1$ $S_2$ [samples]
Samples
Input #1
##
.#
Output #1
Yes

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`.
Input #2
.#
#.
Output #2
No

It is impossible to travel between the top-right and bottom-left black squares, so the answer is `No`.
API Response (JSON)
{
  "problem": {
    "name": "First Grid",
    "description": {
      "content": "We have a grid with $2$ horizontal rows and $2$ vertical columns.   Each of the squares is black or white, and there are at least $2$ black squares.   The colors of the squares are given to you as str",
      "description_type": "Markdown"
    },
    "platform": "AtCoder",
    "limit": {
      "time_limit": 2000,
      "memory_limit": 262144
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "abc229_a"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "We have a grid with $2$ horizontal rows and $2$ vertical columns.  \nEach of the squares is black or white, and there are at least $2$ black squares.  \nThe colors of the squares are given to you as str...",
      "is_translate": false,
      "language": "English"
    }
  ]
}
Full JSON Raw Segments