//#pragma GCC optimize(2)
//#include <bits/stdc++.h>
#include <iostream>
#include <set>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <queue>
#include <vector>
#include <utility>
#include <map>
#define rush()      int T; while(cin>>T) while(T--)
#define ms(a,b)     memset(a,b,sizeof a)
#define lowbit(x)   ((x)&(-x))
#define inf         0x7f7f7f7fll
#define eps         1e-11
#define sd(a)       scanf("%d",&a)
#define sll(a)      scanf("%lld",&a)
#define sll2(a,b)   scanf("%lld%lld",&a,&b)
#define sll3(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define sdd(a,b)    scanf("%d%d",&a,&b)
#define sddd(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define sf(a)       scanf("%lf",&a)
//#define sc(a)       scanf("%c\n",&a)
#define ss(a)       scanf("%s",a)
#define pd(a)       printf("%d\n",a)
#define pdd(a,b)    printf("%d %d\n",a,b)
#define pddd(a,b,c) printf("%d %d %d\n",a,b,c)
#define pll(a)      printf("%lld\n",a)
#define pf(a)       printf("%.1lf\n",a)
#define pc(a)       printf("%c",a)
#define ps(a)       printf("%s\n",a)
#define forn(i,a,b) for(int i=(a);i<=(b);i++)
#define pb(a)       push_back(a)
#define mp(a,b)     make_pair(a,b)
#define debug(a)    cout<<#a<<" : "<<a<<" "<<" ; "
#define dbg(a)      cout<<#a<<" : "<<a<<endl
#define show(a,b)   cout<<a<<" :\t"<<b<<"\t*"<<endl
#define IOS         ios::sync_with_stdio(0); cin.tie(0)
#define PAUSE       system("pause")
//#define print(a)    cout<<a<<endl;continue;
#define fr          first
#define sc          second
#define ceils(a,b)  ((a-1ll+b)/(b))
#define floors(a,b) floor(double(a)/double(b))
using namespace std;
//inline void swap(int &x,int &y){x^=y^=x^=y;}
typedef long long ll;
//using ui=unsigned int;
typedef unsigned long long ull;
typedef pair<int,int> Pair;
const double pi=acos(-1.0);
const int dx[]={0,1,0,-1};
const int dy[]={1,0,-1,0};
const int limit=5e5;

int read()
{
	int s=0;
	char c=getchar(),lc='+';
	while (c<'0'||'9'<c) lc=c,c=getchar();
	while ('0'<=c&&c<='9') s=s*10+c-'0',c=getchar();
	return lc=='-'?-s:s;
}

void write(int x)
{
	if (x<0) putchar('-'),x=-x;
	if (x<10) putchar(x+'0');
	else write(x/10),putchar(x%10+'0');
}

void print(int x,char c='\n')
{
	write(x);
	putchar(c);
}

ll mod=998244353;
const int N=1e6+5;
 
    int n, m, _;
    int i, j, k;
    //int a[N];
    char s[N],t[N];
    vector<int> u,v;

signed main()
{
    //IOS;
    while(cin>>n){
        ss(s+1); ss(t+1);
        for(int i=1;i<=n;i++){
            if(s[i]=='0') u.pb(i);
            if(t[i]=='0') v.pb(i);
        }
        if(u.size()!=v.size()) puts("-1");
        else{
            int ans=0;
            for(int i=0;i<u.size();i++){
                if(u[i]==v[i]) continue;
                ans++;
            }
            pd(ans);
        }
    }
    //PAUSE;
    return 0;
}
#include<bits/stdc++.h>

int main(){
    using namespace std;
    unsigned long N;
    cin >> N;
    vector<unsigned long> A(2 * N);
    for(auto&& i : A)cin >> i;
    vector<pair<unsigned long, unsigned long>> B;
    B.reserve(2 * N);
    transform(begin(A), end(A), back_inserter(B), [cnt{0UL}](unsigned long a) mutable {return make_pair(a, cnt++);});
    nth_element(begin(B), begin(B) + N, end(B));
    vector<unsigned long> HL(2 * N);
    for(unsigned long i{}; i < N; ++i)HL[B[i].second] = 1;
    vector<pair<unsigned long, unsigned long>> rem_idx{};
    string ans(2 * N, ' ');
    for(unsigned long i{}; i < 2 * N; ++i)if(!rem_idx.empty() && rem_idx.back().second != HL[i]){
        ans[rem_idx.back().first] = '(';
        ans[i] = ')';
        rem_idx.pop_back();
    }else rem_idx.emplace_back(i, HL[i]);
    cout << ans << endl;
    return 0;
}
