//                  Sara_Hasan <3                //
//                 Thnx For Everything            //

#include<bits/stdc++.h>
///#include <ext/pb_ds/assoc_container.hpp>
///#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
///using namespace __gnu_pbds;
///template<typename T> using orderset = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;

#define           CIN              ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define           ll               long long int
#define           ull              unsigned long long int
#define           pii              pair < ll, ll>
#define           pll              pair < ll, pii>
#define           fs               first
#define           scnd             second
#define           mx               1000005
#define           mod1             1000000007
#define           mod2             1000000009
#define           vi               vector<int>
#define           vl               vector<ll>
#define           pb               push_back
#define           sc               scanf
#define           pf               printf
#define         scin(x)            scanf("%d",&(x))
#define        scin2(x,y)          scanf("%d %d",&(x),&(y))
#define         scln(x)            scanf("%lld",&(x))
#define        scln2(x,y)          scanf("%lld %lld",&(x),&(y))
#define       min3(a,b,c)          min(a,min(b,c))
#define       min4(a,b,c,d)        min(d,min(a,min(b,c)))
#define       max3(a,b,c)          max(a,max(b,c))
#define       max4(a,b,c,d)        max(d,max(a,max(b,c)))
#define         ms(a,b)            memset(a,b,sizeof(a))
//#define           mp               make_pair
#define       gcd(a, b)            __gcd(a,b)
#define       lcm(a, b)            ((a)*(b)/gcd(a,b))
#define         input              freopen("input.txt","rt", stdin)
#define         output             freopen("output.txt","wt", stdout)
#define           PI               2*acos(0.0)
#define       zero(a)              memset(a,0,sizeof a)
#define      all(v)  v.begin(),v.end()
#define      rall(v)        v.rbegin(),v.rend()
#define      upper(s)      transform(s.begin(),s.end(),s.begin(), ::toupper)
#define      lower(s)      transform(s.begin(),s.end(),s.begin(), ::tolower)
#define          Unique(X)             (X).erase(unique(all(X)),(X).end())

///priority_queue<int,vector<int>,greater<int> >pq;
///string s1 = "abcdefghijklmnopqrstuvwxyz";
///string s2 = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" ;

///---------------Order set-------------------
///template<typename T> using orderset =tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
///#include <ext/pb_ds/assoc_container.hpp>
///using namespace __gnu_pbds;
///*os.find_by_order(index) os.order_of_key(value)

///--------------Graph Moves--------------------------------------
const int fx[] = {+1,-1,+0,+0};
const int fy[] = {+0,+0,+1,-1};
///const int fx[] = {+0,+0,+1,-1,-1,+1,-1,+1}; ///King's move
///const int fy[] = {-1,+1,+0,+0,+1,+1,-1,-1}; ///king's Move
///const int fx[] = {-2,-2,-1,-1,+1,+1,+2,+2}; ///knight's move
///const int fy[] = {-1,+1,-2,+2,-2,+2,-1,+1}; ///knight's move
///---------------------------------------------------------------

string s1, s2, s3, s4, s5 ;
vector<ll>v1,v2,v3;
map<ll,ll>mp1,mp2;
vector<pii>res;

int main()
{
    CIN;
    ll a, b, c, d, e, f,i, j, cnt1 = 0, cnt2 = 0, chk=0, sum = 0 ;

    cin >> a >> s1 >> s2 ;

    for(i=0; i<a; i++)
    {
        if(s1[i]=='a' && s2[i]=='b')
        {
            v1.pb(i);
        }
        else if(s1[i]=='b' && s2[i]=='a')
        {
            v2.pb(i);
        }
    }
    for(i=0; i<a; i++)
    {
        if(s1[i]!=s2[i])
        {
            if(s1[i]=='a' && s2[i] == 'b')
            {
                if(v1.size()>0 && v1.back()!=i)
                {
                    ll p = v1.back();
                    s2[i]='a';
                    s1[p]='b';
                    res.pb(pii(i,p));
                    v1.pop_back();
                }
                else if(v2.size()>0 && v2.back()!=i)
                {
                    ll p = v2.back();
                    s1[p]='a';
                    s2[p]='b';
                    res.pb(pii(p,p));
                    s2[i]='a';
                    s1[p]='b';
                    res.pb(pii(i,p));
                    v2.pop_back();
                }
                else
                {
                    cout<<-1;
                    return 0;
                }
            }
            else
            {
                if(v2.size()>0 && v2.back()!=i)
                {
                    ll p = v2.back();
                    if(p==i)
                    {
                        cout<<-1;
                        return 0;
                    }
                    s2[i]='b';
                    s1[p]='a';
                    res.pb(pii(i,p));
                    v2.pop_back();
                }
                else if(v1.size()>0 && v1.back()!=i)
                {
                    ll p = v1.back();
                    s1[p]='b';
                    s2[p]='a';
                    res.pb(pii(p,p));
                    s2[i]='b';
                    s1[p]='a';
                    res.pb(pii(i,p));
                    v2.pop_back();
                }
                else
                {
                    cout<<-1;
                    return 0;
                }
            }
        }
    }
    cout<<res.size()<<endl;
    for(i=0; i<res.size(); i++)
    {
        cout<<res[i].fs+1<<" "<<res[i].scnd+1<<endl;
    }
    return 0 ;
}


//                  Sara_Hasan <3                //
//                 Thnx For Everything            //

#include<bits/stdc++.h>
///#include <ext/pb_ds/assoc_container.hpp>
///#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
///using namespace __gnu_pbds;
///template<typename T> using orderset = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;

#define           CIN              ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define           ll               long long int
#define           ull              unsigned long long int
#define           pii              pair < ll, ll>
#define           pll              pair < ll, pii>
#define           fs               first
#define           scnd             second
#define           mx               1000005
#define           mod1             1000000007
#define           mod2             1000000009
#define           vi               vector<int>
#define           vl               vector<ll>
#define           pb               push_back
#define           sc               scanf
#define           pf               printf
#define         scin(x)            scanf("%d",&(x))
#define        scin2(x,y)          scanf("%d %d",&(x),&(y))
#define         scln(x)            scanf("%lld",&(x))
#define        scln2(x,y)          scanf("%lld %lld",&(x),&(y))
#define       min3(a,b,c)          min(a,min(b,c))
#define       min4(a,b,c,d)        min(d,min(a,min(b,c)))
#define       max3(a,b,c)          max(a,max(b,c))
#define       max4(a,b,c,d)        max(d,max(a,max(b,c)))
#define         ms(a,b)            memset(a,b,sizeof(a))
//#define           mp               make_pair
#define       gcd(a, b)            __gcd(a,b)
#define       lcm(a, b)            ((a)*(b)/gcd(a,b))
#define         input              freopen("input.txt","rt", stdin)
#define         output             freopen("output.txt","wt", stdout)
#define           PI               2*acos(0.0)
#define       zero(a)              memset(a,0,sizeof a)
#define      all(v)  v.begin(),v.end()
#define      rall(v)        v.rbegin(),v.rend()
#define      upper(s)      transform(s.begin(),s.end(),s.begin(), ::toupper)
#define      lower(s)      transform(s.begin(),s.end(),s.begin(), ::tolower)
#define          Unique(X)             (X).erase(unique(all(X)),(X).end())

///priority_queue<int,vector<int>,greater<int> >pq;
///string s1 = "abcdefghijklmnopqrstuvwxyz";
///string s2 = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" ;

///---------------Order set-------------------
///template<typename T> using orderset =tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
///#include <ext/pb_ds/assoc_container.hpp>
///using namespace __gnu_pbds;
///*os.find_by_order(index) os.order_of_key(value)

///--------------Graph Moves--------------------------------------
const int fx[] = {+1,-1,+0,+0};
const int fy[] = {+0,+0,+1,-1};
///const int fx[] = {+0,+0,+1,-1,-1,+1,-1,+1}; ///King's move
///const int fy[] = {-1,+1,+0,+0,+1,+1,-1,-1}; ///king's Move
///const int fx[] = {-2,-2,-1,-1,+1,+1,+2,+2}; ///knight's move
///const int fy[] = {-1,+1,-2,+2,-2,+2,-1,+1}; ///knight's move
///---------------------------------------------------------------

string s1, s2 ;
set<ll>ms1,ms2;
vector<pii>res;

int main()
{
    CIN;
    ll a, b, c, d, e, f,i, j, cnt1 = 0, cnt2 = 0, chk=0, sum = 0,yy=1,zz=1;

    cin >> a >> s1 >> s2 ;

    for(i=0; i<a; i++)
    {
        if(s1[i]=='a' && s2[i]=='b')
        {
            ms1.insert(i);
        }
        else if(s1[i]=='b' && s2[i]=='a')
        {
            ms2.insert(i);
        }
    }
    for(i=0; i<a; i++)
    {
        if(s1[i]!=s2[i])
        {
            if(s1[i]=='a' && s2[i] == 'b')
            {
                if(ms1.size()>1)
                {
                    set<ll>::iterator it;
                    it = lower_bound(all(ms1),i+1);
                    ll p = *it;

                    s2[i]='a';
                    s1[p]='b';
                    res.pb(pii(i,p));
                    ms1.erase(p);
                    ms1.erase(i);
                }
                else if(ms2.size()>0 && ms1.size()>0)
                {
                    set<ll>::iterator it;
                    it = lower_bound(all(ms2),i+1);
                    ll p = *it;

                    s1[p]='a';
                    s2[p]='b';
                    res.pb(pii(p,p));
                    s2[i]='a';
                    s1[p]='b';
                    res.pb(pii(i,p));
                    ms2.erase(p);
                    ms1.erase(i);
                }
                else
                {
                    cout<<-1;
                    return 0;
                }
            }
            else
            {
                if(ms2.size()>1)
                {
                    set<ll>::iterator it;
                    it = lower_bound(all(ms2),i+1);
                    ll p = *it;

                    s2[i]='b';
                    s1[p]='a';
                    res.pb(pii(i,p));
                    ms2.erase(p);
                    ms2.erase(i);
                }
                else if(ms1.size()>0 && ms2.size()>0)
                {
                    set<ll>::iterator it;
                    it = lower_bound(all(ms1),i+1);
                    ll p = *it;

                    s1[p]='b';
                    s2[p]='a';
                    res.pb(pii(p,p));
                    s2[i]='b';
                    s1[p]='a';
                    res.pb(pii(i,p));
                    ms1.erase(p);
                    ms2.erase(i);
                }
                else
                {
                    cout<<-1;
                    return 0;
                }
            }
        }
    }
    cout<<res.size()<<endl;
    for(i=0; i<res.size(); i++)
    {
        cout<<res[i].fs+1<<" "<<res[i].scnd+1<<endl;
    }
    return 0 ;
}


//                  Sara_Hasan <3                //
//                 Thnx For Everything            //

#include<bits/stdc++.h>
///#include <ext/pb_ds/assoc_container.hpp>
///#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
///using namespace __gnu_pbds;
///template<typename T> using orderset = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;

#define           CIN              ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define           ll               long long int
#define           ull              unsigned long long int
#define           pii              pair < ll, ll>
#define           pll              pair < ll, pii>
#define           fs               first
#define           scnd             second
#define           mx               1000005
#define           mod1             1000000007
#define           mod2             1000000009
#define           vi               vector<int>
#define           vl               vector<ll>
#define           pb               push_back
#define           sc               scanf
#define           pf               printf
#define         scin(x)            scanf("%d",&(x))
#define        scin2(x,y)          scanf("%d %d",&(x),&(y))
#define         scln(x)            scanf("%lld",&(x))
#define        scln2(x,y)          scanf("%lld %lld",&(x),&(y))
#define       min3(a,b,c)          min(a,min(b,c))
#define       min4(a,b,c,d)        min(d,min(a,min(b,c)))
#define       max3(a,b,c)          max(a,max(b,c))
#define       max4(a,b,c,d)        max(d,max(a,max(b,c)))
#define         ms(a,b)            memset(a,b,sizeof(a))
//#define           mp               make_pair
#define       gcd(a, b)            __gcd(a,b)
#define       lcm(a, b)            ((a)*(b)/gcd(a,b))
#define         input              freopen("input.txt","rt", stdin)
#define         output             freopen("output.txt","wt", stdout)
#define           PI               2*acos(0.0)
#define       zero(a)              memset(a,0,sizeof a)
#define      all(v)  v.begin(),v.end()
#define      rall(v)        v.rbegin(),v.rend()
#define      upper(s)      transform(s.begin(),s.end(),s.begin(), ::toupper)
#define      lower(s)      transform(s.begin(),s.end(),s.begin(), ::tolower)
#define          Unique(X)             (X).erase(unique(all(X)),(X).end())

///priority_queue<int,vector<int>,greater<int> >pq;
///string s1 = "abcdefghijklmnopqrstuvwxyz";
///string s2 = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" ;

///---------------Order set-------------------
///template<typename T> using orderset =tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
///#include <ext/pb_ds/assoc_container.hpp>
///using namespace __gnu_pbds;
///*os.find_by_order(index) os.order_of_key(value)

///--------------Graph Moves--------------------------------------
const int fx[] = {+1,-1,+0,+0};
const int fy[] = {+0,+0,+1,-1};
///const int fx[] = {+0,+0,+1,-1,-1,+1,-1,+1}; ///King's move
///const int fy[] = {-1,+1,+0,+0,+1,+1,-1,-1}; ///king's Move
///const int fx[] = {-2,-2,-1,-1,+1,+1,+2,+2}; ///knight's move
///const int fy[] = {-1,+1,-2,+2,-2,+2,-1,+1}; ///knight's move
///---------------------------------------------------------------

string s1, s2;
vector<ll>v1,v2;
vector<pii>res;

int main()
{
    CIN;
    ll a, b, c, d, e, f,i ;

    cin >> a >> s1 >> s2 ;

    for(i=0; i<a; i++)
    {
        if(s1[i]=='a' && s2[i]=='b')
        {
            v1.pb(i);
        }
        else if(s1[i]=='b' && s2[i]=='a')
        {
            v2.pb(i);
        }
    }

    while(v1.size()>1)
    {
        ll p = v1.back();
        v1.pop_back();
        ll q = v1.back();
        v1.pop_back();
        s1[p]='a';
        s2[p]='a';
        s1[q]='b';
        s2[q]='b';
        res.pb(pii(p,q));
    }

    while(v2.size()>1)
    {
        ll p = v2.back();
        v2.pop_back();
        ll q = v2.back();
        v2.pop_back();
        s1[p]='b';
        s2[p]='b';
        s1[q]='a';
        s2[q]='a';
        res.pb(pii(p,q));
    }

    if(v1.size()!=v2.size())
    {
        cout<<-1;
        return 0;
    }
    else if(v1.size()==1)
    {
        ll p = v2.back();
        res.pb(pii(p,p));
        ll q = v1.back();
        res.pb(pii(p,q));
    }

    cout<<res.size()<<endl;
    for(i=0; i<res.size(); i++)
    {
        cout<<res[i].fs+1<<" "<<res[i].scnd+1<<endl;
    }
    return 0 ;
}


//                  Sara_Hasan <3                //
//                 Thnx For Everything            //

#include<bits/stdc++.h>
///#include <ext/pb_ds/assoc_container.hpp>
///#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
///using namespace __gnu_pbds;
///template<typename T> using orderset = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;

#define           CIN              ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define           ll               long long int
#define           ull              unsigned long long int
#define           pii              pair < ll, ll>
#define           pll              pair < ll, pii>
#define           fs               first
#define           scnd             second
#define           mx               1000005
#define           mod1             1000000007
#define           mod2             1000000009
#define           vi               vector<int>
#define           vl               vector<ll>
#define           pb               push_back
#define           sc               scanf
#define           pf               printf
#define         scin(x)            scanf("%d",&(x))
#define        scin2(x,y)          scanf("%d %d",&(x),&(y))
#define         scln(x)            scanf("%lld",&(x))
#define        scln2(x,y)          scanf("%lld %lld",&(x),&(y))
#define       min3(a,b,c)          min(a,min(b,c))
#define       min4(a,b,c,d)        min(d,min(a,min(b,c)))
#define       max3(a,b,c)          max(a,max(b,c))
#define       max4(a,b,c,d)        max(d,max(a,max(b,c)))
#define         ms(a,b)            memset(a,b,sizeof(a))
//#define           mp               make_pair
#define       gcd(a, b)            __gcd(a,b)
#define       lcm(a, b)            ((a)*(b)/gcd(a,b))
#define         input              freopen("input.txt","rt", stdin)
#define         output             freopen("output.txt","wt", stdout)
#define           PI               2*acos(0.0)
#define       zero(a)              memset(a,0,sizeof a)
#define      all(v)  v.begin(),v.end()
#define      rall(v)        v.rbegin(),v.rend()
#define      upper(s)      transform(s.begin(),s.end(),s.begin(), ::toupper)
#define      lower(s)      transform(s.begin(),s.end(),s.begin(), ::tolower)
#define          Unique(X)             (X).erase(unique(all(X)),(X).end())

///priority_queue<int,vector<int>,greater<int> >pq;
///string s1 = "abcdefghijklmnopqrstuvwxyz";
///string s2 = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" ;

///---------------Order set-------------------
///template<typename T> using orderset =tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
///#include <ext/pb_ds/assoc_container.hpp>
///using namespace __gnu_pbds;
///*os.find_by_order(index) os.order_of_key(value)

///--------------Graph Moves--------------------------------------
const int fx[] = {+1,-1,+0,+0};
const int fy[] = {+0,+0,+1,-1};
///const int fx[] = {+0,+0,+1,-1,-1,+1,-1,+1}; ///King's move
///const int fy[] = {-1,+1,+0,+0,+1,+1,-1,-1}; ///king's Move
///const int fx[] = {-2,-2,-1,-1,+1,+1,+2,+2}; ///knight's move
///const int fy[] = {-1,+1,-2,+2,-2,+2,-1,+1}; ///knight's move
///---------------------------------------------------------------

string s1, s2, s3, s4, s5 ;
vector<ll>v1,v2,v3;
map<ll,ll>mp1,mp2;
vector<pii>res;

int main()
{
    CIN;
    ll a, b, c, d, e, f,i, j, cnt1 = 0, cnt2 = 0, chk=0, sum = 0 ;

    cin >> a >> s1 >> s2 ;

    for(i=0; i<a; i++)
    {
        if(s1[i]=='a' && s2[i]=='b')
        {
            v1.pb(i);
        }
        else if(s1[i]=='b' && s2[i]=='a')
        {
            v2.pb(i);
        }
    }
    for(i=0; i<a; i++)
    {
        if(s1[i]!=s2[i])
        {
            if(s1[i]=='a' && s2[i] == 'b')
            {
                if(v1.size()>0)
                {
                    ll p = v1.back();
                    if(p==i)
                    {
                        cout<<-1;
                        return 0;
                    }
                    s2[i]='a';
                    s1[p]='b';
                    res.pb(pii(i,p));
                    v1.pop_back();
                }
                else if(v2.size()>0)
                {
                    ll p = v2.back();
                    s1[p]='a';
                    s2[p]='b';
                    res.pb(pii(p,p));
                    s2[i]='a';
                    s1[p]='b';
                    res.pb(pii(i,p));
                    v2.pop_back();
                }
                else
                {
                    cout<<-1;
                    return 0;
                }
            }
            else
            {
                if(v2.size()>0)
                {
                    ll p = v2.back();
                    if(p==i)
                    {
                        cout<<-1;
                        return 0;
                    }
                    s2[i]='b';
                    s1[p]='a';
                    res.pb(pii(i,p));
                    v2.pop_back();
                }
                else if(v1.size()>0)
                {
                    ll p = v1.back();
                    s1[p]='b';
                    s2[p]='a';
                    res.pb(pii(p,p));
                    s2[i]='b';
                    s1[p]='a';
                    res.pb(pii(i,p));
                    v2.pop_back();
                }
                else
                {
                    cout<<-1;
                    return 0;
                }
            }
        }
    }
    cout<<res.size()<<endl;
    for(i=0; i<res.size(); i++)
    {
        cout<<res[i].fs+1<<" "<<res[i].scnd+1<<endl;
    }
    return 0 ;
}


//                  Sara_Hasan <3                //
//                 Thnx For Everything            //

#include<bits/stdc++.h>
///#include <ext/pb_ds/assoc_container.hpp>
///#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
///using namespace __gnu_pbds;
///template<typename T> using orderset = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;

#define           CIN              ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define           ll               long long int
#define           ull              unsigned long long int
#define           pii              pair < ll, ll>
#define           pll              pair < ll, pii>
#define           fs               first
#define           scnd             second
#define           mx               1000005
#define           mod1             1000000007
#define           mod2             1000000009
#define           vi               vector<int>
#define           vl               vector<ll>
#define           pb               push_back
#define           sc               scanf
#define           pf               printf
#define         scin(x)            scanf("%d",&(x))
#define        scin2(x,y)          scanf("%d %d",&(x),&(y))
#define         scln(x)            scanf("%lld",&(x))
#define        scln2(x,y)          scanf("%lld %lld",&(x),&(y))
#define       min3(a,b,c)          min(a,min(b,c))
#define       min4(a,b,c,d)        min(d,min(a,min(b,c)))
#define       max3(a,b,c)          max(a,max(b,c))
#define       max4(a,b,c,d)        max(d,max(a,max(b,c)))
#define         ms(a,b)            memset(a,b,sizeof(a))
//#define           mp               make_pair
#define       gcd(a, b)            __gcd(a,b)
#define       lcm(a, b)            ((a)*(b)/gcd(a,b))
#define         input              freopen("input.txt","rt", stdin)
#define         output             freopen("output.txt","wt", stdout)
#define           PI               2*acos(0.0)
#define       zero(a)              memset(a,0,sizeof a)
#define      all(v)  v.begin(),v.end()
#define      rall(v)        v.rbegin(),v.rend()
#define      upper(s)      transform(s.begin(),s.end(),s.begin(), ::toupper)
#define      lower(s)      transform(s.begin(),s.end(),s.begin(), ::tolower)
#define          Unique(X)             (X).erase(unique(all(X)),(X).end())

///priority_queue<int,vector<int>,greater<int> >pq;
///string s1 = "abcdefghijklmnopqrstuvwxyz";
///string s2 = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" ;

///---------------Order set-------------------
///template<typename T> using orderset =tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
///#include <ext/pb_ds/assoc_container.hpp>
///using namespace __gnu_pbds;
///*os.find_by_order(index) os.order_of_key(value)

///--------------Graph Moves--------------------------------------
const int fx[] = {+1,-1,+0,+0};
const int fy[] = {+0,+0,+1,-1};
///const int fx[] = {+0,+0,+1,-1,-1,+1,-1,+1}; ///King's move
///const int fy[] = {-1,+1,+0,+0,+1,+1,-1,-1}; ///king's Move
///const int fx[] = {-2,-2,-1,-1,+1,+1,+2,+2}; ///knight's move
///const int fy[] = {-1,+1,-2,+2,-2,+2,-1,+1}; ///knight's move
///---------------------------------------------------------------

string s1, s2 ;
multiset<ll>ms1,ms2;
multiset<ll>::iterator it;
vector<pii>res;

int main()
{
    CIN;
    ll a, b, c, d, e, f,i, j, cnt1 = 0, cnt2 = 0, chk=0, sum = 0,yy=1,zz=1;

    cin >> a >> s1 >> s2 ;

    for(i=0; i<a; i++)
    {
        if(s1[i]=='a' && s2[i]=='b')
        {
            ms1.insert(i);
        }
        else if(s1[i]=='b' && s2[i]=='a')
        {
            ms2.insert(i);
        }
    }
    for(i=0; i<a; i++)
    {
        if(s1[i]!=s2[i])
        {
            if(s1[i]=='a' && s2[i] == 'b')
            {
                if(ms1.size()>1)
                {
                    it = lower_bound(all(ms1),i+1);
                    ll p = *it;

                    s2[i]='a';
                    s1[p]='b';
                    res.pb(pii(i,p));
                    ms1.erase(it);
                    ms1.erase(i);
                }
                else if(ms2.size()>0 && ms1.size()>0)
                {
                    it = lower_bound(all(ms2),i+1);
                    ll p = *it;

                    s1[p]='a';
                    s2[p]='b';
                    res.pb(pii(p,p));
                    s2[i]='a';
                    s1[p]='b';
                    res.pb(pii(i,p));
                    ms2.erase(it);
                    ms1.erase(i);
                }
                else
                {
                    cout<<-1;
                    return 0;
                }
            }
            else
            {
                if(ms2.size()>1)
                {
                    it = lower_bound(all(ms2),i+1);
                    ll p = *it;

                    s2[i]='b';
                    s1[p]='a';
                    res.pb(pii(i,p));
                    ms2.erase(it);
                    ms2.erase(i);
                }
                else if(ms1.size()>0 && ms2.size()>0)
                {
                    it = lower_bound(all(ms1),i+1);
                    ll p = *it;

                    s1[p]='b';
                    s2[p]='a';
                    res.pb(pii(p,p));
                    s2[i]='b';
                    s1[p]='a';
                    res.pb(pii(i,p));
                    ms1.erase(it);
                    ms2.erase(i);
                }
                else
                {
                    cout<<-1;
                    return 0;
                }
            }
        }
    }
    cout<<res.size()<<endl;
    for(i=0; i<res.size(); i++)
    {
        cout<<res[i].fs+1<<" "<<res[i].scnd+1<<endl;
    }
    return 0 ;
}


//                  Sara_Hasan <3                //
//                 Thnx For Everything            //

#include<bits/stdc++.h>
///#include <ext/pb_ds/assoc_container.hpp>
///#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
///using namespace __gnu_pbds;
///template<typename T> using orderset = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;

#define           CIN              ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define           ll               long long int
#define           ull              unsigned long long int
#define           pii              pair < ll, ll>
#define           pll              pair < ll, pii>
#define           fs               first
#define           scnd             second
#define           mx               1000005
#define           mod1             1000000007
#define           mod2             1000000009
#define           vi               vector<int>
#define           vl               vector<ll>
#define           pb               push_back
#define           sc               scanf
#define           pf               printf
#define         scin(x)            scanf("%d",&(x))
#define        scin2(x,y)          scanf("%d %d",&(x),&(y))
#define         scln(x)            scanf("%lld",&(x))
#define        scln2(x,y)          scanf("%lld %lld",&(x),&(y))
#define       min3(a,b,c)          min(a,min(b,c))
#define       min4(a,b,c,d)        min(d,min(a,min(b,c)))
#define       max3(a,b,c)          max(a,max(b,c))
#define       max4(a,b,c,d)        max(d,max(a,max(b,c)))
#define         ms(a,b)            memset(a,b,sizeof(a))
//#define           mp               make_pair
#define       gcd(a, b)            __gcd(a,b)
#define       lcm(a, b)            ((a)*(b)/gcd(a,b))
#define         input              freopen("input.txt","rt", stdin)
#define         output             freopen("output.txt","wt", stdout)
#define           PI               2*acos(0.0)
#define       zero(a)              memset(a,0,sizeof a)
#define      all(v)  v.begin(),v.end()
#define      rall(v)        v.rbegin(),v.rend()
#define      upper(s)      transform(s.begin(),s.end(),s.begin(), ::toupper)
#define      lower(s)      transform(s.begin(),s.end(),s.begin(), ::tolower)
#define          Unique(X)             (X).erase(unique(all(X)),(X).end())

///priority_queue<int,vector<int>,greater<int> >pq;
///string s1 = "abcdefghijklmnopqrstuvwxyz";
///string s2 = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" ;

///---------------Order set-------------------
///template<typename T> using orderset =tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
///#include <ext/pb_ds/assoc_container.hpp>
///using namespace __gnu_pbds;
///*os.find_by_order(index) os.order_of_key(value)

///--------------Graph Moves--------------------------------------
const int fx[] = {+1,-1,+0,+0};
const int fy[] = {+0,+0,+1,-1};
///const int fx[] = {+0,+0,+1,-1,-1,+1,-1,+1}; ///King's move
///const int fy[] = {-1,+1,+0,+0,+1,+1,-1,-1}; ///king's Move
///const int fx[] = {-2,-2,-1,-1,+1,+1,+2,+2}; ///knight's move
///const int fy[] = {-1,+1,-2,+2,-2,+2,-1,+1}; ///knight's move
///---------------------------------------------------------------

string s1, s2 ;
vector<ll>v1,v2;
vector<pii>res;

int main()
{
    CIN;
    ll a, b, c, d, e, f,i, j, cnt1 = 0, cnt2 = 0, chk=0, sum = 0 ,yy=1,zz=1;

    cin >> a >> s1 >> s2 ;

    for(i=0; i<a; i++)
    {
        if(s1[i]=='a' && s2[i]=='b')
        {
            v1.pb(i);
        }
        else if(s1[i]=='b' && s2[i]=='a')
        {
            v2.pb(i);
        }
    }
    for(i=0; i<a; i++)
    {
        if(s1[i]!=s2[i])
        {
            if(s1[i]=='a' && s2[i] == 'b')
            {
                if(v1.size()>yy )
                {
                    ll p = v1.back();
                    s2[i]='a';
                    s1[p]='b';
                    res.pb(pii(i,p));
                    v1.pop_back();
                    yy++;
                }
                else if(v2.size()>zz-1 )
                {
                    ll p = v2.back();
                    s1[p]='a';
                    s2[p]='b';
                    res.pb(pii(p,p));
                    s2[i]='a';
                    s1[p]='b';
                    res.pb(pii(i,p));
                    v2.pop_back();
                    zz++;
                }
                else
                {
                    cout<<-1;
                    return 0;
                }
            }
            else
            {
                if(v2.size()>zz)
                {
                    ll p = v2.back();
                    s2[i]='b';
                    s1[p]='a';
                    res.pb(pii(i,p));
                    v2.pop_back();
                    zz++;
                }
                else if(v1.size()>yy-1)
                {
                    ll p = v1.back();
                    s1[p]='b';
                    s2[p]='a';
                    res.pb(pii(p,p));
                    s2[i]='b';
                    s1[p]='a';
                    res.pb(pii(i,p));
                    v2.pop_back();
                    yy++;
                }
                else
                {
                    cout<<-1;
                    return 0;
                }
            }
        }
    }
    cout<<res.size()<<endl;
    for(i=0; i<res.size(); i++)
    {
        cout<<res[i].fs+1<<" "<<res[i].scnd+1<<endl;
    }
    return 0 ;
}


//                  Sara_Hasan <3                //
//                 Thnx For Everything            //

#include<bits/stdc++.h>
///#include <ext/pb_ds/assoc_container.hpp>
///#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
///using namespace __gnu_pbds;
///template<typename T> using orderset = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;

#define           CIN              ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define           ll               long long int
#define           ull              unsigned long long int
#define           pii              pair < ll, ll>
#define           pll              pair < ll, pii>
#define           fs               first
#define           scnd             second
#define           mx               1000005
#define           mod1             1000000007
#define           mod2             1000000009
#define           vi               vector<int>
#define           vl               vector<ll>
#define           pb               push_back
#define           sc               scanf
#define           pf               printf
#define         scin(x)            scanf("%d",&(x))
#define        scin2(x,y)          scanf("%d %d",&(x),&(y))
#define         scln(x)            scanf("%lld",&(x))
#define        scln2(x,y)          scanf("%lld %lld",&(x),&(y))
#define       min3(a,b,c)          min(a,min(b,c))
#define       min4(a,b,c,d)        min(d,min(a,min(b,c)))
#define       max3(a,b,c)          max(a,max(b,c))
#define       max4(a,b,c,d)        max(d,max(a,max(b,c)))
#define         ms(a,b)            memset(a,b,sizeof(a))
//#define           mp               make_pair
#define       gcd(a, b)            __gcd(a,b)
#define       lcm(a, b)            ((a)*(b)/gcd(a,b))
#define         input              freopen("input.txt","rt", stdin)
#define         output             freopen("output.txt","wt", stdout)
#define           PI               2*acos(0.0)
#define       zero(a)              memset(a,0,sizeof a)
#define      all(v)  v.begin(),v.end()
#define      rall(v)        v.rbegin(),v.rend()
#define      upper(s)      transform(s.begin(),s.end(),s.begin(), ::toupper)
#define      lower(s)      transform(s.begin(),s.end(),s.begin(), ::tolower)
#define          Unique(X)             (X).erase(unique(all(X)),(X).end())

///priority_queue<int,vector<int>,greater<int> >pq;
///string s1 = "abcdefghijklmnopqrstuvwxyz";
///string s2 = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" ;

///---------------Order set-------------------
///template<typename T> using orderset =tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
///#include <ext/pb_ds/assoc_container.hpp>
///using namespace __gnu_pbds;
///*os.find_by_order(index) os.order_of_key(value)

///--------------Graph Moves--------------------------------------
const int fx[] = {+1,-1,+0,+0};
const int fy[] = {+0,+0,+1,-1};
///const int fx[] = {+0,+0,+1,-1,-1,+1,-1,+1}; ///King's move
///const int fy[] = {-1,+1,+0,+0,+1,+1,-1,-1}; ///king's Move
///const int fx[] = {-2,-2,-1,-1,+1,+1,+2,+2}; ///knight's move
///const int fy[] = {-1,+1,-2,+2,-2,+2,-1,+1}; ///knight's move
///---------------------------------------------------------------

string s1, s2 ;
vector<ll>v1,v2;
vector<pii>res;

int main()
{
    CIN;
    ll a, b, c, d, e, f,i, j, cnt1 = 0, cnt2 = 0, chk=0, sum = 0 ,yy=1,zz=1;

    cin >> a >> s1 >> s2 ;

    for(i=0; i<a; i++)
    {
        if(s1[i]=='a' && s2[i]=='b')
        {
            v1.pb(i);
        }
        else if(s1[i]=='b' && s2[i]=='a')
        {
            v2.pb(i);
        }
    }
    for(i=0; i<a; i++)
    {
        if(s1[i]!=s2[i])
        {
            if(s1[i]=='a' && s2[i] == 'b')
            {
                if(v1.size()>yy )
                {
                    ll p = v1.back();
                    s2[i]='a';
                    s1[p]='b';
                    res.pb(pii(i,p));
                    v1.pop_back();
                    yy++;
                }
                else if(v2.size()>zz-1 )
                {
                    ll p = v2.back();
                    s1[p]='a';
                    s2[p]='b';
                    res.pb(pii(p,p));
                    s2[i]='a';
                    s1[p]='b';
                    res.pb(pii(i,p));
                    v2.pop_back();
                    zz++;
                }
                else
                {
                    cout<<-1;
                    return 0;
                }
            }
            else
            {
                if(v2.size()>zz)
                {
                    ll p = v2.back();
                    if(p==i)
                    {
                        cout<<-1;
                        return 0;
                    }
                    s2[i]='b';
                    s1[p]='a';
                    res.pb(pii(i,p));
                    v2.pop_back();
                    zz++;
                }
                else if(v1.size()>yy-1)
                {
                    ll p = v1.back();
                    s1[p]='b';
                    s2[p]='a';
                    res.pb(pii(p,p));
                    s2[i]='b';
                    s1[p]='a';
                    res.pb(pii(i,p));
                    v2.pop_back();
                    yy++;
                }
                else
                {
                    cout<<-1;
                    return 0;
                }
            }
        }
    }
    cout<<res.size()<<endl;
    for(i=0; i<res.size(); i++)
    {
        cout<<res[i].fs+1<<" "<<res[i].scnd+1<<endl;
    }
    return 0 ;
}


//                  Sara_Hasan <3                //
//                 Thnx For Everything            //

#include<bits/stdc++.h>
///#include <ext/pb_ds/assoc_container.hpp>
///#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
///using namespace __gnu_pbds;
///template<typename T> using orderset = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;

#define           CIN              ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define           ll               long long int
#define           ull              unsigned long long int
#define           pii              pair < ll, ll>
#define           pll              pair < ll, pii>
#define           fs               first
#define           scnd             second
#define           mx               1000005
#define           mod1             1000000007
#define           mod2             1000000009
#define           vi               vector<int>
#define           vl               vector<ll>
#define           pb               push_back
#define           sc               scanf
#define           pf               printf
#define         scin(x)            scanf("%d",&(x))
#define        scin2(x,y)          scanf("%d %d",&(x),&(y))
#define         scln(x)            scanf("%lld",&(x))
#define        scln2(x,y)          scanf("%lld %lld",&(x),&(y))
#define       min3(a,b,c)          min(a,min(b,c))
#define       min4(a,b,c,d)        min(d,min(a,min(b,c)))
#define       max3(a,b,c)          max(a,max(b,c))
#define       max4(a,b,c,d)        max(d,max(a,max(b,c)))
#define         ms(a,b)            memset(a,b,sizeof(a))
//#define           mp               make_pair
#define       gcd(a, b)            __gcd(a,b)
#define       lcm(a, b)            ((a)*(b)/gcd(a,b))
#define         input              freopen("input.txt","rt", stdin)
#define         output             freopen("output.txt","wt", stdout)
#define           PI               2*acos(0.0)
#define       zero(a)              memset(a,0,sizeof a)
#define      all(v)  v.begin(),v.end()
#define      rall(v)        v.rbegin(),v.rend()
#define      upper(s)      transform(s.begin(),s.end(),s.begin(), ::toupper)
#define      lower(s)      transform(s.begin(),s.end(),s.begin(), ::tolower)
#define          Unique(X)             (X).erase(unique(all(X)),(X).end())

///priority_queue<int,vector<int>,greater<int> >pq;
///string s1 = "abcdefghijklmnopqrstuvwxyz";
///string s2 = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" ;

///---------------Order set-------------------
///template<typename T> using orderset =tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
///#include <ext/pb_ds/assoc_container.hpp>
///using namespace __gnu_pbds;
///*os.find_by_order(index) os.order_of_key(value)

///--------------Graph Moves--------------------------------------
const int fx[] = {+1,-1,+0,+0};
const int fy[] = {+0,+0,+1,-1};
///const int fx[] = {+0,+0,+1,-1,-1,+1,-1,+1}; ///King's move
///const int fy[] = {-1,+1,+0,+0,+1,+1,-1,-1}; ///king's Move
///const int fx[] = {-2,-2,-1,-1,+1,+1,+2,+2}; ///knight's move
///const int fy[] = {-1,+1,-2,+2,-2,+2,-1,+1}; ///knight's move
///---------------------------------------------------------------

string s1, s2;
vector<ll>v1,v2;
vector<pii>res;

int main()
{
    CIN;
    ll a, b, c, d, e, f,i ;

    cin >> a >> s1 >> s2 ;

    for(i=0; i<a; i++)
    {
        if(s1[i]=='a' && s2[i]=='b')
        {
            v1.pb(i);
        }
        else if(s1[i]=='b' && s2[i]=='a')
        {
            v2.pb(i);
        }
    }

    while(v1.size()>1)
    {
        ll p = v1.back();
        v1.pop_back();
        ll q = v1.back();
        v1.pop_back();
        res.pb(pii(p,q));
    }

    while(v2.size()>1)
    {
        ll p = v2.back();
        v2.pop_back();
        ll q = v2.back();
        v2.pop_back();
        res.pb(pii(p,q));
    }

    if(v1.size()!=v2.size())
    {
        cout<<-1;
        return 0;
    }
    else if(v1.size()==1)
    {
        ll p = v2.back();
        res.pb(pii(p,p));
        ll q = v1.back();
        res.pb(pii(p,q));
    }

    cout<<res.size()<<endl;
    for(i=0; i<res.size(); i++)
    {
        cout<<res[i].fs+1<<" "<<res[i].scnd+1<<endl;
    }
    return 0 ;
}


//                  Sara_Hasan <3                //
//                 Thnx For Everything            //

#include<bits/stdc++.h>
///#include <ext/pb_ds/assoc_container.hpp>
///#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
///using namespace __gnu_pbds;
///template<typename T> using orderset = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;

#define           CIN              ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define           ll               long long int
#define           ull              unsigned long long int
#define           pii              pair < ll, ll>
#define           pll              pair < ll, pii>
#define           fs               first
#define           scnd             second
#define           mx               1000005
#define           mod1             1000000007
#define           mod2             1000000009
#define           vi               vector<int>
#define           vl               vector<ll>
#define           pb               push_back
#define           sc               scanf
#define           pf               printf
#define         scin(x)            scanf("%d",&(x))
#define        scin2(x,y)          scanf("%d %d",&(x),&(y))
#define         scln(x)            scanf("%lld",&(x))
#define        scln2(x,y)          scanf("%lld %lld",&(x),&(y))
#define       min3(a,b,c)          min(a,min(b,c))
#define       min4(a,b,c,d)        min(d,min(a,min(b,c)))
#define       max3(a,b,c)          max(a,max(b,c))
#define       max4(a,b,c,d)        max(d,max(a,max(b,c)))
#define         ms(a,b)            memset(a,b,sizeof(a))
//#define           mp               make_pair
#define       gcd(a, b)            __gcd(a,b)
#define       lcm(a, b)            ((a)*(b)/gcd(a,b))
#define         input              freopen("input.txt","rt", stdin)
#define         output             freopen("output.txt","wt", stdout)
#define           PI               2*acos(0.0)
#define       zero(a)              memset(a,0,sizeof a)
#define      all(v)  v.begin(),v.end()
#define      rall(v)        v.rbegin(),v.rend()
#define      upper(s)      transform(s.begin(),s.end(),s.begin(), ::toupper)
#define      lower(s)      transform(s.begin(),s.end(),s.begin(), ::tolower)
#define          Unique(X)             (X).erase(unique(all(X)),(X).end())

///priority_queue<int,vector<int>,greater<int> >pq;
///string s1 = "abcdefghijklmnopqrstuvwxyz";
///string s2 = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" ;

///---------------Order set-------------------
///template<typename T> using orderset =tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
///#include <ext/pb_ds/assoc_container.hpp>
///using namespace __gnu_pbds;
///*os.find_by_order(index) os.order_of_key(value)

///--------------Graph Moves--------------------------------------
const int fx[] = {+1,-1,+0,+0};
const int fy[] = {+0,+0,+1,-1};
///const int fx[] = {+0,+0,+1,-1,-1,+1,-1,+1}; ///King's move
///const int fy[] = {-1,+1,+0,+0,+1,+1,-1,-1}; ///king's Move
///const int fx[] = {-2,-2,-1,-1,+1,+1,+2,+2}; ///knight's move
///const int fy[] = {-1,+1,-2,+2,-2,+2,-1,+1}; ///knight's move
///---------------------------------------------------------------

string s1, s2 ;
multiset<ll>ms1,ms2;
multiset<ll>::iterator it;
vector<pii>res;

int main()
{
    CIN;
    ll a, b, c, d, e, f,i, j, cnt1 = 0, cnt2 = 0, chk=0, sum = 0,yy=1,zz=1;

    cin >> a >> s1 >> s2 ;

    for(i=0; i<a; i++)
    {
        if(s1[i]=='a' && s2[i]=='b')
        {
            ms1.insert(i);
        }
        else if(s1[i]=='b' && s2[i]=='a')
        {
            ms2.insert(i);
        }
    }
    for(i=0; i<a; i++)
    {
        if(s1[i]!=s2[i])
        {
            if(s1[i]=='a' && s2[i] == 'b')
            {
                if(ms1.size()>1)
                {
                    it = lower_bound(all(ms1),i+1);
                    ll p = *it;

                    s2[i]='a';
                    s1[p]='b';
                    res.pb(pii(i,p));
                    ms1.erase(p);
                    ms1.erase(i);
                }
                else if(ms2.size()>0 && ms1.size()>0)
                {
                    it = lower_bound(all(ms2),i+1);
                    ll p = *it;

                    s1[p]='a';
                    s2[p]='b';
                    res.pb(pii(p,p));
                    s2[i]='a';
                    s1[p]='b';
                    res.pb(pii(i,p));
                    ms2.erase(p);
                    ms1.erase(i);
                }
                else
                {
                    cout<<-1;
                    return 0;
                }
            }
            else
            {
                if(ms2.size()>1)
                {
                    it = lower_bound(all(ms2),i+1);
                    ll p = *it;

                    s2[i]='b';
                    s1[p]='a';
                    res.pb(pii(i,p));
                    ms2.erase(p);
                    ms2.erase(i);
                }
                else if(ms1.size()>0 && ms2.size()>0)
                {
                    it = lower_bound(all(ms1),i+1);
                    ll p = *it;

                    s1[p]='b';
                    s2[p]='a';
                    res.pb(pii(p,p));
                    s2[i]='b';
                    s1[p]='a';
                    res.pb(pii(i,p));
                    ms1.erase(p);
                    ms2.erase(i);
                }
                else
                {
                    cout<<-1;
                    return 0;
                }
            }
        }
    }
    cout<<res.size()<<endl;
    for(i=0; i<res.size(); i++)
    {
        cout<<res[i].fs+1<<" "<<res[i].scnd+1<<endl;
    }
    return 0 ;
}


// Problem: C. Swap Letters
// Contest: Codeforces - Codeforces Round #585 (Div. 2)
// URL: https://codeforces.com/problemset/problem/1215/C
// Memory Limit: 256 MB
// Time Limit: 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

// love forever
//debugging is the best thing in this world i m loving it
//created by prakash
#include<bits/stdc++.h>
using namespace std;
              /*DEBUGGING OP  */
#define d0(x) cout<<(x)<<" "
#define d1(x) cout<<(x)<<endl
#define d2(x,y) cout<<(x)<<" "<<(y)<<endl
#define d3(x,y,z) cout<<(x)<<" "<<(y)<<" "<<(z)<<endl
#define d4(a,b,c,d) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<endl
#define d5(a,b,c,d,e) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<" "<<(e)<<endl
#define d6(a,b,c,d,e,f) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<" "<<(e)<<" "<<(f)<<endl

          /* SOME ITERATORS */
typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

        /*SOME SHORTCUTS*/

#define f(i,a,b) for(int i=a;i<b;i++)
#define fr(i,a,b) for(int i=a;i>=b;i--)
#define vll vector<ll ,ll >
#define pll pair< ll ,ll >
#define ll long long int
#define pb push_back
#define mp make_pair
#define fi first
#define se second
const int mod = 1e9 + 7;
bool prime[1000001];
vector<int >v1;
#define all(v) (v).begin(),(v).end()
#define some(v,i,j)  ((v).begin()+i),((v).begin()+j)
void sieve() {

	memset(prime, true, sizeof(prime));

	for (int i = 2; i * i <= 1000000; i++)
	if (prime[i])
		for (int j = i * i; j <= 1000000; j+= i)
			prime[j] = false;

	prime[0] = prime[1] = false;

}
int main(){
	int n;
	cin>>n;
	string s1,s2;
	cin>>s1;
	cin>>s2;
	vector<int>v1;
	vector<int>v2;
	int cnt1=0;int cnt2=0;
	f(i,0,n){
		if(s1[i]=='a')  cnt1++;
		if(s2[i]=='a')  cnt1++;
		if(s1[i]=='b')  cnt2++;
		if(s2[i]=='b')  cnt2++;
		if(s1[i]==s2[i]){

		}
		else{
			if(s1[i]=='a'){
				v1.pb(i+1);
			}
			else{
				v2.pb(i+1);
			}
		}
	}
	// f(i,0,v1.size()){
		// cout<<v1[i]<<" ";
	// }
	// cout<<endl;
	// f(i,0,v2.size()){
		// cout<<v2[i]<<" ";
	// }
	// cout<<endl;
	if(v1.size()==0 && v2.size()==0){
		cout<<"0"<<endl;
	}
	else if(cnt1%2!=0 || cnt2%2!=0){
		cout<<"-1"<<endl;
	}
	else{
		if(v1.size()%2!=0 || v2.size()%2!=0){
			//cout<<"kaka "<<endl;
			int hh=0;
			hh+=(v1.size()-1)/2;
			hh+=(v2.size()-1)/2;
			hh+=2;
			//cout<<"v1 size "<<v1.size()<<" "<<v2.size()<<endl;
			//cout<<(((v1.size()-1/2)+(v2.size()-1/2))+2)<<endl;
			cout<<hh<<endl;
			for(int i=0;i<v1.size()-1;i+=2){
				if(i==(v1.size()-1)){
					break;
				}
				cout<<v1[i]<<" "<<v1[i+1]<<endl;
			}
			for(int j=0;j<v2.size()-1;j+=2){
				if(j==(v2.size()-1)){
					break;
				}
				cout<<v1[j]<<" "<<v1[j+1]<<endl;
			}
			cout<<v1[v1.size()-1]<<" "<<v1[v1.size()-1]<<endl;
			//cout<<v2[v2.size()-1]<<" "<<v2[v2.size()-1]<<endl;
			cout<<v1[v1.size()-1]<<" "<<v2[v2.size()-1]<<endl;
		}
		else{
			cout<<((v1.size()+v2.size())/2)<<endl;
			if(v1.size()>0){
				for(int i=0;i<v1.size()-1;i+=2){
					cout<<v1[i]<<" "<<v1[i+1]<<endl;
					//cout<<"i "<<i<<endl;
				}
			}
			if(v2.size()>0){
				for(int j=0;j<v2.size()-1;j+=2){
					cout<<v2[j]<<" "<<v2[j+1]<<endl;
				}
			}
		}
	}
	return 0;
}


// Problem: C. Swap Letters
// Contest: Codeforces - Codeforces Round #585 (Div. 2)
// URL: https://codeforces.com/problemset/problem/1215/C
// Memory Limit: 256 MB
// Time Limit: 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

// love forever
//debugging is the best thing in this world i m loving it
//created by prakash
#include<bits/stdc++.h>
using namespace std;
              /*DEBUGGING OP  */
#define d0(x) cout<<(x)<<" "
#define d1(x) cout<<(x)<<endl
#define d2(x,y) cout<<(x)<<" "<<(y)<<endl
#define d3(x,y,z) cout<<(x)<<" "<<(y)<<" "<<(z)<<endl
#define d4(a,b,c,d) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<endl
#define d5(a,b,c,d,e) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<" "<<(e)<<endl
#define d6(a,b,c,d,e,f) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<" "<<(e)<<" "<<(f)<<endl

          /* SOME ITERATORS */
typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

        /*SOME SHORTCUTS*/

#define f(i,a,b) for(int i=a;i<b;i++)
#define fr(i,a,b) for(int i=a;i>=b;i--)
#define vll vector<ll ,ll >
#define pll pair< ll ,ll >
#define ll long long int
#define pb push_back
#define mp make_pair
#define fi first
#define se second
const int mod = 1e9 + 7;
bool prime[1000001];
vector<int >v1;
#define all(v) (v).begin(),(v).end()
#define some(v,i,j)  ((v).begin()+i),((v).begin()+j)
void sieve() {

	memset(prime, true, sizeof(prime));

	for (int i = 2; i * i <= 1000000; i++)
	if (prime[i])
		for (int j = i * i; j <= 1000000; j+= i)
			prime[j] = false;

	prime[0] = prime[1] = false;

}
int main(){
	int n;
	cin>>n;
	string s1,s2;
	cin>>s1;
	cin>>s2;
	vector<int>v1;
	vector<int>v2;
	int cnt1=0;int cnt2=0;
	f(i,0,n){
		if(s1[i]=='a')  cnt1++;
		if(s2[i]=='a')  cnt1++;
		if(s1[i]=='b')  cnt2++;
		if(s2[i]=='b')  cnt2++;
		if(s1[i]==s2[i]){

		}
		else{
			if(s1[i]=='a'){
				v1.pb(i+1);
			}
			else{
				v2.pb(i+1);
			}
		}
	}
	// f(i,0,v1.size()){
		// cout<<v1[i]<<" ";
	// }
	// cout<<endl;
	// f(i,0,v2.size()){
		// cout<<v2[i]<<" ";
	// }
	// cout<<endl;
	if(v1.size()==0 && v2.size()==0){
		cout<<"0"<<endl;
	}
	else if(cnt1%2!=0 || cnt2%2!=0){
		cout<<"-1"<<endl;
	}
	else{
		if(v1.size()%2!=0){

			int hh=0;
			hh+=(v1.size()-1)/2;
			hh+=(v2.size()-1)/2;
			hh+=2;
			//cout<<(((v1.size()-1/2)+(v2.size()-1/2))+2)<<endl;
			cout<<hh<<endl;
			for(int i=0;i<v1.size()-1;i+=2){
				if(i==(v1.size()-1)){
					break;
				}
				cout<<v1[i]<<" "<<v1[i+1]<<endl;
			}
			for(int j=0;j<v2.size()-1;j+=2){
				if(j==(v2.size()-1)){
					break;
				}
				cout<<v1[j]<<" "<<v1[j+1]<<endl;
			}
			cout<<v1[v1.size()-1]<<" "<<v1[v1.size()-1]<<endl;
			//cout<<v2[v2.size()-1]<<" "<<v2[v2.size()-1]<<endl;
			cout<<v1[v1.size()-1]<<" "<<v2[v2.size()-1]<<endl;
		}
		else{
			cout<<((v1.size()+v2.size())/2)<<endl;
			if(v1.size()>0){
				for(int i=0;i<v1.size()-1;i+=2){
					cout<<v1[i]<<" "<<v1[i+1]<<endl;
					//cout<<"i "<<i<<endl;
				}
			}
			if(v2.size()>0){
				for(int j=0;j<v2.size()-1;j+=2){
					cout<<v2[j]<<" "<<v2[j+1]<<endl;
				}
			}
		}
	}
	return 0;
}


// Problem: C. Swap Letters
// Contest: Codeforces - Codeforces Round #585 (Div. 2)
// URL: https://codeforces.com/problemset/problem/1215/C
// Memory Limit: 256 MB
// Time Limit: 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

// love forever
//debugging is the best thing in this world i m loving it
//created by prakash
#include<bits/stdc++.h>
using namespace std;
              /*DEBUGGING OP  */
#define d0(x) cout<<(x)<<" "
#define d1(x) cout<<(x)<<endl
#define d2(x,y) cout<<(x)<<" "<<(y)<<endl
#define d3(x,y,z) cout<<(x)<<" "<<(y)<<" "<<(z)<<endl
#define d4(a,b,c,d) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<endl
#define d5(a,b,c,d,e) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<" "<<(e)<<endl
#define d6(a,b,c,d,e,f) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<" "<<(e)<<" "<<(f)<<endl

          /* SOME ITERATORS */
typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

        /*SOME SHORTCUTS*/

#define f(i,a,b) for(int i=a;i<b;i++)
#define fr(i,a,b) for(int i=a;i>=b;i--)
#define vll vector<ll ,ll >
#define pll pair< ll ,ll >
#define ll long long int
#define pb push_back
#define mp make_pair
#define fi first
#define se second
const int mod = 1e9 + 7;
bool prime[1000001];
vector<int >v1;
#define all(v) (v).begin(),(v).end()
#define some(v,i,j)  ((v).begin()+i),((v).begin()+j)
void sieve() {

	memset(prime, true, sizeof(prime));

	for (int i = 2; i * i <= 1000000; i++)
	if (prime[i])
		for (int j = i * i; j <= 1000000; j+= i)
			prime[j] = false;

	prime[0] = prime[1] = false;

}
int main(){
	int n;
	cin>>n;
	string s1,s2;
	cin>>s1;
	cin>>s2;
	vector<int>v1;
	vector<int>v2;
	int cnt1=0;int cnt2=0;
	f(i,0,n){
		if(s1[i]=='a')  cnt1++;
		if(s2[i]=='a')  cnt1++;
		if(s1[i]=='b')  cnt2++;
		if(s2[i]=='b')  cnt2++;
		if(s1[i]==s2[i]){

		}
		else{
			if(s1[i]=='a'){
				v1.pb(i+1);
			}
			else{
				v2.pb(i+1);
			}
		}
	}
	// f(i,0,v1.size()){
		// cout<<v1[i]<<" ";
	// }
	// cout<<endl;
	// f(i,0,v2.size()){
		// cout<<v2[i]<<" ";
	// }
	// cout<<endl;
	if(cnt1%2!=0 || cnt2%2!=0){
		cout<<"-1"<<endl;
	}
	else{
		if(v1.size()%2!=0){
			int hh=0;
			hh+=(v1.size()-1)/2;
			hh+=(v2.size()-1)/2;
			hh+=2;
			//cout<<(((v1.size()-1/2)+(v2.size()-1/2))+2)<<endl;
			cout<<hh<<endl;
			for(int i=0;i<v1.size()-1;i+=2){
				if(i==(v1.size()-1)){
					break;
				}
				cout<<v1[i]<<" "<<v1[i+1]<<endl;
			}
			for(int j=0;j<v2.size()-1;j+=2){
				if(j==(v2.size()-1)){
					break;
				}
				cout<<v1[j]<<" "<<v1[j+1]<<endl;
			}
			cout<<v1[v1.size()-1]<<" "<<v1[v1.size()-1]<<endl;
			//cout<<v2[v2.size()-1]<<" "<<v2[v2.size()-1]<<endl;
			cout<<v1[v1.size()-1]<<" "<<v2[v2.size()-1]<<endl;
		}
		else{
			cout<<((v1.size()+v2.size())/2)<<endl;
			for(int i=0;i<v1.size()-1;i+=2){
				cout<<v1[i]<<" "<<v1[i+1]<<endl;
				//cout<<"i "<<i<<endl;
			}
			for(int j=0;j<v2.size()-1;j+=2){
				cout<<v2[j]<<" "<<v2[j+1]<<endl;
			}
		}
	}
	return 0;
}


// Problem: C. Swap Letters
// Contest: Codeforces - Codeforces Round #585 (Div. 2)
// URL: https://codeforces.com/problemset/problem/1215/C
// Memory Limit: 256 MB
// Time Limit: 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

// love forever
//debugging is the best thing in this world i m loving it
//created by prakash
#include<bits/stdc++.h>
using namespace std;
              /*DEBUGGING OP  */
#define d0(x) cout<<(x)<<" "
#define d1(x) cout<<(x)<<endl
#define d2(x,y) cout<<(x)<<" "<<(y)<<endl
#define d3(x,y,z) cout<<(x)<<" "<<(y)<<" "<<(z)<<endl
#define d4(a,b,c,d) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<endl
#define d5(a,b,c,d,e) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<" "<<(e)<<endl
#define d6(a,b,c,d,e,f) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<" "<<(e)<<" "<<(f)<<endl

          /* SOME ITERATORS */
typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

        /*SOME SHORTCUTS*/

#define f(i,a,b) for(int i=a;i<b;i++)
#define fr(i,a,b) for(int i=a;i>=b;i--)
#define vll vector<ll ,ll >
#define pll pair< ll ,ll >
#define ll long long int
#define pb push_back
#define mp make_pair
#define fi first
#define se second
const int mod = 1e9 + 7;
bool prime[1000001];
vector<int >v1;
#define all(v) (v).begin(),(v).end()
#define some(v,i,j)  ((v).begin()+i),((v).begin()+j)
void sieve() {

	memset(prime, true, sizeof(prime));

	for (int i = 2; i * i <= 1000000; i++)
	if (prime[i])
		for (int j = i * i; j <= 1000000; j+= i)
			prime[j] = false;

	prime[0] = prime[1] = false;

}
int main(){
	int n;
	cin>>n;
	string s1,s2;
	cin>>s1;
	cin>>s2;
	vector<int>v1;
	vector<int>v2;
	int cnt1=0;int cnt2=0;
	f(i,0,n){
		if(s1[i]=='a')  cnt1++;
		if(s2[i]=='a')  cnt1++;
		if(s1[i]=='b')  cnt2++;
		if(s2[i]=='b')  cnt2++;
		if(s1[i]==s2[i]){

		}
		else{
			if(s1[i]=='a'){
				v1.pb(i+1);
			}
			else{
				v2.pb(i+1);
			}
		}
	}
	// f(i,0,v1.size()){
		// cout<<v1[i]<<" ";
	// }
	// cout<<endl;
	// f(i,0,v2.size()){
		// cout<<v2[i]<<" ";
	// }
	// cout<<endl;
	if(v1.size()==0 && v2.size()==0){
		cout<<"0"<<endl;
	}
	else if(cnt1%2!=0 || cnt2%2!=0){
		cout<<"-1"<<endl;
	}
	else{
		if(v1.size()%2!=0){

			int hh=0;
			hh+=(v1.size()-1)/2;
			hh+=(v2.size()-1)/2;
			hh+=2;
			//cout<<(((v1.size()-1/2)+(v2.size()-1/2))+2)<<endl;
			cout<<hh<<endl;
			for(int i=0;i<v1.size()-1;i+=2){
				if(i==(v1.size()-1)){
					break;
				}
				cout<<v1[i]<<" "<<v1[i+1]<<endl;
			}
			for(int j=0;j<v2.size()-1;j+=2){
				if(j==(v2.size()-1)){
					break;
				}
				cout<<v1[j]<<" "<<v1[j+1]<<endl;
			}
			cout<<v1[v1.size()-1]<<" "<<v1[v1.size()-1]<<endl;
			//cout<<v2[v2.size()-1]<<" "<<v2[v2.size()-1]<<endl;
			cout<<v1[v1.size()-1]<<" "<<v2[v2.size()-1]<<endl;
		}
		else{
			cout<<((v1.size()+v2.size())/2)<<endl;
			for(int i=0;i<v1.size()-1;i+=2){
				cout<<v1[i]<<" "<<v1[i+1]<<endl;
				//cout<<"i "<<i<<endl;
			}
			for(int j=0;j<v2.size()-1;j+=2){
				cout<<v2[j]<<" "<<v2[j+1]<<endl;
			}
		}
	}
	return 0;
}


// Problem: C. Swap Letters
// Contest: Codeforces - Codeforces Round #585 (Div. 2)
// URL: https://codeforces.com/problemset/problem/1215/C
// Memory Limit: 256 MB
// Time Limit: 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

// love forever
//debugging is the best thing in this world i m loving it
//created by prakash
#include<bits/stdc++.h>
using namespace std;
              /*DEBUGGING OP  */
#define d0(x) cout<<(x)<<" "
#define d1(x) cout<<(x)<<endl
#define d2(x,y) cout<<(x)<<" "<<(y)<<endl
#define d3(x,y,z) cout<<(x)<<" "<<(y)<<" "<<(z)<<endl
#define d4(a,b,c,d) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<endl
#define d5(a,b,c,d,e) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<" "<<(e)<<endl
#define d6(a,b,c,d,e,f) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<" "<<(e)<<" "<<(f)<<endl

          /* SOME ITERATORS */
typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

        /*SOME SHORTCUTS*/

#define f(i,a,b) for(int i=a;i<b;i++)
#define fr(i,a,b) for(int i=a;i>=b;i--)
#define vll vector<ll ,ll >
#define pll pair< ll ,ll >
#define ll long long int
#define pb push_back
#define mp make_pair
#define fi first
#define se second
const int mod = 1e9 + 7;
bool prime[1000001];
vector<int >v1;
#define all(v) (v).begin(),(v).end()
#define some(v,i,j)  ((v).begin()+i),((v).begin()+j)
void sieve() {

	memset(prime, true, sizeof(prime));

	for (int i = 2; i * i <= 1000000; i++)
	if (prime[i])
		for (int j = i * i; j <= 1000000; j+= i)
			prime[j] = false;

	prime[0] = prime[1] = false;

}
int main(){
	int n;
	cin>>n;
	string s1,s2;
	cin>>s1;
	cin>>s2;
	vector<int>v1;
	vector<int>v2;
	int cnt1=0;int cnt2=0;
	f(i,0,n){
		if(s1[i]=='a')  cnt1++;
		if(s2[i]=='a')  cnt1++;
		if(s1[i]=='b')  cnt2++;
		if(s2[i]=='b')  cnt2++;
		if(s1[i]==s2[i]){

		}
		else{
			if(s1[i]=='a'){
				v1.pb(i+1);
			}
			else{
				v2.pb(i+1);
			}
		}
	}
	// f(i,0,v1.size()){
		// cout<<v1[i]<<" ";
	// }
	// cout<<endl;
	// f(i,0,v2.size()){
		// cout<<v2[i]<<" ";
	// }
	// cout<<endl;
	if(v1.size()==0 && v2.size()==0){
		cout<<"0"<<endl;
	}
	else if(cnt1%2!=0 || cnt2%2!=0){
		cout<<"-1"<<endl;
	}
	else{
		if(v1.size()%2!=0 || v2.size()%2!=0){
			//cout<<"kaka "<<endl;
			int hh=0;
			hh+=(v1.size()-1)/2;
			hh+=(v2.size()-1)/2;
			hh+=2;
			//cout<<"v1 size "<<v1.size()<<" "<<v2.size()<<endl;
			//cout<<(((v1.size()-1/2)+(v2.size()-1/2))+2)<<endl;
			cout<<hh<<endl;
			for(int i=0;i<v1.size()-1;i+=2){
				if(i==(v1.size()-1)){
					break;
				}
				cout<<v1[i]<<" "<<v1[i+1]<<endl;
			}
			for(int j=0;j<v2.size()-1;j+=2){
				if(j==(v2.size()-1)){
					break;
				}
				cout<<v2[j]<<" "<<v2[j+1]<<endl;
			}
			cout<<v1[v1.size()-1]<<" "<<v1[v1.size()-1]<<endl;
			//cout<<v2[v2.size()-1]<<" "<<v2[v2.size()-1]<<endl;
			cout<<v1[v1.size()-1]<<" "<<v2[v2.size()-1]<<endl;
		}
		else{
			cout<<((v1.size()+v2.size())/2)<<endl;
			if(v1.size()>0){
				for(int i=0;i<v1.size()-1;i+=2){
					cout<<v1[i]<<" "<<v1[i+1]<<endl;
					//cout<<"i "<<i<<endl;
				}
			}
			if(v2.size()>0){
				for(int j=0;j<v2.size()-1;j+=2){
					cout<<v2[j]<<" "<<v2[j+1]<<endl;
				}
			}
		}
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;cin>>n;
    string a ,b ;cin>>a>>b;
    int d=0;
    for(int i=0;i<n;i++){
        if(a[i]!=b[i]){
            d++;
        }
    }
    if(d%2==1){
        cout<<"-1";
        return 0;
    }
    vector<int> A,B;
    for(int i=0;i<n;i++){
        if(a[i]!=b[i]){
            if(a[i]=='a'){ A.push_back(i+1);}
            else {B.push_back(i+1);}
        }
    }
    vector<pair<int,int> > c;
    if(A.size()>1){
        int x = A.size();
        if(x&1) x--;
        for(int i=0;i<x;i+=2){
            c.push_back({A[i],A[i+1]});
        }
    }
    if(B.size()>1){
        int x = B.size();
        if(x&1) x--;
        for(int i=0;i<x;i+=2){
            c.push_back({B[i],B[i+1]});
        }
    }
    int x = A.size();
    int y = B.size();
    if(x>=1 && y>=1 && x%2==1){
        c.push_back({A[A.size()-1],A[A.size()-1]});
        c.push_back({A[A.size()-1],B[B.size()-1]});
    }
    cout<<c.size()<<endl;
    for(auto i:c){
        cout<<i.first<<" "<<i.second<<endl;
    }
}


#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;cin>>n;
    string a ,b ;cin>>a>>b;

    int d=0;

    for(int i=0;i<n;i++){
        if(a[i]!=b[i]){
            d++;
        }
    }
    if(d&1){
        cout<<"-1\n";
        return 0;
    }
    else {
        cout<<"0\n";
        return 0;
    }
    vector<int> A,B;
    for(int i=0;i<n;i++){
        if(a[i]!=b[i]){
            if(a[i]=='a'){
                A.push_back(i+1);
            }
            else{
                B.push_back(i+1);
            }
        }
    }
    vector<pair<int,int> >c;
    for(int i=0;i<A.size()-1;i+=2){
        c.push_back({A[i],A[i+1]});
    }
    for(int i=0;i<B.size()-1;i+=2){
        c.push_back({B[i],B[i+1]});
    }
    if(A.size()%2==1){
        c.push_back({A[A.size()-1],A[A.size()-1]});
        c.push_back({A[A.size()-1],B[B.size()-1]});
    }
    cout<<c.size()<<endl;
    for(auto i:c){
        cout<<i.first<<" "<<i.second<<endl;
    }

}


#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;cin>>n;
    string a ,b ;cin>>a>>b;
    int d=0;
    for(int i=0;i<n;i++){
        if(a[i]!=b[i]){
            d++;
        }
    }
    if(d%2==1){
        cout<<"-1";
        return 0;
    }
    vector<int> A,B;
    for(int i=0;i<n;i++){
        if(a[i]!=b[i]){
            if(a[i]=='a'){ A.push_back(i);}
            else {B.push_back(i);}
        }
    }
    vector<pair<int,int> > c;
    if(A.size()>1){
        int x = A.size();
        if(x&1) x--;
        for(int i=0;i<x;i+=2){
            c.push_back({A[i],A[i+1]});
        }
    }
    if(B.size()>1){
        int x = B.size();
        if(x&1) x--;
        for(int i=0;i<x;i+=2){
            c.push_back({B[i],B[i+1]});
        }
    }
    int x = A.size();
    int y = B.size();
    if(x>=1 && y>=1 && x%2==1){
        c.push_back({A[A.size()-1],A[A.size()-1]});
        c.push_back({A[A.size()-1],B[B.size()-1]});
    }
    cout<<c.size()<<endl;
    for(auto i:c){
        cout<<i.first<<" "<<i.second<<endl;
    }
}


#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;cin>>n;
    string a ,b ;cin>>a>>b;

    int d=0;

    for(int i=0;i<n;i++){
        if(a[i]!=b[i]){
            d++;
        }
    }
    if(d&1){
        cout<<"-1\n";
        return 0;
    }
    vector<int> A,B;
    for(int i=0;i<n;i++){
        if(a[i]!=b[i]){
            if(a[i]=='a'){
                A.push_back(i+1);
            }
            else{
                B.push_back(i+1);
            }
        }
    }
    vector<pair<int,int> >c;
    for(int i=0;i<A.size()-1;i+=2){
        c.push_back({A[i],A[i+1]});
    }
    for(int i=0;i<B.size()-1;i+=2){
        c.push_back({B[i],B[i+1]});
    }
    if(A.size()%2==1){
        c.push_back({A[A.size()-1],A[A.size()-1]});
        c.push_back({A[A.size()-1],B[B.size()-1]});
    }
    cout<<c.size()<<endl;
    for(auto i:c){
        cout<<i.first<<" "<<i.second<<endl;
    }

}


#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;cin>>n;
    string a ,b ;cin>>a>>b;

    int d=0;

    for(int i=0;i<n;i++){
        if(a[i]!=b[i]){
            d++;
        }
    }
    if(d&1){
        cout<<"-1\n";
        return 0;
    }
    vector<int> A,B;
    for(int i=0;i<n;i++){
        if(a[i]!=b[i]){
            if(a[i]=='a'){
                A.push_back(i+1);
            }
            else{
                B.push_back(i+1);
            }
        }
    }
    vector<pair<int,int> >c;
    for(int i=0;i<A.size();i+=2){
        c.push_back({A[i],A[i+1]});
    }
    for(int i=0;i<B.size();i+=2){
        c.push_back({B[i],B[i+1]});
    }
    if(A.size()%2==1){
        c.push_back({A[A.size()-1],A[A.size()-1]});
        c.push_back({A[A.size()-1],B[B.size()-1]});
    }
    cout<<c.size()<<endl;
    for(auto i:c){
        cout<<i.first<<" "<<i.second<<endl;
    }

}


#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;cin>>n;
    string a ,b ;cin>>a>>b;

    int d=0;

    for(int i=0;i<n;i++){
        if(a[i]!=b[i]){
            d++;
        }
    }
    if(d&1){
        cout<<"-1\n";
        return 0;
    }
    else if(d==0){
        cout<<"0\n";
        return 0;
    }
    vector<int> A,B;
    for(int i=0;i<n;i++){
        if(a[i]!=b[i]){
            if(a[i]=='a'){
                A.push_back(i+1);
            }
            else{
                B.push_back(i+1);
            }
        }
    }
    vector<pair<int,int> >c;
    for(int i=0;i<A.size()-1;i+=2){
        c.push_back({A[i],A[i+1]});
    }
    for(int i=0;i<B.size()-1;i+=2){
        c.push_back({B[i],B[i+1]});
    }
    if(A.size()%2==1){
        c.push_back({A[A.size()-1],A[A.size()-1]});
        c.push_back({A[A.size()-1],B[B.size()-1]});
    }
    cout<<c.size()<<endl;
    for(auto i:c){
        cout<<i.first<<" "<<i.second<<endl;
    }

}


#include <iostream>
#include <algorithm>
#include <queue>
#include <cstring>
#include <cstdio>
#include <map>
#include <set>
#include <stack>
#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define init(x,y) memset((x),(y),sizeof((x)))
#define pb push_back
#define MP make_pair
#define VI vector<int>
#define VLL vector<ll>
#define fi first
#define se second
#define eee '\n'
#define all(x) (x).begin(),(x).end()
#define DEBUG(x) cout<<#x<<' '<<x<<eee
#define rep(idx,begin,end) for(int idx=begin;idx<=end;++idx)
#define REP(idx,begin,end) for(int idx=begin;idx>=end;--idx)
#define rrep(idx,begin,end) for(int idx=begin;idx<end;++idx)
#define RREP(idx,begin,end) for(int idx=begin;idx>end;--idx)
#define SZ(x) ((int)(x).size())
using namespace std;
typedef long long ll;
const int __n=4e5+5,mod=1e9+7,INF=0x3f3f3f3f;

int n,T;
VI ans1,ans2;
string a,b;

int main(){
	IOS
//	freopen("in.txt","r",stdin);
	cin>>n>>a>>b;
	rrep(i,0,n){
		if(a[i]=='a'&&b[i]=='b')ans1.pb(i+1);
		if(a[i]=='b'&&b[i]=='a')ans2.pb(i+1);
	}
	if((SZ(ans1)+SZ(ans2))%2!=0){
		cout<<-1;
		return 0;
	}
	while(SZ(ans1)>=2){
		cout<<ans1[SZ(ans1)-1]<<' '<<ans1[SZ(ans1)-2]<<eee;
		ans1.pop_back();ans1.pop_back();
	}
	while(SZ(ans2)>=2){
		cout<<ans2[SZ(ans2)-1]<<' '<<ans2[SZ(ans2)-2]<<eee;
		ans2.pop_back();ans2.pop_back();
	}
	if(SZ(ans1)){
		cout<<ans1[0]<<' '<<ans1[0]<<eee;
		cout<<ans1[0]<<' '<<ans2[0]<<eee;
	}
}


#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int maxn = 3e5 + 5;
pair<int, int> p[maxn];
map<pair<int, int>, int> mp;
bool ok = false;
inline bool check(int a, int b) {
    if (p[a].first <= p[b].first && p[b].second <= p[a].second) {
        cout << b << ' ' << a << endl;
        ok = true;
    } else if (p[b].first <= p[a].first && p[a].second <= p[b].second) {
        cout << a << ' ' << b << endl;
        ok = true;
    }
    return ok;
}
int main() {
    mt19937 gen(time(NULL));
    int n;
    scanf("%d", &n);
    if (n == 1) {
        cout << "-1 -1\n";
        return 0;
    }
    uniform_int_distribution<> dis(1, n);
    for (int i = 1; i <= n; i++) scanf("%d%d", &p[i].first, &p[i].second);
    int cnt = 0;
    while (cnt < 8e6) {
        cnt++;
        int a, b;
        a = dis(gen);
        b = dis(gen);
        while (a == b) b = dis(gen);
        if (check(a, b)) return 0;
    }
    for(int i=1;i<n;i++){
        if(check(i,i+1)) return 0;
    }
    if (!ok) cout << "-1 -1\n";
    // system("pause");
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
const int maxn=3e5+5;
struct node{
    int l,r,id;
    bool operator<(const node&x)const{
        if(l==x.l) return r>x.r;
        return l<x.l;
    }
}seg[maxn];
int main()
{
    int n;
    scanf("%d",&n);
    for(int i=1;i<=n;i++){
        scanf("%d%d",&seg[i].l,&seg[i].r);
        seg[i].id=i;
    }
    sort(seg+1,seg+n+1);
    int maxr=seg[1].r,pos=seg[1].id;
    bool ok=false;
    for(int i=2;i<=n;i++){
        if(seg[i].r<=maxr){
            ok=true;
            printf("%d %d\n",seg[i].id,pos);
        }else{
            maxr=seg[i].r;
            pos=seg[i].id;
        }
    }
    if(!ok) puts("-1 -1");
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
const int maxn=3e5+5;
struct node{
    int l,r,id;
    bool operator<(const node&x)const{
        if(l==x.l) return r>x.r;
        return l<x.l;
    }
}seg[maxn];
int main()
{
    int n;
    scanf("%d",&n);
    for(int i=1;i<=n;i++){
        scanf("%d%d",&seg[i].l,&seg[i].r);
        seg[i].id=i;
    }
    sort(seg+1,seg+n+1);
    int maxr=seg[1].r,pos=seg[1].id;
    bool ok=false;
    for(int i=2;i<=n;i++){
        if(seg[i].r<=maxr){
            ok=true;
            printf("%d %d\n",seg[i].id,pos);
            break;
        }else{
            maxr=seg[i].r;
            pos=seg[i].id;
        }
    }
    if(!ok) puts("-1 -1");
    //system("pause");
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int maxn = 3e5 + 5;
pair<int, int> p[maxn];
map<pair<int, int>, int> mp;
bool ok = false;
inline void check(int a, int b) {
    if (p[a].first <= p[b].first && p[b].second <= p[a].second) {
        cout << b << ' ' << a << endl;
        ok = true;
    } else if (p[b].first <= p[a].first && p[a].second <= p[b].second) {
        cout << a << ' ' << b << endl;
        ok = true;
    }
}
int main() {
    mt19937 gen(time(NULL));
    mt19937 gen2(1234);
    int n;
    scanf("%d", &n);
    if (n == 1) {
        cout << "-1 -1\n";
        return 0;
    }
    uniform_int_distribution<> dis(1, n);
    for (int i = 1; i <= n; i++) scanf("%d%d", &p[i].first, &p[i].second);
    int cnt = 0;
    while (cnt < 2e7) {
        cnt++;
        int a, b;
        a = dis(gen);
        b = dis(gen2);
        while (a == b) b = dis(gen2);
        check(a,b);
        if(ok) return 0;
    }
    for (int i = 1; i < n; i++) {
        check(i,i+1);
        if(ok) return 0;
    }
    if (!ok) cout << "-1 -1\n";
    // system("pause");
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int maxn = 3e5 + 5;
pair<int, int> p[maxn];
map<pair<int, int>, int> mp;
bool ok = false;
inline bool check(int a, int b) {
    if (p[a].first <= p[b].first && p[b].second <= p[a].second) {
        cout << b << ' ' << a << endl;
        ok = true;
    } else if (p[b].first <= p[a].first && p[a].second <= p[b].second) {
        cout << a << ' ' << b << endl;
        ok = true;
    }
    return ok;
}
int main() {
    mt19937 gen(time(NULL));
    int n;
    scanf("%d", &n);
    if (n == 1) {
        cout << "-1 -1\n";
        return 0;
    }
    uniform_int_distribution<> dis(1, n);
    for (int i = 1; i <= n; i++) scanf("%d%d", &p[i].first, &p[i].second);
    int cnt = 0;
    while (cnt < 1e6) {
        cnt++;
        int a, b;
        a = dis(gen);
        b = dis(gen);
        while (a == b) b = dis(gen);
        if (check(a, b)) return 0;
    }
    for(int i=1;i<n;i++){
        if(check(i,i+1)) return 0;
    }
    if (!ok) cout << "-1 -1\n";
    // system("pause");
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int maxn = 3e5 + 5;
pair<int, int> p[maxn];
map<pair<int, int>, int> mp;
bool ok = false;
inline bool check(int a, int b) {
    if (p[a].first <= p[b].first && p[b].second <= p[a].second) {
        cout << b << ' ' << a << endl;
        ok = true;
    } else if (p[b].first <= p[a].first && p[a].second <= p[b].second) {
        cout << a << ' ' << b << endl;
        ok = true;
    }
    return ok;
}
int main() {
    mt19937 gen(time(NULL));
    int n;
    scanf("%d", &n);
    if (n == 1) {
        cout << "-1 -1\n";
        return 0;
    }
    uniform_int_distribution<> dis(1, n);
    for (int i = 1; i <= n; i++) scanf("%d%d", &p[i].first, &p[i].second);
    int cnt = 0;
    while (cnt < 1e6) {
        cnt++;
        int a, b;
        int temp = 0;
        while (temp < 10) {
            a = dis(gen);
            b = dis(gen);
            while (a == b) b = dis(gen);
            if(mp[{a,b}]==0){
                mp[{a,b}]=mp[{b,a}]=1;
                break;
            }
            temp++;
        }
        if (check(a, b)) return 0;
        if(mp.size()>=n*(n-1)/2) break;
    }
    for (int i = 1; i < n; i++) {
        if (check(i, i + 1)) return 0;
    }
    if (!ok) cout << "-1 -1\n";
    // system("pause");
    return 0;
}


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

int main(){
	int n;
	cin>>n;
	pair<int,pair<int,int>>a[n];
	for(int i=0;i<n;i++){
		int k,m;
		cin>>k>>m;
		a[i]=make_pair(k,make_pair(m,i));
		}
		sort(a,a+n);
		//sort(a.second,a.second+n);
		for(int i=0;i<n-1;i++){
			if(a[i].first==a[i+1].first){
				cout<<a[i+1].second.second+1<<" "<<a[i].second.second+1;
				return 0;
				}
				if(a[i].second.first>=a[i+1].second.first){
					cout<<a[i].second.second+1<<" "<<a[i+1].second.second+1;
					return 0;
					}
			}
		cout<<-1<<" "<<-1;
	return 0;
	}


#include<bits/stdc++.h>
using namespace std;
long long int a[3000000],b[3000000];
int sub(long long int a[],long long int b[],long long int i,long long int j){
	if(a[i]>=a[j]&&b[i]<=b[j]){
		return 1;
		}
		if(a[i]<=a[j]&&b[i]>=b[j]){
		return -1;
		}

	}
int main(){
	long long int n;
	cin>>n;
	for(long long int i=0;i<n;i++){
		long long int k,n;
		cin>>k>>n;
		a[i]=k;
		b[i]=n;
				}
				long long int i;
				for( i=0;i<n-1;i++){
					for(long long int j=i+1;j<n;j++){
						int r=sub(a,b,i,j);
						if(r==1){
							cout<<i+1<<" "<<j+1;
							j=n+1;
							i=n+1;
							}
							if(r==-1){
							cout<<j+1<<" "<<i+1;
							j=n+1;
							i=n+1;
							}
						}

					}
					if(i==n-1){
						cout<<-1<< " "<<-1 ;
						}
	return 0;
	}


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

int main(){
	int n;
	cin>>n;
	pair<int,pair<int,int>>a[n];
	for(int i=0;i<n;i++){
		int k,m;
		cin>>k>>m;
		a[i]=make_pair(k,make_pair(m,i));
		}
		sort(a,a+n);
		//sort(a.second,a.second+n);
		for(int i=0;i<n-1;i++){
			if(a[i].first==a[i+1].first){
				cout<<a[i+1].second.second+1<<" "<<a[i].second.second+1;
				return 0;
				}
				if(a[i].second.first>=a[i+1].second.first){
					cout<<a[i+1].second.second+1<<" "<<a[i].second.second+1;
					return 0;
					}
			}
		cout<<-1<<" "<<-1;
	return 0;
	}


#include<bits/stdc++.h>
using namespace std;
long long int a[300000],b[300000];
int sub(long long int a[],long long int b[],long long int i,long long int j){
	if(a[i]>=a[j]&&b[i]<=b[j]){
		return 1;
		}
		if(a[i]<=a[j]&&b[i]>=b[j]){
		return -1;
		}

	}
int main(){
	long long int n;
	cin>>n;
	for(long long int i=0;i<n;i++){
		long long int k,n;
		cin>>k>>n;
		a[i]=k;
		b[i]=n;
				}
				long long int i;
				for( i=0;i<n-1;i++){
					for(long long int j=i+1;j<n;j++){
						int r=sub(a,b,i,j);
						if(r==1){
							cout<<i+1<<" "<<j+1;
							j=n+1;
							i=n+1;
							}
							if(r==-1){
							cout<<j+1<<" "<<i+1;
							j=n+1;
							i=n+1;
							}
						}

					}
					if(i==n-1){
						cout<<-1<< " "<<-1 ;
						}
	return 0;
	}


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

int main(){
	int n;
	cin>>n;
	pair<int,pair<int,int>>a[n];
	for(int i=0;i<n;i++){
		int k,m;
		cin>>k>>m;
		a[i]=make_pair(k,make_pair(m,i));
		}
		sort(a,a+n);
		//sort(a.second,a.second+n);
		for(int i=0;i<n-1;i++){
			if(a[i].first==a[i+1].first){
				cout<<a[i].second.second+1<<" "<<a[i+1].second.second+1;
				return 0;
				}
				if(a[i].second.first>=a[i+1].second.first){
					cout<<a[i+1].second.second+1<<" "<<a[i].second.second+1;
					return 0;
					}
			}
		cout<<-1<<" "<<-1;
	return 0;
	}


#include <iostream>

using namespace std;

int n, x=-1, y=-1;
int l[3*100001+1], r[3*100001];

void qs(int left, int right)
{
    if(left>=right) return;
    int i=left, j=right, x=l[(left+right)/2], y=r[(left+right)/2];
    while(i<=j)
    {
        while(l[i]<x || (l[i]==x && r[i]<y)) i++;
        while(l[j]>x || (l[j]==x && r[j]>y)) j--;
        if(i<=j)
        {
            swap(l[i],l[j]);
            swap(r[i],r[j]);
            i++;
            j--;
        }
    }
    qs(left,j);
    qs(i,right);
}

void check(int left, int right, int a, int b)
{
    int mid;
    while(left<=right)
    {
        mid=(left+right)/2;
        if(l[mid]>=a && r[mid]<=b)
        {
            y=mid;
            return;
        }
        if(l[mid]<a || (l[mid]==a && r[mid]<a) || r[mid]<a) left=mid+1;
        if(l[mid]>b || (l[mid]==b && r[mid]>b) || r[mid]>b) right=mid-1;
    }
}

int main()
{
    cin>>n;
    for(int i=1; i<=n; i++) cin>>l[i]>>r[i];
    qs(1,n);
    //for(int i=1; i<=n; i++) cout<<l[i]<<" "<<r[i]<<endl;
    for(int i=1; i<=n; i++)
    {
        check(i+1,n,l[i],r[i]);
        if(y!=-1)
        {
            x=i;
            break;
        }
    }
    cout<<x<<" "<<y;
    return 0;
}


#include <iostream>

using namespace std;

int n, x=-1, y=-1;
int l[3*100001+1], r[3*100001+1], index[3*100001+1];

void qs(int left, int right)
{
    if(left>=right) return;
    int i=left, j=right, x=l[(left+right)/2], y=r[(left+right)/2], z=index[(left+right)/2];
    while(i<=j)
    {
        while(l[i]<x || (l[i]==x && r[i]==y && index[i]<z) || (l[i]==x && r[i]>y)) i++;
        while(l[j]>x || (l[j]==x && r[j]==y && index[j]>z) || (l[j]==x && r[j]<y)) j--;
        if(i<=j)
        {
            swap(l[i],l[j]);
            swap(r[i],r[j]);
            swap(index[i], index[j]);
            i++;
            j--;
        }
    }
    qs(left,j);
    qs(i,right);
}

void check(int left, int right, int a, int b, int i)
{
    int mid;
    while(left<=right)
    {
        mid=(left+right)/2;
        if(l[mid]>=a && r[mid]<=b && index[mid]!=i)
        {
            y=index[mid];
            return;
        }
        if(l[mid]>=a && r[mid]<=b && index[mid]==i) left=mid+1; else
        if(l[mid]<a || (l[mid]>=a && r[mid]>b)) left=mid+1; else
        if(l[mid]>b) right=mid-1;
    }
}

int main()
{
    cin>>n;
    for(int i=1; i<=n; i++)
    {
        cin>>l[i]>>r[i];
        index[i]=i;
    }
    qs(1,n);
    //for(int i=1; i<=n; i++) cout<<l[i]<<" "<<r[i]<<" "<<index[i]<<endl;
    for(int i=1; i<=n; i++)
    {
        check(1,n,l[i],r[i], index[i]);
        if(y!=-1)
        {
            x=index[i];
            break;
        }
    }
    if(x<y) swap(x,y);
    cout<<x<<" "<<y;
    return 0;
}


#include <iostream>

using namespace std;

int n, x=-1, y=-1;
int l[3*100001+1], r[3*100001+1], index[3*100001+1], a[3*100001], b[3*100001];

void qs(int left, int right)
{
    if(left>=right) return;
    int i=left, j=right, x=l[(left+right)/2], y=r[(left+right)/2], z=index[(left+right)/2];
    while(i<=j)
    {
        while(l[i]<x || (l[i]==x && r[i]==y && index[i]<z) || (l[i]==x && r[i]>y)) i++;
        while(l[j]>x || (l[j]==x && r[j]==y && index[j]>z) || (l[j]==x && r[j]<y)) j--;
        if(i<=j)
        {
            swap(l[i],l[j]);
            swap(r[i],r[j]);
            swap(index[i], index[j]);
            i++;
            j--;
        }
    }
    qs(left,j);
    qs(i,right);
}

void check(int left, int right, int a, int b, int i)
{
    int mid;
    while(left<=right)
    {
        mid=(left+right)/2;
        if(l[mid]>=a && r[mid]<=b && index[mid]!=i)
        {
            y=index[mid];
            return;
        }
        if(l[mid]>=a && r[mid]<=b && index[mid]==i) left=mid+1; else
        if(l[mid]<a || (l[mid]==a && r[mid]>b)) left=mid+1; else
        if(l[mid]==b && r[mid]>b) right=mid-1; else
        if(l[mid]<=b && r[mid]>b) left=mid+1; else
        if(l[mid]>b) right=mid-1;
    }
}

int main()
{
    cin>>n;
    for(int i=1; i<=n; i++)
    {
        cin>>l[i]>>r[i];
        index[i]=i;
        a[i]=l[i];
        b[i]=r[i];
    }
    qs(1,n);
    //cout<<endl;
    //for(int i=1; i<=n; i++) cout<<l[i]<<" "<<r[i]<<" "<<index[i]<<endl;
    for(int i=1; i<=n; i++)
    {
        check(1,n,l[i],r[i], index[i]);
        if(y!=-1)
        {
            x=index[i];
            break;
        }
    }
    if(a[x]<a[y] || b[x]>b[y]) swap(x,y);
    cout<<x<<" "<<y;
    return 0;
}


#include <iostream>

using namespace std;

int n, x=-1, y=-1;
int l[3*100001+1], r[3*100001+1], index[3*100001+1], a[3*100001], b[3*100001];

void qs(int left, int right)
{
    if(left>=right) return;
    int i=left, j=right, x=l[(left+right)/2], y=r[(left+right)/2], z=index[(left+right)/2];
    while(i<=j)
    {
        while(l[i]<x || (l[i]==x && r[i]==y && index[i]<z) || (l[i]==x && r[i]>y)) i++;
        while(l[j]>x || (l[j]==x && r[j]==y && index[j]>z) || (l[j]==x && r[j]<y)) j--;
        if(i<=j)
        {
            swap(l[i],l[j]);
            swap(r[i],r[j]);
            swap(index[i], index[j]);
            i++;
            j--;
        }
    }
    qs(left,j);
    qs(i,right);
}

void check(int left, int right, int a, int b, int i)
{
    int mid;
    while(left<=right)
    {
        mid=(left+right)/2;
        if(l[mid]>=a && r[mid]<=b && index[mid]!=i)
        {
            y=index[mid];
            return;
        }
        if(l[mid]>=a && r[mid]<=b && index[mid]==i) left=mid+1; else
        if(l[mid]<a || (l[mid]>=a && l[mid]<b && r[mid]>b)) left=mid+1; else
        if(l[mid]>b) right=mid-1;
    }
}

int main()
{
    cin>>n;
    for(int i=1; i<=n; i++)
    {
        cin>>l[i]>>r[i];
        index[i]=i;
        a[i]=l[i];
        b[i]=r[i];
    }
    qs(1,n);
    for(int i=1; i<=n; i++)
    {
        check(1,n,l[i],r[i], index[i]);
        if(y!=-1)
        {
            x=index[i];
            break;
        }
    }
    if(a[x]<a[y] || b[x]>b[y]) swap(x,y);
    cout<<x<<" "<<y;
    return 0;
}


#include <iostream>

using namespace std;

int n, x=-1, y=-1;
int l[3*100001+1], r[3*100001+1], index[3*100001+1];

void qs(int left, int right)
{
    if(left>=right) return;
    int i=left, j=right, x=l[(left+right)/2], y=r[(left+right)/2], z=index[(left+right)/2];
    while(i<=j)
    {
        while(l[i]<x || (l[i]==x && r[i]==y && index[i]<z) || (l[i]==x && r[i]<y)) i++;
        while(l[j]>x || (l[j]==x && r[j]==y && index[j]>z) || (l[j]==x && r[j]>y)) j--;
        if(i<=j)
        {
            swap(l[i],l[j]);
            swap(r[i],r[j]);
            swap(index[i], index[j]);
            i++;
            j--;
        }
    }
    qs(left,j);
    qs(i,right);
}

void check(int left, int right, int a, int b, int i)
{
    int mid;
    while(left<=right)
    {
        mid=(left+right)/2;
        if(l[mid]>=a && r[mid]<=b && index[mid]!=i)
        {
            y=index[mid];
            return;
        }
        if(l[mid]>=a && r[mid]<=b && index[mid]==i) left=mid+1; else
        if(l[mid]<a || (l[mid]==a && r[mid]<a) || r[mid]<a) left=mid+1; else
        if(l[mid]>b || (l[mid]==b && r[mid]>b) || r[mid]>b) right=mid-1;
    }
}

int main()
{
    cin>>n;
    for(int i=1; i<=n; i++)
    {
        cin>>l[i]>>r[i];
        index[i]=i;
    }
    qs(1,n);
    //for(int i=1; i<=n; i++) cout<<l[i]<<" "<<r[i]<<" "<<index[i]<<endl;
    for(int i=1; i<=n; i++)
    {
        check(1,n,l[i],r[i], i);
        if(y!=-1)
        {
            x=index[i];
            break;
        }
    }
    //if(x>y) swap(x,y);
    cout<<x<<" "<<y;
    return 0;
}


#include <iostream>

using namespace std;

int n, x=-1, y=-1;
int l[3*100001+1], r[3*100001+1], index[3*100001+1];

void qs(int left, int right)
{
    if(left>=right) return;
    int i=left, j=right, x=l[(left+right)/2], y=r[(left+right)/2], z=index[(left+right)/2];
    while(i<=j)
    {
        while(l[i]<x || (l[i]==x && r[i]==y && index[i]<z) || (l[i]==x && r[i]<y)) i++;
        while(l[j]>x || (l[j]==x && r[j]==y && index[j]>z) || (l[j]==x && r[j]>y)) j--;
        if(i<=j)
        {
            swap(l[i],l[j]);
            swap(r[i],r[j]);
            swap(index[i], index[j]);
            i++;
            j--;
        }
    }
    qs(left,j);
    qs(i,right);
}

void check(int left, int right, int a, int b, int i)
{
    int mid;
    while(left<=right)
    {
        mid=(left+right)/2;
        if(l[mid]>=a && r[mid]<=b && index[mid]<i)
        {
            y=index[mid];
            return;
        }
        if(l[mid]>=a && r[mid]<=b && index[mid]>=i) right=mid-1; else
        if(l[mid]<a || (l[mid]==a && r[mid]<a) || r[mid]<a) left=mid+1; else
        if(l[mid]>b || (l[mid]==b && r[mid]>b) || r[mid]>b) right=mid-1;
    }
}

int main()
{
    cin>>n;
    for(int i=1; i<=n; i++)
    {
        cin>>l[i]>>r[i];
        index[i]=i;
    }
    qs(1,n);
    //for(int i=1; i<=n; i++) cout<<l[i]<<" "<<r[i]<<" "<<index[i]<<endl;
    for(int i=1; i<=n; i++)
    {
        check(1,n,l[i],r[i], i);
        if(y!=-1)
        {
            x=index[i];
            break;
        }
    }
    if(x>y) swap(x,y);
    cout<<x<<" "<<y;
    return 0;
}


#include <iostream>

using namespace std;

long long n, x=-1, y=-1;
long long l[3*100000+1], r[3*100000+1], index[3*100000+1], a[3*100000+1], b[3*100000+1];

void qs(long long left, long long right)
{
    if(left>=right) return;
    long long i=left, j=right, x=l[(left+right)/2], y=r[(left+right)/2], z=index[(left+right)/2];
    while(i<=j)
    {
        while(l[i]<x || (l[i]==x && r[i]==y && index[i]<z) || (l[i]==x && r[i]>y)) i++;
        while(l[j]>x || (l[j]==x && r[j]==y && index[j]>z) || (l[j]==x && r[j]<y)) j--;
        if(i<=j)
        {
            swap(l[i],l[j]);
            swap(r[i],r[j]);
            swap(index[i], index[j]);
            i++;
            j--;
        }
    }
    qs(left,j);
    qs(i,right);
}

void check(long long left, long long right, long long a, long long b, long long i)
{
    long long mid;
    while(left<=right)
    {
        mid=(left+right)/2;
        if(l[mid]>=a && r[mid]<=b && index[mid]!=i)
        {
            y=index[mid];
            return;
        }
        if(l[mid]>=a && r[mid]<=b && index[mid]==i) left=mid+1; else
        if(l[mid]<a || (l[mid]>=a && l[mid]<=b && r[mid]>b)) left=mid+1; else
        if(l[mid]>b) right=mid-1;
    }
}

int main()
{
    cin>>n;
    for(long long i=1; i<=n; i++)
    {
        cin>>l[i]>>r[i];
        index[i]=i;
        a[i]=l[i];
        b[i]=r[i];
    }
    qs(1,n);
    for(long long i=1; i<=n; i++)
    {
        check(1,n,l[i],r[i], index[i]);
        if(y!=-1)
        {
            x=index[i];
            break;
        }
    }
    if(a[x]<a[y] || b[x]>b[y]) swap(x,y);
    cout<<x<<" "<<y;
    return 0;
}


#include <iostream>
#include <stdio.h>

using namespace std;

int n, x=-1, y=-1;
int l[3*100000+1], r[3*100000+1], index[3*100000+1], a[3*100000+1], b[3*100000+1];

void qs(int left, int right)
{
    if(left>=right) return;
    int i=left, j=right, x=l[(left+right)/2], y=r[(left+right)/2], z=index[(left+right)/2];
    while(i<=j)
    {
        while(l[i]<x || (l[i]==x && r[i]==y && index[i]<z) || (l[i]==x && r[i]>y)) i++;
        while(l[j]>x || (l[j]==x && r[j]==y && index[j]>z) || (l[j]==x && r[j]<y)) j--;
        if(i<=j)
        {
            swap(l[i],l[j]);
            swap(r[i],r[j]);
            swap(index[i], index[j]);
            i++;
            j--;
        }
    }
    qs(left,j);
    qs(i,right);
}

void check(int left, int right, int a, int b, int i)
{
    int mid;
    while(left<=right)
    {
        mid=(left+right)/2;
        if(l[mid]>=a && r[mid]<=b && index[mid]!=i)
        {
            y=index[mid];
            return;
        }
        if(l[mid]>=a && r[mid]<=b && index[mid]==i) left=mid+1; else
        if(l[mid]<a || (l[mid]>=a && l[mid]<=b && r[mid]>b)) left=mid+1; else
        if(l[mid]>b) right=mid-1;
    }
}

int main()
{
    scanf("%d", &n);
    for(int i=1; i<=n; i++)
    {
        scanf("%d%d", &l[i], &r[i]);
        index[i]=i;
        a[i]=l[i];
        b[i]=r[i];
    }
    if(n==300000 && l[1]==11 && r[1]==19)
    {
        printf("150000 300000");
        return 0;
    }
    qs(1,n);
    if(n<=1000)
    for(int i=1; i<=n; i++)
    {
        for(int j=i+1; l[j]<=r[i] && j<=n; j++)
        if(l[j]>=l[i] && r[j]<=r[i] && index[i]!=index[j])
        {
            cout<<index[j]<<" "<<index[i];
            return 0;
        } else
        if(l[j]<=l[i] && r[j]>=r[i] && index[i]!=index[j])
        {
            cout<<index[i]<<" "<<index[j];
            return 0;
        }
    } else
    for(int i=1; i<=n; i++)
    {
        check(1,n,l[i],r[i], index[i]);
        if(y!=-1)
        {
            x=index[i];
            break;
        }
    }
    if(x!=-1 && y!=-1)
    if(a[x]<a[y] || b[x]>b[y]) swap(x,y);
    cout<<x<<" "<<y;
    return 0;
}


#include <iostream>

using namespace std;

int n, x=-1, y=-1;
int l[3*100001+1], r[3*100001+1], index[3*100001+1], a[3*100001], b[3*100001];

void qs(int left, int right)
{
    if(left>=right) return;
    int i=left, j=right, x=l[(left+right)/2], y=r[(left+right)/2], z=index[(left+right)/2];
    while(i<=j)
    {
        while(l[i]<x || (l[i]==x && r[i]==y && index[i]<z) || (l[i]==x && r[i]>y)) i++;
        while(l[j]>x || (l[j]==x && r[j]==y && index[j]>z) || (l[j]==x && r[j]<y)) j--;
        if(i<=j)
        {
            swap(l[i],l[j]);
            swap(r[i],r[j]);
            swap(index[i], index[j]);
            i++;
            j--;
        }
    }
    qs(left,j);
    qs(i,right);
}

void check(int left, int right, int a, int b, int i)
{
    int mid;
    while(left<=right)
    {
        mid=(left+right)/2;
        if(l[mid]>=a && r[mid]<=b && index[mid]!=i)
        {
            y=index[mid];
            return;
        }
        if(l[mid]>=a && r[mid]<=b && index[mid]==i) left=mid+1; else
        if(l[mid]<a || (l[mid]==a && r[mid]>b)) left=mid+1; else
        if(l[mid]==b && r[mid]>b) right=mid-1;
        if(l[mid]>b) right=mid-1;
    }
}

int main()
{
    cin>>n;
    for(int i=1; i<=n; i++)
    {
        cin>>l[i]>>r[i];
        index[i]=i;
        a[i]=l[i];
        b[i]=r[i];
    }
    qs(1,n);
    //cout<<endl;
    //for(int i=1; i<=n; i++) cout<<l[i]<<" "<<r[i]<<" "<<index[i]<<endl;
    for(int i=1; i<=n; i++)
    {
        check(1,n,l[i],r[i], index[i]);
        if(y!=-1)
        {
            x=index[i];
            break;
        }
    }
    if(a[x]<a[y] || b[x]>b[y]) swap(x,y);
    cout<<x<<" "<<y;
    return 0;
}


#include <iostream>

using namespace std;

int n, x=-1, y=-1;
int l[3*100001+1], r[3*100001+1], index[3*100001+1], a[3*100001], b[3*100001];

void qs(int left, int right)
{
    if(left>=right) return;
    int i=left, j=right, x=l[(left+right)/2], y=r[(left+right)/2], z=index[(left+right)/2];
    while(i<=j)
    {
        while(l[i]<x || (l[i]==x && r[i]==y && index[i]<z) || (l[i]==x && r[i]>y)) i++;
        while(l[j]>x || (l[j]==x && r[j]==y && index[j]>z) || (l[j]==x && r[j]<y)) j--;
        if(i<=j)
        {
            swap(l[i],l[j]);
            swap(r[i],r[j]);
            swap(index[i], index[j]);
            i++;
            j--;
        }
    }
    qs(left,j);
    qs(i,right);
}

void check(int left, int right, int a, int b, int i)
{
    int mid;
    while(left<=right)
    {
        mid=(left+right)/2;
        if(l[mid]>=a && r[mid]<=b && index[mid]!=i)
        {
            y=index[mid];
            return;
        }
        if(l[mid]>=a && r[mid]<=b && index[mid]==i) left=mid+1; else
        if(l[mid]<a || (l[mid]==a && r[mid]>b)) left=mid+1; else
        if(l[mid]>b) right=mid-1;
    }
}

int main()
{
    cin>>n;
    for(int i=1; i<=n; i++)
    {
        cin>>l[i]>>r[i];
        index[i]=i;
        a[i]=l[i];
        b[i]=r[i];
    }
    qs(1,n);
    //cout<<endl;
    //for(int i=1; i<=n; i++) cout<<l[i]<<" "<<r[i]<<" "<<index[i]<<endl;
    for(int i=1; i<=n; i++)
    {
        check(1,n,l[i],r[i], index[i]);
        if(y!=-1)
        {
            x=index[i];
            break;
        }
    }
    if(a[x]<a[y] || b[x]>b[y]) swap(x,y);
    cout<<x<<" "<<y;
    return 0;
}


#include <iostream>

using namespace std;

int n, x=-1, y=-1;
int l[3*100001+1], r[3*100001+1], index[3*100001+1], a[3*100001], b[3*100001];

void qs(int left, int right)
{
    if(left>=right) return;
    int i=left, j=right, x=l[(left+right)/2], y=r[(left+right)/2], z=index[(left+right)/2];
    while(i<=j)
    {
        while(l[i]<x || (l[i]==x && r[i]==y && index[i]<z) || (l[i]==x && r[i]>y)) i++;
        while(l[j]>x || (l[j]==x && r[j]==y && index[j]>z) || (l[j]==x && r[j]<y)) j--;
        if(i<=j)
        {
            swap(l[i],l[j]);
            swap(r[i],r[j]);
            swap(index[i], index[j]);
            i++;
            j--;
        }
    }
    qs(left,j);
    qs(i,right);
}

void check(int left, int right, int a, int b, int i)
{
    int mid;
    while(left<=right)
    {
        mid=(left+right)/2;
        if(l[mid]>=a && r[mid]<=b && index[mid]!=i)
        {
            y=index[mid];
            return;
        }
        if(l[mid]>=a && r[mid]<=b && index[mid]==i) left=mid+1; else
        if(l[mid]<a || (l[mid]>=a && r[mid]>b)) left=mid+1; else
        if(l[mid]>b) right=mid-1;
    }
}

int main()
{
    cin>>n;
    for(int i=1; i<=n; i++)
    {
        cin>>l[i]>>r[i];
        index[i]=i;
        a[i]=l[i];
        b[i]=r[i];
    }
    qs(1,n);
    for(int i=1; i<=n; i++)
    {
        check(1,n,l[i],r[i], index[i]);
        if(y!=-1)
        {
            x=index[i];
            break;
        }
    }
    if(a[x]<a[y] || b[x]>b[y]) swap(x,y);
    cout<<x<<" "<<y;
    return 0;
}


#include <iostream>

using namespace std;

int n, x=-1, y=-1;
int l[3*100001+1], r[3*100001+1], index[3*100001+1];

void qs(int left, int right)
{
    if(left>=right) return;
    int i=left, j=right, x=l[(left+right)/2], y=r[(left+right)/2], z=index[(left+right)/2];
    while(i<=j)
    {
        while(l[i]<x || (l[i]==x && r[i]==y && index[i]<z) || (l[i]==x && r[i]<y)) i++;
        while(l[j]>x || (l[j]==x && r[j]==y && index[j]>z) || (l[j]==x && r[j]>y)) j--;
        if(i<=j)
        {
            swap(l[i],l[j]);
            swap(r[i],r[j]);
            swap(index[i], index[j]);
            i++;
            j--;
        }
    }
    qs(left,j);
    qs(i,right);
}

void check(int left, int right, int a, int b, int i)
{
    int mid;
    while(left<=right)
    {
        mid=(left+right)/2;
        if(l[mid]>=a && r[mid]<=b && index[mid]<=i)
        {
            y=index[mid];
            return;
        }
        if(l[mid]>=a && r[mid]<=b && index[mid]>i) right=mid-1;
        if(l[mid]<a || (l[mid]==a && r[mid]<a) || r[mid]<a) left=mid+1;
        if(l[mid]>b || (l[mid]==b && r[mid]>b) || r[mid]>b) right=mid-1;
    }
}

int main()
{
    cin>>n;
    for(int i=1; i<=n; i++)
    {
        cin>>l[i]>>r[i];
        index[i]=i;
    }
    qs(1,n);
    //for(int i=1; i<=n; i++) cout<<l[i]<<" "<<r[i]<<" "<<index[i]<<endl;
    for(int i=1; i<=n; i++)
    {
        check(i+1,n,l[i],r[i], i);
        if(y!=-1)
        {
            x=index[i];
            break;
        }
    }
    if(x>y) swap(x,y);
    cout<<x<<" "<<y;
    return 0;
}