import core.bitop;
import core.checkedint;
import core.simd;
import core.stdc.stdlib;
import core.stdc.string;
import std.algorithm;
import std.array;
import std.ascii;
import std.bigint;
import std.bitmanip;
import std.complex;
import std.container;
import std.conv;
import std.datetime;
import std.format;
import std.functional;
import std.math;
import std.meta;
import std.numeric;
import std.random;
import std.range;
import std.regex;
import std.stdio;
import std.string;
import std.typecons;
import std.variant;

__gshared:

auto getAddrTuple() {
    return tuple();
}

auto getAddrTuple(T, U...)(ref T head, ref U tail) {
    return tuple(&head, getAddrTuple(tail).expand);
}

bool read(T...)(ref T vars) if (vars.length > 0) {
    return readf(' ' ~ replicate("%s ", vars.length), getAddrTuple(vars).expand) == vars.length;
}

T[ ] allocate(T)(size_t n) {
    return (cast(T*)malloc(n * T.sizeof))[0 .. n];
}

auto pairwise(R)(R range) if (isForwardRange!R) {
    return lockstep(range, dropOne(range));
}

char[100_001] _a, _b;
bool[100_000] used;

void main() {
    while (true) {
        version (LocalProject)
            memset(used.ptr, 0x00, used.sizeof);
        auto a = _a[ ];
        auto b = _b[ ];
        readln(a);
        if (a.empty)
            break;
        readln(b);
        a = a[0 .. $ - 1];
        b = b[0 .. $ - 1];
        const n = cast(int)a.length;
        const m = cast(int)b.length;
        //b[0 .. lb] ~ b[rb .. m]
        int la = 0, lb = 0, ra = n, rb = m;
        while (la < n && lb < m) {
            while (la < n && a[la] != b[lb])
                la++;
            if (la == n)
                break;
            used[la] = true;
            debug writeln("Left-using ", la);
            la++;
            lb++;
        }
        int lres = lb, rres = m;
        while (ra && rb) {
            ra--;
            rb--;
            int passed = 0;
            while (ra >= 0 && a[ra] != b[rb])
                if (used[ra--])
                    passed++;
            if (ra < 0)
                break;
            if (used[ra])
                passed++;
            debug writeln("Right-using ", ra);
            while (passed-- > 0 || lb > rb) {
                lb--;
                if (lb) {
                    while (a[--la] != b[lb]) { }
                    do
                        used[la--] = false;
                    while (a[la] != b[lb - 1]);
                    la++;
                } else
                    la = 0;
            }
            if (lb + m - rb > lres + m - rres) {
                lres = lb;
                rres = rb;
            }
        }
        if (!lres && rres == m)
            writeln('-');
        else
            writeln(b[0 .. lres], b[rres .. m]);
    }
}
