import java.io.*;

public class password_sm_n3 {

    String sum(String s) {
        int sum = 0;
        for (int i = 0; i < s.length(); i++) {
            sum += s.charAt(i) - '0';
        }
        return "" + sum;
    }

    void solve() throws IOException {
        String from = in.readLine();
        String to = in.readLine();
        for (int i = 0; i < from.length(); i++) {
            for (int j = i; j <= from.length(); j++) {
                String got = from.substring(0, i) + sum(from.substring(i, j)) + from.substring(j);
                if (got.equals(to)) {
                    out.println((i + 1) + " " + (j));
                    return;
                }
            }
        }
        out.println("-1 -1");
    }


    BufferedReader in;
    PrintWriter out;

    void run() throws IOException {
        in = new BufferedReader(new FileReader("password.in"));
        out = new PrintWriter("password.out");
        solve();
        in.close();
        out.close();
    }


    public static void main(String[] args) throws IOException {
        new password_sm_n3().run();
    }
}
