#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define fst first
#define snd second
#define forn(i, n) for (int i = 0; i < int(n); ++i)
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef vector<pii> vii;
#define sz(c) (int)(c).size()
#define ALL(c) (c).begin(), (c).end()

void compr (vi &a)
{
    vi cur = a;
    sort(ALL(cur));
    cur.resize(unique(ALL(cur)) - cur.begin());
    forn (i, sz(a))
        a[i] = lower_bound(ALL(cur), a[i]) - cur.begin();
}

const int inf = (int)1e9;

struct segtree
{
    int tsz;
    vii vals;

    segtree ()
    {
        tsz = -1;
    }

    segtree (int n)
    {
        tsz = 1;
        while (tsz < n)
            tsz *= 2;

        vals.assign(2 * tsz, mp(0, 0));
    }

    void put (int pos, const pii &what)
    {
        vals[pos += tsz] = what;
        for (pos >>= 1; pos > 0; pos >>= 1)
            vals[pos] = max(vals[2 * pos], vals[2 * pos + 1]);
    }

    pii getseg (int l, int r)
    {
        pii ans(0, 0);
        for (l += tsz, r += tsz; l < r; l >>= 1, r >>= 1)
        {
            if (l & 1)
                ans = max(ans, vals[l++]);
            if (r & 1)
                ans = max(ans, vals[--r]);
        }
        return ans;
    }
};

struct segtree2d
{
    vector<segtree> vals;
    vector<vii> who;
    int tsz = 1;

    segtree2d (const vi &a, const vi &b)
    {
        const int A = *max_element(ALL(a));
        const int n = sz(a);

        tsz = 1;
        while (tsz <= A + 1)
            tsz *= 2;

        vals.resize(2 * tsz);
        who.resize(2 * tsz);
        forn (i, n)
            who[a[i] + tsz].pb(mp(b[i], -i));

        forn (i, A + 1)
            sort(ALL(who[i + tsz]));

        for (int i = tsz - 1; i >= 1; i--)
        {
            who[i].resize(sz(who[2 * i]) + sz(who[2 * i + 1]));
            merge(ALL(who[2 * i]), ALL(who[2 * i + 1]), who[i].begin());
        }

        forn (i, 2 * tsz) if (i != 0)
            vals[i] = segtree(sz(who[i]));
    }

    pii query (int pos, int d, int u)
    {
        int l = lower_bound(ALL(who[pos]), mp(d, -inf)) - who[pos].begin();
        int r = lower_bound(ALL(who[pos]), mp(u, -inf)) - who[pos].begin();
        return vals[pos].getseg(l, r);
    }

    pii rect (int l, int r, int d, int u)
    {
        pii ans(0, 0);
        for (l += tsz, r += tsz; l < r; l >>= 1, r >>= 1)
        {
            if (l & 1)
                ans = max(ans, query(l++, d, u));
            if (r & 1)
                ans = max(ans, query(--r, d, u));
        }
        return ans;
    }

    void put_node (int v, int b, int what, int nid)
    {
        int pos = lower_bound(ALL(who[v]), mp(b, -inf)) - who[v].begin();
        assert(pos != sz(who[v]) && who[v][pos].fst == b);
        vals[v].put(pos, mp(what, nid));
    }

    void put (int a, int b, int what, int nid)
    {
        put_node(a += tsz, b, what, nid);
        for (a >>= 1; a > 0; a >>= 1)
            put_node(a, b, what, nid);
    }
};

void solve (int n)
{
    vi a(n), b(n);
    forn (i, n) cin >> a[i];
    forn (i, n) cin >> b[i];
    forn (i, n) a[i] = -a[i];
    compr(a);
    compr(b);

    segtree2d data(a, b);
    const int A = *max_element(ALL(a));
    const int B = *max_element(ALL(b));

    vi dp(n);
    vi ptr(n, -1);
    for (int i = n - 1; i >= 0; i--)
    {
        pii cur = data.rect(a[i], A + 1, b[i], B + 1);
        dp[i] = cur.fst + 1;
        ptr[i] = (cur.fst == 0 ? -1 : -cur.snd);
        data.put(a[i], b[i], dp[i], -i);
    }

    vi who;
    const int cpos = max_element(ALL(dp)) - dp.begin();
    int pos = cpos;
    while (pos != -1)
    {
        who.pb(pos);
        assert(0 <= pos && pos < n);
        pos = ptr[pos];
    }

    assert(dp[cpos] == sz(who));
    cout << dp[cpos] << '\n';
    forn (i, sz(who))
        cout << who[i] + 1 << ' ';
    cout << '\n';
}

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

    int n;
    while (cin >> n)
        solve(n);
}