package com.main;
import java.util.Scanner;
public class Main {
private static Node root=new Node();
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
StringBuffer sb=new StringBuffer();
int m=sc.nextInt();
int n=sc.nextInt();
for (int i = 0; i <m; i++){
String word=sc.nextLine();
sb.append(word);
}
String d=sc.next();
for (int i = 0; i <n; i++){
String a=sc.next();
String b=sc.next();
String c=sc.next();
String key=sc.next();
insert(key,i);
}
sc.close();
}
public static void insert(String str,int id){
if(str.isEmpty()||str==""){
return;
}
Node cnode=root;
for (int i = 0; i < str.length(); i++) {
int index=str.charAt(i)-'0';
if(cnode.child[index]==null){
Node pnode=new Node();
cnode.child[index]=pnode;
}else{
cnode.child[index].num++;
}
cnode=cnode.child[index];
}
cnode.isStr=true;
cnode.id=id;
}
public static int find(String str){
if(str.isEmpty()||str==""){
return 0;
}
Node cnode=root;
for (int i = 0; i < str.length(); i++) {
int index=str.charAt(i)-'0';
if(cnode.child[index]==null){
return 0;
}else{
cnode=cnode.child[index];
}
}
return cnode.num;
}
public static void query(String str){
Node cnode=root;
for (int i = 0; i < str.length(); i++) {
int index=str.charAt(i)-'0';
if(cnode.child[index]==null){
continue;
}else{
}
}
}
}
class Node{
boolean isStr;
int id;
int num;
Node[] child;
public Node(){
isStr=false;
num=1;
child=new Node[10];
}
}
08-21
679
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
08-26