import
java.io.*;
import
java.util.ArrayList;
class
GFG {
static
boolean
findPath(ArrayList<ArrayList<Integer> > maze,
int
xpos,
int
ypos,
boolean
key)
{
if
(xpos <
0
|| xpos >= maze.size() || ypos <
0
|| ypos >= maze.size())
return
false
;
if
(maze.get(xpos).get(ypos) ==
'1'
) {
if
(key ==
true
)
if
(xpos == maze.size() -
1
&& ypos == maze.size() -
1
)
return
true
;
return
findPath(maze, xpos +
1
, ypos,
false
)
|| findPath(maze, xpos, ypos +
1
,
false
);
}
if
(xpos == maze.size() -
1
&& ypos == maze.size() -
1
)
return
true
;
return
findPath(maze, xpos +
1
, ypos, key)
|| findPath(maze, xpos, ypos +
1
, key);
}
static
boolean
mazeProb(ArrayList<ArrayList<Integer> > maze,
int
xpos,
int
ypos)
{
boolean
key =
true
;
if
(findPath(maze, xpos, ypos, key))
return
true
;
return
false
;
}
public
static
void
main(String[] args)
{
int
size =
3
;
ArrayList<ArrayList<Integer> > maze
=
new
ArrayList<ArrayList<Integer> >(size);
for
(
int
i =
0
; i < size; i++) {
maze.add(
new
ArrayList<Integer>());
}
maze.get(
0
).add(
0
);
maze.get(
0
).add(
0
);
maze.get(
0
).add(
1
);
maze.get(
1
).add(
1
);
maze.get(
1
).add(
0
);
maze.get(
1
).add(
1
);
maze.get(
2
).add(
1
);
maze.get(
2
).add(
1
);
maze.get(
2
).add(
0
);
if
(mazeProb(maze,
0
,
0
))
System.out.print(
"Yes"
);
else
System.out.print(
"No"
);
}
}