only. Do not copy. Correct code will upvoted else downvote.   Monocarp is playing a PC game. Presently he needs to finish the principal level of this game.    A level is a rectangular framework of 2 lines and n sections. Monocarp controls a character, what begins in cell (1,1) — at the

EBK JAVA PROGRAMMING
9th Edition
ISBN:9781337671385
Author:FARRELL
Publisher:FARRELL
Chapter3: Using Methods, Classes, And Objects
Section: Chapter Questions
Problem 1GZ
icon
Related questions
Question
100%

C++ only. Do not copy. Correct code will upvoted else downvote.

 

Monocarp is playing a PC game. Presently he needs to finish the principal level of this game. 

 

A level is a rectangular framework of 2 lines and n sections. Monocarp controls a character, what begins in cell (1,1) — at the convergence of the 1-st line and the 1-st segment. 

 

Monocarp's character can move starting with one cell then onto the next in one stage if the cells are nearby by side or potentially corner. Officially, it is feasible to move from cell (x1,y1) to cell (x2,y2) in one stage if |x1−x2|≤1 and |y1−y2|≤1. Clearly, it is denied to go external the matrix. 

 

There are traps in certain cells. In case Monocarp's character winds up in such a cell, he bites the dust, and the game closures. 

 

To finish a level, Monocarp's character should arrive at cell (2,n) — at the crossing point of line 2 and section n. 

 

Assist Monocarp with deciding whether it is feasible to finish the level. 

 

Input 

 

The principal line contains a solitary integer t (1≤t≤100) — the number of experiments. Then, at that point, the experiments follow. Each experiment comprises of three lines. 

 

The principal line contains a solitary integer n (3≤n≤100) — the number of sections. 

 

The following two lines portray the level. The I-th of these lines portrays the I-th line of the level — the line comprises of the characters '0' and '1'. The character '0' compares to a protected cell, the character '1' relates to a snare cell. 

 

Extra limitation on the input: cells (1,1) and (2,n) are protected. 

 

Output 

 

For each experiment, output YES in case it is feasible to finish the level, and NO in any case.

 

Expert Solution
steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT