{"raw_statement":[{"iden":"statement","content":"In the CCC Word Hunt, words are hidden in a grid of letters. The letters of a hidden word always appear in order on horizontal, vertical, or diagonal line segments in one of two ways.One way is for the letters of a word to appear on one line segment. The other way is for the letters of a word to appear on one line segment up to some letter and then on a second line segment that forms a right angle at this letter.\n\nGiven a grid of letters and a single word to search for, your job is to determine the number of times that particular word is hidden in the grid."},{"iden":"input","content":"The first line of input will contain a string of distinct uppercase letters $W$,representing the word you are to search for in the grid. The length of $W$ will be at least two. The second line of input will be an integer $R(1 \\le R \\le 100)$, where $R$ is the number of rows in the grid.The third line of input will be an integer $C(1 \\le C \\le 100)$, where $C$ is the number of columns in the grid.\n\nThe remaining input will provide the letters in the grid. It will consist of $R$ lines, where each line contains $C$ uppercase letters separated by single spaces."},{"iden":"output","content":"The following table shows how the available 15 marks are distributed:\n\n| Marks | Word Placement |\n| :----------: | :---------- |\n| $2$ | On one horizontal line segment |\n| $2$ | On one horizontal or vertical line segment |\n| $2$ | On one horizontal, vertical, or diagonal line segment |\n| $9$ | On one line segment or two perpendicular line segments |\n\nThe output will consist of a single non-negative integer $H$, representing the number of times the word is hidden in the grid."},{"iden":"note","content":"**本题采用捆绑测试**。\n\n- Subtask $1$（$2$ points）：隐藏字符串一定在一条水平线段上。\n- Subtask $2$（$2$ points）：隐藏字符串一定在一个水平或垂直线段上。\n- Subtask $3$（$2$ points）：隐藏字符串一定在一个水平、垂直或对角线线段上。\n- Subtask $4$（$9$ points）：隐藏字符串一定在一个线段或两个互相垂直的线段上。\n\n样例 $1$ 图解：\n\n![](https://cdn.luogu.com.cn/upload/image_hosting/wqo2un8k.png)\n\n样例 $2$ 图解：\n\n![](https://cdn.luogu.com.cn/upload/image_hosting/v082p2qr.png)"}],"translated_statement":null,"sample_group":[["MENU\n5\n7\nF T R U B L K\nP M N A X C U\nA E R C N E O\nM N E U A R M\nM U N E M N S","3"],["NATURE\n6\n9\nN A T S F E G Q N\nS A I B M R H F A\nC F T J C U C L T\nK B H U P T A N U\nD P R R R J D I R\nI E E K M E G B E","4"]],"show_order":[],"formal_statement":null,"simple_statement":null,"has_page_source":false}