import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.io.PrintWriter;

public class password_sm_slow {

    private static final int MAX_LENGTH_OF_SUM = 8;
    private static final int MAX = (int) 1e5;


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

    int sumInt(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();
        if (from.length() > MAX || to.length() > MAX) {
            throw new AssertionError();
        }
        if (from.length() < to.length()) {
            out.println("-1 -1");
            return;
        }
        int pref = 0;
        while (pref < from.length() && pref < to.length() && from.charAt(pref) == to.charAt(pref)) {
            pref++;
        }
        int suf = 0;
        while (suf < from.length() && suf < to.length() && from.charAt(from.length() - 1 - suf) == to.charAt(to.length() - 1 - suf)) {
            suf++;
        }
        for (int left = 0; left < to.length(); left++) {
            forright:
            for (int right = left + 1; right < Math.min(to.length(), left + MAX_LENGTH_OF_SUM); right++) {
                int myPrefix = left;
                int mySuffix = to.length() - right;
                int x = 0;
                for (int i = myPrefix; i < from.length() - mySuffix; i++) {
                    x += from.charAt(i) - '0';
                }
//                System.err.println("try " + left + " " + right + " -> " + x);
                int tmp = x;
                int len = 0;
                while (tmp > 0) {
                    tmp /= 10;
                    len++;
                }

                if (len != right - left) {
                    continue;
                }
                for (int i = 0; i < len; i++) {
                    if (x % 10 != to.charAt(right - 1 - i)) {
                        continue forright;
                    }
                    x /= 10;
                }
                out.println((left + 1) + " " + right);
                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_slow().run();
    }


}
