#include <bits/stdc++.h>
using namespace std;
long long read() {
  long long x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9')
    x = (x << 1) + (x << 3) + ch - '0', ch = getchar();
  return x * f;
}
const int N = 1000005;
struct node {
  long long tag, x, y;
} t[N];
long long n, fl, a[N], b[N], val, tt, pos;
int main() {
  n = read();
  for (int i = 1; i <= n; i++) a[i] = a[i - 1] + read();
  for (int i = 1; i <= n; i++) b[i] = b[i - 1] + read();
  if (a[n] > b[n]) swap(a, b), fl = 1;
  long long tt = -1;
  for (int i = 0; i <= n; i++) {
    while (tt + 1 <= n && b[tt + 1] <= a[i]) tt++;
    val = a[i] - b[tt];
    if (t[val].tag) {
      pos = i;
      break;
    }
    t[val].tag = 1;
    t[val].x = i;
    t[val].y = tt;
  }
  if (fl == 1) swap(t[val].x, t[val].y), swap(pos, tt), swap(a, b);
  printf("%d\n", pos - t[val].x);
  for (int i = t[val].x + 1; i <= pos; i++)
    printf("%d%c", i, (i == pos) ? 10 : 32);
  printf("%d\n", tt - t[val].y);
  for (int i = t[val].y + 1; i <= tt; i++)
    printf("%d%c", i, (i == tt) ? 10 : 32);
  return 0;
}
