#include <bits/stdc++.h>
using namespace std;
int n;
long long a[1000010], b[1000010];
int d[1000010], l[1000010], r[1000010];
int ax, ay, bx, by, flag;
inline int read() {
  int ans = 0;
  char ch = getchar();
  while (ch < '0' || ch > '9') ch = getchar();
  while (ch >= '0' && ch <= '9')
    ans = (ans << 1) + (ans << 3) + ch - '0', ch = getchar();
  return ans;
}
int main() {
  n = read();
  for (int i = 1; i <= n; i++) a[i] = read(), a[i] += a[i - 1];
  for (int i = 1; i <= n; i++) b[i] = read(), b[i] += b[i - 1];
  if (a[n] > b[n]) {
    flag = 1;
    swap(a, b);
  }
  int last = 0;
  for (int i = 0; i <= n; i++) {
    while (last <= n && a[i] >= b[last]) last++;
    last--;
    if (d[a[i] - b[last]]) {
      ax = l[a[i] - b[last]] + 1;
      ay = r[a[i] - b[last]] + 1;
      bx = i;
      by = last;
      break;
    }
    l[a[i] - b[last]] = i;
    r[a[i] - b[last]] = last;
    d[a[i] - b[last]] = 1;
  }
  if (flag) swap(ax, ay), swap(bx, by);
  printf("%d\n", bx - ax + 1);
  for (int i = ax; i <= bx; i++) printf("%d%c", i, i == bx ? '\n' : ' ');
  printf("%d\n", by - ay + 1);
  for (int i = ay; i <= by; i++) printf("%d%c", i, i == by ? '\n' : ' ');
}
