#include <bits/stdc++.h>
using namespace std;
inline char gc() {
  static const int BS = 1 << 22;
  static unsigned char buf[BS], *st, *ed;
  if (st == ed) ed = buf + fread(st = buf, 1, BS, stdin);
  return st == ed ? EOF : *st++;
}
template <class T>
void in(T &x) {
  x = 0;
  bool f = 0;
  char c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-') f = 1;
    c = getchar();
  }
  while ('0' <= c && c <= '9') {
    x = (x << 3) + (x << 1) + (c ^ 48);
    c = getchar();
  }
  if (f) x = -x;
}
long long n;
long long a[1000005], b[1000005];
pair<long long, long long> rem[1000005];
signed main() {
  in(n);
  for (register long long i = 1; i <= n; ++i) in(a[i]);
  for (register long long i = 1; i <= n; ++i) {
    in(b[i]);
    a[i] += a[i - 1];
    b[i] += b[i - 1];
  }
  bool sw = 0;
  if (a[n] > b[n]) {
    sw = 1;
    swap(a, b);
  }
  memset(rem, -1, sizeof rem);
  rem[0] = make_pair(0, 0);
  for (register long long i = 1, j = 0, t; i <= n; ++i) {
    while (j <= n && b[j + 1] <= a[i]) ++j;
    t = a[i] - b[j];
    if (rem[t].first != -1) {
      if (sw) {
        swap(i, j);
        swap(rem[t].first, rem[t].second);
        swap(a, b);
      }
      printf("%lld\n", i - rem[t].first);
      for (register long long k = rem[t].first + 1; k <= i; ++k)
        printf("%lld ", k);
      printf("\n%lld\n", j - rem[t].second);
      for (register long long k = rem[t].second + 1; k <= j; ++k)
        printf("%lld ", k);
      return 0;
    } else
      rem[t] = make_pair(i, j);
  }
  return 0;
}
