#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file  
#include <ext/pb_ds/tree_policy.hpp>  
#include <functional> // for less  
using namespace         std;
#define                 int long long
#define                 pb push_back
#define                 mp make_pair
#define st(arr,a)       memset(arr,a,sizeof arr)
#define                 nl cout<<'\n'
#define bitcount(x)     __builtin_popcountll(x)
const int MOD = 1000000007ll;
#define forn(i,a,b)     for(int i=a;i<=b;i++)
#define rfor(i,a,b)     for(int i=a;i>=b;i--)
#define all(x)          x.begin() , x.end()
#define pi pair<int,int>
#define X first
#define Y second
#define sz(A) (int)A.size()
#define N 1014159
#define  vi vector<int>
#define  v  vector
#define die exit(0)
#define alln(arr) arr+1 , arr+1+n
using namespace __gnu_pbds;  
typedef tree<int, null_type, less<int>, rb_tree_tag,  
            tree_order_statistics_node_update> oset; 

// order_of_key (k) : Number of items strictly smaller than k .
// find_by_order(k) : K-th element in a set (counting from zero).

#define in input_int()
#define ins input_string()
bool sb(int a,int i){return (a&(1LL<<i))>0;}
int p2(int a){return (1LL<<a);}
int input_int(){int a;cin>>a;return a;}
string input_string(){string s;cin>>s;return s;}
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};

int ceil(int a,int b){return (a+b-1)/b;}
int ct,visited[N],ans;
vi adj[N];
int n,m,k,a,b,c,d,x,y,arr[N];
void clr()
{
    forn(i,0,n+10)adj[i].clear(),visited[i]=0,arr[i]=0;
}


string s;
void solve()
{
    cin>>n>>m;
    if(m==0)
    {
        forn(i,1,n)
        {
            cout<<2*i<<" "<<2*i+1;nl;
        }
        return;
    }
    if(m<0)
    {
        cout<<-1;
        return;
    }
    if(m>n-2)
    {
        cout<<-1;
        return;
    }

    

    int last=1e9;
    cout<<1<<" "<<last;nl;
    last--;
    int first=2;

    forn(i,1,n-1)
    {
        if(i<=m)
        {
            cout<<first<<" "<<first+1;nl;
            first+=2;
        }
        else if(i==m+1)
        {
            cout<<first<<" "<<last;nl;
            last--;
            first++;    

        }
         
        else
        {
            cout<<first<<" "<<last;nl;
            first++;
            last--;
        }
    }



}


signed main() 
{
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); 
    int t = 1;
    //cin>>t;
    forn(i,1,t)
    {
        //cout<<":Case #"<<i<<": ";
        solve();
        nl;
    }



    return 0;

}
//       clang++ c.cpp ; ./a.out < a.txt ;  
//go to line 54 for some useful code.
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "debug.hpp"
#else 
#define dbg(...) 47
#define dbgm(...) 47
#endif
// refer https://codeforces.com/blog/entry/66279
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization("unroll-loops")
//refer-> https://codeforces.com/blog/entry/62393 
struct custom_hash {
   static uint64_t splitmix64(uint64_t x) {
       // http://xorshift.di.unimi.it/splitmix64.c
       x += 0x9e3779b97f4a7c15;
       x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
       x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
       return x ^ (x >> 31);
   }
   size_t operator()(uint64_t x) const {
       static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
       return splitmix64(x + FIXED_RANDOM);
   }
};
typedef long long ll;
typedef unsigned long int ul;
typedef unsigned long long int ull;
typedef unsigned int ui;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef vector<vector<ll>> matrix;
typedef vector<ll> vll;
typedef vector<int> vii;
typedef unordered_map<int,int, custom_hash> umap;
typedef unordered_set<int, custom_hash>uset;
#define f(i, x, n) for (int i = x; i < n; i++)
#define rf(i, n, x) for(int i=n;i>=x;--i)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define F first
#define S second
#define pb push_back
#define endl "\n"
#define unique(v) v.erase(unique(v.begin(), v.end()), v.end());
#define mem(a, b) memset(a, b, sizeof(a))
#define fast_io() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define mod ((ll)(1e9+7))
#define oo INT64_MAX
#define rng ((int)(2e5+10))
//*	write code from here 
void solve(){
	ll n;
	cin>>n;
	string s, t;
	cin>>s>>t;
	ll ans = 0;
	vii a, b;
	f(i, 0, n)if(s[i] == '0')a.pb(i);
	f(i, 0, n)if(t[i] == '0')b.pb(i);
	if(a.size()!= b.size()){
		cout<<-1<<endl;
		return;
	}
	for(int i=0;i<a.size();++i){
		if(a[i]!=b[i]) ans++;
	}
	cout<<ans<<endl;
}
int main()
{
	fast_io();
	cerr << "...............Console is yours! :)................." << endl;
	//freopen("input.in","r",stdin);
	solve();
	cerr<<"......^_^....."<<endl;
	return 0;
}
