#include <iostream>
#include <cstdio>

using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

    int x, y;
    cin >> x >> y;

    bool found = false;

    for (int i = x; i <= y; i++) {
        bool c = true;
        int a = i;
        int b = i;

        while (b != 0) {
            a = b % 10;
            b /= 10;

            if (a == 4 || a == 7) {
                c = true;
            } else {
                c = false;
                break;
            }
        }

        if (c == true) {
            cout << i << " ";
            found = true;
        }
    }

    if (found == false) {
        cout << -1 << endl;
    }

    return 0;
}