#include <bits/stdc++.h>
int n, a[1000002], b[1000002], c[1000002], p[1000002];
long long sa[1000002], sb[1000002];
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]), sa[i] = sa[i - 1] + a[i];
  for (int i = 1; i <= n; i++) scanf("%d", &b[i]), sb[i] = sb[i - 1] + b[i];
  for (int i = 0; i < n; i++) c[i] = -1;
  for (int i = 0, j = 0; i <= n; i++) {
    while (j + 1 <= n && sb[j + 1] <= sa[i]) j++;
    p[i] = j;
    if (c[sa[i] - sb[j]] != -1) {
      int t = c[sa[i] - sb[j]];
      printf("%d\n", i - t);
      for (int k = t + 1; k <= i; k++) printf("%d ", k);
      printf("\n%d\n", p[i] - p[t]);
      for (int k = p[t] + 1; k <= p[i]; k++) printf("%d ", k);
      return 0;
    } else
      c[sa[i] - sb[j]] = i;
  }
  return 0;
}
