                #include <bits/stdc++.h>
                using namespace std;
                #define fio              ios_base::sync_with_stdio(false),cin.tie(NULL)
                #define ll              long long int
                #define ull             unsigned long long int
                #define ld              long double
                #define sb              __builtin_popcount
                #define vi              vector<int>
                #define vl              vector<ll>
                #define vc              vector<char>
                #define ii              pair<int,int>
                #define pq              priority_queue<ii,vector<ii>, greater< ii>>
                #define vii             vector<ii>
                #define viii            vector<tuple<ll,ll,ll>>
                #define sz(a)           int((a).size())
                #define f(a,b)          for(int i=a;i<b;i++)
                #define fr(a,b)         for(int i=a-1;i>=b;i--)
                #define tr(x,m)         for(auto x : m)
                #define in(a,b)         (b.find(a) != string::npos)
                #define minin(a)        *min_element (all(a))
                #define maxin(a)        *max_element(all(a))
                #define bs(l,h,k)       equal_range(l,h,k);
                #define X               first
                #define Y               second
                #define fill(a,x)       memset(a,x,sizeof(a))
                #define pb              push_back
                #define pf              push_front
                #define mp              make_pair
                #define all(v)          v.begin(),v.end()
                #define rall(v)         reverse(v.begin(),v.end())
                #define unq(v)          v.erase(unique(all(v)),v.end())
                #define el              "\n"
                #define mx3(a,b,c)      max(max(a,b),c)
                #define S(v)            accumulate(all(v), (ll)0)
                #define IP(v1,v2)       inner_product(all(v1), v2.begin(), (ll)0)
                const long double PI = atan(1.0)*4.0;
                const ll M = 1e9 + 7;
                const ll INF = 1e18;
                const ld EPS = 0.0000001;
                #define N  100005
                bool cmp(pair<string,int>a,pair<string,int>b){
                   return a.Y>b.Y;
                }
                int pw(int x,int n,int M)
                {
                    if(n==0)
                         return 1;
                     else if(n%2 == 0)        //n is even
                         return pw((x*x)%M,n/2,M);
                     else                             //n is odd
                         return (x*pw((x*x)%M,(n-1)/2,M))%M;
                }

                int main(){
                       fio;
                    int n;cin>>n;
                    string s,t,p,q;cin>>s>>t;
                    p=s;
                    q=t;
                    sort(all(p));
                    sort(all(q));
                    if(s==t){
                        cout<<0<<el;
                        return 0;
                    }
                    else if(p!=q){
                        cout<<-1<<el;
                        return 0;
                    }
                    else{
                        vi v;
                        int ind;
                        for(int i=0;i<s.length();i++){
                            if(s[i]!=t[i]){
                                for(int j=i+1;j<s.length();j++){
                                    if(s[j]==t[i]){
                                        ind=j;
                                        break;
                                    }
                                }
                            }
                            char tmp;
                            for(int j=ind-1;j>=i;j--){
                                //swap(s[j],s[j-1]);
                                tmp=s[j];
                                s[j]=s[j+1];
                                s[j+1]=tmp;
                                v.pb(j+1);
                            }
                          //  cout<<s<<el;
                         //for(int j=i+1;j<=ind;j++)v.pb(j);
                        }
                       cout<<v.size()<<el;
                      f(0,v.size())cout<<v[i]<<" ";
                    }

                       return 0;
                  }


                #include <bits/stdc++.h>
                using namespace std;
                #define fio              ios_base::sync_with_stdio(false),cin.tie(NULL)
                #define ll              long long int
                #define ull             unsigned long long int
                #define ld              long double
                #define sb              __builtin_popcount
                #define vi              vector<int>
                #define vl              vector<ll>
                #define vc              vector<char>
                #define ii              pair<int,int>
                #define pq              priority_queue<ii,vector<ii>, greater< ii>>
                #define vii             vector<ii>
                #define viii            vector<tuple<ll,ll,ll>>
                #define sz(a)           int((a).size())
                #define f(a,b)          for(int i=a;i<b;i++)
                #define fr(a,b)         for(int i=a-1;i>=b;i--)
                #define tr(x,m)         for(auto x : m)
                #define in(a,b)         (b.find(a) != string::npos)
                #define minin(a)        *min_element (all(a))
                #define maxin(a)        *max_element(all(a))
                #define bs(l,h,k)       equal_range(l,h,k);
                #define X               first
                #define Y               second
                #define fill(a,x)       memset(a,x,sizeof(a))
                #define pb              push_back
                #define pf              push_front
                #define mp              make_pair
                #define all(v)          v.begin(),v.end()
                #define rall(v)         reverse(v.begin(),v.end())
                #define unq(v)          v.erase(unique(all(v)),v.end())
                #define el              "\n"
                #define mx3(a,b,c)      max(max(a,b),c)
                #define S(v)            accumulate(all(v), (ll)0)
                #define IP(v1,v2)       inner_product(all(v1), v2.begin(), (ll)0)
                const long double PI = atan(1.0)*4.0;
                const ll M = 1e9 + 7;
                const ll INF = 1e18;
                const ld EPS = 0.0000001;
                #define N  100005
                bool cmp(pair<string,int>a,pair<string,int>b){
                   return a.Y>b.Y;
                }
                int pw(int x,int n,int M)
                {
                    if(n==0)
                         return 1;
                     else if(n%2 == 0)        //n is even
                         return pw((x*x)%M,n/2,M);
                     else                             //n is odd
                         return (x*pw((x*x)%M,(n-1)/2,M))%M;
                }

                int main(){
                       fio;
                    int n;cin>>n;
                    string s,t,p,q;cin>>s;
                    cin>>t;
                    p=s;
                    q=t;
                    sort(all(p));
                    sort(all(q));
                    if(s==t){
                        cout<<0<<el;
                        return 0;
                    }
                    else if(p!=q){
                        cout<<-1<<el;
                        return 0;
                    }
                    else{
                        vi v;
                        int ind;
                        for(int i=0;i<s.length()-1;i++){
                            if(s[i]!=t[i]){
                                for(int j=i+1;j<s.length();j++){
                                    if(s[j]==t[i]){
                                        ind=j;
                                        break;
                                    }
                                }
                            }
                            char tmp;
                            for(int j=ind-1;j>=i;j--){
                                //swap(s[j],s[j-1]);
                                tmp=s[j];
                                s[j]=s[j+1];
                                s[j+1]=tmp;
                                v.pb(j+1);
                            }
                          //  cout<<s<<el;
                         //for(int j=i+1;j<=ind;j++)v.pb(j);
                        }
                       cout<<v.size()<<el;
                      f(0,v.size())cout<<v[i]<<" ";
                    }

                       return 0;
                  }


                    /** بسم الله الرحمن الرحيم **/
/*---------------------------------------------------------------------*/
#include<bits/stdc++.h>
#define ll long long
#define fast ios_base::sync_with_stdio(false)
#define compare bool operator <
#define main int main()
#define sf(n) scanf ("%d", &n)
#define pf(n) printf ("%d", n)
#define sfl(n) scanf ("%lld", &n)
#define pfl(n) printf ("%lld", n)
#define pfnewline() printf("\n")
#define pfspace() printf(" ")
#define mem(x,y) memset( (x), (y), sizeof(x) )
#define max3(a,b,c)   max(a , max(b,c) )
#define min3(a,b,c)  min(a, min(b,c) )
#define mxn 1000000009
#define Ex 2.718281828

/** ---8 moves --- **/
//int dx[] = {-1, -1, -1, 0, 0, 1, 1, 1};
//int dy[] = {-1, 0, 1, -1, 1, -1, 0, 1};

/** ---4 moves--**/
//int dx[] = {-1,0,0,1};
//int dy[] = {0,-1,1,0};

using namespace std;

/**--MIM--- *//*

ll coinChange(int n, int need, int coin[])
{
for(i=0;i<n;i++) for(j=coin[i];j<=need;j++) dp[j]=(dp[j]+dp[j-coin[i]]);
 return dp[need];
} */

main
{
    fast;
    int n;
    cin >> n;

    string s, t;
    cin >> s >> t;
    string tms = s;
    string tmt = t;
    sort(tms.begin(), tms.end());
    sort(tmt.begin(), tmt.end());
    if(tms != tmt)
    {
        cout << "-1" << endl;
    }
    else
    {
        queue< pair<char , pair<int , int  > > > q;
        bool flag[n+1];
        vector<int>ans;
        mem(flag, false);
        while(s!=t){
        for(int i = 0; i<n;i++)
        {
            if(s == t){
                    break;
            }
            for(int j = 0; j<n;j++)
            {
                if(!flag[j])
                {
                    if(s[j] == t[i])
                    {
                        int er = j;
                        while(er != i)
                        {

                            if(er<i)
                            {
                                swap(s[er], s[er+1]);
                             ans.push_back(er+1);
                             er +=1;
                            }
                            else
                            {
                                swap(s[er-1], s[er]);
                                ans.push_back(er);
                                er -=1;
                            }

                        }
                        flag[j] = true;
                        break;
                    }
                }
            }
        }
        }

        cout << ans.size() << endl;
        for(int i = 0; i<ans.size();i++)
        {
            cout << ans[i] << " ";
        }

    }
}


                    /** بسم الله الرحمن الرحيم **/
/*---------------------------------------------------------------------*/
#include<bits/stdc++.h>
#define ll long long
#define fast ios_base sync_with_stdio(false)
#define compare bool operator <
#define main int main()
#define sf(n) scanf ("%d", &n)
#define pf(n) printf ("%d", n)
#define sfl(n) scanf ("%lld", &n)
#define pfl(n) printf ("%lld", n)
#define pfnewline() printf("\n")
#define pfspace() printf(" ")
#define mem(x,y) memset( (x), (y), sizeof(x) )
#define max3(a,b,c)   max(a , max(b,c) )
#define min3(a,b,c)  min(a, min(b,c) )
#define mxn 1000000009
#define Ex 2.718281828

/** ---8 moves --- **/
//int dx[] = {-1, -1, -1, 0, 0, 1, 1, 1};
//int dy[] = {-1, 0, 1, -1, 1, -1, 0, 1};

/** ---4 moves--**/
//int dx[] = {-1,0,0,1};
//int dy[] = {0,-1,1,0};

using namespace std;

/**--MIM--- *//*

ll coinChange(int n, int need, int coin[])
{
for(i=0;i<n;i++) for(j=coin[i];j<=need;j++) dp[j]=(dp[j]+dp[j-coin[i]]);
 return dp[need];
} */

main
{
    int n;
    cin >> n;

    string s, t;
    cin >> s >> t;
    string tms = s;
    string tmt = t;
    sort(tms.begin(), tms.end());
    sort(tmt.begin(), tmt.end());
    if(tms != tmt)
    {
        cout << "-1" << endl;
    }
    else
    {
        queue< pair<char , pair<int , int  > > > q;
        bool flag[n+1];
        vector<int>ans;
        mem(flag, false);
        for(int i = 0; i<n;i++)
        {
            for(int j = 0; j<n;j++)
            {
                if(!flag[j])
                {
                    if(s[j] == t[i])
                    {
                        int er = j;
                        while(er != i)
                        {

                            if(er<i)
                            {
                                swap(s[er], s[er+1]);
                             ans.push_back(er+1);
                             er +=1;
                            }
                            else
                            {
                                swap(s[er], s[er-1]);
                                ans.push_back(er);
                                er -=1;
                            }
                           // cout << er << " ";
                        }
                        flag[j] = true;
                        break;
                    }
                }
            }
        }

        cout << ans.size() << endl;
        for(int i = 0; i<ans.size();i++)
        {
            cout << ans[i] << " ";
        }
    }
}


/** بسم الله الرحمن الرحيم **/
/*---------------------------------------------------------------------*/
#include<bits/stdc++.h>
#define ll long long
#define fast ios_base::sync_with_stdio(false)
#define compare bool operator <
#define main int main()
#define sf(n) scanf ("%d", &n)
#define pf(n) printf ("%d", n)
#define sfl(n) scanf ("%lld", &n)
#define pfl(n) printf ("%lld", n)
#define pfnewline() printf("\n")
#define pfspace() printf(" ")
#define mem(x,y) memset( (x), (y), sizeof(x) )
#define max3(a,b,c)   max(a , max(b,c) )
#define min3(a,b,c)  min(a, min(b,c) )
#define mxn 1000000009
#define Ex 2.718281828

/** ---8 moves --- **/
//int dx[] = {-1, -1, -1, 0, 0, 1, 1, 1};
//int dy[] = {-1, 0, 1, -1, 1, -1, 0, 1};

/** ---4 moves--**/
//int dx[] = {-1,0,0,1};
//int dy[] = {0,-1,1,0};

using namespace std;

/**--MIM--- *//*

ll coinChange(int n, int need, int coin[])
{
for(i=0;i<n;i++) for(j=coin[i];j<=need;j++) dp[j]=(dp[j]+dp[j-coin[i]]);
 return dp[need];
} */

main
{
    fast;
    int n;
    cin >> n;

    string s, t;
    cin >> s >> t;
    string tms = s;
    string tmt = t;
    sort(tms.begin(), tms.end());
    sort(tmt.begin(), tmt.end());
    if(tms != tmt)
    {
        cout << "-1" << endl;
    }
    else
    {
        queue< pair<char, pair<int, int  > > > q;
        bool flag[n+1];
        vector<int>ans;
        mem(flag, false);
        // while(s!=t){
        for(int i = 0; i<n; i++)
        {
           // cout << i <<  "i " << endl;
            if(s == t)
            {
                break;
            }
            for(int j = 0; j<n; j++)
            {
                if(!flag[j])
                {
                  //  cout << j << " j " << endl;
                    if(s[j] == t[i])
                    {
                        int er = j;
                        while(er != i)
                        {

                            if(er<i)
                            {
                                swap(s[er], s[er+1]);
                                ans.push_back(er+1);
                                er +=1;
                            }
                            else
                            {
                                swap(s[er-1], s[er]);
                                ans.push_back(er);
                                er -=1;
                            }
                         //   cout << s << endl;
                         //   cout << s[er] << " :/ " << endl;

                        }
                        flag[er] = true;
                        break;
                    }
                }
                //}
            }
        }

        cout << ans.size() << endl;
        for(int i = 0; i<ans.size(); i++)
        {
            cout << ans[i] << " ";
        }

    }
}
/*
4
abcx
xcba
*/


                    /** بسم الله الرحمن الرحيم **/
/*---------------------------------------------------------------------*/
#include<bits/stdc++.h>
#define ll long long
#define fast ios_base sync_with_stdio(false)
#define compare bool operator <
#define main int main()
#define sf(n) scanf ("%d", &n)
#define pf(n) printf ("%d", n)
#define sfl(n) scanf ("%lld", &n)
#define pfl(n) printf ("%lld", n)
#define pfnewline() printf("\n")
#define pfspace() printf(" ")
#define mem(x,y) memset( (x), (y), sizeof(x) )
#define max3(a,b,c)   max(a , max(b,c) )
#define min3(a,b,c)  min(a, min(b,c) )
#define mxn 1000000009
#define Ex 2.718281828

/** ---8 moves --- **/
//int dx[] = {-1, -1, -1, 0, 0, 1, 1, 1};
//int dy[] = {-1, 0, 1, -1, 1, -1, 0, 1};

/** ---4 moves--**/
//int dx[] = {-1,0,0,1};
//int dy[] = {0,-1,1,0};

using namespace std;

/**--MIM--- *//*

ll coinChange(int n, int need, int coin[])
{
for(i=0;i<n;i++) for(j=coin[i];j<=need;j++) dp[j]=(dp[j]+dp[j-coin[i]]);
 return dp[need];
} */

main
{
    int n;
    cin >> n;

    string s, t;
    cin >> s >> t;
    string tms = s;
    string tmt = t;
    sort(tms.begin(), tms.end());
    sort(tmt.begin(), tmt.end());
    if(tms != tmt)
    {
        cout << "-1" << endl;
    }
    else
    {
        queue< pair<char , pair<int , int  > > > q;
        bool flag[n+1];
        vector<int>ans;
        mem(flag, false);
        while(s!=t){
        for(int i = 0; i<n;i++)
        {
            if(s == t){
                    break;
            }
            for(int j = 0; j<n;j++)
            {
                if(!flag[j])
                {
                    if(s[j] == t[i])
                    {
                        int er = j;
                        while(er != i)
                        {

                            if(er<i)
                            {
                                swap(s[er], s[er+1]);
                             ans.push_back(er+1);
                             er +=1;
                            }
                            else
                            {
                                swap(s[er-1], s[er]);
                                ans.push_back(er);
                                er -=1;
                            }

                        }
                        flag[j] = true;
                        break;
                    }
                }
            }
        }

        cout << ans.size() << endl;
        for(int i = 0; i<ans.size();i++)
        {
            cout << ans[i] << " ";
        }
    }
    }
}


                    /** بسم الله الرحمن الرحيم **/
/*---------------------------------------------------------------------*/
#include<bits/stdc++.h>
#define ll long long
#define fast ios_base sync_with_stdio(false)
#define compare bool operator <
#define main int main()
#define sf(n) scanf ("%d", &n)
#define pf(n) printf ("%d", n)
#define sfl(n) scanf ("%lld", &n)
#define pfl(n) printf ("%lld", n)
#define pfnewline() printf("\n")
#define pfspace() printf(" ")
#define mem(x,y) memset( (x), (y), sizeof(x) )
#define max3(a,b,c)   max(a , max(b,c) )
#define min3(a,b,c)  min(a, min(b,c) )
#define mxn 1000000009
#define Ex 2.718281828

/** ---8 moves --- **/
//int dx[] = {-1, -1, -1, 0, 0, 1, 1, 1};
//int dy[] = {-1, 0, 1, -1, 1, -1, 0, 1};

/** ---4 moves--**/
//int dx[] = {-1,0,0,1};
//int dy[] = {0,-1,1,0};

using namespace std;

/**--MIM--- *//*

ll coinChange(int n, int need, int coin[])
{
for(i=0;i<n;i++) for(j=coin[i];j<=need;j++) dp[j]=(dp[j]+dp[j-coin[i]]);
 return dp[need];
} */

main
{
    int n;
    cin >> n;

    string s, t;
    cin >> s >> t;
    string tms = s;
    string tmt = t;
    sort(tms.begin(), tms.end());
    sort(tmt.begin(), tmt.end());
    if(tms != tmt)
    {
        cout << "-1" << endl;
    }
    else
    {
        queue< pair<char , pair<int , int  > > > q;
        bool flag[n+1];
        vector<int>ans;
        mem(flag, false);
        for(int i = 0; i<n;i++)
        {
            if(s == t){
                    break;
            }
            for(int j = 0; j<n;j++)
            {
                if(!flag[j])
                {
                    if(s[j] == t[i])
                    {
                        int er = j;
                        while(er != i)
                        {

                            if(er<i)
                            {
                                swap(s[er], s[er+1]);
                             ans.push_back(er+1);
                             er +=1;
                            }
                            else
                            {
                                swap(s[er-1], s[er]);
                                ans.push_back(er);
                                er -=1;
                            }

                        }
                        flag[j] = true;
                        break;
                    }
                }
            }
        }

        cout << ans.size() << endl;
        for(int i = 0; i<ans.size();i++)
        {
            cout << ans[i] << " ";
        }
    }
}


                    /** بسم الله الرحمن الرحيم **/
/*---------------------------------------------------------------------*/
#include<bits/stdc++.h>
#define ll long long
#define fast ios_base sync_with_stdio(false)
#define compare bool operator <
#define main int main()
#define sf(n) scanf ("%d", &n)
#define pf(n) printf ("%d", n)
#define sfl(n) scanf ("%lld", &n)
#define pfl(n) printf ("%lld", n)
#define pfnewline() printf("\n")
#define pfspace() printf(" ")
#define mem(x,y) memset( (x), (y), sizeof(x) )
#define max3(a,b,c)   max(a , max(b,c) )
#define min3(a,b,c)  min(a, min(b,c) )
#define mxn 1000000009
#define Ex 2.718281828

/** ---8 moves --- **/
//int dx[] = {-1, -1, -1, 0, 0, 1, 1, 1};
//int dy[] = {-1, 0, 1, -1, 1, -1, 0, 1};

/** ---4 moves--**/
//int dx[] = {-1,0,0,1};
//int dy[] = {0,-1,1,0};

using namespace std;

/**--MIM--- *//*

ll coinChange(int n, int need, int coin[])
{
for(i=0;i<n;i++) for(j=coin[i];j<=need;j++) dp[j]=(dp[j]+dp[j-coin[i]]);
 return dp[need];
} */

main
{
    int n;
    cin >> n;

    string s, t;
    cin >> s >> t;
    string tms = s;
    string tmt = t;
    sort(tms.begin(), tms.end());
    sort(tmt.begin(), tmt.end());
    if(tms != tmt)
    {
        cout << "-1" << endl;
    }
    else
    {
        queue< pair<char , pair<int , int  > > > q;
        bool flag[n+1];
        vector<int>ans;
        mem(flag, false);
        while(s!=t){
        for(int i = 0; i<n;i++)
        {
            if(s == t){
                    break;
            }
            for(int j = 0; j<n;j++)
            {
                if(!flag[j])
                {
                    if(s[j] == t[i])
                    {
                        int er = j;
                        while(er != i)
                        {

                            if(er<i)
                            {
                                swap(s[er], s[er+1]);
                             ans.push_back(er+1);
                             er +=1;
                            }
                            else
                            {
                                swap(s[er-1], s[er]);
                                ans.push_back(er);
                                er -=1;
                            }

                        }
                        flag[j] = true;
                        break;
                    }
                }
            }
        }
        }

        cout << ans.size() << endl;
        for(int i = 0; i<ans.size();i++)
        {
            cout << ans[i] << " ";
        }

    }
}


/*
██╗  ██╗ █████╗ ██████╗ ███████╗███████╗███╗   ███╗        ██╗  ██╗██╗  ██╗ █████╗ ██╗     ███████╗██████╗
██║ ██╔╝██╔══██╗██╔══██╗██╔════╝██╔════╝████╗ ████║        ██║ ██╔╝██║  ██║██╔══██╗██║     ██╔════╝██╔══██╗
█████╔╝ ███████║██████╔╝█████╗  █████╗  ██╔████╔██║        █████╔╝ ███████║███████║██║     █████╗  ██║  ██║
██╔═██╗ ██╔══██║██╔══██╗██╔══╝  ██╔══╝  ██║╚██╔╝██║        ██╔═██╗ ██╔══██║██╔══██║██║     ██╔══╝  ██║  ██║
██║  ██╗██║  ██║██║  ██║███████╗███████╗██║ ╚═╝ ██║███████╗██║  ██╗██║  ██║██║  ██║███████╗███████╗██████╔╝
╚═╝  ╚═╝╚═╝  ╚═╝╚═╝  ╚═╝╚══════╝╚══════╝╚═╝     ╚═╝╚══════╝╚═╝  ╚═╝╚═╝  ╚═╝╚═╝  ╚═╝╚══════╝╚══════╝╚═════╝
Believe in yourself ,( try and try and then try ), You can do it
*/
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#include<unordered_map>
#define endl "\n"
#define Ceil(x,y) ((x+y-1)/y)
#define clr(arr, x) memset(arr, x, sizeof arr)
#define all(v) v.begin(),v.end()
#define allr(s) s.rbegin(),s.rend()
#define rt(s) return cout<<s,0
#define watch(x) cout<<(#x)<<" = "<<x<<endl
#define sz(s)	(int)(s.size())
#define OO 0x3f3f3f3f3f3f3f3fLL
const int oo = 0x3f3f3f3f, mod = 1e9 + 7;
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
int dx[] { -1, 0, 0, 1, 1, 1, -1, -1 };
int dy[] { 0, -1, 1, 0, 1, -1, 1, -1 };
void K_K(){
#ifndef ONLINE_JUDGE
	freopen("in.txt", "r", stdin);
	freopen("out.txt", "w", stdout);
#endif  !ONLINEJUDGE
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
}
ll gcd(ll a, ll b) {
	return b == 0 ? abs(a) : gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}

int main(){
	K_K();
	int n;
	cin >> n;
	string s, t;
	cin >> s >> t;
	vector<int>ans;
	map<char, int>mp1, mp2;
	for (int i = 0; i < n; i++){
		mp1[s[i]]++;
	}
	for (int i = 0; i < n; i++){
		mp2[t[i]]++;
	}
	if (mp1 != mp2)
		rt(-1);
	while (true){
		if (s == t)
			break;
		for (int i = 0; i < sz(s); i++){
			if (s == t)
				break;
			if (s[i] != t[i]){
				swap(s[i], s[i + 1]);
				ans.push_back(i + 1);
			}
		}
	}
	cout << sz(ans) << endl;
	for (int i = 0; i < sz(ans); i++)
		cout << ans[i] << ' ';
}


/*
██╗  ██╗ █████╗ ██████╗ ███████╗███████╗███╗   ███╗        ██╗  ██╗██╗  ██╗ █████╗ ██╗     ███████╗██████╗
██║ ██╔╝██╔══██╗██╔══██╗██╔════╝██╔════╝████╗ ████║        ██║ ██╔╝██║  ██║██╔══██╗██║     ██╔════╝██╔══██╗
█████╔╝ ███████║██████╔╝█████╗  █████╗  ██╔████╔██║        █████╔╝ ███████║███████║██║     █████╗  ██║  ██║
██╔═██╗ ██╔══██║██╔══██╗██╔══╝  ██╔══╝  ██║╚██╔╝██║        ██╔═██╗ ██╔══██║██╔══██║██║     ██╔══╝  ██║  ██║
██║  ██╗██║  ██║██║  ██║███████╗███████╗██║ ╚═╝ ██║███████╗██║  ██╗██║  ██║██║  ██║███████╗███████╗██████╔╝
╚═╝  ╚═╝╚═╝  ╚═╝╚═╝  ╚═╝╚══════╝╚══════╝╚═╝     ╚═╝╚══════╝╚═╝  ╚═╝╚═╝  ╚═╝╚═╝  ╚═╝╚══════╝╚══════╝╚═════╝
Believe in yourself ,( try and try and then try ), You can do it
*/
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#include<unordered_map>
#define endl "\n"
#define Ceil(x,y) ((x+y-1)/y)
#define clr(arr, x) memset(arr, x, sizeof arr)
#define all(v) v.begin(),v.end()
#define allr(s) s.rbegin(),s.rend()
#define rt(s) return cout<<s,0
#define watch(x) cout<<(#x)<<" = "<<x<<endl
#define sz(s)	(int)(s.size())
#define OO 0x3f3f3f3f3f3f3f3fLL
const int oo = 0x3f3f3f3f, mod = 1e9 + 7;
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
int dx[] { -1, 0, 0, 1, 1, 1, -1, -1 };
int dy[] { 0, -1, 1, 0, 1, -1, 1, -1 };
void K_K(){
#ifndef ONLINE_JUDGE
	freopen("in.txt", "r", stdin);
	freopen("out.txt", "w", stdout);
#endif  !ONLINEJUDGE
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
}
ll gcd(ll a, ll b) {
	return b == 0 ? abs(a) : gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}

int main(){
	K_K();
	int n;
	cin >> n;
	string s, t;
	cin >> s >> t;
	vector<int>ans;
	map<char, int>mp1, mp2;
	for (int i = 0; i < n; i++)
		mp1[s[i]]++;
	for (int i = 0; i < n; i++)
		mp2[t[i]]++;
	if (mp1 != mp2)
		rt(-1);
	int pos = 0;
	for (int i = 0; i < sz(s); i++){
		if (s == t)
			break;
		if (s[i] != t[i]){
			for (int j = i; j < sz(s); j++){
				if (s[j] == t[i]){
					pos = j;
					break;
				}
			}
			char ch = s[pos];
			s.erase(pos, 1);
			s.insert(s.begin() + i, ch);
			for (int j = pos - 1; j >= i; j--)
				ans.push_back(j + 1);
		}
	 }
	cout << sz(ans) << endl;
	for (int i = 0; i < sz(ans); i++)
		cout << ans[i] << ' ';
}


/*
██╗  ██╗ █████╗ ██████╗ ███████╗███████╗███╗   ███╗        ██╗  ██╗██╗  ██╗ █████╗ ██╗     ███████╗██████╗
██║ ██╔╝██╔══██╗██╔══██╗██╔════╝██╔════╝████╗ ████║        ██║ ██╔╝██║  ██║██╔══██╗██║     ██╔════╝██╔══██╗
█████╔╝ ███████║██████╔╝█████╗  █████╗  ██╔████╔██║        █████╔╝ ███████║███████║██║     █████╗  ██║  ██║
██╔═██╗ ██╔══██║██╔══██╗██╔══╝  ██╔══╝  ██║╚██╔╝██║        ██╔═██╗ ██╔══██║██╔══██║██║     ██╔══╝  ██║  ██║
██║  ██╗██║  ██║██║  ██║███████╗███████╗██║ ╚═╝ ██║███████╗██║  ██╗██║  ██║██║  ██║███████╗███████╗██████╔╝
╚═╝  ╚═╝╚═╝  ╚═╝╚═╝  ╚═╝╚══════╝╚══════╝╚═╝     ╚═╝╚══════╝╚═╝  ╚═╝╚═╝  ╚═╝╚═╝  ╚═╝╚══════╝╚══════╝╚═════╝
Believe in yourself ,( try and try and then try ), You can do it
*/
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#include<unordered_map>
#define endl "\n"
#define Ceil(x,y) ((x+y-1)/y)
#define clr(arr, x) memset(arr, x, sizeof arr)
#define all(v) v.begin(),v.end()
#define allr(s) s.rbegin(),s.rend()
#define rt(s) return cout<<s,0
#define watch(x) cout<<(#x)<<" = "<<x<<endl
#define sz(s)	(int)(s.size())
#define OO 0x3f3f3f3f3f3f3f3fLL
const int oo = 0x3f3f3f3f, mod = 1e9 + 7;
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
int dx[] { -1, 0, 0, 1, 1, 1, -1, -1 };
int dy[] { 0, -1, 1, 0, 1, -1, 1, -1 };
void K_K(){
#ifndef ONLINE_JUDGE
	freopen("in.txt", "r", stdin);
	freopen("out.txt", "w", stdout);
#endif  !ONLINEJUDGE
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
}
ll gcd(ll a, ll b) {
	return b == 0 ? abs(a) : gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}

int main(){
	K_K();
	int n;
	cin >> n;
	string s, t;
	cin >> s >> t;
	vector<int>ans;
	map<char, int>mp1, mp2;
	for (int i = 0; i < n; i++){
		mp1[s[i]]++;
	}
	for (int i = 0; i < n; i++){
		mp2[t[i]]++;
	}
	if (mp1 != mp2)
		rt(-1);
	while (true){
		if (s == t)
			break;
		for (int i = 0; i < sz(s); i++){
			if (s == t)
				break;
			if (s[i] != t[i]){
				for (int j = i; j < sz(s); j++){
					if (s[j] == t[i]){
						char ch = s[j];
						s.erase(j, 1);
						s.insert(s.begin() + i, ch);
						break;
					}
					ans.push_back(j+1);
				}
			}
 		}
	}
 	cout << sz(ans) << endl;
	for (int i = 0; i < sz(ans); i++)
		cout << ans[i] << ' ';
}


/*
██╗  ██╗ █████╗ ██████╗ ███████╗███████╗███╗   ███╗        ██╗  ██╗██╗  ██╗ █████╗ ██╗     ███████╗██████╗
██║ ██╔╝██╔══██╗██╔══██╗██╔════╝██╔════╝████╗ ████║        ██║ ██╔╝██║  ██║██╔══██╗██║     ██╔════╝██╔══██╗
█████╔╝ ███████║██████╔╝█████╗  █████╗  ██╔████╔██║        █████╔╝ ███████║███████║██║     █████╗  ██║  ██║
██╔═██╗ ██╔══██║██╔══██╗██╔══╝  ██╔══╝  ██║╚██╔╝██║        ██╔═██╗ ██╔══██║██╔══██║██║     ██╔══╝  ██║  ██║
██║  ██╗██║  ██║██║  ██║███████╗███████╗██║ ╚═╝ ██║███████╗██║  ██╗██║  ██║██║  ██║███████╗███████╗██████╔╝
╚═╝  ╚═╝╚═╝  ╚═╝╚═╝  ╚═╝╚══════╝╚══════╝╚═╝     ╚═╝╚══════╝╚═╝  ╚═╝╚═╝  ╚═╝╚═╝  ╚═╝╚══════╝╚══════╝╚═════╝
Believe in yourself ,( try and try and then try ), You can do it
*/
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#include<unordered_map>
#define endl "\n"
#define Ceil(x,y) ((x+y-1)/y)
#define clr(arr, x) memset(arr, x, sizeof arr)
#define all(v) v.begin(),v.end()
#define allr(s) s.rbegin(),s.rend()
#define rt(s) return cout<<s,0
#define watch(x) cout<<(#x)<<" = "<<x<<endl
#define sz(s)	(int)(s.size())
#define OO 0x3f3f3f3f3f3f3f3fLL
const int oo = 0x3f3f3f3f, mod = 1e9 + 7;
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
int dx[] { -1, 0, 0, 1, 1, 1, -1, -1 };
int dy[] { 0, -1, 1, 0, 1, -1, 1, -1 };
void K_K(){
#ifndef ONLINE_JUDGE
	freopen("in.txt", "r", stdin);
	freopen("out.txt", "w", stdout);
#endif  !ONLINEJUDGE
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
}
ll gcd(ll a, ll b) {
	return b == 0 ? abs(a) : gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}

int main(){
	K_K();
	int n;
	cin >> n;
	string s, t;
	cin >> s >> t;
	vector<int>ans;
	map<char, int>mp1, mp2;
	for (int i = 0; i < n; i++)
		mp1[s[i]]++;
	for (int i = 0; i < n; i++)
		mp2[t[i]]++;
	if (mp1 != mp2)
		rt(-1);
	for (int i = 0; i < sz(s); i++){
		if (s == t)
			break;
		int pos = 0;
		if (s[i] != t[i]){
			for (int j = i ; j < sz(s); j++){
				if (s[j] == t[i]) {
					pos = j;
					break;
				}
 			}
			for (int j = pos - 1; j >= i; --j) {
				swap(s[j], s[j + 1]);
				ans.push_back(j+1);
			}
		}
	}
	cout << sz(ans) << endl;
	for (int i = 0; i < sz(ans); i++)
		cout << ans[i] << ' ';
}


/*
██╗  ██╗ █████╗ ██████╗ ███████╗███████╗███╗   ███╗        ██╗  ██╗██╗  ██╗ █████╗ ██╗     ███████╗██████╗
██║ ██╔╝██╔══██╗██╔══██╗██╔════╝██╔════╝████╗ ████║        ██║ ██╔╝██║  ██║██╔══██╗██║     ██╔════╝██╔══██╗
█████╔╝ ███████║██████╔╝█████╗  █████╗  ██╔████╔██║        █████╔╝ ███████║███████║██║     █████╗  ██║  ██║
██╔═██╗ ██╔══██║██╔══██╗██╔══╝  ██╔══╝  ██║╚██╔╝██║        ██╔═██╗ ██╔══██║██╔══██║██║     ██╔══╝  ██║  ██║
██║  ██╗██║  ██║██║  ██║███████╗███████╗██║ ╚═╝ ██║███████╗██║  ██╗██║  ██║██║  ██║███████╗███████╗██████╔╝
╚═╝  ╚═╝╚═╝  ╚═╝╚═╝  ╚═╝╚══════╝╚══════╝╚═╝     ╚═╝╚══════╝╚═╝  ╚═╝╚═╝  ╚═╝╚═╝  ╚═╝╚══════╝╚══════╝╚═════╝
Believe in yourself ,( try and try and then try ), You can do it
*/
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#include<unordered_map>
#define endl "\n"
#define Ceil(x,y) ((x+y-1)/y)
#define clr(arr, x) memset(arr, x, sizeof arr)
#define all(v) v.begin(),v.end()
#define allr(s) s.rbegin(),s.rend()
#define rt(s) return cout<<s,0
#define watch(x) cout<<(#x)<<" = "<<x<<endl
#define sz(s)	(int)(s.size())
#define OO 0x3f3f3f3f3f3f3f3fLL
const int oo = 0x3f3f3f3f, mod = 1e9 + 7;
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
int dx[] { -1, 0, 0, 1, 1, 1, -1, -1 };
int dy[] { 0, -1, 1, 0, 1, -1, 1, -1 };
void K_K(){
#ifndef ONLINE_JUDGE
	freopen("in.txt", "r", stdin);
	freopen("out.txt", "w", stdout);
#endif  !ONLINEJUDGE
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
}
ll gcd(ll a, ll b) {
	return b == 0 ? abs(a) : gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}

int main(){
	K_K();
	int n;
	cin >> n;
	string s, t;
	cin >> s >> t;
	vector<int>ans;
	map<char, int>mp1, mp2;
	for (int i = 0; i < n; i++){
		mp1[s[i]]++;
	}
	for (int i = 0; i < n; i++){
		mp2[t[i]]++;
	}
	if (mp1 != mp2)
		rt(-1);
	while (true){
		if (s == t)
			break;
		for (int i = 0; i < sz(s); i++){
			if (s == t)
				break;
			if (s[i] != t[i]){
				for (int j = i; j < sz(s); j++){
					if (s[j] == t[i]){
						char ch = s[j];
						s.erase(j, 1);
						s.insert(s.begin() + i, ch);
						break;
					}
					ans.push_back(j);
				}
			}
		}
	}
 	cout << sz(ans) << endl;
	for (int i = 0; i < sz(ans); i++)
		cout << ans[i] << ' ';
}


/*
██╗  ██╗ █████╗ ██████╗ ███████╗███████╗███╗   ███╗        ██╗  ██╗██╗  ██╗ █████╗ ██╗     ███████╗██████╗
██║ ██╔╝██╔══██╗██╔══██╗██╔════╝██╔════╝████╗ ████║        ██║ ██╔╝██║  ██║██╔══██╗██║     ██╔════╝██╔══██╗
█████╔╝ ███████║██████╔╝█████╗  █████╗  ██╔████╔██║        █████╔╝ ███████║███████║██║     █████╗  ██║  ██║
██╔═██╗ ██╔══██║██╔══██╗██╔══╝  ██╔══╝  ██║╚██╔╝██║        ██╔═██╗ ██╔══██║██╔══██║██║     ██╔══╝  ██║  ██║
██║  ██╗██║  ██║██║  ██║███████╗███████╗██║ ╚═╝ ██║███████╗██║  ██╗██║  ██║██║  ██║███████╗███████╗██████╔╝
╚═╝  ╚═╝╚═╝  ╚═╝╚═╝  ╚═╝╚══════╝╚══════╝╚═╝     ╚═╝╚══════╝╚═╝  ╚═╝╚═╝  ╚═╝╚═╝  ╚═╝╚══════╝╚══════╝╚═════╝
Believe in yourself ,( try and try and then try ), You can do it
*/
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#include<unordered_map>
#define endl "\n"
#define Ceil(x,y) ((x+y-1)/y)
#define clr(arr, x) memset(arr, x, sizeof arr)
#define all(v) v.begin(),v.end()
#define allr(s) s.rbegin(),s.rend()
#define rt(s) return cout<<s,0
#define watch(x) cout<<(#x)<<" = "<<x<<endl
#define sz(s)	(int)(s.size())
#define OO 0x3f3f3f3f3f3f3f3fLL
const int oo = 0x3f3f3f3f, mod = 1e9 + 7;
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
int dx[] { -1, 0, 0, 1, 1, 1, -1, -1 };
int dy[] { 0, -1, 1, 0, 1, -1, 1, -1 };
void K_K(){
#ifndef ONLINE_JUDGE
	freopen("in.txt", "r", stdin);
	freopen("out.txt", "w", stdout);
#endif  !ONLINEJUDGE
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
}
ll gcd(ll a, ll b) {
	return b == 0 ? abs(a) : gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}

int main(){
	K_K();
	int n;
	cin >> n;
	string s, t;
	cin >> s >> t;
	vector<int>ans;
	map<char, int>mp1, mp2;
	for (int i = 0; i < n; i++){
		mp1[s[i]]++;
	}
	for (int i = 0; i < n; i++){
		mp2[t[i]]++;
	}
	if (mp1 != mp2)
		rt(-1);
	while (true){
		if (s == t)
			break;
		for (int i = 0; i < sz(s); i++){
			if (s == t)
				break;
			if (s[i] != t[i]){
				for (int j = i; j < sz(s); j++){
					ans.push_back(j + 1);
					if (s[j] == t[i]){
						char ch = s[j];
						s.erase(j, 1);
						s.insert(s.begin() + i, ch);
						break;
					}
				}

			}
		}
	}
 	cout << sz(ans) << endl;
	for (int i = 0; i < sz(ans); i++)
		cout << ans[i] << ' ';
}


#include <iostream>
#include <vector>
#include <bits/stdc++.h>
#include <math.h>
#include <string.h>
using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
   int flag;

        int n ;
        int cnt = 0 ;
    cin >> n;
    char s[n],t[n];
    cin >> s>>t ;
    vector<int> ans;

    for(int i =0;i < n;i++){
           // cout << "Searching for "<<t[i]<<endl;
           int  flag = 0;

            if(s[i]==t[i]){
               // cout<<"found without changing"<<endl;
                flag = 1;
                continue;
            }
        for(int j=i;j <  n;j++){
               // cout<<"in s array"<<s[j]<<endl;
                if(s[j]==t[i]){
                    // cout<<j<<"int s and  "<<i<<"int t"<<endl;
                    for(int m = j;m >=i+1;m--){
                        char temp = s[m];
                        s[m] = s[m-1];
                        s[m-1] = temp;
                        flag = 1;
                        cnt++;
                        ans.push_back(m);
                       /* for(int i =0;i < n;i++){
                            cout << s[i]<<" ";
                        }
                        cout <<flag<< endl;*/

                    }

                }

        }
        if(flag==0){
           break;
        }

    }
    if(flag==0 || cnt > 10000){
        cout << -1 << endl;
    }
    else{
        cout << cnt<< endl;
        for(int i =0;i < ans.size();i++){
            cout <<ans[i]<<" ";
            if(i==ans.size()-1){
                cout<<endl;
            }
        }

    }

}


#include <iostream>
#include <vector>
#include <bits/stdc++.h>
#include <math.h>
#include <string.h>
using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
   int t,flag;
   cin >> t;
   while(t--){
        int n ,cnt = 0 ;
    cin >> n;
    char s[n],t[n];
    cin >> s>>t ;
    vector<int> ans;

    for(int i =0;i < n;i++){
           // cout << "Searching for "<<t[i]<<endl;
            flag = 0;

            if(s[i]==t[i]){
               // cout<<"found without changing"<<endl;
                flag = 1;

                continue;
            }
        for(int j=i;j <  n;j++){
               // cout<<"in s array"<<s[j]<<endl;
                if(s[j]==t[i]){
                    // cout<<j<<"int s and  "<<i<<"int t"<<endl;
                    for(int m = j;m >=i+1;m--){
                        char temp = s[m];
                        s[m] = s[m-1];
                        s[m-1] = temp;
                        flag = 1;
                        cnt++;
                        ans.push_back(m);
                       /* for(int i =0;i < n;i++){
                            cout << s[i]<<" ";
                        }
                        cout <<flag<< endl;*/

                    }

                }

        }
        if(flag==0){
           break;
        }

    }
    if(flag==0 || cnt >10000){
        cout << -1 << endl;
    }
    else{
        cout << cnt<< endl;
        for(int i =0;i < ans.size();i++){
            cout <<ans[i]<<" ";
        }
        cout << endl;
    }

   }

}


#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <string.h>
using namespace std;

vector <int> v1;
int bubblecounter(char a[],int n ){
    char temp;
    int counter=0;
    for(int i =0;i < n-1;i++){

        for(int j =0;j < n-1-i;j++){
                if(a[j]>a[j+1]){
                        temp = a[j+1];
                        a[j+1] = a[j];
                        a[j]=temp;
                            counter++;
                            v1.push_back(j);

                }

        }
    }
    return counter;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n ;
    cin >> n;
    char s[n];
    char t[n];
    cin >> s>>t;
     int x =bubblecounter(s,n);
      int y =bubblecounter(t,n);

     for(int i =0;i < n;i++){
        if(s[i]!=t[i]){
            cout << -1<<endl;
            return 0;
        }
    }
  if(x+y <= 10000){
        cout <<x+y<<endl;
        for(int i =0;i < v1.size();i++){
            cout << v1[i]+1<<" ";
        }
    }
    else{
        cout << -1<<endl;
    }

}


#include <iostream>
#include <vector>
#include <bits/stdc++.h>
#include <math.h>
#include <string.h>
using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
   int flag;

        int n ;
        int cnt = 0 ;
    cin >> n;
    string s,t;
    cin >> s>>t ;
    vector<int> ans;

    for(int i =0;i < n;i++){
           int  flag = 0;
            if(s[i]==t[i]){
                flag = 1;
                continue;
            }
        for(int j=i;j <  n;j++){
                if(s[j]==t[i]){
                    for(int m = j;m >=i+1;m--){
                        char temp = s[m];
                        s[m] = s[m-1];
                        s[m-1] = temp;
                        flag = 1;
                        cnt++;
                        ans.push_back(m);
                    }
                }

        }
        if(flag==0){
           cout << -1<<endl;
           return 0;
        }

    }

     if(cnt >  10000){
        cout << -1<<endl;
        return 0;
    }
    else{
        cout << cnt << endl;
        for(int i =0;i <  ans.size();i++){
            cout << ans[i]<<" ";
        }
    }

}


#include <iostream>
#include <vector>
#include <bits/stdc++.h>
#include <math.h>
#include <string.h>
using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
   int flag;

        int n ;
        int cnt = 0 ;
    cin >> n;
    string s,t;
    cin >> s>>t ;
    vector<int> ans;

    for(int i =0;i < n;i++){
           int  flag = 0;
            if(s[i]==t[i]){
                flag = 1;
                continue;
            }
        for(int j=i;j <  n;j++){
                if(s[j]==t[i]){
                    for(int m = j;m >=i+1;m--){
                       swap(s[m],s[m-1]);
                        flag = 1;
                        cnt++;
                        ans.push_back(m);

                    }
                    break;
                }

        }
        if(flag==0){
           cout << -1<<endl;
           return 0;
        }

    }

        cout << cnt << endl;
        for(int i =0;i <  ans.size();i++){
            cout << ans[i]<<" ";
        }

}


#include <iostream>
#include <vector>
#include <bits/stdc++.h>
#include <math.h>
#include <string.h>
using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
   int flag;

        int n ;
        int cnt = 0 ;
    cin >> n;
    string s,t;
    cin >> s>>t ;
    vector<int> ans;

    for(int i =0;i < n;i++){
           int  flag = 0;
            if(s[i]==t[i]){
                flag = 1;
                continue;
            }
        for(int j=i;j <  n;j++){
                if(s[j]==t[i]){
                    for(int m = j;m >=i+1;m--){
                        char temp = s[m];
                        s[m] = s[m-1];
                        s[m-1] = temp;
                        flag = 1;
                        cnt++;
                        ans.push_back(m);
                    }
                }

        }
        if(flag==0){
           break;
        }

    }
    if(flag==0){
        cout << -1<<endl;
        return 0;
    }
    else if(cnt >  10000){
        cout << -1<<endl;
        return 0;
    }
    else{
        cout << cnt << endl;
        for(int i =0;ii <  ans.size();i++){
            cout << ans[i]<<" ";
        }
    }

}


#include <iostream>
#include <vector>
#include <bits/stdc++.h>
#include <math.h>
#include <string.h>
using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
   int t,flag;
   cin >> t;
   while(t--){
        int n ;
        int cnt = 0 ;
    cin >> n;
    char s[n],t[n];
    cin >> s>>t ;
    vector<int> ans;

    for(int i =0;i < n;i++){
           // cout << "Searching for "<<t[i]<<endl;
           int  flag = 0;

            if(s[i]==t[i]){
               // cout<<"found without changing"<<endl;
                flag = 1;
                continue;
            }
        for(int j=i;j <  n;j++){
               // cout<<"in s array"<<s[j]<<endl;
                if(s[j]==t[i]){
                    // cout<<j<<"int s and  "<<i<<"int t"<<endl;
                    for(int m = j;m >=i+1;m--){
                        char temp = s[m];
                        s[m] = s[m-1];
                        s[m-1] = temp;
                        flag = 1;
                        cnt++;
                        ans.push_back(m);
                       /* for(int i =0;i < n;i++){
                            cout << s[i]<<" ";
                        }
                        cout <<flag<< endl;*/

                    }

                }

        }
        if(flag==0){
           break;
        }

    }
    if(flag==0 || cnt > 10000){
        cout << -1 << endl;
    }
    else{
        cout << cnt<< endl;
        for(int i =0;i < ans.size();i++){
            cout <<ans[i]<<" ";
            if(i=ans.size()-1){
                cout<<endl;
            }
        }

    }

   }

}


import java.util.Scanner;

public class letters {
    static long[] ans = new long[2];

    public static void main(String[] args) {
        Scanner inpu = new Scanner(System.in);
        int a = inpu.nextInt();
        int b = inpu.nextInt();
        long[] rooms = new long[a];
        long[] letter = new long[b];

        for (int i = 0; i < a; i++) {
            rooms[i] = inpu.nextLong();
        }
        for (int i = 0; i < b; i++) {
            letter[i] = inpu.nextLong();
        }

        long[] prefix = new long[a];
        prefix[0] = rooms[0];
        for (int i = 1; i < a; i++) {
            prefix[i] = rooms[i] + rooms[i - 1];
        }
        for (int i = 0; i < b; i++) {
            binsearch(letter[i], prefix, 0, a - 1);
            System.out.println(Long.toString(ans[0]) + " " + Long.toString(ans[1]));
        }
        inpu.close();
    }

    public static void binsearch(long b, long[] prefix, int start, int a) {
        // System.out.println("start = " + Integer.toString(start));
        // System.out.println("end = " + Integer.toString(a));
        int mid = (int) (a + start) / 2;
        // System.out.println("mid = " + Integer.toString(mid));
        if (Math.abs(start - a) <= 1) {
            if (prefix[start] >= b) {
                ans[0] = (long) start + 1;
                if (start == 0) {
                    ans[1] = b;
                } else {
                    ans[1] = b - (long) prefix[start - 1];
                }
                return;

            } else {
                if (a == 0) {
                    ans[1] = (long) prefix[a];
                } else {

                    ans[1] = b - (long) prefix[a - 1];
                }
                ans[0] = (long) a + 1;
                return;
            }

        }
        if (prefix[mid] <= b) {
            binsearch(b, prefix, mid + 1, a);
        } else {

            binsearch(b, prefix, start, mid);
        }

    }
}


import java.util.Arrays;
import java.util.Scanner;

public class letters {
    static long[] ans = new long[2];

    public static void main(String[] args) {
        Scanner inpu = new Scanner(System.in);
        int a = inpu.nextInt();
        int b = inpu.nextInt();
        long[] rooms = new long[a];
        long[] letter = new long[b];

        for (int i = 0; i < a; i++) {
            rooms[i] = inpu.nextLong();
        }
        for (int i = 0; i < b; i++) {
            letter[i] = inpu.nextLong();
        }

        long[] prefix = new long[a];
        prefix[0] = rooms[0];
        for (int i = 1; i < a; i++) {
            prefix[i] = rooms[i] + prefix[i - 1];
        }
        for (int i = 0; i < b; i++) {
            binsearch(letter[i], prefix, 0, a - 1);
            System.out.println(Long.toString(ans[0]) + " " + Long.toString(ans[1]));
        }
        inpu.close();
    }

    public static void binsearch(long b, long[] prefix, int start, int a) {
        // System.out.println("start = " + Integer.toString(start));

        int mid = (int) (a + start) / 2;
        // System.out.println("mid = " + Integer.toString(mid));
        // System.out.println("end = " + Integer.toString(a));
        // System.out.println("b = " + Long.toString(b));
        // System.out.println("Array is " + Arrays.toString(prefix));
        if (Math.abs(start - a) <= 1) {
            if (prefix[start] >= b) {
                ans[0] = (long) start + 1;
                if (start == 0) {
                    ans[1] = b;
                } else {
                    ans[1] = b - (long) prefix[start - 1];
                }
                return;

            } else {
                if (a == 0) {
                    ans[1] = (long) prefix[a];
                } else {

                    ans[1] = b - (long) prefix[a - 1];
                }
                ans[0] = (long) a + 1;
                return;
            }

        }
        if (prefix[mid] < b) {
            binsearch(b, prefix, mid + 1, a);
        } else {

            binsearch(b, prefix, start, mid);
        }

    }
}


import java.util.Scanner;

public class letters {
    static int[] ans = new int[2];

    public static void main(String[] args) {
        Scanner inpu = new Scanner(System.in);
        int a = inpu.nextInt();
        int b = inpu.nextInt();
        int[] rooms = new int[a];
        int[] letter = new int[b];

        for (int i = 0; i < a; i++) {
            rooms[i] = inpu.nextInt();
        }
        for (int i = 0; i < b; i++) {
            letter[i] = inpu.nextInt();
        }

        int[] prefix = new int[a];
        prefix[0] = rooms[0];
        for (int i = 1; i < a; i++) {
            prefix[i] = rooms[i] + rooms[i - 1];
        }
        for (int i = 0; i < b; i++) {
            binsearch(letter[i], prefix, 0, a - 1);
            System.out.println(Integer.toString(ans[0]) + " " + Integer.toString(ans[1]));
        }
        inpu.close();
    }

    public static void binsearch(int b, int[] prefix, int start, int a) {
        // System.out.println("start = " + Integer.toString(start));
        // System.out.println("end = " + Integer.toString(a));
        int mid = (int) (a + start) / 2;
        // System.out.println("mid = " + Integer.toString(mid));
        if (Math.abs(start - a) <= 1) {
            if (prefix[start] >= b) {
                ans[0] = start + 1;
                if (start == 0) {
                    ans[1] = b;
                } else {
                    ans[1] = b - prefix[start - 1];
                }
                return;

            } else {
                if (a == 0) {
                    ans[1] = prefix[a];
                } else {

                    ans[1] = b - prefix[a - 1];
                }
                ans[0] = a + 1;
                return;
            }

        }
        if (prefix[mid] <= b) {
            binsearch(b, prefix, mid + 1, a);
        } else {

            binsearch(b, prefix, start, mid);
        }

    }
}


import java.io.*;
import java.util.*;

public class SDS {
    public static void main(String[] args) throws Exception{

    //   Scanner sc=new Scanner(System.in);
     BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        OutputWriter out = new OutputWriter(System.out);
        String sizes[] = br.readLine().trim().split(" ");
		   int n = Integer.parseInt(sizes[0]);
		   int m = Integer.parseInt(sizes[1]);
        long a[]=new long[n];
        long b[]=new long[m];
        long sum =0;

         String first[] = br.readLine().split(" ");
        for(int i=0;i<n;i++){
            long k= Integer.parseInt(first[i]);
            a[i]=sum+k;
            sum=sum+k;
        }
    String second[] = br.readLine().split(" ");
        for(int i=0;i<m;i++){
            b[i]=Integer.parseInt(second[i]);
        }
        int j=0;
        sum=0;
        for(int i=0;i<n;i++){
            if(b[j]<=a[i]){
                //System.out.println(sum);
                out.printLine((i+1)+" "+(b[j]-sum));
                //System.out.println(b[j]-sum);
                j++;
                i--;

            }

            else{
                sum=a[i];
            }

             if(j==m){
                break;
            }

        }
        out.flush();
        out.close();
    }
}

class OutputWriter {
		private final PrintWriter writer;
		public OutputWriter(OutputStream outputStream) {
			writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
		}
		public OutputWriter(Writer writer) {
			this.writer = new PrintWriter(writer);
		}
		public void print(Object...objects) {
			for (int i = 0; i < objects.length; i++) {
				if (i != 0)
					writer.print(' ');
				writer.print(objects[i]);
			}
		}
		public void printLine(Object...objects) {
			print(objects);
			writer.println();
		}
		public void close() {
			writer.close();
		}
		public void flush() {
			writer.flush();
		}
		}


import java.io.*;
import java.util.*;

public class SDS {
    public static void main(String[] args) {

       Scanner sc=new Scanner(System.in);

        int n= sc.nextInt();
        int m= sc.nextInt();
        long a[]=new long[n];
        long b[]=new long[m];
        long sum =0;

        for(int i=0;i<n;i++){
            long k=sc.nextLong();
            a[i]=sum+k;
            sum=sum+k;
        }

        for(int i=0;i<m;i++){
            b[i]=sc.nextLong();
        }
        int j=0;
        sum=0;
        for(int i=0;i<n;i++){
            if(b[j]<=a[i]){
                //System.out.println(sum);
                System.out.println((i+1)+" "+(b[j]-sum));
                //System.out.println(b[j]-sum);
                j++;
                i--;

            }

            else{
                sum=a[i];
            }

             if(j==m){
                break;
            }

        }
    }
}


    import java.io.*;
    import java.lang.reflect.Array;
    import java.util.*;

    public class Main {
        public static void main(String[] args) throws IOException {
            FastReader scan = new FastReader();
            //PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter("taming.out")));
            PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
            Task solver = new Task();
            //int t = scan.nextInt();
            int t = 1;
            for(int i = 1; i <= t; i++) solver.solve(i, scan, out);
            out.close();
        }
        static class Task {
            public void solve(int testNumber, FastReader sc, PrintWriter pw) {
                int n = sc.nextInt();
                int m = sc.nextInt();
                long[] arr=  new long[n+1];
                for(int i=1;i<=n;i++){
                    arr[i]=sc.nextLong()+arr[i-1];
                }
                for(int i=0;i<m;i++){
                    long a = sc.nextLong();
                    int ind = Arrays.binarySearch(arr,a);
                    if(ind<0){
                        ind=-ind-1;
                    }
                    pw.println(ind+" "+(a-arr[ind-1]));

                }
            }
        }

        static class tup implements Comparable<tup> {
            int a, b;

            tup() {
            }

            ;

            tup(int a, int b) {
                this.a = a;
                this.b = b;
            }

            @Override
            public int compareTo(tup o2) {
                return a==o2.a?Integer.compare(o2.b,b):Integer.compare(o2.a, a);
            }
        }
        static void shuffle(long[] a) {
            Random get = new Random();
            for (int i = 0; i < a.length; i++) {
                int r = get.nextInt(a.length);
                long temp = a[i];
                a[i] = a[r];
                a[r] = temp;
            }
        }
        static void shuffle(int[] a) {
            Random get = new Random();
            for (int i = 0; i < a.length; i++) {
                int r = get.nextInt(a.length);
                int temp = a[i];
                a[i] = a[r];
                a[r] = temp;
            }
        }
        static class FastReader {
            BufferedReader br;
            StringTokenizer st;

            public FastReader() {
                br = new BufferedReader(new InputStreamReader(System.in));
            }

            public FastReader(String s) throws FileNotFoundException {
                br = new BufferedReader(new FileReader(new File(s)));
            }

            String next() {
                while (st == null || !st.hasMoreElements()) {
                    try {
                        st = new StringTokenizer(br.readLine());
                    } catch (IOException e) {
                        e.printStackTrace();
                    }
                }
                return st.nextToken();
            }

            int nextInt() {
                return Integer.parseInt(next());
            }

            long nextLong() {
                return Long.parseLong(next());
            }

            double nextDouble() {
                return Double.parseDouble(next());
            }

            String nextLine() {
                String str = "";
                try {
                    str = br.readLine();
                } catch (IOException e) {
                    e.printStackTrace();
                }
                return str;
            }
        }

    }


import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Scanner;

public class codeforcesDP {
    static int MOD = 1000000007;
    static Scanner sc = new Scanner(System.in);
    public static void main(String[] args) {

        int n = sc.nextInt();
        int m = sc.nextInt();

        long[] arr = takeInputLong(n);
        long[] letters = takeInputLong(m);

        long[] prefix = prefixSumLong(arr);

        int temp = 0;
        long room = 0;
        StringBuilder sb = new StringBuilder();
        for(int i = 0;i<m;i++){
            temp = binarySearch(prefix,letters[i]);
            if(temp == -1){
                temp = 1;
                room = letters[i];
                sb.append(temp + " " + room + "\n");
                continue;
            }
            room = letters[i] - prefix[temp];
            if(room == 0)
                room = arr[temp];
            else
                temp++;
            temp++;
            sb.append(temp + " " + room + "\n");
        }
        System.out.println(sb.toString());
    }

    static int binarySearch(int[] arr, int x){
        int low = 0;
        int high = arr.length-1;
        int mid;
        while(low < high){
            mid = (low + high)/2;
            if(arr[mid] == x)
                return mid;
            if(arr[mid] < x){
                low = mid + 1;
            }
            else {
                high = mid-1;
            }
        }
        if(arr[low] > x)
            return low-1;
        return low;
    }

    static int binarySearch(long[] arr, long x){
        int low = 0;
        int high = arr.length-1;
        int mid;
        while(low < high){
            mid = (low + high)/2;
            if(arr[mid] == x)
                return mid;
            if(arr[mid] < x){
                low = mid + 1;
            }
            else {
                high = mid-1;
            }
        }
        if(arr[low] > x)
            return low-1;
        return low;
    }

    static int binarySearchUB(int[] arr,int x){
        int low = 0;
        int high = arr.length-1;
        int mid;
        int ans = 0;
        int upper = 0;
        while(low <= high){
            mid = (low + high)/2;
            if(arr[mid] == x){
                low = mid + 1;
                ans = mid;
            }
            else if(arr[mid] < x){
                low = mid+1;
                upper = low;
            }
            else {
                high = mid - 1;
            }
        }
        if(arr[ans] == x)
            return ans;
        return upper;
    }

    static int binarySearchLB(int[] arr,int x){
        int low = 0;
        int high = arr.length-1;
        int mid;
        int ans = 0;
        int lower = 0;
        while(low <= high){
            mid = (low + high)/2;
            if(arr[mid] == x){
                ans = mid;
                high = mid - 1;
            }
            else if(arr[mid] < x){
                low = mid + 1;
            }
            else {
                high = mid - 1;
                lower = high;
            }
        }
        if(arr[ans] == x)
            return ans;
        return lower;
    }

    static int[] prefixSum(int[] arr){
        int[] ans = new int[arr.length];
        ans[0] = arr[0];
        for(int  i = 1;i<arr.length;i++){
            ans[i] = ans[i-1] + arr[i];
        }
        return ans;
    }

    static long[] prefixSumLong(long[] arr){
        long[] ans = new long[arr.length];
        ans[0] = arr[0];
        for(int  i = 1;i<arr.length;i++){
            ans[i] = ans[i-1] + arr[i];
        }
        return ans;
    }
    static int kadane(int[] arr){

        int max = Integer.MIN_VALUE;
        int tempMax = 0;

        for(int i = 0;i<arr.length;i++){
            if(tempMax + arr[i] < arr[i]){
                tempMax = arr[i];
            }
            else {
                tempMax += arr[i];
            }
            if(tempMax > max){
                max = tempMax;
            }
        }
        return max;
    }

    static void printArr(long[] arr){
        for(long i : arr)
            System.out.print(i + " ");
        System.out.println();
    }

    static void printDP(int[][] dp){
        for(int i=0;i<dp.length;i++){
            for(int j = 0;j<dp[0].length;j++){
                System.out.print(dp[i][j] + " ");
            }
            System.out.println();
        }

    }

    static int helpMe(int index, char[] ch, int length, int[][] dp){

        char c = 'Q';
        if(length == 1)
            c = 'A';
        if(length == 3)
            return 1;
        if(index == ch.length)
            return 0;
        if(dp[index][length] != -1)
            return dp[index][length];
        int considering = 0;
        if(c == ch[index])
            considering = helpMe(index+1,ch,length+1,dp);
        int notConsidering = helpMe(index+1,ch,length,dp);
        dp[index][length] = considering+notConsidering;
        return considering+notConsidering;
    }

    static int[] takeInputInt(int n){
        int[] input = new int[n];
        for(int i=0;i<n;i++){
            input[i] = sc.nextInt();
        }
        return input;
    }
    static long[] takeInputLong(int n){
        long[] input = new long[n];
        for(int i=0;i<n;i++){
            input[i] = sc.nextLong();
        }
        return input;
    }

}


import java.util.*;
public class GG
{

	public static void main(String[] args)
	{
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();int t=sc.nextInt();
		long a[]=new long[n+1];
		for (int i=0;i<n;i++)
			a[i+1]=a[i]+sc.nextLong();
		long k;int l,u,mid;
		while (t-->0)
		{
			k=sc.nextLong();l=0;u=n;mid=0;
			while (0<u-l)
			{
				mid=(u+l)/2;
				if (a[mid]>k)u=mid-1;
				else  if(a[mid]<k)l=mid+1;
				else {break;}
			}
			//System.out.println(Arrays.toString(a));
			//System.out.println(l+" "+u+" "+mid);
			//System.out.println();
			if (a[mid]==k)
			System.out.println((mid)+" "+(k-a[mid-1]));
			else if (u==l && l==n)
			System.out.println(n+" "+(k-a[n-1]));
			else if (u==l && l==0)
			System.out.println(1+" "+(k));
			else
			System.out.println(l+" "+(k-a[u]));
			//System.out.println(l+" "+(k-a[l]));
		}
	}
}


import java.util.*;
public class GG
{

	public static void main(String[] args)
	{
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();int t=sc.nextInt();
		long a[]=new long[n+1];
		for (int i=0;i<n;i++)
			a[i+1]=a[i]+sc.nextLong();
		long k;int l,u,mid;
		System.out.println(Arrays.toString(a));
		while (t-->0)
		{
			k=sc.nextLong();l=0;u=n;mid=0;
			while (0<u-l)
			{
				mid=(u+l)/2;
				if (a[mid]>k)u=mid-1;
				else  if(a[mid]<k)l=mid+1;
				else {break;}
			}

			//System.out.println(k+"-"+l+"-"+u+"-"+mid);
			for (int i=Math.max(Math.min(Math.min(u,l),mid)-1,0);
				i<=Math.min(Math.max(Math.max(u,l),mid),n-1);i++)
				if (a[i]<k && k<=a[i+1])System.out.println((i+1)+" "+(k-a[i]));
			//System.out.println();
		}
	}
}


import java.util.*;
public class GG
{

	public static void main(String[] args)
	{
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();int t=sc.nextInt();
		long a[]=new long[n+1];
		for (int i=0;i<n;i++)
			a[i+1]=a[i]+sc.nextLong();
		long k;int l,u,mid;
		//System.out.println(Arrays.toString(a));
		while (t-->0)
		{
			k=sc.nextLong();l=0;u=n;mid=0;
			while (0<u-l)
			{
				mid=(u+l)/2;
				if (a[mid]>k)u=mid-1;
				else  if(a[mid]<k)l=mid+1;
				else {break;}
			}

			//System.out.println(k+"-"+l+"-"+u+"-"+mid);
			for (int i=Math.max(Math.min(Math.min(u,l),mid)-1,0);
				i<=Math.min(Math.max(Math.max(u,l),mid),n-1);i++)
				if (a[i]<k && k<=a[i+1])System.out.println((i+1)+" "+(k-a[i]));
			//System.out.println();
		}
	}
}


import java.io.*;
import java.util.*;

public class Main {
    public static void main (String[]args){
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int m = scanner.nextInt();
        long a[] = new long [n];
        long b[] = new long [m];
        long total=0;
        for (int i=0;i<n;i++){
            total+=(scanner.nextLong());
            a[i]=total;
        }
        int dormIndex=0;
        long previousTotal=0;
        for (int i=0;i<m;i++){
            long room=scanner.nextLong();
            while(room>a[dormIndex]){
                dormIndex++;
                previousTotal=a[dormIndex-1];
            }
            System.out.print(dormIndex+1+" ");
            System.out.println(room-previousTotal);

        }

    }
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;
import java.util.Collections;
import java.util.StringTokenizer;

public class Codeforces978C {

	public static void main(String[] args) {
		FastScanner sc=new FastScanner();
		long n = sc.nextInt() , k = sc.nextInt();
		long a[] = new long[(int)n+1];
		long presum[] = new long[(int)n+1];
		for(int i = 1 ; i <= n ; i++) {
			a[i] = sc.nextLong();
			presum[i] = a[i] + presum[i-1];
		}
		for(int i = 0 ; i  < k ; i++) {
			long b = sc.nextLong();
			long left = 0 , right = n , index = 0;
			while(left <= right) {
				long mid = left + (right - left)/2 ;
				if(presum[(int)mid] >= b) {
					index = mid;
					right = mid - 1;
				}else if(presum[(int)mid] < b){left = mid + 1;}
			}
			long dorm = index;
	        long room = b - presum[(int)index - 1];
	        System.out.println(dorm + " " + room);
		}
	}

	public void sort(int[] a) {
		ArrayList<Integer> l=new ArrayList<>();
		for (int i:a) l.add(i);
		Collections.sort(l);
		for (int i=0; i<a.length; i++) a[i]=l.get(i);
	}

	static class FastScanner {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer("");

		public String next() {
			while (!st.hasMoreElements())
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		long nextLong() {
			return Long.parseLong(next());
		}

		int[] readArray(int n) {
			int[] a=new int[n];
			for (int i=0; i<n; i++) a[i]=nextInt();
			return a;
		}
	}

}


import java.util.*;

public class solution {

	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		int m=sc.nextInt();
		long[] a=new long[n+1];
		a[0]=0;
		long[] b=new long[m];
		for(int i=1;i<=n;i++) {
			a[i]=sc.nextLong();
		}
		for(int i=0;i<m;i++) {
			b[i]=sc.nextLong();
		}
		long t=a[1];
		int k=1;
		int i=0;
		while(i<m) {
			if(b[i]<=t) {
				System.out.println(k +" "+ (b[i]-(t-a[k])));
				i++;
			}
			else {
				k++;
				t+=a[k];
			}
		}
		sc.close();
	}
}


import java.util.*;

public class Test{
    public static void main(String[] args) {
        int n,m;
        Scanner in = new Scanner(System.in);
        n = in.nextInt();
        m = in.nextInt();
        long [] arr  = new long [n];
        for(int i=0;i<n;i++) {
            if(i==0) {
                arr[i] = in.nextLong();
                continue;
            }
            long tmp = in.nextLong();
            arr[i] = arr[i-1]+tmp;
        }

        for(int i=0;i<m;i++) {
            long num = in.nextLong();
            long ans = binary_search(arr,0,n-1,num);
            long ans2 = 0;
            if(ans == 0) {
                ans2 = num;
            }
            else {
                ans2 = num - arr[(int)(ans-1)];
            }
            System.out.println(ans+1+" "+ans2);
        }
    }

    public static long binary_search(long[] arr,int s,int e,long n) {
        int ans=-1;
        while(s<=e) {
            int mid = (s+e)/2;

            // if(arr[mid] >= n && arr[mid-1]<n) {
            //     return mid;
            // }
            // else if(arr[mid]<n) {
            //     s = mid+1;
            // }
            // else if(arr[mid]>n && arr[mid-1]>n) {
            //     e=mid-1;
            // }
            if(arr[mid]<n){
                s = mid+1;
            }
            else{
                ans = mid;
                e = mid-1;
            }
        }
        return ans;
    }
}


import java.util.*;

public class Test{
    public static void main(String[] args) {
        int n,m;
        Scanner in = new Scanner(System.in);
        n = in.nextInt();
        m = in.nextInt();
        long [] arr  = new long [n];
        for(int i=0;i<n;i++) {
            if(i==0) {
                arr[i] = in.nextLong();
                continue;
            }
            long tmp = in.nextLong();
            arr[i] = arr[i-1]+tmp;
        }

        for(int i=0;i<m;i++) {
            long num = in.nextLong();
            long ans = binary_search(arr,0,n-1,num);
            long ans2 = 0;
            if(ans == 0) {
                ans2 = num;
            }
            else {
                ans2 = num - arr[(int)(ans-1)];
            }
            System.out.println(ans+1+" "+ans2);
        }
    }

    public static long binary_search(long[] arr,int s,int e,long n) {
        int ans=-1;
        while(s<=e) {
            int mid = (s+e)/2;
            if(mid == 0 && arr[mid]>=n) {
                return mid;
            }
            if(mid == 0 && arr[mid]<n){
                s = mid+1;
                continue;
            }

            if(arr[mid] >= n && arr[mid-1]<n) {
                return mid;
            }
            else if(arr[mid]<n) {
                s = mid+1;
            }
            else if(arr[mid]>n && arr[mid-1]>n) {
                e=mid-1;
            }
            // if(arr[mid]<n){
            //     s = mid+1;
            // }
            // else{
            //     ans = mid;
            //     e = mid-1;
            // }
        }
        return -1;
    }
}


import java.util.*;
public class cf481_3_3 {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt(),m=sc.nextInt();
		long a[] = new long[n];

		for(int i=0;i<n;i++) {
			a[i] = sc.nextLong();
		}

		long pre[] = new long[n];
		pre[0]=a[0];
		for(int i=1;i<n;i++) {
			pre[i] = pre[i-1]+a[i];
		}

		for(int i=0;i<m;i++) {
			long b = sc.nextLong();
			int l=0,r=n-1,ans=-1;
			while(r>=l) {
				int mid = (l+r)/2;
				if(pre[mid] >= b) {
					ans = mid;
					r = mid-1;
				}else {
					l=mid+1;
				}
			}
			if(ans == 0) {
				System.out.println(1 + " " + b);
			}else {
				System.out.println((ans+1) + " " + (b-pre[ans-1]));
			}
		}
		sc.close();
	}

}


import java.util.Scanner;

//Codeforces Round #481 (Div. 3) C

public class Letters {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int N = in.nextInt(); //number of dorms
		int M = in.nextInt(); //number of letters

		long[] roomCt = new long[N];
		for(int i=1; i<N; i++)
			roomCt[i] = roomCt[i-1] + in.nextLong();

		long RN = in.nextLong();
		for(int j=0; j<M; j++)
		{
			RN = in.nextLong(); int i=0;
			while(i<N-1 && RN > roomCt[i+1]) i++;
			RN -= roomCt[i];
			System.out.println(i+1 + " " + RN);
		}
		in.close();

	}

}


import java.util.Scanner;

//Codeforces Round #481 (Div. 3) C

public class Letters {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int N = in.nextInt(); //number of dorms
		int M = in.nextInt(); //number of letters

		long[] roomCt = new long[N+1];
		for(int i=1; i<N+1; i++)
			roomCt[i] = roomCt[i-1] + in.nextLong();

		for(int j=0; j<M; j++)
		{
			long RN = in.nextLong();
			int upper = N; //index of upper bound
			int lower = 0; //index of lower bound

			//binary search to improve time
			while(!(RN > roomCt[lower] && RN <= roomCt[lower + 1]))
			{
				if(RN > roomCt[(lower + upper)/2])
					lower = (lower + upper)/2;
				else
					upper = (lower + upper)/2;
			}

			RN -= roomCt[lower];
			System.out.println(lower+1 + " " + RN);
		}
		in.close();

	}

}


//package codeforces.com.tasks.archive;

import java.io.PrintStream;
import java.util.Scanner;

public class C978 {

    private static PrintStream out = System.out;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int houses = sc.nextInt(), letters = sc.nextInt();
        long[] flatsInHouse = new long[houses];
        for (int i = 0; i < houses; i++)
            flatsInHouse[i] = sc.nextLong();

        long flatsSum = 0;
        int houseNumber = 0;
        for (int i = 0; i < letters; i++) {
            long flat = sc.nextLong();
            while (flatsSum + flatsInHouse[houseNumber] < flat)
                flatsSum += flatsInHouse[houseNumber++];
            out.println(houseNumber + 1 + " " + (flat - flatsSum));
        }
    }
}


//package codeforces.com.tasks.task978C;

import java.util.Scanner;

public class Program {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int houses = sc.nextInt(), letters = sc.nextInt();
        long[] flatsInHouse = new long[houses];
        for (int i = 0; i < houses; i++)
            flatsInHouse[i] = sc.nextLong();

        long flatsSum = 0;
        int houseNumber = 0;
        for (int i = 0; i < letters; i++) {
            long flat = sc.nextLong();
            while (flatsSum + flatsInHouse[houseNumber] < flat)
                flatsSum += flatsInHouse[houseNumber++];
            System.out.println(houseNumber + 1 + " " + (flat - flatsSum));
        }
    }
}


//package codeforces.com.tasks.task978C;

import java.util.Scanner;

public class Program {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int houses = sc.nextInt();
        int letters = sc.nextInt();
        long[] flatsInHouse = new long[houses];
        for (int i = 0; i < houses; i++) {
            flatsInHouse[i] = sc.nextLong();
        }
        for (int i = 0; i < letters; i++) {
            long address = sc.nextLong();
            long addrSum = 0;
            int houseNumber = 0;
            while (address > addrSum && houseNumber < houses) {
                addrSum += flatsInHouse[houseNumber];
                houseNumber++;
            }
            long flatNumber = address - (addrSum - flatsInHouse[houseNumber-1]);
            System.out.println(houseNumber + " " + flatNumber);

        }
    }
}


//package codeforces.com.tasks.task978C;

import java.util.Scanner;

public class Program {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int houses = sc.nextInt();
        int letters = sc.nextInt();
        long[] flatsInHouse = new long[houses];
        for (int i = 0; i < houses; i++) {
            flatsInHouse[i] = sc.nextLong();
        }
        for (int i = 0; i < letters; i++) {
            long address = sc.nextLong();
            long addrSum = 0;
            int houseNumber = 0;
            while (houseNumber < houses && addrSum + flatsInHouse[houseNumber] < address)
                addrSum += flatsInHouse[houseNumber++];
            System.out.println(houseNumber + 1 + " " + (address - addrSum));
        }
    }
}


//package codeforces.com.tasks.task978C;

import java.util.Scanner;

public class Program {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int houses = sc.nextInt(), letters = sc.nextInt();
        long[] flatsInHouse = new long[houses];
        for (int i = 0; i < houses; i++)
            flatsInHouse[i] = sc.nextLong();

        for (int i = 0; i < letters; i++) {
            long address = sc.nextLong();
            long addrSum = 0;
            int houseNumber = 0;
            while (houseNumber < houses && addrSum + flatsInHouse[houseNumber] < address)
                addrSum += flatsInHouse[houseNumber++];
            System.out.println(houseNumber + 1 + " " + (address - addrSum));
        }
    }
}


package codeforces.com.tasks.archive;//package codeforces.com.tasks.task978C;

import java.io.PrintStream;
import java.util.Scanner;

public class C978 {

    private static PrintStream out = System.out;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int houses = sc.nextInt(), letters = sc.nextInt();
        long[] flatsInHouse = new long[houses];
        for (int i = 0; i < houses; i++)
            flatsInHouse[i] = sc.nextLong();

        long flatsSum = 0;
        int houseNumber = 0;
        for (int i = 0; i < letters; i++) {
            long flat = sc.nextLong();
            while (flatsSum + flatsInHouse[houseNumber] < flat)
                flatsSum += flatsInHouse[houseNumber++];
            out.println(houseNumber + 1 + " " + (flat - flatsSum));
        }
    }
}


package codeforces.com.tasks.task978C;

import java.util.Scanner;

public class Program {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int houses = sc.nextInt();
        int letters = sc.nextInt();
        long[] flatsInHouse = new long[houses];
        for (int i = 0; i < houses; i++) {
            flatsInHouse[i] = sc.nextLong();
        }
        for (int i = 0; i < letters; i++) {
            long address = sc.nextLong();
            long addrSum = 0;
            int houseNumber = 0;
            while (houseNumber < houses && addrSum + flatsInHouse[houseNumber] < address)
                addrSum += flatsInHouse[houseNumber++];
            System.out.println(houseNumber + 1 + " " + (address - addrSum));
        }
    }
}


package codeforces.com.tasks.task978C;

import java.util.Scanner;

public class Program {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int houses = sc.nextInt(), letters = sc.nextInt();
        long[] flatsInHouse = new long[houses];
        for (int i = 0; i < houses; i++)
            flatsInHouse[i] = sc.nextLong();

        for (int i = 0; i < letters; i++) {
            long address = sc.nextLong();
            long addrSum = 0;
            int houseNumber = 0;
            while (houseNumber < houses && addrSum + flatsInHouse[houseNumber] < address)
                addrSum += flatsInHouse[houseNumber++];
            System.out.println(houseNumber + 1 + " " + (address - addrSum));
        }
    }
}


//package codeforces.com.tasks.task978C;

import java.util.Scanner;

public class Program {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int houses = sc.nextInt();
        int letters = sc.nextInt();
        long[] flatsInHouse = new long[houses];
        for (int i = 0; i < houses; i++) {
            flatsInHouse[i] = sc.nextLong();
        }
        for (int i = 0; i < letters; i++) {
            long address = sc.nextLong();

            for (int j = 0; j < houses; j++) {
                if (address <= flatsInHouse[j]) {
                    System.out.println(j + 1 + " " + address);
                    break;
                } else {
                    address -= flatsInHouse[j];
                }
            }
        }
    }

}


//package codeforces.com.tasks.task978C;

import java.util.Scanner;

public class Program {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int houses = sc.nextInt();
        int letters = sc.nextInt();
        int[] flatsInHouse = new int[houses];
        int[] letterAddresses = new int[letters];
        for (int i = 0; i < houses; i++) {
            flatsInHouse[i] = sc.nextInt();
        }
        for (int i = 0; i < letters; i++) {
            letterAddresses[i] = sc.nextInt();
        }
        for (int i = 0; i < letters; i++) {
            int address = letterAddresses[i];
            for (int j = 0; j < houses; j++) {
                if (address <= flatsInHouse[j]) {
                    System.out.println(j + 1 + " " + address);
                    break;
                } else {
                    address -= flatsInHouse[j];
                }
            }
        }
    }

}


//package codeforces.com.tasks.task978C;

import java.util.Scanner;

public class Program {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int houses = sc.nextInt();
        int letters = sc.nextInt();
        long[] flatsInHouse = new long[houses];
        long[] letterAddresses = new long[letters];
        for (int i = 0; i < houses; i++) {
            flatsInHouse[i] = sc.nextLong();
        }
        for (int i = 0; i < letters; i++) {
            letterAddresses[i] = sc.nextLong();
        }
        for (int i = 0; i < letters; i++) {
            long address = letterAddresses[i];
            for (int j = 0; j < houses; j++) {
                if (address <= flatsInHouse[j]) {
                    System.out.println(j + 1 + " " + address);
                    break;
                } else {
                    address -= flatsInHouse[j];
                }
            }
        }
    }

}


//package codeforces.com.tasks.task978C;

import java.util.Scanner;

public class Program {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int houses = sc.nextInt();
        int letters = sc.nextInt();
        Long[] flatsInHouse = new Long[houses];
        Long[] letterAddresses = new Long[letters];
        for (int i = 0; i < houses; i++) {
            flatsInHouse[i] = sc.nextLong();
        }
        for (int i = 0; i < letters; i++) {
            letterAddresses[i] = sc.nextLong();
        }
        for (int i = 0; i < letters; i++) {
            long address = letterAddresses[i];
            for (int j = 0; j < houses; j++) {
                if (address <= flatsInHouse[j]) {
                    System.out.println(j + 1 + " " + address);
                    break;
                } else {
                    address -= flatsInHouse[j];
                }
            }
        }
    }

}


import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.Scanner;

public class Letters {
    public static void main(String [] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        double [] dormwiseRooms = new double[n];
        for (int i = 0; i < n; ++i){
            dormwiseRooms[i] = sc.nextDouble();
        }
        double [] letterAddresses = new double[m];
        for (int j = 0; j < m; ++j){
            letterAddresses[j] = sc.nextDouble();
        }
        double count = 0;
        int k = 0;
        double prevCount = count;
        for (int i = 0; i < m; ++i) {
            if (i > 0) System.out.println();
            double currAddress = letterAddresses[i];
            while (count < currAddress) {
                prevCount = count;
                count = count + dormwiseRooms[k];
                k++;
            }

            double largeDouble = currAddress - prevCount;
            BigDecimal big = new BigDecimal(largeDouble);
            big = big.setScale(0, RoundingMode.HALF_UP);

            System.out.print(k + " ");
            System.out.print(big);
        }
        sc.close();
    }
}


import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.util.StringTokenizer;

public class Training_Lecture {

    public static void main(String[] args) throws Exception {
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer tk = new StringTokenizer(in.readLine());
        BufferedWriter out = new BufferedWriter(new OutputStreamWriter(System.out));
        int n = Integer.parseInt(tk.nextToken());
        int m = Integer.parseInt(tk.nextToken());
        long arr1[] = new long[n];
        tk = new StringTokenizer(in.readLine());
        for (int i = 0; i < n; i++) {
            arr1[i] = Long.parseLong(tk.nextToken());
        }
        long cum[] = new long[n + 1];
        cum[0] = arr1[0];
        for (int i = 1; i < n; i++) {
            cum[i] = cum[i - 1] + arr1[i];
        }
        tk = new StringTokenizer(in.readLine());
        for (int i = 0; i < m; i++) {
            long x = Long.parseLong(tk.nextToken());
            int ans = Binary_Search(x, cum) + 1;
            long room = (ans == 1) ? x : x - cum[ans - 2];
            out.write(ans + " " + room);
            out.newLine();
        }
        out.flush();
    }

    public static int Binary_Search(long num, long arr[]) {
        int l = 0, h = arr.length - 1, mid = 0;
        while (l <= h) {
            mid = (l + h) / 2;
            if (arr[mid] > num) {
                h = mid - 1;
            } else if (arr[mid] < num) {
                l = mid + 1;
            } else if (arr[mid] == num) {
                return mid;
            }
        }
        if (arr[mid] < num) {
            return mid + 1;
        }
        return mid;
    }
}


import java.util.*;

public class Problem3 {
	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		int dorm = s.nextInt();
		int letters = s.nextInt();
		long accumulatedRooms[] = new long[dorm + 1];
		for (int i = 1; i <= dorm; i++) {
			long temp = s.nextLong();
			accumulatedRooms[i] = accumulatedRooms[i - 1] + temp;
		}

		int index = 0;
		for (int i = 0; i < letters; i++) {
			long roomNumber = s.nextLong();
			while (roomNumber > accumulatedRooms[index + 1]) {
				index++;
			}

			System.out.println((index + 1) + " " + (roomNumber - accumulatedRooms[index]));

		}
	}
}


import java.util.Scanner;

public class CLetters2 {

	public static void main(String[] args) {

		Scanner sc = new Scanner (System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		long[] a = new long[(int)n];
		for(int i = 0;i<n;i++) {
			a[i] = sc.nextLong();

		}
		long sum = 0;
		int res = 1;
		for(int i =0;i<m;i++) {
			long x = sc.nextLong();
			while(sum + a[res-1] < x) {
				sum += a[res - 1];
				res ++;
			}
			System.out.print(res + " ");
			System.out.println(x - sum);
		}

	}

}


import java.util.*;
public class CLetters {

	public static void main(String[] args) {

		Scanner sc = new Scanner (System.in);
		long n = sc.nextLong();
		long m = sc.nextLong();
		long[] a = new long[(int)n];
		long[] b = new long[(int)m];
		for(long i =0;i<n;i++) {
			a[(int)i] = sc.nextLong();
		}
		for(long i =0;i<m;i++) {
			b[(int)i] = sc.nextLong();
		}
		long temp = 0;
		long res = 0;
		for(long i =0;i<m;i++) {
			res = 0;
			temp = b[(int)i];
			for(long j = 0;temp - a[(int)j] > 0;j++) {
				temp -= a[(int)j];
				res ++;
			}
			if(temp == 0) {
				System.out.println(res + " " +a[(int)res-1]);
			} else {
				System.out.println((res + 1) + " "+temp);
			}
		}

	}

}


import java.util.Scanner;

public class CLetters2 {

	public static void main(String[] args) {

		Scanner sc = new Scanner (System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int[] a = new int[(int)n];
		for(int i = 0;i<n;i++) {
			a[i] = sc.nextInt();

		}
		int sum = 0;
		int res = 1;
		for(int i =0;i<m;i++) {
			int x = sc.nextInt();
			while(sum + a[res-1] < x) {
				sum += a[res - 1];
				res ++;
			}
			System.out.print(res + " ");
			System.out.println(x - sum);
		}

	}

}


import java.util.*;

public class CLetters2 {

	public static void main(String[] args) {

		Scanner sc = new Scanner (System.in);
		long n = sc.nextLong();
		long m = sc.nextLong();
		long[] a = new long[(int)n];
		for(int i = 0;i<n;i++) {
			a[i] = sc.nextLong();

		}
		int sum = 0;
		int res = 1;
		for(int i =0;i<m;i++) {
			long x = sc.nextLong();
			while(sum + a[res-1] < x) {
				sum += a[res - 1];
				res ++;
			}
			System.out.print(res + " ");
			System.out.println(x - sum);
		}

	}

}


import java.util.*;
public class binarysearchapp {
    static long[] room;
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        int m=sc.nextInt();
        long sum=0;
        //long[] letter=new long[n];
        room=new long[n];
        for(int i=0;i<n;i++){
            sum+=sc.nextLong();
            room[i]=sum;
        }
        for(int i=0;i<m;i++){
            long x=sc.nextLong();
            long dom=binsearch(0,n-1,x);
            System.out.print((dom+1)+" ");
            if(dom!=0){
                long roo=x - room[(int)dom-1];
                System.out.println(roo);}
            else
                System.out.println(x);
        }
    }
    static long binsearch(long start, long end, long e){
        int mid=(int)(start+end)/2;
        if(mid==0){
            if(room[mid]>=e){
                return mid;
            }
            else
                return binsearch(1,end,e);
        }
        else if((room[mid]>=e)&&(room[mid-1]<e))
            return mid;

        else if((room[mid]>=e)&&(room[mid-1]>=e)){
            return binsearch(start, mid-1,e);
        }
        else
            return binsearch(mid+1,end,e);
    }
}


import java.util.*;
public class contest1 {
    static long[] room;
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        int m=sc.nextInt();
        long sum=0;
        //long[] letter=new long[n];
        room=new long[n];
        for(int i=0;i<n;i++){
            sum+=sc.nextLong();
            room[i]=sum;
        }
        for(int i=0;i<m;i++){
            long x=sc.nextLong();
            long dom=binsearch(0,n-1,x);
            System.out.print((dom+1)+" ");
            if(dom!=0){
                long roo=x - room[(int)dom-1];
                System.out.println(roo);}
            else
                System.out.println(x);
        }
    }
    static long binsearch(long start, long end, long e){
        int mid=(int)(start+end)/2;
        if(mid==0){
            if(room[mid]>=e){
                return mid;
            }
            else
                return binsearch(1,end,e);
        }
        else if((room[mid]>=e)&&(room[mid-1]<e))
            return mid;

        else if((room[mid]>=e)&&(room[mid-1]>=e)){
            return binsearch(start, mid-1,e);
        }
        else
            return binsearch(mid+1,end,e);
    }
}


	import java.util.*;

import java.io.*;
	import java.math.*;
	import java.awt.geom.*;

	import static java.lang.Math.*;

	public class Solution implements Runnable {

	    public void solve() throws Exception {

//	    	int t=sc.nextInt();
//	    	long mod=(long)1e9+7;
//
//	    	while(t-->0)
//	    	{
	    		int n=sc.nextInt();
	    		int m=sc.nextInt();
	    		long arr[]=new long[n];

	    		for(int i=0;i<n;i++)
	    		{
	    			arr[i]=sc.nextLong();
	    		}

	    		for(int i=1;i<n;i++)
	    		{

	    			arr[i]=arr[i]+arr[i-1];
	    			//out.println(arr[i]);
	    		}
	    		for(int i=0;i<m;i++)
	    		{
	    			long x=sc.nextLong();
	    			int start=0;
	    			int end=n-1;
	    			if(start==end)
	    			{
	    				out.println(1+" "+x);
	    				continue;
	    			}
	    			if(x>=arr[end])
    				{

    					out.println((end+1)+" "+(arr[end]-((end==0)?0:arr[end-1])));
    					continue;
    				}
	    			if(x<=arr[start])
    				{

    					out.println((1)+" "+x);
    					continue;
    				}
	    			while(start<=end)
	    			{
	    				int mid=start+(end-start)/2;
	    				if(x==arr[mid])
	    				{
	    					out.println((mid+1)+" "+(arr[mid]-((mid==0)?0:arr[mid-1])));
	    					break;
	    				}
	    				if(mid+1<n)
	    				{
	    				if(x>=arr[mid] && x<arr[mid+1])
	    				{
	    					out.println((mid+2)+" "+(x-arr[mid]));
	    					break;
	    				}
	    				}
	    				if(x<arr[mid])
	    				{
	    					end=mid-1;
	    				}
	    				else if(x>arr[mid] && x>=arr[mid+1])
	    				{
	    					start=mid+1;
	    				}
	    			}
	    		}

	    }

	    static long power(long x, long y, long p)
	    {

	        long res = 1;

	        x = x % p;

	       if (x == 0) return 0;

	        while (y > 0)
	        {
	            if((y & 1)==1)
	                res = (res * x) % p;
	            y = y >> 1;
	            x = (x * x) % p;
	        }
	        return res;
	    }

	    static Throwable uncaught;

	    BufferedReader in;
	    FastScanner sc;
	    PrintWriter out;

	    @Override
	    public void run() {
	        try {
	            in = new BufferedReader(new InputStreamReader(System.in));
	            out = new PrintWriter(System.out);
	            sc = new FastScanner(in);
	            solve();
	        } catch (Throwable uncaught) {
	            Solution.uncaught = uncaught;
	        } finally {
	            out.close();
	        }
	    }

	    public static void main(String[] args) throws Throwable {
	        Thread thread = new Thread(null, new Solution(), "", (1 << 26));
	        thread.start();
	        thread.join();
	        if (Solution.uncaught != null) {
	            throw Solution.uncaught;
	        }
	    }

	}

	class FastScanner {

	    BufferedReader in;
	    StringTokenizer st;

	    public FastScanner(BufferedReader in) {
	        this.in = in;
	    }

	    public String nextToken() throws Exception {
	        while (st == null || !st.hasMoreTokens()) {
	            st = new StringTokenizer(in.readLine());
	        }
	        return st.nextToken();
	    }

	    public int nextInt() throws Exception {
	        return Integer.parseInt(nextToken());
	    }

	    public int[] readArray(int n) throws Exception {
			int[] a=new int[n];
			for (int i=0; i<n; i++) a[i]=nextInt();
			return a;
		}

	    public long nextLong() throws Exception {
	        return Long.parseLong(nextToken());
	    }

	    public double nextDouble() throws Exception {
	        return Double.parseDouble(nextToken());
	    }

	}