#include <bits/stdc++.h>
using namespace std;
const int INF = 1 << 30;
const long long LLINF = 1LL << 62;
const int mod = 1000000007;
int n, i, j, k, chg;
long long sa, sb;
int a[1000005], b[1000005];
map<int, pair<int, int> > mp;
int main() {
  scanf("%d", &n);
  for (i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    sa += a[i];
  }
  for (i = 1; i <= n; i++) {
    scanf("%d", &b[i]);
    sb += b[i];
  }
  if (sa > sb) {
    chg = 1;
    for (i = 1; i <= n; i++) swap(a[i], b[i]);
  }
  mp[0] = {0, 0};
  sa = sb = 0;
  j = 0;
  for (i = 1; i <= n; i++) {
    sa += a[i];
    while (j < n && sb + b[j + 1] <= sa) {
      j++;
      sb += b[j];
    }
    if (mp.count(sa - sb)) {
      if (chg) {
        printf("%d\n", j - mp[sa - sb].second);
        for (k = mp[sa - sb].second + 1; k <= j; k++) printf("%d ", k);
        printf("\n");
        printf("%d\n", i - mp[sa - sb].first);
        for (k = mp[sa - sb].first + 1; k <= i; k++) printf("%d ", k);
        return 0;
      } else {
        printf("%d\n", i - mp[sa - sb].first);
        for (k = mp[sa - sb].first + 1; k <= i; k++) printf("%d ", k);
        printf("\n");
        printf("%d\n", j - mp[sa - sb].second);
        for (k = mp[sa - sb].second + 1; k <= j; k++) printf("%d ", k);
        return 0;
      }
      return 0;
    }
    mp[sa - sb] = {i, j};
  }
  return 0;
}
