#include<bits/stdc++.h>
#define LL long long

using namespace std;
const int N=1e6+10;
int rd()
{
    int x=0,w=1;char ch=0;
    while(ch<'0'||ch>'9'){if(ch=='-') w=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+(ch^48);ch=getchar();}
    return x*w;
}
int n,q[N<<1],hd,tl,tg;
char cc[N],ss[N];

int main()
{
    ///
    n=rd();
    scanf("%s%s",cc+1,ss+1);
    hd=n+1,tl=n;
    int ans=0;
    for(int i=n,j=n;i;--i)
    {
	while(j&&(i<j||cc[j]!=ss[i])) --j;
	if(!j){puts("-1");return 0;}
	if(i==j){hd=n+1,tl=n,tg=0;continue;}
	if(hd>tl) q[++tl]=j-tg,q[++tl]=i-tg,ans=max(ans,1);
	else
	{
	    --tg;
	    q[--hd]=j-tg;
	    while(hd<=tl&&q[tl]+tg>=i) --tl;
	    q[++tl]=i-tg;
	    ans=max(ans,tl-hd);
	}
	while(i>j&&ss[i-1]==ss[i]) --i;
    }
    printf("%d\n",ans);
    return 0;
}

#include "bits/stdc++.h"
using namespace std;


int main() {
	int N;
	cin >> N;
	vector<int>A(N +1 );
	for (int n = 0;n<N;++n) {
		cin >> A[n + 1];
	}
	vector<int>B(N + 1);
	for (int n = N;n>=1;--n) {
		int sum = 0;
		for (int m = n + n;m <= N;m += n) {
			sum += B[m];
		}
		if (A[n] == sum%2) {
			B[n] = 0;
		}
		else{
			B[n] = 1;
		}
	}
	vector<int>Ans;
	for (int n = 0; n < N; ++n) {
		if (0 != B[n + 1]) {
			Ans.push_back(n + 1);
		}
	}
	cout << Ans.size()<<endl;
	for (int n = 0; n < Ans.size(); ++n) {
		if (0 !=n) {
			cout << " ";
		}
		cout << Ans[n];
	}
	return 0;
}