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

using ll = long long;
using ld = long double;

int sled0[500005];
int sled1[500005];
int mvs[500005];

int main(){
    ios_base::sync_with_stdio(false), cin.tie(0);
    cout.precision(10);
    cout << fixed;

    int n;
    cin >> n;
    string s, t;
    cin >> s >> t;
    string aa = s, bb = t;
    sort(aa.begin(), aa.end());
    sort(bb.begin(), bb.end());
    if(aa != bb){
        cout << -1;
        return 0;
    }
    vector <int> p;
    vector <int> d;
    for(int i=0; i<n; i++){
        if(s[i] == '0') p.push_back(i);
        if(t[i] == '0') d.push_back(i);
    }
    int res = 0;
    for(int i=0; i<p.size(); i++){
        if(p[i] != d[i]) res++;
    }
    cout << res;
    return 0;
}

#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = (s); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) for(int i = (n); i >= 0; i--)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << '\n';
#define CFYN(n) cout << ( (n) ? "YES":"NO") << '\n';
#define OUT(n) cout << (n) << '\n';
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

int main(void)
{
    auto ansout = [](int a,int b,int c,int d){
        cout << a << " " << b << " " << c << " " << d << '\n';};
    IOS
    int n; cin >> n;
    vector<int> x(n), y(n), r(n);
    REP(i,n) {
        cin >> x[i] >> y[i] >> r[i];
    }
    REP(i,n) ansout(x[i],y[i],x[i]+1,y[i]+1);

    return 0;
}