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

public class password_sm_wrong {

    private static final int MAX_LENGTH_OF_SUM = 10;
    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++;
        }
        int len = from.length() - to.length();
        for (int left = 0; left < from.length(); left++) {
//            System.err.println("" + (Math.min(left + len + MAX_LENGTH_OF_SUM, from.length()) - Math.max(left + len - 1, 0)));

            for (int right = Math.max(left + len - 1, left + 1); right <= Math.min(left + len + MAX_LENGTH_OF_SUM, from.length()); right++) {
                boolean a = left <= pref;
                boolean b = from.length() - right <= suf;

                int toRight = to.length() - from.length() + right;

                if (left > toRight) {
                    continue;
                }

                int sourceSum = sumInt(from.substring(left, right));
                boolean c = true;
                for (int i = 0; i < toRight - left; i++) {
                    if (sourceSum == 0) {
                        break;
                    }
                    c &= (to.charAt(toRight - 1 - i) - '0') == sourceSum % 10;
                    sourceSum /= 10;
                }

//                boolean c = sourceSubstring.equals(targetSubstring);

//                String got = from.substring(0, left) + sumOfDigit(from.substring(left, right)) + from.substring(right);
//                if (got.equals(to) != (a && b && c)) {
//                    throw new AssertionError();
//                }
                if (a && b && c) {
                    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_wrong().run();
    }


}
