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

public class password_sm_greed_naive {

    private static final int MAGIC = 10;


    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();
        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++;
        }
        if (sum(from.substring(pref, from.length() - suf)).equals(to.substring(pref, to.length() - suf))) {
            out.println((suf + 1) + " " + (from.length() - suf));
            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_greed_naive().run();
    }


}
