#include <bits/stdc++.h>
using namespace std;
long long N, a[1000010], b[1000010], visited[1000010];
pair<long long, long long> sol[1000010];
bool swapped = false;
void output(long long fl, long long fr, long long sl, long long sr) {
  if (!swapped) {
    cout << fr - fl << '\n';
    for (long long i = fl + 1; i <= fr; i++) {
      cout << i + 1 << " ";
    }
    cout << '\n';
    cout << sr - sl << '\n';
    for (long long i = sl + 1; i <= sr; i++) {
      cout << i + 1 << " ";
    }
    cout << '\n';
  } else {
    cout << sr - sl << '\n';
    for (long long i = sl + 1; i <= sr; i++) {
      cout << i + 1 << " ";
    }
    cout << '\n';
    cout << fr - fl << '\n';
    for (long long i = fl + 1; i <= fr; i++) {
      cout << i + 1 << " ";
    }
    cout << '\n';
  }
}
void solve() {
  long long i = 0, j = 0, suma = 0, sumb = 0;
  while (i < N) {
    suma += a[i];
    while (sumb + b[j] <= suma) {
      sumb += b[j];
      j++;
    }
    long long diff = suma - sumb;
    if (visited[diff]) {
      output(sol[diff].first, i, sol[diff].second, j - 1);
      return;
    } else if (diff == 0) {
      output(-1, i, -1, j - 1);
      return;
    } else {
      visited[diff] = true;
      sol[diff] = {i, j - 1};
    }
    i++;
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cin >> N;
  long long totala = 0, totalb = 0;
  for (long long i = 0; i < N; i++) {
    cin >> a[i];
    totala += a[i];
  }
  for (long long i = 0; i < N; i++) {
    cin >> b[i];
    totalb += b[i];
  }
  if (totala > totalb) {
    swapped = true;
    for (long long i = 0; i < N; i++) {
      swap(a[i], b[i]);
    }
  }
  solve();
}
