Skip to content
C

Word Search in Grid

Hardjavapythonccppjavascript

Given a grid of letters and a target word, determine whether the word can be formed by a path of adjacent cells (up, down, left or right). The same cell may not be used more than once in a single path.

Input Format

The first line contains two integers R and C. Each of the next R lines contains C characters (uppercase letters, no spaces). The last line contains the target word.

Output Format

Print 1 if the word can be formed, otherwise print 0.

Input (stdin)

Output

Run your code to see output here...