import java.io.File;
import java.io.FileNotFoundException;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;

public class Interact {
    private static final int MAX_QUERIES = 1024;

    public static void main(String[] args) throws FileNotFoundException {
        Scanner in = new Scanner(new File("password.in"));
        Scanner part = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);

        int n = in.nextInt();
        String s = in.next();

        out.println(n);
        out.flush();
        int cnt = 0;
        while (true) {
            cnt++;
            if (cnt > MAX_QUERIES) {
                WA("Too many queries");
                return;
            }
            
            String substr;
            try {
                substr = part.next();
            } catch (Throwable e) {
                PE("Wrong string");
                return;
            }

            if (substr.length() == 0) {
                PE("Empty string is wrong string");
                return;
            }
            if (substr.equals(s)) { 
                out.println("Success");
                out.flush();
                OK(cnt);
                return;
            }

            boolean found = false;
            if (substr.length() <= n) {
                for (int i = 0; i < substr.length(); i++) {
                    if (substr.charAt(i) != '0' && substr.charAt(i) != '1') {
                        PE("Wrong symbols in string");
                        return;
                    }
                }
                StringBuilder t = new StringBuilder(substr);
                t.append("#");
                t.append(s);

                int[] p = new int[t.length()];
                for (int i = 1; i < p.length; i++) {
                    int j = p[i - 1];
                    while (j > 0 && t.charAt(j) != t.charAt(i))
                        j = p[j - 1];
                    if (t.charAt(j) == t.charAt(i))
                        j++;
                    p[i] = j;
                }
 
                for (int i = substr.length() + 1; i < t.length(); i++) {
                    if (p[i] == substr.length()) {
                        found = true;
                        break;
                    }
                }
            }

            if (found)
                out.println("1");
            else
                out.println("0");
            out.flush();
        }
    }

    private static void OK(int cnt) throws FileNotFoundException {
        PrintWriter pw = new PrintWriter("password.out");
        pw.print("OK ");
        pw.println("Contestant found the way after " + cnt + " moves");
        pw.close();
    }

    private static void PE(String s) throws FileNotFoundException {
        PrintWriter pw = new PrintWriter("password.out");
        pw.print("PE ");
        pw.println(s);
        pw.close();
    }

    private static void WA(String string) throws FileNotFoundException {
        PrintWriter pw = new PrintWriter("password.out");
        pw.print("WA ");
        pw.println(string);
        pw.close();
    }
}
