#include <bits/stdc++.h>
using namespace std;
long long a[1000111], b[1000111], prea[1000111], preb[1000111];
map<long long, pair<long long, long long> > m;
set<long long> s;
bool bswap;
void print(long long z, long long k) {
  printf("%lld\n", k - z + 1);
  for (long long j = z; j <= k; j++) printf("%lld ", j);
  printf("\n");
}
int main() {
  long long n;
  bswap = 0;
  scanf("%lld", &n);
  for (long long i = 1; i <= n; i++) {
    scanf("%lld", a + i);
    prea[i] = prea[i - 1] + a[i];
  }
  for (long long i = 1; i <= n; i++) {
    scanf("%lld", b + i);
    preb[i] = preb[i - 1] + b[i];
  }
  if (preb[n] < prea[n]) {
    bswap = 1;
    swap(a, b);
    swap(prea, preb);
  }
  long long ind = 0;
  for (long long i = 0; i <= n; i++) {
    while (ind + 1 <= n && preb[ind + 1] <= prea[i]) ind++;
    long long diff = prea[i] - preb[ind];
    if (s.find(diff) != s.end()) {
      long long ii = m[diff].first + 1;
      long long iind = m[diff].second + 1;
      if (!bswap) {
        print(ii, i);
        print(iind, ind);
      }
      if (bswap) {
        print(iind, ind);
        print(ii, i);
      }
      return 0;
    }
    s.insert(diff);
    m[diff] = make_pair(i, ind);
  }
  return 0;
}
