public static String solve(int n) {

        int n3 = 0;
        boolean found = false;
        for (; n3 <= n; n3 += 5) {
            if ((n - n3) % 3 == 0) {
                found = true;
                break;
            }

        }

        if (!found) {
            return "-1";
        }
        StringBuilder sb = new StringBuilder();

        for (int i = 0; i < n - n3; i++) {
            sb.append('5');
        }

        for (int i = 0; i < n3; i++) {
            sb.append('3');
        }

        return sb.toString();

    }