#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e6 + 5;
int n, x, a[MAXN], b[MAXN], sig;
long long suma[MAXN], sumb[MAXN];
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &x), suma[i] = suma[i - 1] + x;
  for (int i = 1; i <= n; i++) scanf("%d", &x), sumb[i] = sumb[i - 1] + x;
  if (suma[n] > sumb[n]) swap(suma, sumb), sig = 1;
  for (int i = 0, j = 0; i <= n; i++) {
    while (j <= n && sumb[j + 1] <= suma[i]) j++;
    long long x = suma[i] - sumb[j];
    if (a[x]) {
      if (!sig) {
        printf("%d\n", i - a[x] + 1);
        for (int k = a[x]; k <= i; k++) printf("%d ", k);
        printf("\n");
        printf("%d\n", j - b[x] + 1);
        for (int k = b[x]; k <= j; k++) printf("%d ", k);
        printf("\n");
        return 0;
      } else {
        printf("%d\n", j - b[x] + 1);
        for (int k = b[x]; k <= j; k++) printf("%d ", k);
        printf("\n");
        printf("%d\n", i - a[x] + 1);
        for (int k = a[x]; k <= i; k++) printf("%d ", k);
        printf("\n");
        return 0;
      }
    }
    a[x] = i + 1;
    b[x] = j + 1;
  }
}
