#include <bits/stdc++.h>
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const long long maxn = 3e6;
const long long mod = 1e9 + 7;
const long double PI = acos((long double)-1);
long long pw(long long a, long long b, long long md = mod) {
  long long res = 1;
  while (b) {
    if (b & 1) {
      res = (a * res) % md;
    }
    a = (a * a) % md;
    b >>= 1;
  }
  return (res);
}
int n;
long long a[maxn], b[maxn];
long long diff[maxn];
int ind[maxn];
int cnt[maxn];
void range(int l, int r) {
  cout << r - l + 1 << '\n';
  for (int i = l; i <= r; i++) cout << i << ' ';
  cout << '\n';
}
int32_t main() {
  ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i], a[i] += a[i - 1];
  for (int i = 1; i <= n; i++) cin >> b[i], b[i] += b[i - 1];
  int f = 0;
  if (a[n] > b[n]) swap(a, b), f = 1;
  int pos = 0;
  for (int i = 1; i <= n; i++) {
    while (b[pos] < a[i]) pos++;
    if (a[i] == b[pos]) {
      if (f)
        range(1, pos), range(1, i);
      else
        range(1, i), range(1, pos);
      return (0);
    }
    ind[i] = pos;
    int x = b[pos] - a[i];
    if (cnt[x]) {
      if (f)
        range(ind[cnt[x]] + 1, pos), range(cnt[x] + 1, i);
      else
        range(cnt[x] + 1, i), range(ind[cnt[x]] + 1, pos);
      return (0);
    }
    cnt[x] = i;
  }
  return (0);
}
