//https://2no.co/2bjRx5
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#pragma GCC target("popcnt")  //https://godbolt.org/z/yQv94Y

typedef long long int ll;
typedef unsigned long long int  ull;
typedef long double ld;

const ld pi = 4.0*atan(1.0);
#define xlr8 ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); cout.precision(10); cout<<fixed

typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
// T.insert(a), T.erase(a), T.size()
// T.order_of_key(a) -- number of elements strictly less than a
// *T.find_by_order(k) -- k-th element in increasing order

struct Timer
{   chrono::time_point<chrono::high_resolution_clock> start , end; chrono:: duration<float> dur;
    Timer(){start = chrono::high_resolution_clock::now();}
    ~Timer(){   end = chrono::high_resolution_clock::now(); dur = end - start;  cout<<"\nTime Elapsed : " <<dur.count() << " s\n";  }
};

template<typename T>
void getVec(vector<T>& a , int st, int en)
{
    int dif = (en > st ? 1 : -1);
    for(int  i = st ; i!= en ; i+= dif)
        cin>>a[i];
}
template<typename T>
void getVecPair(vector<pair<T , T > >& a , int st, int en)
{
    int dif = (en > st ? 1 : -1);
    for(int  i = st ; i!= en ; i+= dif)
        cin>>a[i].first>>a[i].second;
}

//76149
template<int D, typename T>
struct Vec : public vector<Vec<D - 1, T>> {
  static_assert(D >= 1, "Vector dimension must be greater than zero!");
  template<typename... Args>
  Vec(int n = 0, Args... args) : vector<Vec<D - 1, T>>(n, Vec<D - 1, T>(args...)) {
  }
};
template<typename T>
struct Vec<1, T> : public vector<T> {
  Vec(int n = 0, T val = T()) : vector<T>(n, val) {
  }
};

// const int MAX = 1000;
// Vec<2 , int > dp(MAX + 1, MAX + 1, -1);

int main()
{
    xlr8;
    int testCases  = 1;
    //cin>>testCases;
    while (testCases--)
    {
       int n;
       cin>>n;
        vector<string> a(n);

        unordered_map<string, int> m;

        const int N = 9;
        for(int i = 0 ; i < n ; i++)
            {
                cin>>a[i];
                for(int l =  1 ; l <= N ; l++)
                    for(int j =  0 ; j < N ; j++)
                        m[a[i].substr(j , l)]++;
            }
        for(int i = 0 ; i< n ; i++)
        {
            for(int l = 1; l<= N ; l++)
                for(int j = 0 ; j< N ; j++)
                        m[a[i].substr(j , l)]--;

            bool f = true;
            for(int l = 1; f && l<= N ; l++)
            {
                for(int j = 0 ; f && j < N; j++)
                {
                    if(!m.find(a[i].substr(j , l))->second)
                    {
                        cout<<a[i].substr(j , l)<<"\n";
                        f = false;
                    }
                }
            }
            for(int l = 1 ; l <= N;  l++)
            {
                for(int j = 0 ; j < N; j ++)
                    m[a[i].substr(j , l)]++;
            }
        }
    }
}


//https://2no.co/2bjRx5
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#pragma GCC target("popcnt")  //https://godbolt.org/z/yQv94Y

typedef long long int ll;
typedef unsigned long long int  ull;
typedef long double ld;

const ld pi = 4.0*atan(1.0);
#define xlr8 ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); cout.precision(10); cout<<fixed

typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
// T.insert(a), T.erase(a), T.size()
// T.order_of_key(a) -- number of elements strictly less than a
// *T.find_by_order(k) -- k-th element in increasing order

struct Timer
{   chrono::time_point<chrono::high_resolution_clock> start , end; chrono:: duration<float> dur;
    Timer(){start = chrono::high_resolution_clock::now();}
    ~Timer(){   end = chrono::high_resolution_clock::now(); dur = end - start;  cout<<"\nTime Elapsed : " <<dur.count() << " s\n";  }
};

template<typename T>
void getVec(vector<T>& a , int st, int en)
{
    int dif = (en > st ? 1 : -1);
    for(int  i = st ; i!= en ; i+= dif)
        cin>>a[i];
}
template<typename T>
void getVecPair(vector<pair<T , T > >& a , int st, int en)
{
    int dif = (en > st ? 1 : -1);
    for(int  i = st ; i!= en ; i+= dif)
        cin>>a[i].first>>a[i].second;
}

//76149
template<int D, typename T>
struct Vec : public vector<Vec<D - 1, T>> {
  static_assert(D >= 1, "Vector dimension must be greater than zero!");
  template<typename... Args>
  Vec(int n = 0, Args... args) : vector<Vec<D - 1, T>>(n, Vec<D - 1, T>(args...)) {
  }
};
template<typename T>
struct Vec<1, T> : public vector<T> {
  Vec(int n = 0, T val = T()) : vector<T>(n, val) {
  }
};

// const int MAX = 1000;
// Vec<2 , int > dp(MAX + 1, MAX + 1, -1);

int main()
{
    xlr8;
    int testCases  = 1;
    //cin>>testCases;
    while (testCases--)
    {
       int n;
       cin>>n;
        vector<string> a(n);
        map<string, int> m;

        const int N = 9;
        for(int i = 0 ; i < n ; i++)
            {
                cin>>a[i];
                for(int l =  1 ; l <= N ; l++)
                    for(int j =  0 ; j < N ; j++)
                        m[a[i].substr(j , l)]++;
            }
        for(int i = 0 ; i< n ; i++)
        {
            for(int l = 1; l<= N ; l++)
                for(int j = 0 ; j< N ; j++)
                        m[a[i].substr(j , l)]--;

            bool f = true;
            for(int l = 1; f && l<= N ; l++)
            {
                for(int j = 0 ; f && j < N; j++)
                {
                    if(!m.find(a[i].substr(j , l))->second)
                    {
                        cout<<a[i].substr(j , l)<<"\n";
                        f = false;
                    }
                }
            }
            for(int l = 1 ; l <= N;  l++)
            {
                for(int j = 0 ; j < N; j ++)
                    m[a[i].substr(j , l)]++;
            }
        }
    }
}


//https://2no.co/2bjRx5
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#pragma GCC target("popcnt")  //https://godbolt.org/z/yQv94Y

typedef long long int ll;
typedef unsigned long long int  ull;
typedef long double ld;

const ld pi = 4.0*atan(1.0);
#define xlr8 ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); cout.precision(10); cout<<fixed

typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
// T.insert(a), T.erase(a), T.size()
// T.order_of_key(a) -- number of elements strictly less than a
// *T.find_by_order(k) -- k-th element in increasing order

struct Timer
{   chrono::time_point<chrono::high_resolution_clock> start , end; chrono:: duration<float> dur;
    Timer(){start = chrono::high_resolution_clock::now();}
    ~Timer(){   end = chrono::high_resolution_clock::now(); dur = end - start;  cout<<"\nTime Elapsed : " <<dur.count() << " s\n";  }
};

template<typename T>
void getVec(vector<T>& a , int st, int en)
{
    int dif = (en > st ? 1 : -1);
    for(int  i = st ; i!= en ; i+= dif)
        cin>>a[i];
}
template<typename T>
void getVecPair(vector<pair<T , T > >& a , int st, int en)
{
    int dif = (en > st ? 1 : -1);
    for(int  i = st ; i!= en ; i+= dif)
        cin>>a[i].first>>a[i].second;
}

//76149
template<int D, typename T>
struct Vec : public vector<Vec<D - 1, T>> {
  static_assert(D >= 1, "Vector dimension must be greater than zero!");
  template<typename... Args>
  Vec(int n = 0, Args... args) : vector<Vec<D - 1, T>>(n, Vec<D - 1, T>(args...)) {
  }
};
template<typename T>
struct Vec<1, T> : public vector<T> {
  Vec(int n = 0, T val = T()) : vector<T>(n, val) {
  }
};

// const int MAX = 1000;
// Vec<2 , int > dp(MAX + 1, MAX + 1, -1);

int main()
{
    xlr8;
    int testCases  = 1;
    //cin>>testCases;
    while (testCases--)
    {
       int n;
       cin>>n;
        vector<string> a(n);
        map<string, int> m;

        const int N = 9;
        for(int i = 0 ; i < n ; i++)
            {
                cin>>a[i];
                for(int l =  1 ; l <= N ; l++)
                    for(int j =  0 ; j < N ; j++)
                        m[a[i].substr(j , l)]++;
            }
        for(int i = 0 ; i< n ; i++)
        {
            for(int l = 1; l<= N ; l++)
                for(int j = 0 ; j< N ; j++)
                    {
                        m[a[i].substr(j , l)]--;
                        if(m[a[i].substr(j , l)] == 0)
                            m.erase(a[i].substr(j , l));
                    }

            bool f = true;
            for(int l = 1; f && l<= N ; l++)
            {
                for(int j = 0 ; f && j < N; j++)
                {
                    if(m.find(a[i].substr(j , l)) == m.end())
                    {
                        cout<<a[i].substr(j , l)<<"\n";
                        f = false;
                    }
                }
            }
            for(int l = 1 ; l <= N;  l++)
            {
                for(int j = 0 ; j < N; j ++)
                    m[a[i].substr(j , l)]++;
            }
        }
    }
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define vi vector<int>
#define vs vector<string>
#define vll vector<ll>
#define ii pair<int, int>
#define pll pair<ll, ll>
#define vpll vector<pll>
#define vii vector<ii>
#define vvi vector<vi>
#define vvii vector<vii>
#define ld long double
#define iii tuple<int, int, int>
#define sc scanf
#define pb push_back
#define forn(i, x, n) for(int i=x; i<=n; ++i)
#define rofn(i, x, n) for(int i=x; i>=n; --i)
#define MOD 1000000007
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define sze(x) (int) x.size()

vs a(70000);
map<string, set<int>> mp;
vs ans(70000);
int sz[70000];

int main() {

    int n;
    sc("%d", &n);

    forn(i, 0, n-1) {
        cin>>a[i];

        for(int j=1; j<=9; ++j) {
            for(int k=0; k<=8; ++k) {
                if(k+j <= 9) {
                    mp[a[i].substr(k, j)].insert(i);
                }
            }
        }
        sz[i] = 10;
    }

    for(auto p: mp) {

        if(sze(p.S) == 1) {
            if(sze(p.F) < sz[*p.S.begin()]) {
                ans[*p.S.begin()] = p.F;
                sz[*p.S.begin()] = sze(p.F);
            }
        }
    }

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


#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define vi vector<int>
#define vs vector<string>
#define vll vector<ll>
#define ii pair<int, int>
#define pll pair<ll, ll>
#define vpll vector<pll>
#define vii vector<ii>
#define vvi vector<vi>
#define vvii vector<vii>
#define ld long double
#define iii tuple<int, int, int>
#define sc scanf
#define pb push_back
#define forn(i, x, n) for(int i=x; i<=n; ++i)
#define rofn(i, x, n) for(int i=x; i>=n; --i)
#define MOD 1000000007
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define sze(x) (int) x.size()

vs a(70000);
map<string, set<int>> mp;

void f(int i) {

    for(int j=1; j<=9; j++) {
        for(int k=0; k<=8; ++k) {
            if(k+j<=9) {
                if(sze(mp[a[i].substr(k, j)]) == 1) {
                    cout<<a[i].substr(k, j)<<endl;
                    return;
                }
            }
        }
    }

}

int main() {

    int n;
    sc("%d", &n);

    forn(i, 0, n-1) {
        cin>>a[i];

        for(int j=1; j<=9; ++j) {
            for(int k=0; k<=8; ++k) {
                if(k+j <= 9) {
                    mp[a[i].substr(k, j)].insert(i);
                }
            }
        }
    }

    forn(i, 0, n-1) {
        f(i);
    }
}


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

int main()
{
	int n;
	cin>>n;
	vector<string> v(n);
	for(int i=0;i<n;i++)
	cin>>v[i];

	map<string,set<int>> m;
	for(int i=0;i<n;i++)
	{
		string s=v[i];
		for(int k=0;k<9;k++)
		{
			string res="";
			for(int j=k;j<9;j++)
			{
				res+=s[j];
				m[res].insert(i);
			}
		}
	}
	for(int i=0;i<n;i++)
	{

	   int minsize=INT_MAX;
	   bool ok=false;
	   string s=v[i];
	   string ans="";
	   for(int k=0;k<9;k++)
	   {
	   	  string res="";
	      for(int j=k;j<9;j++)
	      {
	      	res+=s[j];
	      	if(m[res].size()==1)
	      	{
	      		int si=res.size();
	      		if(si<minsize)
	      		{
	      			minsize=si;
	      			ans=res;
	      		}

	      	}
	      }
	   }
	   cout<<ans<<endl;

	   //cout<<minl<<endl;
	}
}


#include <iostream>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int main()
{
    string str;
    int n,k,ret;
    while(cin>>n>>k)
    {
        if(k>n) cout<<-1<<endl;
        else
        {
            str="";
            rep(i,n-k+2)
            {
                if(i%2) cout<<"<<"b";
                else cout<<"a";
            }
            rep(i,k-2)
            {
                cout<<(char)(i+'c');
            }
        }
        cout<<endl;
    }
    return 0;
}


#include <iostream>
using namespace std;
typedef long long ll;

char ar[]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};

int main()
{
    string str="";
    ll n,k;
    while(cin>>n>>k)
    {

             if(n<k) cout<<-1<<endl;
             else
             {
                    str="";
                    bool fl=true;
                for(int i=0;i<n&&fl;i++)
                {
                    for(int j=0;j<k&&fl;j++)
                    {
                        if(str.size()<n)
                        {
                            str+=ar[j];
                        }
                        else
                        {
                            fl=false;
                            break;
                        }
                    }
                    if(str.size()==n)
                    {
                        fl=false;
                        break;
                    }
                }
                cout<<str<<endl;
             }

    }
    return 0;
}


#include <iostream>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int main()
{
    string str;
    int n,k,ret;
    while(cin>>n>>k)
    {
        if(n==k&&(n==1&&k==1)) cout<<"a"<<endl;
       else if(k>n||k==1) cout<<-1<<endl;
        else
        {
            str="";
            for(int i=0;i<n-k+2;i++)
            {
                if(i%2) cout<<"b";
                else cout<<"a";
            }
            for(int i=0;i<k-2;i++)
            {
                cout<<(char)(i+'c');
            }
        }
        cout<<endl;
    }
    return 0;
}


#include <iostream>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int main()
{
    string str;
    int n,k,ret;
    while(cin>>n>>k)
    {
        if(k>n) cout<<-1<<endl;
        else
        {
            str="";
            for(int i=0;i<n-k+2;i++)
            {
                if(i%2) cout<<"b";
                else cout<<"a";
            }
            for(int i=0;i<k-2;i++)
            {
                cout<<(char)(i+'c');
            }
        }
        cout<<endl;
    }
    return 0;
}


#include <iostream>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int main()
{
    string str;
    int n,k,ret;
    while(cin>>n>>k)
    {
        if(k>n||k==1) cout<<-1<<endl;
        else
        {
            str="";
            for(int i=0;i<n-k+2;i++)
            {
                if(i%2) cout<<"b";
                else cout<<"a";
            }
            for(int i=0;i<k-2;i++)
            {
                cout<<(char)(i+'c');
            }
        }
        cout<<endl;
    }
    return 0;
}


/*
ID: omarmuh1
PROG: test
LANG: C++
*/
#include <iostream>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <ctime>
#include <iomanip>
#include <string.h>
#include <stdio.h>

using namespace std;

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define pob pop_back
#define pii pair<int ,int>

//ifstream cin("test.in");
//ofstream cout("test.out");

int a,b,c,d;

int main()
{
 cin>>a>>b;

 a -= b;

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

 for(int i = 1 ; i <= a+2 ; i++)
 {
      if(i % 2 == 1) cout<<"a";
      else cout<<"b";
 }

 for(int i = b-2 ; i < b ; i++)
      cout<<char(i + 97);

 cout<<endl;

 return 0;
}


/*
ID: omarmuh1
PROG: test
LANG: C++
*/
#include <iostream>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <ctime>
#include <iomanip>
#include <string.h>
#include <stdio.h>

using namespace std;

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define pob pop_back
#define pii pair<int ,int>

//ifstream cin("test.in");
//ofstream cout("test.out");

int a,b,c,d,n,m;

int main()
{
 cin>>a>>b;

 if(a == 1 && b == 1)
 {
    cout<<"a"<<endl;
    return 0;
 }

 if(a < 0 || b == 1)
 {
      cout<<-1<<endl;
      return 0;
 }

 for(int i = 1 ; i <= a-b+2 ; i++)
 {
      if(i % 2 == 1) cout<<"a";
      else     	     cout<<"b";
 }

 for(int i = 2 ; i < b ; i++)
      cout<<char(i + 97);

 cout<<endl;

 return 0;
}


/*
ID: omarmuh1
PROG: test
LANG: C++
*/
#include <iostream>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <ctime>
#include <iomanip>
#include <string.h>
#include <stdio.h>

using namespace std;

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define pob pop_back
#define pii pair<int ,int>

//ifstream cin("test.in");
//ofstream cout("test.out");

int a,b,c,d;

int main()
{
 cin>>a>>b;

 a -= b;

 if(a < 0 || a/b == a)
 {
    cout<<-1<<endl;
    return 0;
 }

 for(int i = 1 ; i <= a+2 ; i++)
 {
      if(i % 2 == 1) cout<<"a";
      else cout<<"b";
 }

 for(int i = 2 ; i < b ; i++)
      cout<<char(i + 97);

 cout<<endl;

 return 0;
}


/*
ID: omarmuh1
PROG: test
LANG: C++
*/
#include <iostream>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <ctime>
#include <iomanip>
#include <string.h>
#include <stdio.h>

using namespace std;

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define pob pop_back
#define pii pair<int ,int>

//ifstream cin("test.in");
//ofstream cout("test.out");

int a,b,c,d,n,m;

int main()
{
 cin>>a>>b;

 if(a == 1 && b == 1)
 {
    cout<<"a"<<endl;
    return 0;
 }

 if(a < b || b == 1)
 {
      cout<<-1<<endl;
      return 0;
 }

 for(int i = 1 ; i <= a-b+2 ; i++)
 {
      if(i % 2 == 1) cout<<"a";
      else     	     cout<<"b";
 }

 for(int i = 2 ; i < b ; i++)
      cout<<char(i + 97);

 cout<<endl;

 return 0;
}


#include <stdio.h>
#include <stack>
#include <cstring>
#include <iostream>
#include <cmath>
#include <map>
#include <algorithm>
#include <queue>
#define infinity 10000010
using namespace std;
char x[infinity] ;

int main()
{
    int n , k ;
    cin >> n >> k ;
    if((k<2 && n > 2 ) || k>n)
    {cout << -1 << endl ;return 0 ;}
    int loop = (n > 1) ? n-(k-2) : 1 ;
    int i = 0 ;
    for(;i<loop;i++)
    {
        x[i] = 'a' + i%2 ;
    }
    for(int j = 2;i<n ;j++ ,i++)
    {
        x[i] = 'a' + j ;
    }
    cout << x << endl ;
    return 0;
}


#include <stdio.h>
#include <stack>
#include <cstring>
#include <iostream>
#include <cmath>
#include <map>
#include <algorithm>
#include <queue>
#define infinity 10000010
using namespace std;
char x[infinity] ;

int main()
{
    int n , k ;
    cin >> n >> k ;
    if((k<2 && n > 2 ) || k>n)
    {cout << -1 << endl ;return 0 ;}
    int loop = n-(k-2) ;
    int i = 0 ;
    for(;i<loop;i++)
    {
        x[i] = 'a' + i%2 ;
    }
    for(int j = 2;i<n ;j++ ,i++)
    {
        x[i] = 'a' + j ;
    }
    cout << x << endl ;
    return 0;
}


#include <stdio.h>
#include <stack>
#include <cstring>
#include <iostream>
#include <cmath>
#include <map>
#include <algorithm>
#include <queue>
#define infinity 10000
using namespace std;
char x[infinity] ;

int main()
{
    int n , k ;
    cin >> n >> k ;
    if(k<2 || k>n)
    {cout << -1 << endl ;return 0 ;}
    int loop = n-(k-2) ;
    int i = 0 ;
    for(;i<loop;i++)
    {
        x[i] = 'a' + i%2 ;
    }
    for(int j = 2;i<n ;j++ ,i++)
    {
        x[i] = 'a' + j ;
    }
    cout << x << endl ;
    return 0;
}


#include <stdio.h>
#include <stack>
#include <cstring>
#include <iostream>
#include <cmath>
#include <map>
#include <algorithm>
#include <queue>
#define infinity 10000010
using namespace std;
char x[infinity] ;

int main()
{
    int n , k ;
    cin >> n >> k ;
    if(k<2 || k>n)
    {cout << -1 << endl ;return 0 ;}
    int loop = n-(k-2) ;
    int i = 0 ;
    for(;i<loop;i++)
    {
        x[i] = 'a' + i%2 ;
    }
    for(int j = 2;i<n ;j++ ,i++)
    {
        x[i] = 'a' + j ;
    }
    cout << x << endl ;
    return 0;
}


#include <stdio.h>
#include <stack>
#include <cstring>
#include <iostream>
#include <cmath>
#include <map>
#include <algorithm>
#include <queue>
#define infinity 10000010
using namespace std;
char x[infinity] ;

int main()
{
    int n , k ,i = 0;
    scanf("%d %d",&n ,&k) ;
    if((k<2 && n > 2 ) || k>n)
    {printf("-1") ;return 0 ;}
    int loop = (n > 1) ? n-(k-2) : 1 ;
    for(;i<loop;i++){x[i] = 'a' + i%2 ;}
    for(int j = 2;i<n ;j++ ,i++){x[i] = 'a' + j ;}
     printf("%s",x) ;
    return 0;
}


#include <iostream>

using namespace std;

int main()
{   int n,k,i;
    cin>>n>>k;
    if(n<k || k==1) {cout<<"-1"<<'\n'; return 0;}
   // else if(n==k) {for(i=1;i<=n;i++) cout<<char(i+96); cout<<'\n'; return 0;}

    k=k-2;
    n=n-k;
    for(i=1;i<=n;i++)
    {
        if(i%2==1) cout<<'a';
        else cout<<'b';
    }
    for(i=1;i<=k;i++) cout<<char(i+98);
    cout<<'\n';
    return 0;
}


#include <iostream>

using namespace std;

int main()
{   int n,k,i;
    cin>>n>>k;
    if(n<k || k==1 || k==0) {cout<<"-1"<<'\n'; return 0;}
   // else if(n==k) {for(i=1;i<=n;i++) cout<<char(i+96); cout<<'\n'; return 0;}

    k=k-2;
    n=n-k;
    for(i=1;i<=n;i++)
    {
        if(i%2==1) cout<<'a';
        else cout<<'b';
    }
    for(i=1;i<=k;i++) cout<<char(i+98);
    cout<<'\n';
    return 0;
}


#include <iostream>

using namespace std;

int main()
{   int n,k,i;
    cin>>n>>k;
    if(n<k) {cout<<"-1"<<'\n'; return 0;}
   // else if(n==k) {for(i=1;i<=n;i++) cout<<char(i+96); cout<<'\n'; return 0;}

    k=k-2;
    n=n-k;
    for(i=1;i<=n;i++)
    {
        if(i%2==1) cout<<'a';
        else cout<<'b';
    }
    for(i=1;i<=k;i++) cout<<char(i+98);
    cout<<'\n';
    return 0;
}


#include <iostream>

using namespace std;

int main()
{   int n,k,i;
    cin>>n>>k;
    if(n<k || (k==1 && n!=1)) {cout<<"-1"<<'\n'; return 0;}
   // else if(n==k) {for(i=1;i<=n;i++) cout<<char(i+96); cout<<'\n'; return 0;}
    if(k==n && k==1) {cout<<'a'<<'\n'; return 0;}
    k=k-2;
    n=n-k;
    for(i=1;i<=n;i++)
    {
        if(i%2==1) cout<<'a';
        else cout<<'b';
    }
    for(i=1;i<=k;i++) cout<<char(i+98);
    cout<<'\n';
    return 0;
}


#include <iostream>

using namespace std;

int main()
{   int n,k,i;
    cin>>n>>k;
    if(n<k) {cout<<"-1"<<'\n'; return 0;}

    k=k-2;
    n=n-k;
    for(i=1;i<=n;i++)
    {
        if(i%2==1) cout<<'a';
        else cout<<'b';
    }
    for(i=1;i<=k;i++) cout<<char(i+98);
    cout<<'\n';
    return 0;
}


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

int main()
{
    int n,k,x,i;
    cin>>n>>k;
    if(n==1 && k==1)
    cout<<"a";
    else if(k>n || k<2)
    cout<<"-1";
    else
    {
        for(i=1;i<=n-k+2;i++)
        {
            if(i%2!=0)
            cout<<"a";
            else
            cout<<"b";
        }
        x=99;
        for(i=1;i<=k-2;i++)
        {
            cout<<char(x);
            x++;
        }
    }
    return 0;
}


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

int main()
{
    int n,k,f,i,ch;
    cin>>n>>k;
    if(k==1 && n==1)
    cout<<"a";
    else if(k==1 && n>1)
    cout<<"-1";
    else if(k>n)
    cout<<"-1";
    else
    {
        f=1;
        for(i=1;i<=n-k+2;i++)
        {
            if(f)
            cout<<"a";
            else
            cout<<"b";
            f=1-f;
        }
        ch=99;
        for(i=1;i<=k-2;i++)
        {
            cout<<char(ch);
            ch++;
        }
    }
    // your code goes here
    return 0;
}


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

int main()
{
    int n,k,x,i;
    cin>>n>>k;
    if(k>n || k<2)
    cout<<"-1";
    else
    {
        for(i=1;i<=n-k+2;i++)
        {
            if(i%2!=0)
            cout<<"a";
            else
            cout<<"b";
        }
        x=99;
        for(i=1;i<=k-2;i++)
        {
            cout<<char(x);
            x++;
        }
    }
    return 0;
}


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

int main()
{
	int n,k,i;
	cin>>n>>k;
	if(k<2 || k>n)
	cout<<"-1";
	else
	{
		for(i=1;i<=n-k+2;i++)
		{
			if(i%2!=0)
			cout<<"a";
			else
			cout<<"b";
		}
		int x=99;
		for(i=1;i<=k-2;i++)
		{
			cout<<char(x);
			x++;
		}
	}
	// your code goes here
	return 0;
}


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

int main()
{
    int n,k,i;
    cin>>n>>k;
    if((k<2 || k>n) && n!=1)
    cout<<"-1";
    else if(n==1 && k!=1)
    cout<<"-1";
    else if(k==1 && n==1)
    cout<<"a";
    else
    {
        for(i=1;i<=n-k+2;i++)
        {
            if(i%2!=0)
            cout<<"a";
            else
            cout<<"b";
        }
        int x=99;
        for(i=1;i<=k-2;i++)
        {
            cout<<char(x);
            x++;
        }
    }
    // your code goes here
    return 0;
}


#include<stdio.h>
#include<iostream>
#include<cstring>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#define PI 3.14159265
#define mod 1000000007
using namespace std;

int main()
{
	int n,k,ans=0;
	char str[26];
	cin>>n>>k;
	if( (k==1&&n!=1)||k>26)
        {
            cout<<"-1";
            return 0;
        }
	else
    if(k>n)
        cout<<"-1";
    else{
            char ch='a';
            int i;
            for(i=0;i<k&&i<26;i++){
            str[i]=ch;
            ch++;
    }
       str[i]='\0';

        int x=n/k,y=n%k;

        for(i=0;i<x;i++)
            printf("%s",str);
        for(i=0;i<y;i++)
            printf("%c",str[i]);
    }
	return 0;
}


#include<stdio.h>
#include<iostream>
#include<cstring>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#define PI 3.14159265
#define mod 1000000007
using namespace std;

int main()
{
	int n,k,ans=0;
	char str[26];
	cin>>n>>k;
	if( (k==1&&n!=1)||k>26)
        {
            cout<<"-1";
            return 0;
        }
	else
    if(k>n)
        cout<<"-1";
    else{
            char ch='a';
            int i;
            for(i=0;i<k&&i<26;i++){
            str[i]=ch;
            ch++;
    }
       str[i]='\0';
        k=k-2;
        int flag=0;
        for(i=0;i<n-k;i++)
        {
            if(flag==0){
                cout<<'a';
                flag=1;
            }
            else{
                cout<<'b';
                flag=0;
            }
        }
        for(i=2;i<k+2;i++){

        printf("%c",str[i]);}
    }
	return 0;
}


#include<stdio.h>
#include<iostream>
#include<cstring>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#define PI 3.14159265
#define mod 1000000007
using namespace std;

int main()
{
	int n,k,ans=0,l,r;
	cin>>n>>k;
        for(int i=1;i<=n;i++){
            cin>>l>>r;
            if(l*r<0)
            {
                ans=ans+l+(-r)+1;
            }
            else
            ans+=abs(r)-abs(l)+1;
		}
		int i=1;
		int res=k;
        while(res<ans)
          {

          res=res*i;
          i++;
          }

        cout<<(res-ans);

	return 0;
}


#include<stdio.h>
#include<iostream>
#include<cstring>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#define PI 3.14159265
#define mod 1000000007
using namespace std;

int main()
{
	int n,k,ans=0;
	char str[26];
	cin>>n>>k;
	if( (k==1&&n!=1)||k>26)
        {
            cout<<"-1";
            return 0;
        }
	else
	if(n==k&&k==1)
	{
	    cout<<'a';
	    return 0;
	}
    if(k>n)
        cout<<"-1";
    else{
            char ch='a';
            int i;
            for(i=0;i<k&&i<26;i++){
            str[i]=ch;
            ch++;
    }
       str[i]='\0';
        k=k-2;
        int flag=0;
        for(i=0;i<n-k;i++)
        {
            if(flag==0){
                cout<<'a';
                flag=1;
            }
            else{
                cout<<'b';
                flag=0;
            }
        }
        for(i=2;i<k+2;i++){

        printf("%c",str[i]);}
    }
	return 0;
}


#include<stdio.h>
#include<iostream>
#include<cstring>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#define PI 3.14159265
#define mod 1000000007
using namespace std;

int main()
{
	int n,k,ans=0;
	char str[26];
	cin>>n>>k;
	if( (k==1&&n!=1)||k>26)
        {
            cout<<"-1";
            return 0;
        }
	else
	if(n==k&&k==1)
	{
	    cout<<'a';
	    retturn 0;
	}
    if(k>n)
        cout<<"-1";
    else{
            char ch='a';
            int i;
            for(i=0;i<k&&i<26;i++){
            str[i]=ch;
            ch++;
    }
       str[i]='\0';
        k=k-2;
        int flag=0;
        for(i=0;i<n-k;i++)
        {
            if(flag==0){
                cout<<'a';
                flag=1;
            }
            else{
                cout<<'b';
                flag=0;
            }
        }
        for(i=2;i<k+2;i++){

        printf("%c",str[i]);}
    }
	return 0;
}


#include <iostream>
#include <stdio.h>
using namespace std;

int main()
{
   // freopen("i.txt","r",stdin);
 int n,k;
 string s,s1="abcdefghijklmnopqrstuvwxyz";

 cin>>n>>k;
 if(k>n) {cout<<-1; return 0;}
 if(k==1&&n>1){cout<<-1; return 0;}
 if(k==1)
 {
     for(int i=0; i<n; i++)
        cout<<"a";
     return 0;
 }
 while (s.size()<n)
  {

  s+="a";
 // cout<<s;
  if(s.size()==n) break;
  s+="b";
  }
  //cout<<s<<endl;;
  int x=2;
 for(int i=n-k+2; i<n; i++)
 {
    // s[i]="a";
     s[i]=s1[x];
     x++;
   }
   cout<<s;
    return 0;
}


#include <iostream>
#include <stdio.h>
using namespace std;

int main()
{
   // freopen("i.txt","r",stdin);
 int n,k;
 string s,s1="abcdefghijklmnopqrstuvwxyz";

 cin>>n>>k;
 if(k>n) {cout<<-1; return 0;}
 if(k==1)
 {
     for(int i=0; i<n; i++)
        cout<<"a";
     return 0;
 }
 while (s.size()<n)
  {

  s+="a";
 // cout<<s;
  if(s.size()==n) break;
  s+="b";
  }
  //cout<<s<<endl;;
  int x=2;
 for(int i=n-k+2; i<n; i++)
 {
    // s[i]="a";
     s[i]=s1[x];
     x++;
   }
   cout<<s;
    return 0;
}


#include <iostream>
#include <stdio.h>
using namespace std;

int main()
{
   // freopen("i.txt","r",stdin);
 int n,k;
 string s,s1="abcdefghijklmnopqrstuvwxyz";

 cin>>n>>k;
 if(k>n) {cout<<-1; return 0;}
 while (s.size()<n)
  {

  s+="a";
 // cout<<s;
  if(s.size()==n) break;
  s+="b";
  }
  //cout<<s<<endl;;
  int x=2;
 for(int i=n-k+2; i<n; i++)
 {
    // s[i]="a";
     s[i]=s1[x];
     x++;
   }
   cout<<s;
    return 0;
}


#include <iostream>
#include <stdio.h>
using namespace std;

int main()
{
   // freopen("i.txt","r",stdin);
 int n,k;
 string s,s1="abcdefghijklmnopqrstuvwxyz";

 cin>>n>>k;
 if(k>n) {cout<<-1; return 0;}
 while (s.size()<n)
  {

  s+="a";
 // cout<<s;
  if(s.size()==n) break;
  s+="b";
  }
  cout<<s<<endl;;
  int x=2;
 for(int i=n-k+2; i<n; i++)
 {
    // s[i]="a";
     s[i]=s1[x];
     x++;
   }
   cout<<s;
    return 0;
}


/** author : ayush sharma **/
#include<iostream>
#include<functional>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<algorithm>
#include<string>
#include<sstream>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<stack>
#define FOR(i,a,b) for(int i=a; i<b; i++)
#define FORr(i,a,b) for(int i=a ; i>=b; i--)
#define pb push_back
#define mp make_pair
#define ub upper_bound
#define lb lower_bound
#define si1(n) scanf("%d",&n)
#define si2(n1, n2) scanf("%d%d",&n1,&n2)
#define si3(n1,n2,n3) scanf("%d%d%d",&n1, &n2, &n3)
#define si4(n1,n2,n3,n4) scanf("%d%d%d%d",&n1, &n2, &n3, &n4)
#define FF first
#define SS second
#define READ(x) freopen(x,"r",stdin)
#define WRITE(x) freopen(x,"w",stdout)
#define show1(a) cout<<a<<"\n"
#define show2(a, b) cout<<a<<"   "<<b<<"\n"
#define show3(a, b, c) cout<<a<<"   "<<b<<"    "<<c<<"\n"
#define show4(a, b, c,d) cout<<a<<"   "<<b<<"    "<<c<<"   "<<d<<"\n"

using namespace std;
typedef long long LL;
typedef pair <int,int> pii;
typedef pair<string,int> psi;
typedef vector<int> vi;
typedef unsigned long long ull;

#define sz 1000005

int main(){
    int n, k;
    si2(n,k);
    string s="";
    if(n<k) { printf("-1"); return 0; }
    if(k==1){ FOR(i,0,n) s+='a';  show1(s); return 0;}
    int part2=n-k+2;
    FOR(i,0,part2){
        if(i%2) s+='b';
        else s+='a';
    }
    int i=2;
    while(part2<n){
        s+=char('a'+i); i++; part2++;
    }
    show1(s);
    return 0;
}


/** author : ayush sharma **/
#include<iostream>
#include<functional>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<algorithm>
#include<string>
#include<sstream>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<stack>
#define FOR(i,a,b) for(int i=a; i<b; i++)
#define FORr(i,a,b) for(int i=a ; i>=b; i--)
#define pb push_back
#define mp make_pair
#define ub upper_bound
#define lb lower_bound
#define si1(n) scanf("%d",&n)
#define si2(n1, n2) scanf("%d%d",&n1,&n2)
#define si3(n1,n2,n3) scanf("%d%d%d",&n1, &n2, &n3)
#define si4(n1,n2,n3,n4) scanf("%d%d%d%d",&n1, &n2, &n3, &n4)
#define FF first
#define SS second
#define READ(x) freopen(x,"r",stdin)
#define WRITE(x) freopen(x,"w",stdout)
#define show1(a) cout<<a<<"\n"
#define show2(a, b) cout<<a<<"   "<<b<<"\n"
#define show3(a, b, c) cout<<a<<"   "<<b<<"    "<<c<<"\n"
#define show4(a, b, c,d) cout<<a<<"   "<<b<<"    "<<c<<"   "<<d<<"\n"

using namespace std;
typedef long long LL;
typedef pair <int,int> pii;
typedef pair<string,int> psi;
typedef vector<int> vi;
typedef unsigned long long ull;

#define sz 1000005

int main(){
    int n, k;
    si2(n,k);
    string s="";
    if(n<k || (n>1 && k==1)) { printf("-1"); return 0; }
    if(n==1) { printf("a"); return 0; }
    int part2=n-k+2;
    FOR(i,0,part2){
        if(i%2) s+='b';
        else s+='a';
    }
    int i=2;
    while(part2<n){
        s+=char('a'+i); i++; part2++;
    }
    show1(s);
    return 0;
}


/** author : ayush sharma **/
#include<iostream>
#include<functional>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<algorithm>
#include<string>
#include<sstream>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<stack>
#define FOR(i,a,b) for(int i=a; i<b; i++)
#define FORr(i,a,b) for(int i=a ; i>=b; i--)
#define pb push_back
#define mp make_pair
#define ub upper_bound
#define lb lower_bound
#define si1(n) scanf("%d",&n)
#define si2(n1, n2) scanf("%d%d",&n1,&n2)
#define si3(n1,n2,n3) scanf("%d%d%d",&n1, &n2, &n3)
#define si4(n1,n2,n3,n4) scanf("%d%d%d%d",&n1, &n2, &n3, &n4)
#define FF first
#define SS second
#define READ(x) freopen(x,"r",stdin)
#define WRITE(x) freopen(x,"w",stdout)
#define show1(a) cout<<a<<"\n"
#define show2(a, b) cout<<a<<"   "<<b<<"\n"
#define show3(a, b, c) cout<<a<<"   "<<b<<"    "<<c<<"\n"
#define show4(a, b, c,d) cout<<a<<"   "<<b<<"    "<<c<<"   "<<d<<"\n"

using namespace std;
typedef long long LL;
typedef pair <int,int> pii;
typedef pair<string,int> psi;
typedef vector<int> vi;
typedef unsigned long long ull;

#define sz 1000005

int main(){
    int n, k;
    si2(n,k);
    string s="";
    if(n<k) { printf("-1"); return 0; }
    int part2=n-k+2;
    FOR(i,0,part2){
        if(i%2) s+='b';
        else s+='a';
    }
    int i=2;
    while(part2<n){
        s+=char('a'+i); i++; part2++;
    }
    show1(s);
    return 0;
}


#include <iostream>
#include <cstring>
using namespace std;
int main(int argc, const char * argv[])
{
    string s;
    int lng=0,k=0;
    cin>>lng>>k;
    int cnt=0;
    if(k>lng){cout<<-1;return 0;}
    if(lng==1)
    {
        cout<<'a';
        return 0;
    }
    if(k==1)
    {
        for(int i=0;i<lng;i++)
            cout<<"a";
        return 0;
    }
    else
    {
        for(int i=0;i<lng-k+2;i++)
        {
            if(cnt%2==0)
                s.push_back('a');
            else
                s.push_back('b');
            cnt++;
        }
        cnt=0;
        for(int i=lng-k+2;i<lng;i++)
        {
            s.push_back('a'+cnt+2);
            cnt++;
        }
    }
    cout<<s;
    return 0;
}


#include <iostream>
#include <cstring>
using namespace std;
int main(int argc, const char * argv[])
{
    string s;
    int lng=0,k=0;
    cin>>lng>>k;
    int cnt=0;
    if(k>lng){cout<<-1;return 0;}
    if(lng==1)
    {
        cout<<'a';
        return 0;
    }
    if(k==1)
    {
        for(int i=0;i<lng;i++)
            cout<<"a";
        return 0;
    }
    else
    {
        for(int i=0;i<lng-k+2;i++)
        {
            if(cnt%2==0)
                cout<<'a';
            else
                cout<<'b';
            cnt++;
        }
        cnt=2;
        for(int i=lng-k+2;i<lng;i++)
        {
            char c='a'+cnt;
            cout<<c;
            cnt++;
        }
    }
    return 0;
}


#include <iostream>
#include <cstring>
using namespace std;
int main(int argc, const char * argv[])
{
    string s;
    int lng=0,k=0;
    cin>>lng>>k;
    int cnt=0;
    if(k>lng){cout<<-1;return 0;}
    if(lng==1)
    {
        cout<<'a';
        return 0;
    }
    else
    {
        for(int i=0;i<lng-k+2;i++)
        {
            if(cnt%2==0)
                s.push_back('a');
            else
                s.push_back('b');
            cnt++;
        }
        cnt=0;
        for(int i=lng-k+2;i<lng;i++)
        {
            s.push_back('a'+cnt+2);
            cnt++;
        }
    }
    cout<<s;
    return 0;
}


#include <iostream>
#include <cstring>
using namespace std;
int main(int argc, const char * argv[])
{
    string s;
    int lng=0,k=0;
    cin>>lng>>k;
    int cnt=0;
    if(k>lng){cout<<-1;return 0;}
    if(lng==1)
    {
        cout<<'a';
        return 0;
    }
    if(k==1)
    {
        cout<<-1;
        return 0;
    }
    else
    {
        for(int i=0;i<lng-k+2;i++)
        {
            if(cnt%2==0)
                cout<<'a';
            else
                cout<<'b';
            cnt++;
        }
        cnt=2;
        for(int i=lng-k+2;i<lng;i++)
        {
            char c='a'+cnt;
            cout<<c;
            cnt++;
        }
    }
    return 0;
}


#include <iostream>
#include <cstring>
#include<assert.h>
using namespace std;
int main(int argc, const char * argv[])
{
    string s;
    int lng=0,k=0;
    cin>>lng>>k;
    int cnt=0;
    if(k>lng){cout<<-1;return 0;}
    if(lng==1)
    {
        cout<<'a';
        return 0;
    }
    if(k==1)
    {
        for(int i=0;i<lng;i++)
            cout<<"a";
        return 0;
    }
    else
    {
        for(int i=0;i<lng-k+2;i++)
        {
            if(cnt%2==0)
                s.push_back('a');
            else
                s.push_back('b');
            cnt++;
        }
        cnt=0;
        for(int i=lng-k+2;i<lng;i++)
        {
            s.push_back('a'+cnt+2);
            cnt++;
        }
    }
    assert(s.length()==lng);
    cout<<s;
    return 0;
}


#include<cstdio>
using namespace std;
int main(){
	int n,k;scanf("%d %d",&n,&k);
	if(k>n){printf("-1\n");return 0;}
	if(n==1){printf("a\n");}
	else if(n==2){printf("ab\n");}
	else{
		k -= 2;
		for(int i=0;i<(n-k)/2;i++) printf("ab");
		for(int i=0;i<k;i++) printf("%c",'c'+i);
		printf("\n");
	}
	return 0;
}


#include<cstdio>
using namespace std;
int main(){
	int n,k;scanf("%d %d",&n,&k);
	if(k>n){printf("-1\n");return 0;}
	if(n==1){printf("a\n");}
	else if(n==2){printf("ab\n");}
	else{
		if(n-k>0){
			for(int i=0;i<n-k+2;i++) printf("%c",(i%2==0 ? 'a' : 'b'));
			for(int i=0;i<k-2;i++) printf("%c",'c'+i);
		}else{
			for(int i=0;i<k;i++) printf("%c",'a'+i);
		}
		printf("\n");
	}
	return 0;
}


#include<cstdio>
using namespace std;
int main(){
	int n,k;scanf("%d %d",&n,&k);
	if(k>n || (n>1 && k==1)){printf("-1\n");return 0;}
	if(n==1){printf("a\n");}
	else if(n==2){printf("ab\n");}
	else{
		if(n-k>0){
			for(int i=0;i<n-k+2;i++) printf("%c",(i%2==0 ? 'a' : 'b'));
			for(int i=0;i<k-2;i++) printf("%c",'c'+i);
		}else{
			for(int i=0;i<k;i++) printf("%c",'a'+i);
		}
		printf("\n");
	}
	return 0;
}


#include<cstdio>
using namespace std;
int main(){
	int n,k;scanf("%d %d",&n,&k);
	if(k>n){printf("-1\n");return 0;}
	if(n==1){printf("a\n");}
	else if(n==2){printf("ab\n");}
	else{
		k -= 2;
		for(int i=0;i<n-k/2;i++){
			printf("%c",(i%2==0 ? 'a' : 'b'));
		}
		for(int i=0;i<k;i++) printf("%c",'c'+i);
		printf("\n");
	}
	return 0;
}


#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;

int main()
{
    int n,k;
    while(~scanf("%d%d",&n,&k))
    {
        if(n < k)
            printf("-1\n");
        else if( n == k && n == 1)
        {
            printf("a\n");
        }
        else if(k == 1)
        {
            printf("-1\n");
        }
        else
        {
            int t = n-k+2;
            for(int i=1; i<=t; i++)
            {
                if(i%2)
                    printf("a");
                else
                    printf("b");
            }
            char c = 'c';
            for(int i=0; i<=n-t-1; i++)
            {
                printf("%c",c);
                c = (char)(c+1);
            }
            printf("\n");
        }
    }
    return 0;
}


#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;

int main()
{
    int n,k;
    while(~scanf("%d%d",&n,&k))
    {
        if(n < k)
            printf("-1\n");
        else if(k == 1)
        {
            printf("-1\n");
        }
        else
        {
            int t = n - k+2;
            for(int i=1; i<=t; i++)
            {
                if(i%2)
                    printf("a");
                else
                    printf("b");
            }
            char c = 'c';
            for(int i=0; i<=n-t-1; i++)
            {
                printf("%c",c);
                c = (char)(c+1);
            }
            printf("\n");
        }
    }
    return 0;
}


#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;

int main()
{
    int n,k;
    while(~scanf("%d%d",&n,&k))
    {
        if(n < k)
            printf("-1\n");
        else
        {
            int t = n - k+2;
            for(int i=1; i<=t; i++)
            {
                if(i%2)
                    printf("a");
                else
                    printf("b");
            }
            char c = 'c';
            for(int i=0; i<=n-t-1; i++)
            {
                printf("%c",c);
                c = (char)(c+1);
            }
            printf("\n");
        }
    }
    return 0;
}


#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;

int main()
{
    int n,k;
    while(~scanf("%d%d",&n,&k))
    {
        if(n < k)
            printf("-1\n");
        else if(k == 1)
        {
            for(int i=1; i<=n; i++)
                printf("a");
            printf("\n");
        }
        else
        {
            int t = n - k+2;
            for(int i=1; i<=t; i++)
            {
                if(i%2)
                    printf("a");
                else
                    printf("b");
            }
            char c = 'c';
            for(int i=0; i<=n-t-1; i++)
            {
                printf("%c",c);
                c = (char)(c+1);
            }
            printf("\n");
        }
    }
    return 0;
}


#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;

int main()
{
    int n,k;
    while(~scanf("%d%d",&n,&k))
    {
        if(n < k)
            printf("-1\n");
        else if(k == 1 || k > 26)
        {
            printf("-1\n");
        }
        else
        {
            int t = n-k+2;
            for(int i=1; i<=t; i++)
            {
                if(i%2)
                    printf("a");
                else
                    printf("b");
            }
            char c = 'c';
            for(int i=0; i<=n-t-1; i++)
            {
                printf("%c",c);
                c = (char)(c+1);
            }
            printf("\n");
        }
    }
    return 0;
}


/* Author: Turaev Mehrubon */
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <queue>
#include <cmath>
#include <vector>
#include <memory.h>
#include <stdio.h>
#include <fstream>
#include <string>
#include <iostream>
#include <algorithm>

using namespace std;

#define sc scanf
#define fi first
#define eps 1e-8
#define se second
#define pr printf
#define pi acos(-1)
#define ll long long
#define mp make_pair
#define pb push_back
#define sqr(x) (x)*(x)
#define N (int)(1e+2)*2
#define mod (int)(1e+9)+7
#define inf (int)INFINITY/4
#define in(s) freopen(s, "r", stdin);
#define out(s) freopen(s, "w", stdout);
#define mse(x, y) memset(x, y, sizeof(x))

int main(){
    int n, k; char c;
    cin >> n >> k;

    if(k == 1)
        for(int i = 1; i <= n; i++){
            if(i % 2 == 1) cout << 'a';
            else
                 cout << 'b';
        }
else    if(k > n)
        cout << -1;
    else if(k == n){
        for(c = 'a'; c < 'a' + k; c++)
            cout << c;
    }
    else{
        k -= 2;
        n = n - k; c = 'a';
        for(int i = 1; i <= n; i++){
            cout << c;
            if(c == 'a')
                c = 'b';
            else
                c = 'a';
        }
        for(c = 'c'; c < 'c' + k; c++)
            cout << c;
    }

}


/* Author: Turaev Mehrubon */
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <queue>
#include <cmath>
#include <vector>
#include <memory.h>
#include <stdio.h>
#include <fstream>
#include <string>
#include <iostream>
#include <algorithm>

using namespace std;

#define sc scanf
#define fi first
#define eps 1e-8
#define se second
#define pr printf
#define pi acos(-1)
#define ll long long
#define mp make_pair
#define pb push_back
#define sqr(x) (x)*(x)
#define N (int)(1e+2)*2
#define mod (int)(1e+9)+7
#define inf (int)INFINITY/4
#define in(s) freopen(s, "r", stdin);
#define out(s) freopen(s, "w", stdout);
#define mse(x, y) memset(x, y, sizeof(x))

int main(){
    int n, k, q = 0; char c;
    cin >> n >> k;

    if(k > n || (k == 1 && n != 1))
        cout << -1;
    else if(k <= 2)
        for(int i = 1; i <= n; i++){
            if(i % 2 == 1) cout << 'a';
            else
                 cout << 'b';
        }
    else{
        k -= 2;
        n = n - k; c = 'a';
        for(int i = 1; i <= n; i++){
            cout << c;
            if(c == 'a')
                c = 'b';
            else
                c = 'a';
            q++;
        }
        for(c = 'c'; c < 'c' + k; c++)
            cout << c, q++;
//        cout << q ;

    }

}


/* Author: Turaev Mehrubon */
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <queue>
#include <cmath>
#include <vector>
#include <memory.h>
#include <stdio.h>
#include <fstream>
#include <string>
#include <iostream>
#include <algorithm>

using namespace std;

#define sc scanf
#define fi first
#define eps 1e-8
#define se second
#define pr printf
#define pi acos(-1)
#define ll long long
#define mp make_pair
#define pb push_back
#define sqr(x) (x)*(x)
#define N (int)(1e+2)*2
#define mod (int)(1e+9)+7
#define inf (int)INFINITY/4
#define in(s) freopen(s, "r", stdin);
#define out(s) freopen(s, "w", stdout);
#define mse(x, y) memset(x, y, sizeof(x))

int main(){
    int n, k; char c;
    cin >> n >> k;

 if(k > n)
        cout << -1;
    else if(k == n){
        for(c = 'a'; c < 'a' + k; c++)
            cout << c;
    }
    else{
        k -= 2;
        n = n - k; c = 'a';
        for(int i = 1; i <= n; i++){
            cout << c;
            if(c == 'a')
                c = 'b';
            else
                c = 'a';
        }
        for(c = 'c'; c < 'c' + k; c++)
            cout << c;
    }

}


/* Author: Turaev Mehrubon */
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <queue>
#include <cmath>
#include <vector>
#include <memory.h>
#include <stdio.h>
#include <fstream>
#include <string>
#include <iostream>
#include <algorithm>

using namespace std;

#define sc scanf
#define fi first
#define eps 1e-8
#define se second
#define pr printf
#define pi acos(-1)
#define ll long long
#define mp make_pair
#define pb push_back
#define sqr(x) (x)*(x)
#define N (int)(1e+2)*2
#define mod (int)(1e+9)+7
#define inf (int)INFINITY/4
#define in(s) freopen(s, "r", stdin);
#define out(s) freopen(s, "w", stdout);
#define mse(x, y) memset(x, y, sizeof(x))

int main(){
    int n, k; char c;
    cin >> n >> k;
    if(k == 1)
        for(int i = 1; i <= n; i++)
            cout << 'a';

    else if(k > n)
        cout << -1;
    else if(k == n){
        for(c = 'a'; c < 'a' + k; c++)
            cout << c;
    }
    else{
        k -= 2;
        n = n - k; c = 'a';
        for(int i = 1; i <= n; i++){
            cout << c;
            if(c == 'a')
                c = 'b';
            else
                c = 'a';
        }
        for(c = 'c'; c < 'c' + k; c++)
            cout << c;
    }

}


/* Author: Turaev Mehrubon */
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <queue>
#include <cmath>
#include <vector>
#include <memory.h>
#include <stdio.h>
#include <fstream>
#include <string>
#include <iostream>
#include <algorithm>

using namespace std;

#define sc scanf
#define fi first
#define eps 1e-8
#define se second
#define pr printf
#define pi acos(-1)
#define ll long long
#define mp make_pair
#define pb push_back
#define sqr(x) (x)*(x)
#define N (int)(1e+2)*2
#define mod (int)(1e+9)+7
#define inf (int)INFINITY/4
#define in(s) freopen(s, "r", stdin);
#define out(s) freopen(s, "w", stdout);
#define mse(x, y) memset(x, y, sizeof(x))

int main(){
    int n, k; char c;
    cin >> n >> k;

    if(k > n)
        cout << -1;
    else if(k <= 2)
        for(int i = 1; i <= n; i++){
            if(i % 2 == 1) cout << 'a';
            else
                 cout << 'b';
        }
    else{
        k -= 2;
        n = n - k; c = 'a';
        for(int i = 1; i <= n; i++){
            cout << c;
            if(c == 'a')
                c = 'b';
            else
                c = 'a';
        }
        for(c = 'c'; c < 'c' + k; c++)
            cout << c;
    }

}


/* Author: Turaev Mehrubon */
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <queue>
#include <cmath>
#include <vector>
#include <memory.h>
#include <stdio.h>
#include <fstream>
#include <string>
#include <iostream>
#include <algorithm>

using namespace std;

#define sc scanf
#define fi first
#define eps 1e-8
#define se second
#define pr printf
#define pi acos(-1)
#define ll long long
#define mp make_pair
#define pb push_back
#define sqr(x) (x)*(x)
#define N (int)(1e+2)*2
#define mod (int)(1e+9)+7
#define inf (int)INFINITY/4
#define in(s) freopen(s, "r", stdin);
#define out(s) freopen(s, "w", stdout);
#define mse(x, y) memset(x, y, sizeof(x))

int main(){
    int n, k, q = 0; char c;
    cin >> n >> k;

    if(k > n || (k == 1 && n != 1))
        cout << -1;
    else if(k <= 2)
        for(int i = 1; i <= n; i++){
            if(i % 2 == 1) cout << 'a';
            else
                 cout << 'b';
        }
    else{
        k -= 2;
        n = n - k; c = 'a';
        for(int i = 1; i <= n; i++){
            cout << c;
            if(c == 'a')
                c = 'b';
            else
                c = 'a';
            q++;
        }
        for(c = 'c'; c < 'c' + k; c++)
            cout << c, q++;
        cout << q ;

    }

}


#include<stdio.h>

int main()
{
    int n,k,i;

    while(scanf("%d%d",&n,&k)==2)
    {
        if(n<k)
            printf("-1\n");
        else
        {
            int d=n-k+2;

            for(i=1;i<=d;i++)
                if(i%2)
                    printf("a");
                else
                    printf("b");

            for(i=1;i<=k-2;i++)
                if(i<=24)
                    printf("%c",'a'+i+1);
                else
                    if(i%2)
                        printf("a");
                    else
                        printf("b");

            printf("\n");
        }
    }

    return 0;
}


#include<stdio.h>

int main()
{
    int n,k,i;

    while(scanf("%d%d",&n,&k)==2)
    {
        if(k==1 && n>1)
            printf("-1\n");
        else if(n<k)
            printf("-1\n");
        else
        {
            int d=n-k+2;

            for(i=1;i<=d;i++)
                if(i%2)
                    printf("a");
                else
                    printf("b");

            for(i=1;i<=k-2;i++)
                if(i<=24)
                    printf("%c",'a'+i+1);
                else
                    if(i%2)
                        printf("a");
                    else
                        printf("b");

            printf("\n");
        }
    }

    return 0;
}


#include<stdio.h>

int main()
{
    int n,k,i;

    while(scanf("%d%d",&n,&k)==2)
    {
        if(k==1 && n==1)
            printf("a\n");
        else if(k==1 && n>1)
            printf("-1\n");
        else if(n<k)
            printf("-1\n");
        else
        {
            int d=n-k+2;

            for(i=1;i<=d;i++)
                if(i%2)
                    printf("a");
                else
                    printf("b");

            for(i=1;i<=k-2;i++)
                if(i<=24)
                    printf("%c",'a'+i+1);
                else
                    if(i%2)
                        printf("a");
                    else
                        printf("b");

            printf("\n");
        }
    }

    return 0;
}


#include<stdio.h>

int main()
{
    int n,k,i;

    while(scanf("%d%d",&n,&k)==2)
    {
        if(n<k)
            printf("-1\n");
        else
        {
            int d=n-k+2;

            for(i=1;i<=d;i++)
                if(i%2)
                    printf("a");
                else
                    printf("b");

            for(i=1;i<=k-2;i++)
            {
                printf("%c",'a'+i+1);
            }

            printf("\n");
        }
    }

    return 0;
}


#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <iostream>
#include <math.h>
#include <conio.h>
using namespace std;
int main()
{
 int i,j,k,n,m,sum,sim;
 scanf("%d %d",&n,&k);
 char S[n+1];
 if(k>n)
   {
   printf("-1");
   return 0;
   }
 if(k==1 && n>1)
   {
   printf("-1");
   return 0;
   }
 sim=n-k+1;
 for(i=0;i<=sim;i++)
    {
    if(i%2==0){S[i]='a';}
    else{S[i]='b';}
    }
 S[i]='c';
 sim=i+1;
 for(i=sim;i<n;i++)
    {
    S[i]=S[i-1]+1;
    }
 for(i=0;i<n;i++) printf("%c",S[i]);
return 0;
}


#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <iostream>
#include <math.h>
#include <conio.h>
using namespace std;
int n,k,sum;
int main()
{
char sim,s[1000000];
int n,k;
scanf("%d %d",&n,&k);
if(n<k || k>26){printf("-1");return 0;}
int i=0;
while(i<n)
     {
     if(i%2){s[i]='b';}
     else{s[i]='a';}
     i++;
     }
i=n-k;
if(s[i-1]=='a'){s[i]='b';s[i+1]='a';}
else{s[i]='a';s[i+1]='b';}
sim='c';
i+=2;
while(i<n)
     {
     s[i]=sim;
     sim+=1;i++;
     }
for(i=0;i<n;i++){printf("%c",s[i]);}
return 0;
}


#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <iostream>
#include <math.h>
#include <conio.h>
using namespace std;
int n,k,sum;
int main()
{
char ch[]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','q','r','s','t','u','v','w','x','y','z'};
int n,k;
scanf("%d %d",&n,&k);
if(n<k){printf("-1");return 0;}
int i=0;
while(i<n-(k-2))
     {
     if(i%2){printf("b");}
     else{printf("a");}
     i++;
     }
int s=2;
while(i<n)
     {
     printf("%c",ch[s]);
     s++;i++;
     }
return 0;
}


#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <iostream>
#include <math.h>
#include <conio.h>
using namespace std;
int n,k,sum;
int main()
{
char sim;
int n,k;
scanf("%d %d",&n,&k);
if(n<k || k>26){printf("-1");return 0;}
int i=0;
while(i<n-k)
     {
     if(i%2){printf("b");}
     else{printf("a");}
     i++;
     }
sim='a';
while(i<n)
     {
     printf("%c",sim);
     sim+=1;i++;
     }
return 0;
}


#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <iostream>
#include <math.h>
#include <conio.h>
using namespace std;
int n,k,sum;
int main()
{
char sim;
int n,k;
scanf("%d %d",&n,&k);
if(n<k || k>26){printf("-1");return 0;}
int i=0;
while(i<n-(k-2))
     {
     if(i%2){printf("b");}
     else{printf("a");}
     i++;
     }
sim='c';
while(i<n)
     {
     printf("%c",sim);
     sim+=1;i++;
     }
return 0;
}


#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<algorithm>
#include<cstring>
#include<ctime>
#include<deque>
#include<sstream>
#include<iomanip>
#include<sstream>
#include<vector>
#include<queue>
#include<stack>
#include<cctype>
#include<memory>
#include<string>
#include<climits>
#include<map>
#include<set>
#include<list>
#include<cassert>
#include<deque>
#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define INF 1<<27
#define all(n) n.begin(),n.end()
#define insert(a,b,c,d) PP(P(a,b),P(c,d))
#define F first
#define S second
#define pb push_back
#define pf push_front
using namespace std;
typedef pair<int,int> P;
typedef pair<P,P> PP;
typedef long long ll;
typedef unsigned long long ull;

int main(){
  //freopen("","r",stdin);
  //freopen("","w",stdout);
  int n,k;

  cin >> n >> k;
  if(n < k)
    {
      cout << -1 << endl;
      return 0;
    }
  string ans;

  for(int i=0;i<n-(k-2);i++)
    ans += !(i%2)?"a":"b";

  for(int i=0;i<k-2;i++)
    ans += (char)('c'+i);

  cout << ans << endl;
return 0;
}


#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<algorithm>
#include<cstring>
#include<ctime>
#include<deque>
#include<sstream>
#include<iomanip>
#include<sstream>
#include<vector>
#include<queue>
#include<stack>
#include<cctype>
#include<memory>
#include<string>
#include<climits>
#include<map>
#include<set>
#include<list>
#include<cassert>
#include<deque>
#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define INF 1<<27
#define all(n) n.begin(),n.end()
#define insert(a,b,c,d) PP(P(a,b),P(c,d))
#define F first
#define S second
#define pb push_back
#define pf push_front
using namespace std;
typedef pair<int,int> P;
typedef pair<P,P> PP;
typedef long long ll;
typedef unsigned long long ull;

int main(){
  //freopen("","r",stdin);
  //freopen("","w",stdout);
  int n,k;

  cin >> n >> k;
  if(n < k || k == 1)
    {
      cout << -1 << endl;
      return 0;
    }
  string ans;

  for(int i=0;i<n-(k-2);i++)
    ans += !(i%2)?"a":"b";

  for(int i=0;i<k-2;i++)
    ans += (char)('c'+i);

  cout << ans << endl;
return 0;
}


#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<algorithm>
#include<cstring>
#include<ctime>
#include<deque>
#include<sstream>
#include<iomanip>
#include<sstream>
#include<vector>
#include<queue>
#include<stack>
#include<cctype>
#include<memory>
#include<string>
#include<climits>
#include<map>
#include<set>
#include<list>
#include<cassert>
#include<deque>
#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define INF 1<<27
#define all(n) n.begin(),n.end()
#define insert(a,b,c,d) PP(P(a,b),P(c,d))
#define F first
#define S second
#define pb push_back
#define pf push_front
using namespace std;
typedef pair<int,int> P;
typedef pair<P,P> PP;
typedef long long ll;
typedef unsigned long long ull;

int main(){
  //freopen("","r",stdin);
  //freopen("","w",stdout);
  int n,k;

  cin >> n >> k;
  if(n < k || (n > 1 && k == 1))
    {
      cout << -1 << endl;
      return 0;
    }
  string ans;
  if(n == 1 && k == 1)
    {
      cout << "a" << endl;
      return 0;
    }

  for(int i=0;i<n-(k-2);i++)
    ans += !(i%2)?"a":"b";

  for(int i=0;i<k-2;i++)
    ans += (char)('c'+i);

  cout << ans << endl;
return 0;
}


#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<algorithm>
#include<cstring>
#include<ctime>
#include<deque>
#include<sstream>
#include<iomanip>
#include<sstream>
#include<vector>
#include<queue>
#include<stack>
#include<cctype>
#include<memory>
#include<string>
#include<climits>
#include<map>
#include<set>
#include<list>
#include<cassert>
#include<deque>
#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define INF 1<<27
#define all(n) n.begin(),n.end()
#define insert(a,b,c,d) PP(P(a,b),P(c,d))
#define F first
#define S second
#define pb push_back
#define pf push_front
using namespace std;
typedef pair<int,int> P;
typedef pair<P,P> PP;
typedef long long ll;
typedef unsigned long long ull;

int main(){
  //freopen("","r",stdin);
  //freopen("","w",stdout);
  int n,k;
  cin >> n >> k;
  if(n < k)
    {
      cout << -1 << endl;
      return 0;
    }
  string ans;

  for(int i=0;i<n-(k-2);i++)
    ans += !(i%2)?"a":"b";

  for(int i=0;i<k-2;i++)
    ans += (char)('c'+i);

  cout << ans << endl;
return 0;
}


#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<algorithm>
#include<cstring>
#include<ctime>
#include<deque>
#include<sstream>
#include<iomanip>
#include<sstream>
#include<vector>
#include<queue>
#include<stack>
#include<cctype>
#include<memory>
#include<string>
#include<climits>
#include<map>
#include<set>
#include<list>
#include<cassert>
#include<deque>
#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define INF 1<<27
#define all(n) n.begin(),n.end()
#define insert(a,b,c,d) PP(P(a,b),P(c,d))
#define F first
#define S second
#define pb push_back
#define pf push_front
using namespace std;
typedef pair<int,int> P;
typedef pair<P,P> PP;
typedef long long ll;
typedef unsigned long long ull;

int main(){
  //freopen("","r",stdin);
  //freopen("","w",stdout);
  int n,k;

  cin >> n >> k;
  if(n < k || (n > 1 && k == 1))
    {
      cout << -1 << endl;
      return 0;
    }
  string ans;

  for(int i=0;i<n-(k-2);i++)
    ans += !(i%2)?"a":"b";

  for(int i=0;i<k-2;i++)
    ans += (char)('c'+i);

  cout << ans << endl;
return 0;
}


#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<algorithm>
#include<cstring>
#include<ctime>
#include<deque>
#include<sstream>
#include<iomanip>
#include<sstream>
#include<vector>
#include<queue>
#include<stack>
#include<cctype>
#include<memory>
#include<string>
#include<climits>
#include<map>
#include<set>
#include<list>
#include<cassert>
#include<deque>
#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define INF 1<<27
#define all(n) n.begin(),n.end()
#define insert(a,b,c,d) PP(P(a,b),P(c,d))
#define F first
#define S second
#define pb push_back
#define pf push_front
using namespace std;
typedef pair<int,int> P;
typedef pair<P,P> PP;
typedef long long ll;
typedef unsigned long long ull;

int main(){
  //freopen("","r",stdin);
  //freopen("","w",stdout);
  int n,k;

  cin >> n >> k;
  if(n < k || (n > 1 && k == 1))
    {
      cout << -1 << endl;
      return 0;
    }
  string ans;

  for(int i=0;i<n-(k-2);i++)
    ans += !(i%2)?"a":"b";

  for(int i=0;i<k-2;i++)
    {
      assert('c'+i <= 'z');
      ans += (char)('c'+i);
    }
  cout << ans << endl;
return 0;
}


#include<bits/stdc++.h>
#include<functional>
#include<string>
using namespace std;
#define ll long long int
#define mod 1000000007
#define mp make_pair
#define s second
#define pi pair<ll,ll>
#define pii pair<pi,ll>
#define pb push_back
int main(){
ll n,k;
cin>>n>>k;
if(n<k){
cout<<-1;
return 0;
}
if(n==k){
char c='a';
while(k--){
cout<<c;
c++;
}
return 0;
}
if(k==1){
cout<<-1;
return 0;
}
char c='c';
k-=2;
ll left=n-k;
while(left>2){
left-=2;
cout<<"ab";
}
if(left>0) cout<<'a';
while(k>0){
cout<<c;
c++;
k--;
}
}


#include<bits/stdc++.h>
#include<functional>
#include<string>
using namespace std;
#define ll long long int
#define mod 1000000007
#define mp make_pair
#define s second
#define pi pair<ll,ll>
#define pii pair<pi,ll>
#define pb push_back
int main(){
ll n,k;
cin>>n>>k;
if(n<k){
cout<<-1;
return 0;
}
if(n==k){
char c='a';
while(k--){
cout<<c;
c++;
}
return 0;
}
if(k==1){
cout<<-1;
return 0;
}
char c='c';
k-=2;
ll left=n-k;
if(left%2==0){
while(left-2>=0){
cout<<"ab";
left-=2;
}
}
else{
while(left-2>=0){
cout<<"ab";
left-=2;
}
cout<<'a';
}
while(k>0){
cout<<c;
c++;
k--;
}
}


#include<bits/stdc++.h>
#include<functional>
#include<string>
using namespace std;
#define ll long long int
#define mod 1000000007
#define mp make_pair
#define s second
#define pi pair<ll,ll>
#define pii pair<pi,ll>
#define pb push_back
int main(){
ll n,k;
cin>>n>>k;
if(n<k){
cout<<-1;
return 0;
}
if(n==k){
char c='a';
while(k--){
cout<<c;
c++;
}
return 0;
}
if(k==1){
cout<<-1;
return 0;
}
char c='c';
k-=2;
ll left=n-k;
while(left>2){
left-=2;
cout<<"ab";
}
//if(left>0) cout<<'a';
while(k>0){
cout<<c;
c++;
k--;
}
}


#include<bits/stdc++.h>
#include<functional>
#include<string>
using namespace std;
#define ll long long int
#define mod 1000000007
#define mp make_pair
#define s second
#define pi pair<ll,ll>
#define pii pair<pi,ll>
#define pb push_back
int main(){
ll n,k;
cin>>n>>k;
if(n<k){
cout<<-1;
return 0;
}
if(k==1){
if(n==1) cout<<'a';
else cout<<-1;
return 0;
}
cout<<'a';
char c='c';
ll left=n-k;
while(left>2){
cout<<"ba";
left-=2;
}
cout<<'b';
k-=2;
if(left) cout<<'a';
while(k>0){
cout<<c;
c++;
k--;
}
}


#include <iostream>
#include <set>
#include <vector>
#include <cstdio>
#include <cmath>
#include <limits>
#include <iomanip>
#include <algorithm>
#include <fstream>
#include <queue>
using namespace std;
#define FILEIO(taskname) ifstream cin((string(taskname)+".in").c_str()); ofstream cout((string(taskname)+".out").c_str())
#define FILEIOTXT ifstream cin("input.txt"); ofstream cout("output.txt");
#define FORE(a, b) for(typeof((b).begin()) a = (b).begin(); a!=(b).end();a++)
typedef size_t st;
typedef long long ll;
int gcd(int a, int b) {
    if (a < b)
        return gcd(b, a);
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
int main() {
    ios_base::sync_with_stdio(false);
    st n, m;
    cin >> n >> m;
    if (n < m || m <= 1) {
        cout << -1 << endl;
        return 0;
    }
    vector<char> chrs;
    chrs.reserve(n);
    for (st i = 0; i <= n - m + 1; i++) {
        chrs.push_back((i % 2 == 0) ? 'a' : 'b');
    }
    for (char i = 'c'; chrs.size() < n && i <= 'z'; i++)
        chrs.push_back(i);
    if (chrs.size() < n) {
        cout << -1 << endl;
        return 0;
    }
    for (st i = 0; i < chrs.size(); i++)
        cout << chrs[i];
    cout << endl;
    return 0;
}


#include <iostream>
#include <set>
#include <vector>
#include <cstdio>
#include <cmath>
#include <limits>
#include <iomanip>
#include <algorithm>
#include <fstream>
#include <queue>
using namespace std;
#define FILEIO(taskname) ifstream cin((string(taskname)+".in").c_str()); ofstream cout((string(taskname)+".out").c_str())
#define FILEIOTXT ifstream cin("input.txt"); ofstream cout("output.txt");
#define FORE(a, b) for(typeof((b).begin()) a = (b).begin(); a!=(b).end();a++)
typedef size_t st;
typedef long long ll;
int gcd(int a, int b) {
    if (a < b)
        return gcd(b, a);
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
int main() {
    ios_base::sync_with_stdio(false);
    st n, m;
    cin >> n >> m;
    if (n < m || (m <= 1 && n > 1)) {
        cout << -1 << endl;
        return 0;
    }
    vector<char> chrs;
    chrs.reserve(n);
    for (st i = 0; i <= n - m + 1; i++) {
        chrs.push_back((i % 2 == 0) ? 'a' : 'b');
    }
    for (char i = 'c'; chrs.size() < n && i <= 'z'; i++)
        chrs.push_back(i);
    if (chrs.size() < n) {
        cout << -1 << endl;
        return 0;
    }
    for (st i = 0; i < chrs.size(); i++)
        cout << chrs[i];
    cout << endl;
    return 0;
}


#include <iostream>
#include <set>
#include <vector>
#include <cstdio>
#include <cmath>
#include <limits>
#include <iomanip>
#include <algorithm>
#include <fstream>
#include <queue>
using namespace std;
#define FILEIO(taskname) ifstream cin((string(taskname)+".in").c_str()); ofstream cout((string(taskname)+".out").c_str())
#define FILEIOTXT ifstream cin("input.txt"); ofstream cout("output.txt");
#define FORE(a, b) for(typeof((b).begin()) a = (b).begin(); a!=(b).end();a++)
typedef size_t st;
typedef long long ll;
int gcd(int a, int b) {
    if (a < b)
        return gcd(b, a);
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
int main() {
    ios_base::sync_with_stdio(false);
    st n, m;
    cin >> n >> m;
    if (n < m || (m <= 1 && n > 1)) {
        cout << -1 << endl;
        return 0;
    }
    if(n == 1 && m == 1)
    {
        cout << "a" << endl;
        return 0;
    }
    vector<char> chrs;
    chrs.reserve(n);
    for (st i = 0; i < n - m + 2; i++) {
        chrs.push_back((i % 2 == 0) ? 'a' : 'b');
    }
    for (char i = 'c'; chrs.size() < n && i <= 'z'; i++)
        chrs.push_back(i);
    if (chrs.size() < n) {
        cout << -1 << endl;
        return 0;
    }
    for (st i = 0; i < chrs.size(); i++)
        cout << chrs[i];
    cout << endl;
    return 0;
}


#include <iostream>
#include <set>
#include <vector>
#include <cstdio>
#include <cmath>
#include <limits>
#include <iomanip>
#include <algorithm>
#include <fstream>
#include <queue>
using namespace std;
#define FILEIO(taskname) ifstream cin((string(taskname)+".in").c_str()); ofstream cout((string(taskname)+".out").c_str())
#define FILEIOTXT ifstream cin("input.txt"); ofstream cout("output.txt");
#define FORE(a, b) for(typeof((b).begin()) a = (b).begin(); a!=(b).end();a++)
typedef size_t st;
typedef long long ll;
int gcd(int a, int b) {
    if (a < b)
        return gcd(b, a);
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
int main() {
    ios_base::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    if (n < m) {
        cout << -1 << endl;
        return 0;
    }
    vector<char> chrs;
    chrs.reserve(n);
    for (int i = 0; i <= n - m + 1; i++) {
        chrs.push_back((i % 2 == 0) ? 'a' : 'b');
    }
    for (int i = 'c'; chrs.size() < n; i++)
        chrs.push_back(i);
    for (int i = 0; i < chrs.size(); i++)
        cout << chrs[i];
    cout << endl;
    return 0;
}


#include <iostream>
#include <set>
#include <vector>
#include <cstdio>
#include <cmath>
#include <limits>
#include <iomanip>
#include <algorithm>
#include <fstream>
#include <queue>
using namespace std;
#define FILEIO(taskname) ifstream cin((string(taskname)+".in").c_str()); ofstream cout((string(taskname)+".out").c_str())
#define FILEIOTXT ifstream cin("input.txt"); ofstream cout("output.txt");
#define FORE(a, b) for(typeof((b).begin()) a = (b).begin(); a!=(b).end();a++)
typedef size_t st;
typedef long long ll;
int gcd(int a, int b) {
    if (a < b)
        return gcd(b, a);
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
int main() {
    ios_base::sync_with_stdio(false);
    st n, m;
    cin >> n >> m;
    if (n < m) {
        cout << -1 << endl;
        return 0;
    }
    vector<char> chrs;
    chrs.reserve(n);
    for (st i = 0; i <= n - m + 1; i++) {
        chrs.push_back((i % 2 == 0) ? 'a' : 'b');
    }
    for (char i = 'c'; chrs.size() < n && i <= 'z'; i++)
        chrs.push_back(i);
    if (chrs.size() < n) {
        cout << -1 << endl;
        return 0;
    }
    for (st i = 0; i < chrs.size(); i++)
        cout << chrs[i];
    cout << endl;
    return 0;
}


#include <iostream>
#include <string>

#define forn(i,x,y) for(int i=x;i<y;i++)

using namespace std;

int main(void) {
    int n,k; cin >> n >> k;
    if(k > n || k > 26) {
        cout << -1 << endl;
        return 0;
    }
    if(k == 1) {
        if(n == 1) cout << 'a' << endl;
        else cout << -1 << endl;
        return 0;
    }
    bool a = true;
    forn(i,0,n-k+2) {
        if(a) cout << 'a';
        else cout << 'b';
        a = !a;
    }
    n = n - (n-k+2);
    char let='c';
    forn(i,0,n) {
        cout << let;
        let++;
    }
    cout << endl;
}


#include <iostream>
#include <string>

#define forn(i,x,y) for(int i=x;i<y;i++)

using namespace std;

int main(void) {
    int n,k; cin >> n >> k;
    if(k > n || k > 26) {
        cout << -1 << endl;
        return 0;
    }
    if(k == 1) {
        while(true);
        forn(i,0,n-1) cout << 'a';
        cout << 'b';
        cout << endl;
        return 0;
    }
    bool a = true;
    forn(i,0,n-k+2) {
        if(a) cout << 'a';
        else cout << 'b';
        a = !a;
    }
    n = n - (n-k+2);
    char let='c';
    forn(i,0,n) {
        cout << let;
        let++;
    }
    cout << endl;
}


#include <iostream>
#include <string>

#define forn(i,x,y) for(int i=x;i<y;i++)

using namespace std;

int main(void) {
    int n,k; cin >> n >> k;
    if(k > n || k > 26) {
        cout << -1 << endl;
        return 0;
    }
    if(k == 1) {
        forn(i,0,n-1) cout << 'a';
        cout << 'b';
        cout << endl;
        return 0;
    }
    bool a = true;
    forn(i,0,n-k+2) {
        if(a) cout << 'a';
        else cout << 'b';
        a = !a;
    }
    n = n - (n-k+2);
    char let='c';
    forn(i,0,n) {
        cout << let;
        let++;
    }
    cout << endl;
}


#include <iostream>
#include <string>

#define forn(i,x,y) for(int i=x;i<y;i++)

using namespace std;

int main(void) {
    int n,k; cin >> n >> k;
    if(k>n || k > 26) {
        cout << -1 << endl;
        return 0;
    }
    k -= 2;
    string ans = "";
    bool b = true;
    forn(i,0,n-k) {
        if(b) ans+='a';
        else ans+='b';
        b = !b;
    }
    char let = 'c';
    forn(i,n-k,n) {
        ans+=let; let++;
    }
    cout << ans << endl;
}


#include <iostream>
#include <string>

#define forn(i,x,y) for(int i=x;i<y;i++)

using namespace std;

int main(void) {
    int n,k; cin >> n >> k;
    if(k > n) {
        cout << -1 << endl;
        return 0;
    }
    if(k == 1) {
        forn(i,0,n) cout << 'a';
        cout << endl;
        return 0;
    }
    bool a = true;
    forn(i,0,n-k+2) {
        if(a) cout << 'a';
        else cout << 'b';
        a = !a;
    }
    n = n - (n-k+2);
    char let='c';
    forn(i,0,n) {
        cout << let;
        let++;
    }
    cout << endl;
}


#include <iostream>
#include <string>

#define forn(i,x,y) for(int i=x;i<y;i++)

using namespace std;

int main(void) {
    int n,k; cin >> n >> k;
    if(k>n || k > 26) {
        cout << -1 << endl;
        return 0;
    }
    if(k == 1) {
        forn(i,0,n) cout << 'a';
        cout << endl;
        return 0;
    }
    k -= 2;
    string ans = "";
    bool b = true;
    forn(i,0,n-k) {
        if(b) ans+='a';
        else ans+='b';
        b = !b;
    }
    char let = 'c';
    forn(i,n-k,n) {
        ans+=let; let++;
    }
    cout << ans << endl;
}


#pragma comment(linker, "/STACK:256000000")
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <stdio.h>
#include <cstdlib>
#include <string>
#include <cmath>
#include <algorithm>
#include <utility>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>

using namespace std;

typedef long long ll;
typedef long double ldb;
typedef pair<int, int> pii;

#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define has(mask,i) (((mask) & (1<<(i))) == 0 ? false : true)
#define E(x) {cout << #x << " = " << (x) << endl;}

int main(){
	//freopen("IN.in", "r", stdin);
	//freopen("OUT.out", "w", stdout);
	int n, k, l = 0;
	scanf("%d %d", &n, &k);
	if(k > n)
		printf("-1");
	else{
		k -= 2;
		for(int i=0;i<(n-k);i++){
			printf("%c", char('a'+ l));
			l++;
			l %= 2;
		}
		for(int i=0;i<k;i++)
			printf("%c", char('a'+2+i));
	}
	return 0;
}


#pragma comment(linker, "/STACK:256000000")
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <stdio.h>
#include <cstdlib>
#include <string>
#include <cmath>
#include <algorithm>
#include <utility>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>

using namespace std;

typedef long long ll;
typedef long double ldb;
typedef pair<int, int> pii;

#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define has(mask,i) (((mask) & (1<<(i))) == 0 ? false : true)
#define E(x) {cout << #x << " = " << (x) << endl;}

int main(){
	//freopen("IN.in", "r", stdin);
	//freopen("OUT.out", "w", stdout);
	int n, k, l = 0;
	scanf("%d %d", &n, &k);
	if(k > n || k == 1)
		printf("-1");
	else{
		k -= 2;
		for(int i=0;i<(n-k);i++){
			printf("%c", char('a'+ l));
			l++;
			l %= 2;
		}
		for(int i=0;i<k;i++)
			printf("%c", char('a'+2+i));
	}
	return 0;
}


#pragma comment(linker, "/STACK:256000000")
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <stdio.h>
#include <cstdlib>
#include <string>
#include <cmath>
#include <algorithm>
#include <utility>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>

using namespace std;

typedef long long ll;
typedef long double ldb;
typedef pair<int, int> pii;

#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define has(mask,i) (((mask) & (1<<(i))) == 0 ? false : true)
#define E(x) {cout << #x << " = " << (x) << endl;}

int main(){
	//freopen("IN.in", "r", stdin);
	//freopen("OUT.out", "w", stdout);
	int n, k, l = 0;
	scanf("%d %d", &n, &k);
	if(k == n == 1){
		printf("a");
		return 0;
	}
	if(k > n || k == 1)
		printf("-1");
	else{
		k -= 2;
		for(int i=0;i<(n-k);i++){
			printf("%c", char('a'+ l));
			l++;
			l %= 2;
		}
		for(int i=0;i<k;i++)
			printf("%c", char('a'+2+i));
	}
	return 0;
}


#pragma comment(linker, "/STACK:256000000")
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <stdio.h>
#include <cstdlib>
#include <string>
#include <cmath>
#include <algorithm>
#include <utility>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>

using namespace std;

typedef long long ll;
typedef long double ldb;
typedef pair<int, int> pii;

#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define has(mask,i) (((mask) & (1<<(i))) == 0 ? false : true)
#define E(x) {cout << #x << " = " << (x) << endl;}

int main(){
	//freopen("IN.in", "r", stdin);
	//freopen("OUT.out", "w", stdout);
	int n, k, l = 0;
	scanf("%d %d", &n, &k);
	if(k == n && n == 1){
		printf("a");
		return 0;
	}
	if(k > n || k == 1)
		printf("-1");
	else{
		k -= 2;
		for(int i=0;i<(n-k);i++){
			printf("%c", char('a'+ l));
			l++;
			l %= 2;
		}
		for(int i=0;i<k;i++)
			printf("%c", char('a'+2+i));
	}
	return 0;
}


#pragma comment(linker, "/STACK:256000000")
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <stdio.h>
#include <cstdlib>
#include <string>
#include <cmath>
#include <algorithm>
#include <utility>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>

using namespace std;

typedef long long ll;
typedef long double ldb;
typedef pair<int, int> pii;

#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define has(mask,i) (((mask) & (1<<(i))) == 0 ? false : true)
#define E(x) {cout << #x << " = " << (x) << endl;}

int main(){
	//freopen("IN.in", "r", stdin);
	//freopen("OUT.out", "w", stdout);
	int n, k, l = 0;
	scanf("%d %d", &n, &k);
	if(k == 1){
		for(int i=0;i<n;i++)
			printf("a");
		return 0;
	}
	if(k > n)
		printf("-1");
	else{
		k -= 2;
		for(int i=0;i<(n-k);i++){
			printf("%c", char('a'+ l));
			l++;
			l %= 2;
		}
		for(int i=0;i<k;i++)
			printf("%c", char('a'+2+i));
	}
	return 0;
}


#include <conio.h>
#include <iostream>

using namespace std;

int n,k,sum;

int main()
{

cin>>n>>k;
//cout<<n; getch();
if(k>n) {cout<<-1; return 0;}
int i=0,z=0;
if(n==1) {cout<<'a'; return 0; }
if(n==2) {cout<<'a'<<'b'; return 0; }
if(k==1 && n>1) {cout<<-1; return 0; }

while(n-k+1>=i) { cout<<(char)('a'+z); z=!z; i++; }
z=2;
while(i<n) {cout<<(char)('a'+z); z++; i++;}

return 0;
}


#include <iostream>

using namespace std;

int n,k,sum;

int main()
{

cin>>n>>k;
if(k>n || k>26) {cout<<-1; return 0;}
int i=0,z=0;
if(n==1) {cout<<'a'; return 0; }
if(n==2) {cout<<'a'<<'b'; return 0; }
while(n-k+1>=i) { cout<<(char)('a'+z); z=!z; i++; }
z=2;
while(i<n) {cout<<(char)('a'+z); z++; i++;}

return 0;
}


#include <iostream>

using namespace std;

int n,k,sum;

int main()
{

cin>>n>>k;
if(k>n || k>26) {cout<<-1; return 0;}
int i=0,z=0;
while(n-k>=i-1) { cout<<(char)('a'+z); z=!z; i++; }
z=2;
while(i<n) {cout<<(char)('a'+z); z++; i++;}

return 0;
}


#include <iostream>

using namespace std;

int n,k,sum;

int main()
{

cin>>n>>k;
//cout<<n; getch();
if(k>n) {cout<<-1; return 0;}
int i=0,z=0;
if(n==1) {cout<<'a'; return 0; }
if(n==2) {cout<<'a'<<'b'; return 0; }

if(k==1 && n>1) {cout<<-1; return 0; }
while(n-k+1>=i) { cout<<(char)('a'+z); z=!z; i++; }
z=2;
while(i<n) {cout<<(char)('a'+z); z++; i++;}

return 0;
}


#include <conio.h>
#include <iostream>
using namespace std;

int main()
{
 int i,j,k,n,med;
 cin>>n>>k;
 char str[n+2];
 if(k>n) { cout<<-1; return 0;}
 if(k==1 && n>1) {cout<<-1; return 0; }
 med=n-k+1;
 for(i=0;i<=med;i++) {if(i%2==0) str[i]='a'; else str[i]='b';}
 str[i]='c';
 med=i+1;
 for(i=med;i<n;i++) str[i]=str[i-1]+1;
 for(i=0;i<n;i++) cout<<str[i];

}


#include <conio.h>
#include <iostream>

using namespace std;

int n,k,sum;

int main()
{

cin>>n>>k;

if(k>n || k>26) {cout<<-1; return 0;}
int i=0,z=0;
if(n==1) {cout<<'a'; return 0; }
if(n==2) {cout<<'a'<<'b'; return 0; }
if(k==1) { while(i<n) {cout<<'a'; z++; i++;} return 0; }
while(n-k+1>=i) { cout<<(char)('a'+z); z=!z; i++; }
z=2;
while(i<n) {cout<<(char)('a'+z); z++; i++;}

return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define dump(x) cerr << #x " = " << (x) << '\n'
#define sz(x) ((int)(x).size())
#define endl '\n'

#ifdef _DEBUG27_
    //#define STRESS 1
#endif

const int INF = 2e9;
const long long LINF = 2e18;

typedef long long llong;

void inv(bool e);
template<typename T> void die(T& a);

bool brute, alter;
int cnt_tests = 1;

// Div1 ?

// Code below

int n, k;
vector<pair<string, int> > data;
void inp() {
    cin >> k >> n;
    string t;
    int x;
    data.resize(k);
    for (int i = 0; i < k; i++) {
        cin >> t >> x;
        data[i] = {t, x};
    }
}

bool palindrom(string x) {
    string xx = x;
    reverse(all(x));
    return (x == xx);
}

inline bool cmp(const pair<string, int>& a, pair<string, int>& b) {
    return a.se < b.se;
}

void solve() {
    map<string, vector<llong> > mx;
    sort(all(data), cmp);
    for (auto x: data) {
        mx[x.fi].pb(x.se);
    }
    string s;
    llong summ = 0ll, ans = 0ll;;
    llong magic = 0ll, magic2 = 0ll;
    llong fir, sec;
    for (auto x: data) {
        if (palindrom(x.fi)) {
            if (sz(mx[x.fi]) > 1) {
                fir = mx[x.fi][sz(mx[x.fi]) - 1];
                sec = mx[x.fi][sz(mx[x.fi]) - 2];
                if (fir + sec >= 0) {
                    summ += fir + sec;
                }
                mx[x.fi].pop_back();
                mx[x.fi].pop_back();
            }
            magic = max(magic, fir - sec);
        }
        else {
            s = x.fi;
            reverse(all(s));
            if (sz(mx[s]) != 0 && sz(mx[x.fi]) != 0) {
                fir = mx[x.fi].back();
                sec = mx[s].back();
                if (fir + sec > 0) {
                    summ += fir + sec;
                }
                mx[x.fi].pop_back();
                mx[s].pop_back();
            }
        }
    }
    cout << summ + magic;
}

void stress() {

}

void naive() {

}

void run();
int main() {
    #ifdef _DEBUG27_
        if (1)
            freopen("input.txt", "r", stdin);
    #else
        ios_base::sync_with_stdio(false);
        cin.tie(0);
        cout.tie(0);
        if (0) {
            freopen("stack.in", "r", stdin);
            freopen("stack.out", "w", stdout);
        }
    #endif
    #ifdef STRESS
        srand(time(0));
        brute = true;
    #else
        brute = false;
    #endif

    for (int i = 0; (i < cnt_tests); i++) {
        run();
    }
    cerr << endl << "Time: " << clock() / 1000.0 << " ms";
    return 0;
}

void run() {
    if (!brute) {
        inp();
    }
    else {
        stress();
    }
    solve();
}

template<typename T>
void die(T& a) {
    cout << a;
    exit(0);
}

void inv(bool e) {
    if (!e) {
        vector<int> a;
        a[-1] += 1;
    }
}

/** CLEARING BUFFER

    cout << VAL << flush;

    OR

    printf(VAL);
    fflush(stdout);
*/


#include <bits/stdc++.h>

using namespace std;

#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define dump(x) cerr << #x " = " << (x) << '\n'
#define sz(x) ((int)(x).size())
#define endl '\n'

#ifdef _DEBUG27_
    //#define STRESS 1
#endif

const int INF = 2e9;
const long long LINF = 2e18;

typedef long long llong;

void inv(bool e);
template<typename T> void die(T& a);

bool brute, alter;
int cnt_tests = 1;

// Div1 ?

// Code below

int n, k;
vector<pair<string, int> > data;
void inp() {
    cin >> k >> n;
    string t;
    int x;
    data.resize(k);
    for (int i = 0; i < k; i++) {
        cin >> t >> x;
        data[i] = {t, x};
    }
}

bool palindrom(string x) {
    string xx = x;
    reverse(all(x));
    return (x == xx);
}

inline bool cmp(const pair<string, int>& a, pair<string, int>& b) {
    return a.se < b.se;
}

void solve() {
    map<string, vector<llong> > mx;
    sort(all(data), cmp);
    for (auto x: data) {
        mx[x.fi].pb(x.se);
    }
    string s;
    llong summ = 0ll, ans = 0ll;;
    llong magic = 0ll, magic2 = 0ll;
    llong fir, sec;
    for (auto x: data) {
        if (sz(mx[x.fi]) == 0)
            continue;
        if (palindrom(x.fi)) {
            if (sz(mx[x.fi]) > 1) {
                fir = mx[x.fi][sz(mx[x.fi]) - 1];
                sec = mx[x.fi][sz(mx[x.fi]) - 2];
                if (fir + sec >= 0) {
                    summ += fir + sec;
                    mx[x.fi].pop_back();
                    mx[x.fi].pop_back();
                    if (sec < 0) {
                        magic2 = max(magic2, -sec);
                    }
                }
            }
            else {
                magic = max(magic, mx[x.fi].back());
            }
        }
        else {
            s = x.fi;
            reverse(all(s));
            if (sz(mx[s]) != 0 && sz(mx[x.fi]) != 0) {
                fir = mx[x.fi].back();
                sec = mx[s].back();
                if (fir + sec > 0) {
                    summ += fir + sec;
                    mx[x.fi].pop_back();
                    mx[s].pop_back();
                }
            }
        }
    }
    cout << summ + max(magic2, magic);
}

void stress() {

}

void naive() {

}

void run();
int main() {
    #ifdef _DEBUG27_
        if (1)
            freopen("input.txt", "r", stdin);
    #else
        ios_base::sync_with_stdio(false);
        cin.tie(0);
        cout.tie(0);
        if (0) {
            freopen("stack.in", "r", stdin);
            freopen("stack.out", "w", stdout);
        }
    #endif
    #ifdef STRESS
        srand(time(0));
        brute = true;
    #else
        brute = false;
    #endif

    for (int i = 0; (i < cnt_tests); i++) {
        run();
    }
    cerr << endl << "Time: " << clock() / 1000.0 << " ms";
    return 0;
}

void run() {
    if (!brute) {
        inp();
    }
    else {
        stress();
    }
    solve();
}

template<typename T>
void die(T& a) {
    cout << a;
    exit(0);
}

void inv(bool e) {
    if (!e) {
        vector<int> a;
        a[-1] += 1;
    }
}

/** CLEARING BUFFER

    cout << VAL << flush;

    OR

    printf(VAL);
    fflush(stdout);
*/


#include <bits/stdc++.h>

using namespace std;

#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define dump(x) cerr << #x " = " << (x) << '\n'
#define sz(x) ((int)(x).size())
#define endl '\n'

#ifdef _DEBUG27_
    //#define STRESS 1
#endif

const int INF = 2e9;
const long long LINF = 2e18;

typedef long long llong;

void inv(bool e);
template<typename T> void die(T& a);

bool brute, alter;
int cnt_tests = 1;

// Div1 ?

// Code below

int n, k;
vector<pair<string, int> > data;
void inp() {
    cin >> k >> n;
    string t;
    int x;
    data.resize(k);
    for (int i = 0; i < k; i++) {
        cin >> t >> x;
        data[i] = {t, x};
    }
}

bool palindrom(string x) {
    string xx = x;
    reverse(all(x));
    return (x == xx);
}

inline bool cmp(const pair<string, int>& a, pair<string, int>& b) {
    return a.se < b.se;
}

void solve() {
    map<string, vector<llong> > mx;
    sort(all(data), cmp);
    for (auto x: data) {
        mx[x.fi].pb(x.se);
    }
    string s;
    llong summ = 0ll, ans = 0ll;;
    llong magic = 0ll, magic2 = 0ll;
    llong fir, sec;
    for (auto x: data) {
        if (sz(mx[x.fi]) == 0)
            continue;
        if (palindrom(x.fi)) {
            if (sz(mx[x.fi]) > 1) {
                fir = mx[x.fi][sz(mx[x.fi]) - 1];
                sec = mx[x.fi][sz(mx[x.fi]) - 2];
                if (fir + sec > 0) {
                    summ += fir + sec;
                    mx[x.fi].pop_back();
                    mx[x.fi].pop_back();
                }
                if (fir + sec < fir) {
                    magic2 = max(magic2, -sec);
                }
            }
            else {
                magic = max(magic, mx[x.fi].back());
            }
        }
        else {
            s = x.fi;
            reverse(all(s));
            if (sz(mx[s]) != 0 && sz(mx[x.fi]) != 0) {
                fir = mx[x.fi].back();
                sec = mx[s].back();
                if (fir + sec > 0) {
                    summ += fir + sec;
                    mx[x.fi].pop_back();
                    mx[s].pop_back();
                }
            }
        }
    }
    cout << summ + max(magic2, magic);
}

void stress() {

}

void naive() {

}

void run();
int main() {
    #ifdef _DEBUG27_
        if (1)
            freopen("input.txt", "r", stdin);
    #else
        ios_base::sync_with_stdio(false);
        cin.tie(0);
        cout.tie(0);
        if (0) {
            freopen("stack.in", "r", stdin);
            freopen("stack.out", "w", stdout);
        }
    #endif
    #ifdef STRESS
        srand(time(0));
        brute = true;
    #else
        brute = false;
    #endif

    for (int i = 0; (i < cnt_tests); i++) {
        run();
    }
    cerr << endl << "Time: " << clock() / 1000.0 << " ms";
    return 0;
}

void run() {
    if (!brute) {
        inp();
    }
    else {
        stress();
    }
    solve();
}

template<typename T>
void die(T& a) {
    cout << a;
    exit(0);
}

void inv(bool e) {
    if (!e) {
        vector<int> a;
        a[-1] += 1;
    }
}

/** CLEARING BUFFER

    cout << VAL << flush;

    OR

    printf(VAL);
    fflush(stdout);
*/


#include <bits/stdc++.h>

using namespace std;

#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define dump(x) cerr << #x " = " << (x) << '\n'
#define sz(x) ((int)(x).size())
#define endl '\n'

#ifdef _DEBUG27_
    //#define STRESS 1
#endif

const int INF = 2e9;
const long long LINF = 2e18;

typedef long long llong;

void inv(bool e);
template<typename T> void die(T& a);

bool brute, alter;
int cnt_tests = 1;

// Div1 ?

// Code below

int n, k;
vector<pair<string, int> > data;
void inp() {
    cin >> k >> n;
    string t;
    int x;
    data.resize(k);
    for (int i = 0; i < k; i++) {
        cin >> t >> x;
        data[i] = {t, x};
    }
}

bool palindrom(string x) {
    string xx = x;
    reverse(all(x));
    return (x == xx);
}

inline bool cmp(const pair<string, int>& a, pair<string, int>& b) {
    return a.se < b.se;
}

void solve() {
    map<string, vector<llong> > mx;
    sort(all(data), cmp);
    for (auto x: data) {
        mx[x.fi].pb(x.se);
    }
    string s;
    llong summ = 0ll, ans = 0ll;;
    llong magic = 0ll, magic2 = 0ll;
    llong fir, sec;
    for (auto x: data) {
        if (sz(mx[x.fi]) == 0)
            continue;
        if (palindrom(x.fi)) {
            if (sz(mx[x.fi]) > 1) {
                fir = mx[x.fi][sz(mx[x.fi]) - 1];
                sec = mx[x.fi][sz(mx[x.fi]) - 2];
                if (fir + sec >= 0) {
                    summ += fir + sec;
                    if (sec < 0) {
                        magic2 = max(magic2, -sec);
                    }
                }
                mx[x.fi].pop_back();
                mx[x.fi].pop_back();
            }
            else {
                magic = max(magic, mx[x.fi].back());
            }
        }
        else {
            s = x.fi;
            reverse(all(s));
            if (sz(mx[s]) != 0 && sz(mx[x.fi]) != 0) {
                fir = mx[x.fi].back();
                sec = mx[s].back();
                if (fir + sec > 0) {
                    summ += fir + sec;
                }
                mx[x.fi].pop_back();
                mx[s].pop_back();
            }
        }
    }
    cout << summ + max(magic2, magic);
}

void stress() {

}

void naive() {

}

void run();
int main() {
    #ifdef _DEBUG27_
        if (1)
            freopen("input.txt", "r", stdin);
    #else
        ios_base::sync_with_stdio(false);
        cin.tie(0);
        cout.tie(0);
        if (0) {
            freopen("stack.in", "r", stdin);
            freopen("stack.out", "w", stdout);
        }
    #endif
    #ifdef STRESS
        srand(time(0));
        brute = true;
    #else
        brute = false;
    #endif

    for (int i = 0; (i < cnt_tests); i++) {
        run();
    }
    cerr << endl << "Time: " << clock() / 1000.0 << " ms";
    return 0;
}

void run() {
    if (!brute) {
        inp();
    }
    else {
        stress();
    }
    solve();
}

template<typename T>
void die(T& a) {
    cout << a;
    exit(0);
}

void inv(bool e) {
    if (!e) {
        vector<int> a;
        a[-1] += 1;
    }
}

/** CLEARING BUFFER

    cout << VAL << flush;

    OR

    printf(VAL);
    fflush(stdout);
*/


/*jai mata di
let's rock*/
#include<bits/stdc++.h>
using namespace std;
int main()
{
	map<string,priority_queue<long long> >mp;
	map<string,priority_queue<long long> >::iterator it;
	long long n,k,ans=0,a;
	string s[100001];
	cin>>k>>n;
	long long x=0;
	for(int i=0;i<k;i++)
	{
		cin>>s[i]>>a;
		mp[s[i]].push(a);
	}
	for(int i=0;i<k;i++)
	{
		string cun=s[i];
		reverse(cun.begin(),cun.end());
		if(cun!=s[i])
		{
			while(mp[cun].empty()==0&&mp[s[i]].empty()==0&&mp[s[i]].top()+mp[cun].top()>0)
			{
				ans+=mp[s[i]].top()+mp[cun].top();
				mp[s[i]].pop();
				mp[cun].pop();
			}
		}
		else
		{
			while(mp[s[i]].size()>1)
			{
				long long now=mp[s[i]].top();
				mp[s[i]].pop();
				if(now+mp[s[i]].top()>0)
				{
					ans+=now+mp[s[i]].top();
					x=min(x,mp[s[i]].top());
					mp[s[i]].pop();
				}
				else
				{
					mp[s[i]].push(now);
					break;
				}
			}
		}
	}
	for(int i=0;i<k;i++)
	{
		string temp=s[i];
		reverse(temp.begin(),temp.end());
		if(temp==s[i]&&mp[temp].empty()==0)
		{
			x=max(x,mp[temp].top());
		}
	}
	printf("%I64d\n",ans+x);
	return 0;
}


/*jai mata di
let's rock*/
#include<bits/stdc++.h>
using namespace std;
int main()
{
	map<string,priority_queue<long long> >mp;
	map<string,priority_queue<long long> >::iterator it;
	long long n,k,ans=0,a;
	string s[100001];
	cin>>k>>n;
	long long x=0;
	for(int i=0;i<k;i++)
	{
		cin>>s[i]>>a;
		mp[s[i]].push(a);
	}
	for(int i=0;i<k;i++)
	{
		string cun=s[i];
		reverse(cun.begin(),cun.end());
		if(cun!=s[i])
		{
			while(mp[cun].empty()==0&&mp[s[i]].empty()==0&&mp[s[i]].top()+mp[cun].top()>0)
			{
				ans+=mp[s[i]].top()+mp[cun].top();
				mp[s[i]].pop();
				mp[cun].pop();
			}
		}
		else
		{
			while(mp[s[i]].size()>1)
			{
				long long now=mp[s[i]].top();
				mp[s[i]].pop();
				if(now+mp[s[i]].top()>0)
				{
					ans+=now+mp[s[i]].top();
					x=min(x,mp[s[i]].top());
					mp[s[i]].pop();
				}
				else
				{
					mp[s[i]].push(now);
					break;
				}
			}
		}
	}
	x=-x;
	for(int i=0;i<k;i++)
	{
		string temp=s[i];
		reverse(temp.begin(),temp.end());
		if(temp==s[i]&&mp[temp].empty()==0)
		{
			x=max(x,mp[temp].top());
		}
	}
	printf("%I64d\n",ans+x);
	return 0;
}


#include<bits/stdc++.h>
#define ll long long

#define nl printf("\n")
#define pb(x) push_back(x)

#define S(a) scanf("%d",&a)
#define S2(a,b) scanf("%d%d",&a,&b)
#define S3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define P(a) printf("%d",a)

#define max(a,b) ((a>b)?a:b)
#define min(a,b) ((a<b)?a:b)

#define PL(a) printf("%lld",a)
#define PLN(a) printf("%lld\n",a)
#define PLC(a) printf("%lld ",a)
#define SL(a) scanf("%lld",&a)
#define SL2(a,b) scanf("%lld%lld",&a,&b)
#define SL3(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define SL4(a,b,c,d) scanf("%lld%lld%lld%lld",&a,&b,&c,&d)

#define CLR(a) memset(a,0,sizeof(a))
#define SET(a) memset(a,-1,sizeof(a))
#define FOOL(a) memset(a,false,sizeof(a))
#define fr(i,a,n) for(i=a;i<=n;i++)
#define frv(i,v) for(i=0;i<(int)v.size();i++)
#define frs(i,v) for(i=0;i<(int)v.length();i++)
#define pi acos(-1.0)
#define po 400001
#define co 1000000
#define mod 786433
#define inf 10000000

using namespace std;
ll f[100001];
struct node
{
    ll a,b,c,d;
    node(){};
    node(ll aa,ll bb,ll cc,ll dd){a=aa,b=bb,c=cc,d=dd;}
};
struct cmp
{
    bool operator()(const node& x,const node& y)const
    {
        if(x.a!=y.a)return x.a<y.a;
        if(x.b!=y.b)return x.b<y.b;
        if(x.c!=y.c)return x.c>y.c;
        return x.d<y.d;
    }
};
ll ptr=-1;
int main()
{
    string ss;
    ll k,n,x,y,i,z,ans=0,sofar;
    set<node,cmp> s;
    f[0]=1;
    fr(i,1,100000)
        f[i]=(f[i-1]*31LL)%mod;
    SL2(k,n);
    while(k--)
    {
        cin>>ss;
        x=0,y=0;
        frs(i,ss)
        {
            x=(x+(ss[i]-'a')*f[i])%mod;
            y=(y+(ss[i]-'a')*f[n-1-i])%mod;
        }
        SL(z);
            s.insert(node(x,y,z,++ptr));
    }
    sofar=0;
    while(1)
    {
        if(s.empty())break;
        auto it=s.begin();
        node e=*it;s.erase(it);
        auto jt=s.lower_bound(node(e.b,e.a,inf,-1));
        if(jt==s.end())
        {
            if(e.a==e.b)
                sofar=max(sofar,e.c);
            continue;
        }
        if(e.b==jt->a and e.a==jt->b and (e.c+jt->c)>0)
        {
            ans+=(e.c+jt->c);
            if(e.a==e.b)
                sofar=max(sofar,-jt->c);
            s.erase(jt);
        }
        else if(e.a==e.b)
            sofar=max(sofar,e.c);
    }
    ans+=sofar;
    PLN(ans);
}