#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int x = 0;
  bool t = false;
  char ch = getchar();
  while ((ch < '0' || ch > '9') && ch != '-') ch = getchar();
  if (ch == '-') t = true, ch = getchar();
  while (ch <= '9' && ch >= '0') x = x * 10 + ch - 48, ch = getchar();
  return t ? -x : x;
}
int n, a[1000100], b[1000100], fl;
long long A[1000100], B[1000100];
void Output(int l1, int r1, int l2, int r2) {
  if (fl) swap(l1, l2), swap(r1, r2);
  printf("%d\n", r1 - l1);
  for (int i = l1 + 1; i <= r1; ++i) printf("%d ", i);
  puts("");
  printf("%d\n", r2 - l2);
  for (int i = l2 + 1; i <= r2; ++i) printf("%d ", i);
  puts("");
  exit(0);
}
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;
  for (int i = 0; i < n; ++i) a[i] = -1;
  for (int i = 0, j = 0; i <= n; ++i) {
    while (B[j] < A[i]) ++j;
    int d = B[j] - A[i];
    if (~a[d]) Output(a[d], i, b[d], j);
    a[d] = i;
    b[d] = j;
  }
  puts("-1");
  return 0;
}
