import java.util.*;
import java.io.*;
public class Main {

	public static void main(String[] args) throws IOException {
		String line = null;
		String line1 = null;
		String [] parts;
		int counter = 0;
		int k=0;
		int arr[] = new int[200];
		for(int m=0;m<199;m++){
			arr[m] = 100000;
		}
		// TODO Auto-generated method stub
		try {
			BufferedReader bufferedReader = new BufferedReader(new FileReader("C:\\Users\\HP\\Desktop\\Plasmids\\pBR322.txt"));
			BufferedReader bufferedReader1 = new BufferedReader(new FileReader("C:\\Users\\HP\\Desktop\\Plasmids\\Unique 6+ Cutters.txt"));
			while ((line = bufferedReader.readLine()) != null){
				System.out.println(line.substring(2109, 2117));
				while ((line1 = bufferedReader1.readLine()) != null){
						parts = line1.split(" ");
						int length = parts[1].length();
						int abc = Integer.parseInt(parts[2]);
						for(int i=0;i<=(line.length() - length);i++){
							String ab = line.substring(i,i+length);
							for(int h=0;h<length;h++){
								if(parts[1].charAt(h) == 'N'){
									//System.out.println(parts[1]);
									counter++;
									continue;
								}
								else{
									if(ab.charAt(h) == parts[1].charAt(h)){
										counter++;
									}
									else{
										
									}
								}
							}
							if(counter == length){
								arr[k++] = i+abc;
								//System.out.println("i = "+(i+abc)+" enzyme = "+parts[0]);
							}
							counter=0;
						}
				}
			}
			
		} catch (FileNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		Arrays.sort(arr);
		
		for(int m=0;m<70;m++){
			System.out.println(arr[m]);
		}
	}

}
