import java.util.*;
import java.lang.*;
import java.io.*;

// The main method must be in a class named "Main".
class Main {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        String str1=sc.next();
        String[] arr=new String[n];
        for(int i=0;i<n;i++){
            arr[i]=sc.next();
        }

        Set<String> st=new HashSet<>();
        for(int i=0;i<n;i++){
            st.add(arr[i]);
        }

        for(int i=0;i<str1.length();i++){
            StringBuilder ch=new StringBuilder();
            for(int j=i;j<str1.length();j++){
                    ch.append(str1.charAt(j));
                     String res=ch.toString();
                     System.out.println(res);
                    if(st.contains(res)){
                       st.remove(res);
                    }
                }
               
            }  

        if(st.size()==0) System.out.println(true);
        else System.out.println(false);
    }
}

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: