#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
    int k;
    cin>>k;
    string s;
    cin>>s;
    int n=s.length();
    int fr[26]={0};
    for(int i=0;i<n;i++)
    fr[s[i]-'a']++;
    if(n%k!=0)
    {
    	cout<<-1;
    	return 0;
	}
	k=n/k;
	string ans="";
	for(int i=0;i<26;i++)
	{
		if(fr[i]%(n/k)!=0)
		{
			cout<<-1;
			return 0;
		}
		for(int j=0;j<fr[i]/(n/k);j++)
		ans+=char(i+'a');
	}
	for(int i=0;i<n/k;i++)
	cout<<ans;
	cout<<endl;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
	int k;
	cin>>k;
	string s;
	cin>>s;
	int n=s.length();
	int a[26];
	memset(a,0,sizeof(a));
	if(n%k!=0)
	{
		cout<<-1;
		return 0;
	}
	k=n/k;
	for(int i=0;i<n;i++)
	a[s[i]-'a']++;
	for(int i=0;i<n;i++)
	{
		if(a[i]%k!=0)
		{
			cout<<-1;
			return  0;
		}

	}
	string ans="";
	for(int i=0;i<26;i++)
	{
		for(int j=0;j<a[i]/k;j++)
		ans+=char('a'+i);
	}
	for(int i=0;i<n/(n/k);i++)
	cout<<ans;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
	int k;
	cin>>k;
	string s;
	cin>>s;
	int n=s.length();
	int a[26];
	memset(a,0,sizeof(a));
	if(n%k!=0)
	{
		cout<<-1;
		return 0;
	}
	for(int i=0;i<n;i++)
	a[s[i]-'a']++;
	for(int i=0;i<26;i++)
	{
		if(a[i]%k!=0)
		{
			cout<<-1;
			return  0;
		}

	}
	string ans="";
	int c=0;
	for(int i=0;i<26;i++)
	{
		for(int j=0;j<a[i]/k;j++)
		ans+=char('a'+i);
	}
	for(int i=0;i<n/k;i++)
	cout<<ans;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
	int k;
	cin>>k;
	string s;
	cin>>s;
	int n=s.length();
	int a[26];
	memset(a,0,sizeof(a));
	if(n%k!=0)
	{
		cout<<-1;
		return 0;
	}
	for(int i=0;i<n;i++)
	a[s[i]-'a']++;
	for(int i=0;i<n;i++)
	{
		if(a[i]%k!=0)
		{
			cout<<-1;
			return  0;
		}

	}
	string ans="";
	int c=0;
	for(int i=0;i<26;i++)
	{
		for(int j=0;j<a[i]/k;j++)
		ans+=char('a'+i);
	}
	for(int i=0;i<n/k;i++)
	cout<<ans;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
	int k;
	cin>>k;
	string s;
	cin>>s;
	int n=s.length();
	int a[26];
	memset(a,0,sizeof(a));
	if(n%k!=0)
	{
		cout<<-1;
		return 0;
	}
	k=n/k;
	for(int i=0;i<n;i++)
	a[s[i]-'a']++;
	for(int i=0;i<n;i++)
	{
		if(a[i]%k!=0)
		{
			cout<<-1;
			return  0;
		}

	}
	string ans="";
	int c=0;
	for(int i=0;i<26;i++)
	{
		for(int j=0;j<a[i]/k;j++)
		ans+=char('a'+i);
	}
	for(int i=0;i<n/k;i++)
	cout<<ans;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
	int k;
	cin>>k;
	string s;
	cin>>s;
	int n=s.length();
	int a[26];
	k=n/k;
	memset(a,0,sizeof(a));
	if(n%k!=0)
	{
		cout<<-1;
		return 0;
	}
	for(int i=0;i<n;i++)
	a[s[i]-'a']++;
	for(int i=0;i<26;i++)
	{
		if(a[i]%k!=0)
		{
			cout<<-1;
			return  0;
		}

	}
	string ans="";
	int c=0;
	for(int i=0;i<26;i++)
	{
		for(int j=0;j<a[i]/k;j++)
		ans+=char('a'+i);
	}
	for(int i=0;i<k;i++)
	cout<<ans;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
	int k;
	cin>>k;
	string s;
	cin>>s;
	int n=s.length();
	int a[26];
	memset(a,0,sizeof(a));
	if(n%k!=0)
	{
		cout<<-1;
		return 0;
	}
	k=n/k;
	for(int i=0;i<n;i++)
	a[s[i]-'a']++;
	for(int i=0;i<n;i++)
	{
		if(a[i]%k!=0)
		{
			cout<<-1;
			return  0;
		}

	}
	if(k==1)
	{
	    cout<<s<<endl;
	    return 0;
	}
	string ans="";
	for(int i=0;i<26;i++)
	{
		for(int j=0;j<a[i]/k;j++)
		ans+=char('a'+i);
	}
	for(int i=0;i<n/k;i++)
	cout<<ans;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
    int k;
    cin>>k;
    string s;
    cin>>s;
    int n=s.length();
    int fr[26]={0};
    for(int i=0;i<n;i++)
    fr[s[i]-'a']++;
    if(n%k!=0)
    {
    	cout<<-1;
    	return 0;
	}
	k=n/k;
	string ans="";
	for(int i=0;i<26;i++)
	{
		if(fr[i]%(n/k!=0)
		{
			cout<<-1;
			return 0;
		}
		for(int j=0;j<fr[i]/(n/k);j++)
		ans+=char(i+'a');
	}
	for(int i=0;i<n/k;i++)
	cout<<ans;
	cout<<endl;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
	int k;
	cin>>k;
	string s;
	cin>>s;
	int n=s.length();
	int a[26];
	memset(a,0,sizeof(a));
	if(n%k!=0)
	{
		cout<<-1;
		return 0;
	}
	for(int i=0;i<n;i++)
	a[s[i]-'a']++;
	for(int i=0;i<n;i++)
	{
		if(a[i]%k!=0)
		{
			cout<<-1;
			return  0;
		}

	}
	string ans="";
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<26;j++)
		{
			if(a[j])
			ans+=char('a'+j),a[j]--;
		}
	}
	cout<<ans<<endl;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
	int k;
	cin>>k;
	string s;
	cin>>s;
	int n=s.length();
	int a[26];
	memset(a,0,sizeof(a));
	if(n%k!=0)
	{
		cout<<-1;
		return 0;
	}
	for(int i=0;i<n;i++)
	a[s[i]-'a']++;
	for(int i=0;i<n;i++)
	{
		if(a[i]%k!=0)
		{
			cout<<-1;
			return  0;
		}

	}
	string ans="";
	for(int i=0;i<n*n;i++)
	{
		for(int j=0;j<26;j++)
		{
			if(a[j])
			ans+=char('a'+j),a[j]--;
		}
	}
	cout<<ans<<endl;
}


#include <stdio.h>

int main () {
    int n = 0;
    int len = 0;
    int alphabet[26] = {0};
    char s[1001] = {0};

    scanf("%d %s", &n, s);

    for (int i = 0; s[i] != '\x00'; i++) {
        alphabet[s[i] - 0x61]++;
        len++;
    }

    char substring[(len / n) + 1] = {0};

    for (int i = 0, k = 0; i < 26; i++) {
        if (alphabet[i] > 0) {
            if ((alphabet[i] % n) == 0) {
                for (int j = 0; j < (alphabet[i] / n); j++) {
                    substring[k++] = i + 0x61;
                }
            } else {
                printf("%d\n", -1);
                return 0;
            }
        }
    }

    for (int i = 0; i < n; i++) {
        printf("%s", substring);
    }
    printf("\n");

    return 0;
}


#include <stdio.h>
#include <stdlib.h>

int main () {
    int n = 0;
	char alphabet[26] = {0};
	char s[1001] = {0};

	scanf("%d %s", &n, s);

	for (int i = 0; s[i] != '\x00'; i++) {
		alphabet[s[i] - 0x61]++;
	}

    char substring[27] = {0};

    for (int i = 0, j = 0; i < sizeof(alphabet); i++) {
        if (alphabet[i] > 0) {
            bool parity = ((alphabet[s[i] - 0x61] & 1) == 1) ? true : false;
            if (parity == (n & 1)) {
                substring[j++] = i + 0x61;
            } else {
                printf("%d\n", -1);
                return 0;
            }
        }
    }

    printf("%s\n", substring);
    return 0;
}


#include <stdio.h>
#include <stdlib.h>

int main () {
    int n = 0;
    int alphabet[26] = {0};
    char s[1001] = {0};

    scanf("%d %s", &n, s);

    for (int i = 0; s[i] != '\x00'; i++) {
        alphabet[s[i] - 0x61]++;
    }

    char substring[1001] = {0};

    for (int i = 0, k = 0; i < sizeof(alphabet) / sizeof(int); i++) {
        if (alphabet[i] > 0) {
            bool parity = ((alphabet[i] & 1) == 1) ? true : false;
            if (parity == (n & 1)) {
                for (int j = 0; j < (alphabet[i] / n); j++) {
                    substring[k++] = i + 0x61;
                }
            } else {
                printf("%d\n", -1);
                return 0;
            }
        }
    }

    for (int i = 0; i < n; i++) {
        printf("%s", substring);
    }
    printf("\n");

    return 0;
}


#include <stdio.h>
#include <stdlib.h>

int main () {
    int n = 0;
    int alphabet[26] = {0};
    char s[1001] = {0};

    scanf("%d %s", &n, s);

    for (int i = 0; s[i] != '\x00'; i++) {
        alphabet[s[i] - 0x61]++;
    }

    char substring[n + 1] = {0};

    for (int i = 0, k = 0; i < sizeof(alphabet) / sizeof(int); i++) {
        if (alphabet[i] > 0) {
            bool parity = ((alphabet[i] & 1) == 1) ? true : false;
            if (parity == (n & 1)) {
                for (int j = 0; j < (alphabet[i] / n); j++) {
                    substring[k++] = i + 0x61;
                }
            } else {
                printf("%d\n", -1);
                return 0;
            }
        }
    }

    for (int i = 0; i < n; i++) {
        printf("%s", substring);
    }
    printf("\n");

    return 0;
}


#include <stdio.h>
#include <stdlib.h>

int main () {
    int n = 0;
    char alphabet[26] = {0};
    char s[1001] = {0};

    scanf("%d %s", &n, s);

    for (int i = 0; s[i] != '\x00'; i++) {
        alphabet[s[i] - 0x61]++;
    }

    char substring[27] = {0};

    for (int i = 0, j = 0; i < sizeof(alphabet); i++) {
        if (alphabet[i] > 0) {
            bool parity = ((alphabet[i] & 1) == 1) ? true : false;
            if (parity == (n & 1)) {
                substring[j++] = i + 0x61;
            } else {
                printf("%d\n", -1);
                return 0;
            }
        }
    }

    for (int i = 0; i < n; i++) {
        printf("%s", substring);
    }
    printf("\n");

    return 0;
}


#include <stdio.h>

int main () {
    int n = 0;
    int len = 0;
    int alphabet[26] = {0};
    char s[1001] = {0};

    scanf("%d %s", &n, s);

    for (int i = 0; s[i] != '\x00'; i++) {
        alphabet[s[i] - 0x61]++;
        len++;
    }

    char substring[(len / n) + 1] = {0};

    for (int i = 0, k = 0; i < sizeof(alphabet) / sizeof(int); i++) {
        if (alphabet[i] > 0) {
            if ((alphabet[i] % n) == 0) {
                for (int j = 0; j < (alphabet[i] / n); j++) {
                    substring[k++] = i + 0x61;
                }
            } else {
                printf("%d\n", -1);
                return 0;
            }
        }
    }

    for (int i = 0; i < n; i++) {
        printf("%s", substring);
    }
    printf("\n");

    return 0;
}


#include <stdio.h>

int main () {
    int n = 0;
    int l = 0;

    int alphabet[26] = {0};
    char s[1001] = {0};

    scanf("%d %s", &n, s);

    for (int i = 0; s[i] != '\x00'; i++) {
        alphabet[s[i] - 0x61]++;
    }

    char substring[n * n];

    for (int i = 0; i < 26; i++) {
        if (alphabet[i] == 0) {
            continue;
        } else if ((alphabet[i] % n) != 0) {
            printf("%d\n", -1);
            return 0;
        }

        for (int j = 0; j < (alphabet[i] / n); j++) {
            substring[l++] = i + 0x61;
        }
    }

    substring[l] = '\x00';

    for (int i = 0; i < n; i++) {
        printf("%s", substring);
    }
    printf("\n");

    return 0;
}


#include <stdio.h>

int main () {
    int n = 0;
    int len = 0;
    int alphabet[26] = {0};
    char s[1001] = {0};

    scanf("%d %s", &n, s);

    for (int i = 0; s[i] != '\x00'; i++) {
        alphabet[s[i] - 0x61]++;
        len++;
    }

    char substring[n + 1] = {0};

    for (int i = 0, k = 0; i < 26; i++) {
        if (alphabet[i] > 0) {
            if ((alphabet[i] % n) == 0) {
                for (int j = 0; j < (alphabet[i] / n); j++) {
                    substring[k++] = i + 0x61;
                }
            } else {
                printf("%d\n", -1);
                return 0;
            }
        }
    }

    for (int i = 0; i < n; i++) {
        printf("%s", substring);
    }
    printf("\n");

    return 0;
}


#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main () {
    int n = 0;
    int alphabet[26] = {0};
    char s[1001] = {0};

    scanf("%d %s", &n, s);

    int len = 0;

    for (int i = 0; s[i] != '\x00'; i++) {
        alphabet[s[i] - 0x61]++;
        len++;
    }

    if (len % n != 0) {
        printf("%d\n", -1);
        return 0;
    }

    char substring[1001] = {0};

    for (int i = 0, k = 0; i < sizeof(alphabet) / sizeof(int); i++) {
        if (alphabet[i] > 0) {
            bool parity = (((alphabet[i] / n) & 1) == 1) ? true : false;
            if (parity == (n & 1)) {
                for (int j = 0; j <= (alphabet[i] / n); j++) {
                    substring[k++] = i + 0x61;
                }
            } else {
                printf("%d\n", -1);
                return 0;
            }
        }
    }

    for (int i = 0; i < n; i++) {
        printf("%s", substring);
    }
    printf("\n");

    return 0;
}


#include <stdio.h>

int main () {
    int n = 0;
    int l = 0;

    int alphabet[26] = {0};
    char s[1001] = {0};

    scanf("%d %s", &n, s);

    for (int i = 0; s[i] != '\x00'; i++) {
        alphabet[s[i] - 0x61]++;
    }

    char substring[n * n];

    for (int i = 0; i < 26; i++) {
        if (alphabet[i] == 0) {
            continue;
        } else if ((alphabet[i] % n) != 0) {
            printf("%d\n", -1);
            return 0;
        }

        for (int j = 0; j < (alphabet[i] / n); j++) {
            substring[l++] = i + 0x61;
        }
    }

    for (int i = 0; i < n; i++) {
        printf("%s", substring);
    }
    printf("\n");

    return 0;
}


#include <stdio.h>

int main () {
    int n = 0;
    int alphabet[26] = {0};
    char s[1001] = {0};

    scanf("%d %s", &n, s);

    for (int i = 0; s[i] != '\x00'; i++) {
        alphabet[s[i] - 0x61]++;
    }

    char substring[n + 1] = {0};

    for (int i = 0, k = 0; i < 26; i++) {
        if (alphabet[i] == 0) {
            continue;
        } else if ((alphabet[i] % n) != 0) {
            printf("%d\n", -1);
            return 0;
        }

        for (int j = 0; j < (alphabet[i] / n); j++) {
            substring[k++] = i + 0x61;
        }
    }

    for (int i = 0; i < n; i++) {
        printf("%s", substring);
    }
    printf("\n");

    return 0;
}


#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main () {
    int n = 0;
	char alphabet[26] = {0};
	char s[1001] = {0};

	scanf("%d %s", &n, s);

    int len = strlen(s);

	for (int i = 0; i < len; i++) {
		alphabet[s[i] - 0x61]++;
	}

    char substring[len + 1] = {0};

    for (int i = 0, j = 0; i < len; i++) {
        if (alphabet[s[i] - 0x61] > 0) {
            bool parity = ((alphabet[s[i] - 0x61] & 1) == 1) ? true : false;
            if (parity == (n & 1)) {
                substring[j++] = s[i];
            } else {
                printf("%d\n", -1);
                return 0;
            }
        }
    }

    printf("%s", substring);

    return 0;
}


#include <stdio.h>
#include <stdlib.h>

int main () {
    int n = 0;
	char alphabet[26] = {0};
	char s[1001] = {0};

	scanf("%d %s", &n, s);

	for (int i = 0; s[i] != '\x00'; i++) {
		alphabet[s[i] - 0x61]++;
	}

    char substring[27] = {0};

    for (int i = 0, j = 0; i < sizeof(alphabet); i++) {
        if (alphabet[i] > 0) {
            bool parity = ((alphabet[s[i] - 0x61] & 1) == 1) ? true : false;
            if (parity == (n & 1)) {
                substring[j++] = i + 0x61;
            } else {
                printf("%d\n", -1);
                return 0;
            }
        }
    }

    for (int i = 0; i < n; i++) {
        printf("%s", substring);
    }
    printf("\n");

    return 0;
}


#include <stdio.h>

int main () {
    int n = 0;
    int len = 0;
    int alphabet[26] = {0};
    char s[1001] = {0};

    scanf("%d %s", &n, s);

    for (int i = 0; s[i] != '\x00'; i++) {
        alphabet[s[i] - 0x61]++;
        len++;
    }

    char substring[(len / n) + 1] = {0};

    for (int i = 0, k = 0; i < 26; i++) {
        if (alphabet[i] == 0) {
            continue;
        } else if ((alphabet[i] % n) != 0) {
            printf("%d\n", -1);
            return 0;
        }

        for (int j = 0; j < (alphabet[i] / n); j++) {
            substring[k++] = i + 0x61;
        }
    }

    for (int i = 0; i < n; i++) {
        printf("%s", substring);
    }
    printf("\n");

    return 0;
}


#include <stdio.h>
#include <stdlib.h>

int main () {
    int n = 0;
    int alphabet[26] = {0};
    char s[1001] = {0};

    scanf("%d %s", &n, s);

    for (int i = 0; s[i] != '\x00'; i++) {
        alphabet[s[i] - 0x61]++;
    }

    char substring[27] = {0};

    for (int i = 0, j = 0; i < sizeof(alphabet) / sizeof(int); i++) {
        if (alphabet[i] > 0) {
            bool parity = ((alphabet[i] & 1) == 1) ? true : false;
            if (parity == (n & 1)) {
                substring[j++] = i + 0x61;
            } else {
                printf("%d\n", -1);
                return 0;
            }
        }
    }

    for (int i = 0; i < n; i++) {
        printf("%s", substring);
    }
    printf("\n");

    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define int long long
#define pb(x) emplace_back(x)
#define sz(x) static_cast<int> ((x).size())
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
const ll infl = 0x3f3f3f3f3f3f3f3fLL;
const int infi = 0x3f3f3f3f;
const ll mod = 1000000007;
//const ll mod = 998244353;
//const ll mod = infl;
int gcd(int a, int b);
int pow(int a, int b);

void solve() {
	int k; cin >> k;
    string s; cin >> s;
    map<char, int> mm;
    for(auto x: s) {
        mm[x]++;
    }
    if(sz(mm) == 1) {
        if(k <= sz(s)) {
        	for(int i = 0; i < k; i++) {
        		cout << mm.begin()->fi;
        	}
        } else {
        	cout << "-1";
        }
        return;
    }
    bool ok = true;
    int check = mm.begin()->second;
    for(auto x: mm) {
        if(x.second != check) ok = false;
    }
    if(!ok) {
        cout << "-1\n";
        cout << "here"<<endl;
        return ;
    }
    string ans = "";
    for(auto x: mm) {
        ans += x.first;
    }
    int times = sz(s) / k;
    while(times--) cout << ans;
    return;
}

signed main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout << fixed << setprecision(20);
	int tt;	tt = 1;
	//cin >> tt;
	while(tt--){
		solve();
	}
	return 0;
}

int gcd(int a, int b){
	if(b == 0){
		return a;
	}
	return gcd(b, a % b);
}
int pow(int a, int b) {
	int res = 1;
	while(b) {
		if(b & 1)
			res = (res * a) % mod;
		a = ( a * a ) % mod;
		b >>= 1;
	}
	return res;
}


#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define int long long
#define pb(x) emplace_back(x)
#define sz(x) static_cast<int> ((x).size())
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
const ll infl = 0x3f3f3f3f3f3f3f3fLL;
const int infi = 0x3f3f3f3f;
const ll mod = 1000000007;
//const ll mod = 998244353;
//const ll mod = infl;
int gcd(int a, int b);
int pow(int a, int b);

void solve() {
	int k; cin >> k;
	string s; cin >> s;
	map<char, int> mm;
	for(auto c: s) {
		mm[c]++;
	}
	sort(all(s));
	bool ok = true;
	for(auto it: mm) {
		if(it.se % k != 0) ok = false;
	}
	if(!ok) {
		cout << "-1\n";
		return;
	}
	string ans = "";
	for(auto x: mm) {
		for(int i = 0; i < x.se / k; i++) {
			ans += x.fi;
		}
	}
	for(int i = 0; i < k; i++) cout << ans;
}

signed main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout << fixed << setprecision(20);
	int tt;	tt = 1;
	//cin >> tt;
	while(tt--){
		solve();
	}
	return 0;
}

int gcd(int a, int b){
	if(b == 0){
		return a;
	}
	return gcd(b, a % b);
}
int pow(int a, int b) {
	int res = 1;
	while(b) {
		if(b & 1)
			res = (res * a) % mod;
		a = ( a * a ) % mod;
		b >>= 1;
	}
	return res;
}


#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define int long long
#define pb(x) emplace_back(x)
#define sz(x) static_cast<int> ((x).size())
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
const ll infl = 0x3f3f3f3f3f3f3f3fLL;
const int infi = 0x3f3f3f3f;
const ll mod = 1000000007;
//const ll mod = 998244353;
//const ll mod = infl;
int gcd(int a, int b);
int pow(int a, int b);

void solve() {
	int k; cin >> k;
    string s; cin >> s;
    map<char, int> mm;
    for(auto x: s) {
        mm[x]++;
    }
    if(sz(mm) == 1) {
        if(k <= sz(s)) {
        	for(int i = 0; i < k; i++) {
        		cout << mm.begin()->fi;
        	}
        } else {
        	cout << "-1";
        }
        return;
    }
    bool ok = true;
    int check = mm.begin()->second;
    for(auto x: mm) {
        if(x.second != check) ok = false;
    }
    if(!ok) {
        cout << "-1\n";
        return ;
    }
    string ans = "";
    for(auto x: mm) {
        ans += x.first;
    }
    int times = sz(s) / k;
    while(times--) cout << ans;
    return;
}

signed main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout << fixed << setprecision(20);
	int tt;	tt = 1;
	//cin >> tt;
	while(tt--){
		solve();
	}
	return 0;
}

int gcd(int a, int b){
	if(b == 0){
		return a;
	}
	return gcd(b, a % b);
}
int pow(int a, int b) {
	int res = 1;
	while(b) {
		if(b & 1)
			res = (res * a) % mod;
		a = ( a * a ) % mod;
		b >>= 1;
	}
	return res;
}


#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define int long long
#define pb(x) emplace_back(x)
#define sz(x) static_cast<int> ((x).size())
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
const ll infl = 0x3f3f3f3f3f3f3f3fLL;
const int infi = 0x3f3f3f3f;
const ll mod = 1000000007;
//const ll mod = 998244353;
//const ll mod = infl;
int gcd(int a, int b);
int pow(int a, int b);

void solve() {
	int k; cin >> k;
    string s; cin >> s;
    map<char, int> mm;
    for(auto x: s) {
        mm[x]++;
    }
    if(sz(mm) != k) {
        cout << "-1\n";
        return ;
    }
    bool ok = true;
    int check = mm.begin()->second;
    for(auto x: mm) {
        if(x.second != check) ok = false;
    }
    if(!ok) {
        cout << "-1\n";
        return ;
    }
    string ans = "";
    for(auto x: mm) {
        ans += x.first;
    }
    int times = sz(s) / k;
    while(times--) cout << ans;
    return;
}

signed main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout << fixed << setprecision(20);
	int tt;	tt = 1;
	//cin >> tt;
	while(tt--){
		solve();
	}
	return 0;
}

int gcd(int a, int b){
	if(b == 0){
		return a;
	}
	return gcd(b, a % b);
}
int pow(int a, int b) {
	int res = 1;
	while(b) {
		if(b & 1)
			res = (res * a) % mod;
		a = ( a * a ) % mod;
		b >>= 1;
	}
	return res;
}


#include<bits/stdc++.h>
using namespace std;
#define sz(x) static_cast<int> ((x).size()

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int k; cin >> k;
    string s; cin >> s;
    map<char, int> mm;
    for(auto x: s) {
        m[x]++;
    }
    if(sz(mm) != k) {
        cout << "-1\n";
        return 0;
    }
    bool ok = true;
    int check = mm.begin()->first;
    for(auto x: mm) {
        if(x.second != mm) ok = false;
    }
    if(!ok) {
        cout << "-1\n";
        return 0;
    }
    string ans = "";
    for(auto x: mm) {
        ans += x.first;
    }
    int times = k / sz(ans);
    while(times--) cout << ans;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define sz(x) static_cast<int> ((x).size()

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int k; cin >> k;
    string s; cin >> s;
    map<char, int> mm;
    for(auto x: s) {
        mm[x]++;
    }
    if(sz(mm) != k) {
        cout << "-1\n";
        return 0;
    }
    bool ok = true;
    int check = mm.begin()->first;
    for(auto x: mm) {
        if(x.second != mm) ok = false;
    }
    if(!ok) {
        cout << "-1\n";
        return 0;
    }
    string ans = "";
    for(auto x: mm) {
        ans += x.first;
    }
    int times = k / sz(ans);
    while(times--) cout << ans;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define int long long
#define pb(x) emplace_back(x)
#define sz(x) static_cast<int> ((x).size())
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
const ll infl = 0x3f3f3f3f3f3f3f3fLL;
const int infi = 0x3f3f3f3f;
const ll mod = 1000000007;
//const ll mod = 998244353;
//const ll mod = infl;
int gcd(int a, int b);
int pow(int a, int b);

void solve() {
	int k; cin >> k;
    string s; cin >> s;
    map<char, int> mm;
    for(auto x: s) {
        mm[x]++;
    }
    if(sz(mm) == 1) {
        if(k <= sz(s)) {
        	for(int i = 0; i < k; i++) {
        		cout << mm.begin()->fi;
        	}
        } else {
        	cout << "-1";
        }
        return;
    }
    bool ok = true;
    int check = mm.begin()->second;
    for(auto x: mm) {
        if(x.second < check) ok = false;
    }
    if(!ok) {
        cout << "-1\n";
        return ;
    }
    string ans = "";
    for(auto x: mm) {
        ans += x.first;
    }
    int times = sz(s) / k;
    while(times--) cout << ans;
    return;
}

signed main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout << fixed << setprecision(20);
	int tt;	tt = 1;
	//cin >> tt;
	while(tt--){
		solve();
	}
	return 0;
}

int gcd(int a, int b){
	if(b == 0){
		return a;
	}
	return gcd(b, a % b);
}
int pow(int a, int b) {
	int res = 1;
	while(b) {
		if(b & 1)
			res = (res * a) % mod;
		a = ( a * a ) % mod;
		b >>= 1;
	}
	return res;
}


#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define int long long
#define pb(x) emplace_back(x)
#define sz(x) static_cast<int> ((x).size())
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
const ll infl = 0x3f3f3f3f3f3f3f3fLL;
const int infi = 0x3f3f3f3f;
const ll mod = 1000000007;
//const ll mod = 998244353;
//const ll mod = infl;
int gcd(int a, int b);
int pow(int a, int b);

void solve() {
	int k; cin >> k;
    string s; cin >> s;
    map<char, int> mm;
    for(auto x: s) {
        mm[x]++;
    }
    if(sz(mm) == 1) {
        if(k <= sz(s)) {
        	for(int i = 0; i < k; i++) {
        		cout << mm.begin()->fi;
        	}
        } else {
        	cout << "-1";
        }
        return;
    }
    bool ok = true;
    int check = mm.begin()->second;
    for(auto x: mm) {
        if(x.second % check != 0) ok = false;
    }
    if(!ok) {
        cout << "-1\n";
        return ;
    }
    string ans = "";
    for(auto x: mm) {
        ans += x.first;
    }
    int times = sz(s) / k;
    while(times--) cout << ans;
    return;
}

signed main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout << fixed << setprecision(20);
	int tt;	tt = 1;
	//cin >> tt;
	while(tt--){
		solve();
	}
	return 0;
}

int gcd(int a, int b){
	if(b == 0){
		return a;
	}
	return gcd(b, a % b);
}
int pow(int a, int b) {
	int res = 1;
	while(b) {
		if(b & 1)
			res = (res * a) % mod;
		a = ( a * a ) % mod;
		b >>= 1;
	}
	return res;
}


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

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int k; cin >> k;
    string s; cin >> s;
    map<char, int> mm;
    for(auto x: s) {
        m[x]++;
    }
    if(sz(mm) != k) {
        cout << "-1\n";
        return 0;
    }
    bool ok = true;
    int check = mm.begin()->first;
    for(auto x: mm) {
        if(x.second != mm) ok = false;
    }
    if(!ok) {
        cout << "-1\n";
        return 0;
    }
    string ans = "";
    for(auto x: mm) {
        ans += x.first;
    }
    int times = k / sz(ans);
    while(times--) cout << ans;
    return 0;
}


#include<bits/stdc++.h>
#define ll long long int
using namespace std;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	ll k,i,f=0;
	string s,ans="",p="";
	cin>>k>>s;
	ll a[26]={0};
	for(i=0;i<s.size();i++)
	a[s[i]-'a']++;
	for(i=0;i<26;i++){
	    if(a[i]!=0 && a[i]==k){
	    ans+='a'+i;
	    }
	    else if(a[i]!=0 && a[i]!=k)
	    {
	        f=0;
	        break;
	    }
	}
	if(f==0)
	cout<<-1<<endl;
	else{
	    for(i=0;i<k;i++)
	    p+=ans;
	    cout<<p<<endl;
	}
	return 0;
}


#include<bits/stdc++.h>
#define ll long long int
using namespace std;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	ll k,i,f=1;
	string s,ans="",p="";
	cin>>k>>s;
	ll a[26]={0};
	for(i=0;i<s.size();i++)
	a[s[i]-'a']++;
	for(i=0;i<26;i++){
	    if(a[i]%k==0 && a[i]!=0){
	    ans+='a'+i;
	    }
	    else if(a[i]%k!=0)
	    {
	        cout<<-1<<endl;
	        return 0;
	    }
	}
	    for(i=0;i<k;i++)
	    p+=ans;
	    cout<<p<<endl;
	return 0;
}


#include<bits/stdc++.h>
#define ll long long int
using namespace std;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	ll k,i,f=0;
	string s,ans="",p="";
	cin>>k>>s;
	ll a[26]={0};
	for(i=0;i<s.size();i++)
	a[s[i]-'a']++;
	for(i=0;i<26;i++){
	    if(a[i]!=0 && a[i]==k){
	    ans+='a'+i;
	    f=1;
	    }
	    else if(a[i]!=0 && a[i]!=k)
	    {
	        f=0;
	        break;
	    }
	}
	if(f==0)
	cout<<-1<<endl;
	else{
	    for(i=0;i<k;i++)
	    p+=ans;
	    cout<<p<<endl;
	}
	return 0;
}


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

int k;
string s,t="";
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    cin>>k;cin.ignore();cin>>s;
    vector<int>a(26);
    for(char c:s)a[c-'a']++;
    for(int i=0;i<26;i++){
        if(a[i]%k){
            cout<<-1;return 0;
        }
    }
    for(int i=0;i<26;i++){
        for(int j=0;j<a[i]/k;j++){
            t+=char(i+'a');
        }
    }
    for(int i=0;i<k;i++)cout<<t;
}


#include<bits/stdc++.h>
#define ll long long int
using namespace std;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	ll k,i,f=1;
	string s,ans="",p="";
	cin>>k>>s;
	ll a[26]={0};
	for(i=0;i<s.size();i++)
	a[s[i]-'a']++;
	for(i=0;i<26;i++){
	    if(a[i]!=0 && a[i]==k){
	    ans+='a'+i;
	    }
	    else if(a[i]!=0 && a[i]!=k)
	    {
	        f=0;
	        break;
	    }
	}
	if(f==0)
	cout<<-1<<endl;
	else{
	    for(i=0;i<k;i++)
	    p+=ans;
	    cout<<p<<endl;
	}
	return 0;
}


#include<bits/stdc++.h>
#define ll long long int
using namespace std;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	ll k,i,f=1;
	string s,ans="",p="";
	cin>>k>>s;
	ll a[26]={0};
	for(i=0;i<s.size();i++)
	a[s[i]-'a']++;
	for(i=0;i<26;i++){
	    if(a[i]%k==0 && a[i]!=0){
	    ans+='a'+i;
	    }
	    else if(a[i]%k!=0)
	    {
	        f=0;
	        break;
	    }
	}
	if(f==0)
	cout<<-1<<endl;
	else{
	    for(i=0;i<k;i++)
	    p+=ans;
	    cout<<p<<endl;
	}
	return 0;
}


#include<bits/stdc++.h>
#define ll long long int
using namespace std;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	ll k,i,f=1;
	string s,ans="",p="";
	cin>>k>>s;
	ll a[26]={0};
	for(i=0;i<s.size();i++)
	a[s[i]-'a']++;
	for(i=0;i<26;i++){
	    if(a[i]!=0 && a[i]%k==0){
	    ans+='a'+i;
	    }
	    else if(a[i]!=0 && a[i]%k!=0)
	    {
	        f=0;
	        break;
	    }
	}
	if(f==0)
	cout<<-1<<endl;
	else{
	    for(i=0;i<k;i++)
	    p+=ans;
	    cout<<p<<endl;
	}
	return 0;
}


/*
digu_J
Digvijay Janartha
*/

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

typedef double db;
typedef long long ll;

#define debug(x) cout << (#x) << " is " << (x) << endl
#define fast_io() ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0)

int main() {
    fast_io();
    // freopen("input.in", "r", stdin);
    ll k;
    cin >> k;
    string s;
    cin >> s;
    if (k == 1) {
        cout << s;
        return 0;
    }
    sort(s.begin(), s.end());
    ll cnt = 0;
    for (ll i = 0; i < s.size() - 1; ++i) {
        if (s[i] == s[i + 1]) {
            ++cnt;
        } else {
            break;
        }
    }
    if (k % cnt == 0) {
        for (ll j = 0; j < k; ++j) {
            for (ll i = 0; i < s.size(); i += k) {
                cout << s[i];
            }
        }
    } else {
        cout << "-1";
    }
    return 0;
}


/*
digu_J
Digvijay Janartha
*/

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

typedef double db;
typedef long long ll;

#define debug(x) cout << (#x) << " is " << (x) << endl
#define fast_io() ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0)

ll a[26];

int main() {
    fast_io();
    // freopen("input.in", "r", stdin);
    ll k;
    cin >> k;
    string s;
    cin >> s;
    if (k == 1) {
        cout << s;
        return 0;
    }
    set < char > lace;
    for (ll i = 0; i < s.size(); ++i) {
        ++a[s[i] - 'a'];
        lace.insert(s[i]);
    }
    sort(a, a + 26);
    for (ll i = 25; i > -1; --i) {
        if (a[i] == 0) {
            break;
        }
        if (a[i] != k) {
            cout << "-1";
            return 0;
        }
    }
    for (ll i = 0; i < k; ++i) {
        for (auto x : lace) {
            cout << x;
        }
    }
    return 0;
}


/*
digu_J
Digvijay Janartha
*/

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

typedef double db;
typedef long long ll;

#define debug(x) cout << (#x) << " is " << (x) << endl
#define fast_io() ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0)

ll a[26];

int main() {
    fast_io();
    freopen("input.in", "r", stdin);
    ll k;
    cin >> k;
    string s;
    cin >> s;
    if (k == 1) {
        cout << s;
        return 0;
    }
    set < char > lace;
    for (ll i = 0; i < s.size(); ++i) {
        ++a[s[i] - 'a'];
        lace.insert(s[i]);
    }
    sort(a, a + 26);
    for (ll i = 25; i > -1; --i) {
        if (a[i] == 0) {
            break;
        }
        if (a[i] != k) {
            cout << "-1";
            return 0;
        }
    }
    for (ll i = 0; i < k; ++i) {
        for (auto x : lace) {
            cout << x;
        }
    }
    return 0;
}


/*
digu_J
Digvijay Janartha
*/

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

typedef double db;
typedef long long ll;

#define debug(x) cout << (#x) << " is " << (x) << endl
#define fast_io() ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0)

ll a[26];

int main() {
    fast_io();
    // freopen("input.in", "r", stdin);
    ll k;
    cin >> k;
    string s;
    cin >> s;
    if (k == 1) {
        cout << s;
        return 0;
    }
    multiset < char > lace;
    for (ll i = 0; i < s.size(); ++i) {
        ++a[s[i] - 'a'];
        lace.insert(s[i]);
    }
    sort(a, a + 26);
    for (ll i = 25; i > -1; --i) {
        if (a[i] == 0) {
            break;
        }
        if (a[i] % k != 0) {
            cout << "-1";
            return 0;
        }
    }
    sort(s.begin(), s.end());
    ll j = 0, t = 0;
    for (ll f = 0; f < k; ++f) {
        for (ll i = 0; i < 26; ++i) {
            while (j < a[25 - i] / 2) {
                cout << s[t];
                ++j;
            }
            t += k;
            j = 0;
        }
        t = 0;
    }
    return 0;
}


/*
digu_J
Digvijay Janartha
*/

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

typedef double db;
typedef long long ll;

#define debug(x) cout << (#x) << " is " << (x) << endl
#define fast_io() ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0)

int main() {
    fast_io();
    // freopen("input.in", "r", stdin);
    ll k;
    cin >> k;
    string s;
    cin >> s;
    sort(s.begin(), s.end());
    ll cnt = 0;
    for (ll i = 0; i < s.size(); ++i) {
        if (s[i] == s[i + 1]) {
            ++cnt;
        } else {
            break;
        }
    }
    if (k % cnt == 0) {
        for (ll j = 0; j < k; ++j) {
            for (ll i = 0; i < s.size(); i += k) {
                cout << s[i];
            }
        }
    } else {
        cout << "-1";
    }
    return 0;
}


/*
digu_J
Digvijay Janartha
*/

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

typedef double db;
typedef long long ll;

#define debug(x) cout << (#x) << " is " << (x) << endl
#define fast_io() ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0)

ll a[27];

int main() {
    fast_io();
    // freopen("input.in", "r", stdin);
    ll k;
    cin >> k;
    string s;
    cin >> s;
    if (k == 1) {
        cout << s;
        return 0;
    }
    sort(s.begin(), s.end());
    for (ll i = 0; i < s.size(); ++i) {
        ++a[s[i] - 'a'];
    }
    for (ll i = 0; i < 26; ++i) {
        if (a[i] % k != 0) {
            cout << "-1";
            return 0;
        }
    }
    ll t = 0, cnt = 0;
    for (ll j = 0; j < k; ++j) {
        for (ll u = 0; u < 26; ++u) {
            while (cnt < a[u] / k) {
                cout << s[t];
                ++cnt;
            }
            cnt = 0;
            if (a[u + 1] != 0) {
                t += k;
            }
        }
        t = 0;
    }
    return 0;
}


/*
digu_J
Digvijay Janartha
*/

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

typedef double db;
typedef long long ll;

#define debug(x) cout << (#x) << " is " << (x) << endl
#define fast_io() ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0)

ll a[27];

int main() {
    fast_io();
    // freopen("input.in", "r", stdin);
    ll k;
    cin >> k;
    string s;
    cin >> s;
    if (k == 1) {
        cout << s;
        return 0;
    }
    sort(s.begin(), s.end());
    for (ll i = 0; i < s.size(); ++i) {
        ++a[s[i] - 'a'];
    }
    for (ll i = 0; i < 26; ++i) {
        if (a[i] % k != 0) {
            cout << "-1";
            return 0;
        }
    }
    ll t = 0, cnt = 0;
    for (ll j = 0; j < k; ++j) {
        for (ll u = 0; u < 26; ++u) {
            while (cnt < a[u] / k) {
                cout << s[t];
                ++cnt;
            }
            cnt = 0;
            t += a[u];
        }
        t = 0;
    }
    return 0;
}


/*
digu_J
Digvijay Janartha
*/

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

typedef double db;
typedef long long ll;

#define debug(x) cout << (#x) << " is " << (x) << endl
#define fast_io() ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0)

int main() {
    fast_io();
    // freopen("input.in", "r", stdin);
    ll k;
    cin >> k;
    string s;
    cin >> s;
    sort(s.begin(), s.end());
    ll cnt = 0;
    for (ll i = 0; i < s.size(); ++i) {
        if (s[i] == s[i + 1]) {
            ++cnt;
        } else {
            break;
        }
    }
    if (k % cnt == 0) {
        for (ll i = 0; i < s.size(); i += cnt) {
            cout << s[i];
        }
    } else {
        cout << "-1";
    }
    return 0;
}


/*
digu_J
Digvijay Janartha
*/

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

typedef double db;
typedef long long ll;

#define debug(x) cout << (#x) << " is " << (x) << endl
#define fast_io() ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0)

int main() {
    fast_io();
    // freopen("input.in", "r", stdin);
    ll k;
    cin >> k;
    string s;
    cin >> s;
    if (k == 1) {
        cout << s;
        return 0;
    }
    sort(s.begin(), s.end());
    ll cnt = 1;
    for (ll i = 0; i < s.size() - 1; ++i) {
        if (s[i] == s[i + 1]) {
            ++cnt;
        } else {
            break;
        }
    }
    if (k % cnt == 0) {
        for (ll j = 0; j < k; ++j) {
            for (ll i = 0; i < s.size(); i += k) {
                cout << s[i];
            }
        }
    } else {
        cout << "-1";
    }
    return 0;
}


/*
digu_J
Digvijay Janartha
*/

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

typedef double db;
typedef long long ll;

#define debug(x) cout << (#x) << " is " << (x) << endl
#define fast_io() ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0)

ll a[26];

int main() {
    fast_io();
    // freopen("input.in", "r", stdin);
    ll k;
    cin >> k;
    string s;
    cin >> s;
    if (k == 1) {
        cout << s;
        return 0;
    }
    for (ll i = 0; i < s.size(); ++i) {
        ++a[s[i] - 'a'];
    }
    sort(a, a + 26);
    for (ll i = 25; i > -1; --i) {
        if (a[i] == 0) {
            break;
        }
        if (a[i] % k != 0) {
            cout << "-1";
            return 0;
        }
    }
    sort(s.begin(), s.end());
    ll j = 0, t = 0;
    for (ll f = 0; f < k; ++f) {
        for (ll i = 0; i < 26; ++i) {
            while (j < a[25 - i] / k) {
                cout << s[t];
                ++j;
            }
            t += k;
            j = 0;
        }
        t = 0;
    }
    return 0;
}


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

#define ll long long
#define all(x) x.begin(),x.end()
#define allr(x) x.rbegin(),x.rend()

int dx[]={ 1, 0, -1, 0 };
int dy[]={ 0, 1, 0, -1 };

int arr[27];

void solve()
{
    int n;cin>>n;
    set<char> st;
    string s;cin>>s;
    for(int i=0; i<s.length(); i++)
    {
       st.insert(s[i]);
       arr[s[i]- 'a'] ++;
    }
    for(auto it : st)
    {
        if(arr[it-'a'] < n)
        {
            // cout<<arr[it];
            cout<<-1;return;
        }
    }
    for(int i=0; i<n*n ; i+=n)
    {
        for(auto it : st)cout<<it;
    }

}

int main()
{
    // ios::sync_with_stdio(0); cin.tie(NULL);

    int t =1;

    // cin>>t;

    while (t--)
    {
        solve();
    }

    return 0;
}


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

#define ll long long
#define all(x) x.begin(),x.end()
#define allr(x) x.rbegin(),x.rend()

int dx[]={ 1, 0, -1, 0 };
int dy[]={ 0, 1, 0, -1 };

int arr[27];

void solve()
{
    int n;cin>>n;
    set<char> st;
    string s;cin>>s;
    for(int i=0; i<s.length(); i++)
    {
       st.insert(s[i]);
       arr[s[i]- 'a'] ++;
    }
    for(auto it : st)
    {
        if(arr[it-'a'] < n)
        {
            // cout<<arr[it];
            cout<<-1;return;
        }
    }
    for(int i=0; i<n*n ; i+=n)
    {
        for(auto it: st)
        {
            for(int i=0; i<arr[it - 'a'] /n; i++)cout<<it;
        }
    }

}

int main()
{
    // ios::sync_with_stdio(0); cin.tie(NULL);

    int t =1;

    // cin>>t;

    while (t--)
    {
        solve();
    }

    return 0;
}


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

#define ll long long
#define all(x) x.begin(),x.end()
#define allr(x) x.rbegin(),x.rend()

int dx[]={ 1, 0, -1, 0 };
int dy[]={ 0, 1, 0, -1 };

void solve()
{
   int n; cin>>n;
   string s;cin>>s;
set<char> st;
   for(int i=0; i<s.length(); i+=n)
   {
       st.insert(s[i]);
    //    if(s.substr(i,n) != s.substr(0,n)) {cout<<-1; return;}

   }

if(st.size() == 1)
{
    for(int i=0; i<n; i++)
        cout<<*st.begin();
        return;
}
 if(st.size() == n)
 {
     for(int i=0; i< n*n;  i+=n)
     {for(auto it : st)
        cout<<it;}
 }
else cout<<-1;

}

int main()
{
    // ios::sync_with_stdio(0); cin.tie(NULL);

    int t =1;

    // cin>>t;

    while (t--)
    {
        solve();
    }

    return 0;
}


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

#define ll long long
#define all(x) x.begin(),x.end()
#define allr(x) x.rbegin(),x.rend()

int dx[]={ 1, 0, -1, 0 };
int dy[]={ 0, 1, 0, -1 };

void solve()
{
   int n; cin>>n;
   string s;cin>>s;
set<char> st;
   for(int i=0; i<s.length(); i+=n)
   {
       st.insert(s[i]);
    //    if(s.substr(i,n) != s.substr(0,n)) {cout<<-1; return;}

   }

 if(st.size() == n)
 {
     for(int i=0; i< n*n;  i+=n)
     {for(auto it : st)
        cout<<it;}
 }
else cout<<-1;

}

int main()
{
    // ios::sync_with_stdio(0); cin.tie(NULL);

    int t =1;

    // cin>>t;

    while (t--)
    {
        solve();
    }

    return 0;
}


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

#define ll long long
#define all(x) x.begin(),x.end()
#define allr(x) x.rbegin(),x.rend()

int dx[]={ 1, 0, -1, 0 };
int dy[]={ 0, 1, 0, -1 };

int arr['z' +1 ] ;
void solve()
{
   int n; cin>>n;
   string s;cin>>s;
   vector<char> v;
set<char> st;

   for(int i=0; i<s.length(); i++)
   {
       if(arr[s[i]] == 0 )v.push_back(s[i]);
       arr[s[i]]++;
   }
   for(auto it : v)
   {
       if(arr[it] < n )
       {
           cout<<-1; return;
       }
   }
   for(int j=0; j <n*n; j+=n)
   {
   for(auto it: v)
    cout<<it;
   }

}

int main()
{
    // ios::sync_with_stdio(0); cin.tie(NULL);

    int t =1;

    // cin>>t;

    while (t--)
    {
        solve();
    }

    return 0;
}


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

#define ll long long
#define all(x) x.begin(),x.end()
#define allr(x) x.rbegin(),x.rend()

int dx[]={ 1, 0, -1, 0 };
int dy[]={ 0, 1, 0, -1 };

int arr[27];

void solve()
{
    int n;cin>>n;
    set<char> st;
    string s;cin>>s;
    for(int i=0; i<s.length(); i++)
    {
       st.insert(s[i]);
       arr[s[i]- 'a'] ++;
    }

    for(auto it : st)
    {
        if(arr[it-'a'] < n)
        {
            // cout<<arr[it];
            cout<<-1;return;
        }
    }
    if(st.size()*n != s.length())
    {
    cout<<-1;return;
    }

    for(int i=0; i<n*n ; i+=n)
    {
        for(auto it: st)
        {
            for(int i=0; i<arr[it - 'a'] /n; i++)cout<<it;
        }
    }

}

int main()
{
    // ios::sync_with_stdio(0); cin.tie(NULL);

    int t =1;

    // cin>>t;

    while (t--)
    {
        solve();
    }

    return 0;
}


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

#define ll long long
#define all(x) x.begin(),x.end()
#define allr(x) x.rbegin(),x.rend()

int dx[]={ 1, 0, -1, 0 };
int dy[]={ 0, 1, 0, -1 };

int arr[27];

void solve()
{
    int n;cin>>n;
    set<char> st;
    string s;cin>>s;
    for(int i=0; i<s.length(); i++)
    {
       st.insert(s[i]);
       arr[s[i]- 'a'] ++;
    }
    if(st.size()*n != s.length())
    {
    for(auto it : st)
    {
        if(arr[it-'a'] < n)
        {
            // cout<<arr[it];
            cout<<-1;return;
        }
    }
    cout<<-1;return;
    }

    for(int i=0; i<n*n ; i+=n)
    {
        for(auto it: st)
        {
            for(int i=0; i<arr[it - 'a'] /n; i++)cout<<it;
        }
    }

}

int main()
{
    // ios::sync_with_stdio(0); cin.tie(NULL);

    int t =1;

    // cin>>t;

    while (t--)
    {
        solve();
    }

    return 0;
}


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

#define ll long long
#define all(x) x.begin(),x.end()
#define allr(x) x.rbegin(),x.rend()

int dx[]={ 1, 0, -1, 0 };
int dy[]={ 0, 1, 0, -1 };

int arr[27];

void solve()
{
    int n;cin>>n;
    set<char> st;
    string s;cin>>s;
    for(int i=0; i<s.length(); i++)
    {
       st.insert(s[i]);
       arr[s[i]- 'a'] ++;
    }
    for(int i=0; i<26; i++)
    {
        if(arr[i] < n)
        {
            cout<<-1;return;
        }
    }
    for(int i=0; i<n*n ; i++)
    {
        for(auto it : st)cout<<it;
    }

}

int main()
{
    // ios::sync_with_stdio(0); cin.tie(NULL);

    int t =1;

    // cin>>t;

    while (t--)
    {
        solve();
    }

    return 0;
}


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

#define ll long long
#define all(x) x.begin(),x.end()
#define allr(x) x.rbegin(),x.rend()

int dx[]={ 1, 0, -1, 0 };
int dy[]={ 0, 1, 0, -1 };

int arr[27];

void solve()
{
    int n;cin>>n;
    set<char> st;
    string s;cin>>s;
    for(int i=0; i<s.length(); i++)
    {
       st.insert(s[i]);
       arr[s[i]- 'a'] ++;
    }
    if(st.size() * n == s.length())
    {
    for(auto it : st)
    {
        if(arr[it-'a'] < n)
        {
            // cout<<arr[it];
            cout<<-1;return;
        }
    }
    }
    for(int i=0; i<n*n ; i+=n)
    {
        for(auto it: st)
        {
            for(int i=0; i<arr[it - 'a'] /n; i++)cout<<it;
        }
    }

}

int main()
{
    // ios::sync_with_stdio(0); cin.tie(NULL);

    int t =1;

    // cin>>t;

    while (t--)
    {
        solve();
    }

    return 0;
}


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

#define ll long long
#define all(x) x.begin(),x.end()
#define allr(x) x.rbegin(),x.rend()

int dx[]={ 1, 0, -1, 0 };
int dy[]={ 0, 1, 0, -1 };

void solve()
{
   int n; cin>>n;
   string s;cin>>s;
set<char> st;
   for(int i=0; i<s.length(); i+=n)
   {
       st.insert(s[i]);
    //    if(s.substr(i,n) != s.substr(0,n)) {cout<<-1; return;}

   }

 if(st.size() == n)
 {
     for(int i=1; i< n*n;  i*=n)
     {for(auto it : st)
        cout<<it;}
 }
else cout<<-1;

}

int main()
{
    // ios::sync_with_stdio(0); cin.tie(NULL);

    int t =1;

    // cin>>t;

    while (t--)
    {
        solve();
    }

    return 0;
}


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

#define ll long long
#define all(x) x.begin(),x.end()
#define allr(x) x.rbegin(),x.rend()

int dx[]={ 1, 0, -1, 0 };
int dy[]={ 0, 1, 0, -1 };

void solve()
{
   int n; cin>>n;
   string s;cin>>s;
set<char> st;
   for(int i=0; i<s.length(); i++)
   {
       st.insert(s[i]);
    //    if(s.substr(i,n) != s.substr(0,n)) {cout<<-1; return;}

   }

if(st.size() == 1)
{
    for(int i=0; i<n; i++)
        cout<<*st.begin();
        return;
}
 if(st.size() == n)
 {

     for(int i=0; i< n*n;  i+=n)
     {
         for(auto it : st)
        cout<<it;
        }
 }
else cout<<-1;

}

int main()
{
    // ios::sync_with_stdio(0); cin.tie(NULL);

    int t =1;

    // cin>>t;

    while (t--)
    {
        solve();
    }

    return 0;
}


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

#define ll long long
#define all(x) x.begin(),x.end()
#define allr(x) x.rbegin(),x.rend()

int dx[]={ 1, 0, -1, 0 };
int dy[]={ 0, 1, 0, -1 };

void solve()
{
   int n; cin>>n;
   string s;cin>>s;
set<char> st;
   for(int i=0; i<s.length(); i+=n)
   {
       st.insert(s[i]);
       if(s.substr(i,n) != s.substr(0,n)) {cout<<-1; return;}

   }

   for(auto it : st)
   cout<<st;

}

int main()
{
    // ios::sync_with_stdio(0); cin.tie(NULL);

    // int t =1;

    cin>>t;

    while (t--)
    {
        solve();
    }

    return 0;
}


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

#define ll long long
#define all(x) x.begin(),x.end()
#define allr(x) x.rbegin(),x.rend()

int dx[]={ 1, 0, -1, 0 };
int dy[]={ 0, 1, 0, -1 };

void solve()
{
   int n; cin>>n;
   string s;cin>>s;
set<char> st;
   for(int i=0; i<s.length(); i+=n)
   {
       st.insert(s[i]);
       if(s.substr(i,n) != s.substr(0,n)) {cout<<-1; return;}

   }

   for(auto it : st)
   cout<<it;

}

int main()
{
    // ios::sync_with_stdio(0); cin.tie(NULL);

    int t =1;

    // cin>>t;

    while (t--)
    {
        solve();
    }

    return 0;
}


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

#define ll long long
#define all(x) x.begin(),x.end()
#define allr(x) x.rbegin(),x.rend()

int dx[]={ 1, 0, -1, 0 };
int dy[]={ 0, 1, 0, -1 };

int arr['z' + 1 ] ;
void solve()
{
   int n; cin>>n;
   string s;cin>>s;
   vector<char> v;
set<char> st;

   for(int i=0; i<s.length(); i++)
   {
       if(arr[s[i]] == 0 )v.push_back(s[i]);
       arr[s[i]]++;
   }

   for(auto it: v)
   {
       if(arr[it] < n )
       {
           cout<<-1; return;
       }
   }

   for(int j=0; j <n*n; j+=n)
   {
   for(char i ='a'; i<= 'z'; i++)

   while(arr[i]-- > 0)cout<<i;

   }

}

int main()
{
    // ios::sync_with_stdio(0); cin.tie(NULL);

    int t =1;

    // cin>>t;

    while (t--)
    {
        solve();
    }

    return 0;
}


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

#define ll long long
#define all(x) x.begin(),x.end()
#define allr(x) x.rbegin(),x.rend()

int dx[]={ 1, 0, -1, 0 };
int dy[]={ 0, 1, 0, -1 };

int arr['z' + 1 ] ;
void solve()
{
   int n; cin>>n;
   string s;cin>>s;
   vector<char> v;
set<char> st;

   for(int i=0; i<s.length(); i++)
   {
       if(arr[s[i]] == 0 )v.push_back(s[i]);
       arr[s[i]]++;
   }

   for(auto it: v)
   {
       if(arr[it] < n )
       {
           cout<<-1; return;
       }
   }

   for(int j=0; j <n*n; j+=n)
   {
   for(char i ='a'; i<= 'z'; i++)
   if(arr[i] != 0)cout<<i;

   }

}

int main()
{
    // ios::sync_with_stdio(0); cin.tie(NULL);

    int t =1;

    // cin>>t;

    while (t--)
    {
        solve();
    }

    return 0;
}


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

#define ll long long
#define all(x) x.begin(),x.end()
#define allr(x) x.rbegin(),x.rend()

int dx[]={ 1, 0, -1, 0 };
int dy[]={ 0, 1, 0, -1 };

void solve()
{
   int n; cin>>n;
   string s;cin>>s;
set<char> st;
   for(int i=0; i<s.length(); i+=n)
   {
       st.insert(s[i]);
    //    if(s.substr(i,n) != s.substr(0,n)) {cout<<-1; return;}

   }

if(st.size() == 1)
{
    for(int i=0; i<n; i++)
        cout<<*st.begin();
        return;
}
 if(st.size() == n)
 {
     for(int i=1; i<= n*n;  i*=n)
     {for(auto it : st)
        cout<<it;}
 }
else cout<<-1;

}

int main()
{
    // ios::sync_with_stdio(0); cin.tie(NULL);

    int t =1;

    // cin>>t;

    while (t--)
    {
        solve();
    }

    return 0;
}


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

#define ll long long
#define all(x) x.begin(),x.end()
#define allr(x) x.rbegin(),x.rend()

int dx[]={ 1, 0, -1, 0 };
int dy[]={ 0, 1, 0, -1 };

int arr['z' +1 ] ;
void solve()
{
   int n; cin>>n;
   string s;cin>>s;
   vector<char> v;
set<char> st;

   for(int i=0; i<s.length(); i++)
   {
       if(arr[s[i]] == 0 )v.push_back(s[i]);
       arr[s[i]]++;
   }
   for(auto it: v)
   {
       if(arr[it] < n )
       {
           cout<<-1; return;
       }
   }
   for(int j=0; j <n*n; j+=n)
   {
   for(char i ='a'; i<= 'z'; i++)
   if(arr[i] != 0)cout<<arr[i];

   }

}

int main()
{
    // ios::sync_with_stdio(0); cin.tie(NULL);

    int t =1;

    // cin>>t;

    while (t--)
    {
        solve();
    }

    return 0;
}


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

#define ll long long
#define all(x) x.begin(),x.end()
#define allr(x) x.rbegin(),x.rend()

int dx[]={ 1, 0, -1, 0 };
int dy[]={ 0, 1, 0, -1 };

int arr[27];

void solve()
{
    int n;cin>>n;
    set<char> st;
    string s;cin>>s;
    for(int i=0; i<s.length(); i++)
    {
       st.insert(s[i]);
       arr[s[i]- 'a'] ++;
    }
    for(auto it : st)
    {
        if(arr[it-'a'] < n)
        {
            // cout<<arr[it];
            cout<<-1;return;
        }
    }
    for(int i=0; i<n*n ; i++)
    {
        for(auto it : st)cout<<it;
    }

}

int main()
{
    // ios::sync_with_stdio(0); cin.tie(NULL);

    int t =1;

    // cin>>t;

    while (t--)
    {
        solve();
    }

    return 0;
}


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

#define ll long long
#define all(x) x.begin(),x.end()
#define allr(x) x.rbegin(),x.rend()

int dx[]={ 1, 0, -1, 0 };
int dy[]={ 0, 1, 0, -1 };

void solve()
{
   int n; cin>>n;
   string s;cin>>s;
set<char> st;
   for(int i=0; i<s.length(); i+=n)
   {
       st.insert(s[i]);
       if(s.substr(i,n) != s.substr(0,n)) {cout<<-1; return;}

   }

   for(auto it : st)
   cout<<it;

}

int main()
{
    // ios::sync_with_stdio(0); cin.tie(NULL);

    // int t =1;

    cin>>t;

    while (t--)
    {
        solve();
    }

    return 0;
}


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

#define ll long long
#define all(x) x.begin(),x.end()
#define allr(x) x.rbegin(),x.rend()

int dx[]={ 1, 0, -1, 0 };
int dy[]={ 0, 1, 0, -1 };

int arr['z' +1 ] ;
void solve()
{
   int n; cin>>n;
   string s;cin>>s;
   vector<char> v;
set<char> st;

   for(int i=0; i<s.length(); i++)
   {
       if(arr[s[i]] == 0 )v.push_back(s[i]);
       arr[s[i]]++;
   }
   for(auto it: v)
   {
       if(arr[it] < n )
       {
           cout<<-1; return;
       }
   }
   for(int j=0; j <n*n; j+=n)
   {
   for(char i ='a'; i<= 'z'; i++)
   if(arr[i] != 0)cout<<i;

   }

}

int main()
{
    // ios::sync_with_stdio(0); cin.tie(NULL);

    int t =1;

    // cin>>t;

    while (t--)
    {
        solve();
    }

    return 0;
}


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

#define ll long long
#define all(x) x.begin(),x.end()
#define allr(x) x.rbegin(),x.rend()

int dx[]={ 1, 0, -1, 0 };
int dy[]={ 0, 1, 0, -1 };

int arr[27];

void solve()
{
    int n;cin>>n;
    set<char> st;
    string s;cin>>s;
    for(int i=0; i<s.length(); i++)
    {
       st.insert(s[i]);
       arr[s[i]- 'a'] ++;
    }

    for(auto it : st)
    {
        if(arr[it-'a'] % n != 0)
        {
            // cout<<arr[it];
            cout<<-1;return;
        }
    }
    // if(st.size()*n != s.length())
    // {
    // cout<<-1;return;
    // }

    for(int i=0; i<n*n ; i+=n)
    {
        for(auto it: st)
        {
            for(int i=0; i<arr[it - 'a'] /n; i++)cout<<it;
        }
    }

}

int main()
{
    // ios::sync_with_stdio(0); cin.tie(NULL);

    int t =1;

    // cin>>t;

    while (t--)
    {
        solve();
    }

    return 0;
}


#include<bits/stdc++.h>
#include<iostream>

#define fi first
#define se second
#define all(v) v.begin(), v.end()
#define sz size()
#define endl "\n"
#define pb push_back
#define pp pop_back
#define mp make_pair
#define REP(I,n) for(int I = 0; I < n; I++)
#define REP_1(I,n) for(int I = 1; I <= n; I++)
#define FOR(I,A,B) for(int I = A; I < B; I++)
#define DWN(I,B,A) for(int I = B-1; I >= A; I++)
#define FOR_1(I,A,B) for(int I = A; I <= B; I++)
#define DWN_1(I,B,A) for(int I = B; I >= A; I++)
#define Read() freopen("input1.txt", "r", stdin)
#define Write() freopen("output1.txt", "w", stdout)

#define ll long long
#define ull unsigned long long

#define MOD 1000000007

using namespace std;

typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef map<int,int> mii;
typedef map<string,int> msi;
typedef map<int,string> mis;
typedef set<int> si;
typedef set<string> ss;
typedef map<char,int> mci;

void f_i_o() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
}
void c_r_w() {
	#ifndef ONLINE_JUDGE
		Read();
		Write();
	#endif
}
int main()
{
	c_r_w();
	f_i_o();
	int n;
	cin>>n;
	string str;
	cin>>str;
	mci map;
	REP(i,str.size()) {
		map[str[i]]++;
	}

	int flag = 0;
	int prev;
	string result="";
	for(auto itr = map.begin(); itr != map.end(); itr++) {
		result = result + itr->fi;
		if(flag==1&&itr->se != prev) {
				flag=0;
				break;
		}
		else {
			flag = 1;
			prev = itr->se;
		}
	}
	if(!flag) {
		cout<<"-1"<<endl;
	}
	else {
		while(n--) {
			cout<<result;
		}
	}

}


#include<bits/stdc++.h>
#include<iostream>
using namespace std;
int main()
{
	#ifndef ONLINE_JUDGE
	freopen("input1.txt", "r", stdin);
	freopen("output1.txt", "w", stdout);
	#endif
	int n;
	cin>>n;
	string str;
	cin>>str;
	int value = str.size();
	sort(str.begin(), str.end());
	auto res = unique(str.begin(), str.end());
	str.erase(res, str.end());

	if(str.size()*n == value) {
		while(n--)
			cout<<str;
		cout<<endl;
	}
	else
		cout<<"-1"<<endl;
}


#include<bits/stdc++.h>
#include<iostream>
using namespace std;
int main()
{
	#ifndef ONLINE_JUDGE
	freopen("input1.txt", "r", stdin);
	freopen("output1.txt", "w", stdout);
	#endif
	int n;
	cin>>n;
	string str;
	cin>>str;
	int value = str.size();
	int flag=0;
	sort(str.begin(), str.end());
	int count=0;
	for(int i = 0; i < str.size()-1; i++) {
		if(str[i] == str[i+1])
			count++;
		else {
			if(count!=(value/2)-1) {
				flag=1;
				break;
			}
			count=0;
		}
	}
	auto res = unique(str.begin(), str.end());
	str.erase(res, str.end());

	if(flag == 0 && str.size()*n == value) {
		while(n--)
			cout<<str;
		cout<<endl;
	}
	else
		cout<<"-1"<<endl;
}


#include<bits/stdc++.h>
#include<iostream>

#define fi first
#define se second
#define all(v) v.begin(), v.end()
#define sz size()
#define endl "\n"
#define pb push_back
#define pp pop_back
#define mp make_pair
#define REP(I,n) for(int I = 0; I < n; I++)
#define REP_1(I,n) for(int I = 1; I <= n; I++)
#define FOR(I,A,B) for(int I = A; I < B; I++)
#define DWN(I,B,A) for(int I = B-1; I >= A; I++)
#define FOR_1(I,A,B) for(int I = A; I <= B; I++)
#define DWN_1(I,B,A) for(int I = B; I >= A; I++)
#define Read() freopen("input1.txt", "r", stdin)
#define Write() freopen("output1.txt", "w", stdout)

#define ll long long
#define ull unsigned long long

#define MOD 1000000007

using namespace std;

typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef map<int,int> mii;
typedef map<string,int> msi;
typedef map<int,string> mis;
typedef set<int> si;
typedef set<string> ss;
typedef map<char,int> mci;

void f_i_o() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
}
void c_r_w() {
	#ifndef ONLINE_JUDGE
		Read();
		Write();
	#endif
}
int main()
{
	c_r_w();
	f_i_o();

	int n;
	cin>>n;
	string str;
	cin>>str;
	mci map;
	REP(i,str.size()) {
		map[str[i]]++;
	}

	string result="";
	int count = 0;
	for(auto itr = map.begin(); itr != map.end(); itr++) {
		result.append(itr->se/n,itr->fi);
		count = count + itr->se;
		if(itr->se % n & 1)	{
			result="-1";
		}
	}
	if(result == "-1") {
		cout<<"-1"<<endl;
	}
	else {
		while(n--)
			cout<<result;
	}

}


#include<bits/stdc++.h>
#include<iostream>
using namespace std;
int main()
{
	#ifndef ONLINE_JUDGE
	freopen("input1.txt", "r", stdin);
	freopen("output1.txt", "w", stdout);
	#endif
	int n;
	cin>>n;
	string str;
	cin>>str;
	int value = str.size();
	sort(str.begin(), str.end());
	auto res = unique(str.begin(), str.end());
	str.erase(res, str.end());

	if(str.size()*n == value) {
		while(--n)
			cout<<str;
		cout<<endl;
	}
	else
		cout<<"-1"<<endl;
}


#include<bits/stdc++.h>
#include<iostream>

#define fi first
#define se second
#define all(v) v.begin(), v.end()
#define sz size()
#define endl "\n"
#define pb push_back
#define pp pop_back
#define mp make_pair
#define REP(I,n) for(int I = 0; I < n; I++)
#define REP_1(I,n) for(int I = 1; I <= n; I++)
#define FOR(I,A,B) for(int I = A; I < B; I++)
#define DWN(I,B,A) for(int I = B-1; I >= A; I++)
#define FOR_1(I,A,B) for(int I = A; I <= B; I++)
#define DWN_1(I,B,A) for(int I = B; I >= A; I++)
#define Read() freopen("input1.txt", "r", stdin)
#define Write() freopen("output1.txt", "w", stdout)

#define ll long long
#define ull unsigned long long

#define MOD 1000000007

using namespace std;

typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef map<int,int> mii;
typedef map<string,int> msi;
typedef map<int,string> mis;
typedef set<int> si;
typedef set<string> ss;
typedef map<char,int> mci;

void f_i_o() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
}
void c_r_w() {
	#ifndef ONLINE_JUDGE
		Read();
		Write();
	#endif
}
int main()
{
	c_r_w();
	f_i_o();
	int n;
	cin>>n;
	string str;
	cin>>str;
	mci map;
	REP(i,str.size()) {
		map[str[i]]++;
	}

	int flag = 0;
	int prev;
	string result="";
	for(auto itr = map.begin(); itr != map.end(); itr++) {
		result = result + itr->fi;
		if(itr->se != n) {
				flag = 1;
				break;
		}
	}
	if(flag) {
		cout<<"-1"<<endl;
	}
	else {
		while(n--) {
			cout<<result;
		}
	}

}


#include<bits/stdc++.h>
#include<iostream>

#define fi first
#define se second
#define all(v) v.begin(), v.end()
#define sz size()
#define endl "\n"
#define pb push_back
#define pp pop_back
#define mp make_pair
#define REP(I,n) for(int I = 0; I < n; I++)
#define REP_1(I,n) for(int I = 1; I <= n; I++)
#define FOR(I,A,B) for(int I = A; I < B; I++)
#define DWN(I,B,A) for(int I = B-1; I >= A; I++)
#define FOR_1(I,A,B) for(int I = A; I <= B; I++)
#define DWN_1(I,B,A) for(int I = B; I >= A; I++)
#define Read() freopen("input1.txt", "r", stdin)
#define Write() freopen("output1.txt", "w", stdout)

#define ll long long
#define ull unsigned long long

#define MOD 1000000007

using namespace std;

typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef map<int,int> mii;
typedef map<string,int> msi;
typedef map<int,string> mis;
typedef set<int> si;
typedef set<string> ss;
typedef map<char,int> mci;

void f_i_o() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
}
void c_r_w() {
	#ifndef ONLINE_JUDGE
		Read();
		Write();
	#endif
}
int main()
{
	c_r_w();
	f_i_o();
	int n;
	cin>>n;
	string str;
	cin>>str;
	mci map;
	REP(i,str.size()) {
		map[str[i]]++;
	}

	string result="";
	int count = 0;
	for(auto itr = map.begin(); itr != map.end(); itr++) {
		result = result + itr->fi;
		count = count + itr->se;
	}
	if(count%n & 1) {
		cout<<"-1"<<endl;
	}
	else {
		while(n--) {
			cout<<result;
		}
	}

}


#include<bits/stdc++.h>
#include<iostream>

#define fi first
#define se second
#define all(v) v.begin(), v.end()
#define sz size()
#define endl "\n"
#define pb push_back
#define pp pop_back
#define mp make_pair
#define REP(I,n) for(int I = 0; I < n; I++)
#define REP_1(I,n) for(int I = 1; I <= n; I++)
#define FOR(I,A,B) for(int I = A; I < B; I++)
#define DWN(I,B,A) for(int I = B-1; I >= A; I++)
#define FOR_1(I,A,B) for(int I = A; I <= B; I++)
#define DWN_1(I,B,A) for(int I = B; I >= A; I++)
#define Read() freopen("input1.txt", "r", stdin)
#define Write() freopen("output1.txt", "w", stdout)

#define ll long long
#define ull unsigned long long

#define MOD 1000000007

using namespace std;

typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef map<int,int> mii;
typedef map<string,int> msi;
typedef map<int,string> mis;
typedef set<int> si;
typedef set<string> ss;
typedef map<char,int> mci;

void f_i_o() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
}
void c_r_w() {
	#ifndef ONLINE_JUDGE
		Read();
		Write();
	#endif
}
int main()
{
	c_r_w();
	f_i_o();

	int n;
	cin>>n;
	string str;
	cin>>str;
	mci map;
	REP(i,str.size()) {
		map[str[i]]++;
	}

	string result="";
	int count = 0;
	for(auto itr = map.begin(); itr != map.end(); itr++) {
		result.append(itr->se/n,itr->fi);
		count = count + itr->se;
		if(itr->se % n & 1)	{
			result="-1";
			break;
		}
	}
	if(result == "-1") {
		cout<<"-1"<<endl;
	}
	else {
		while(n--)
			cout<<result;
	}

}


#include<bits/stdc++.h>
using namespace std;
int gcd(int a, int b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);

}

int main()
{

	int n;int g=0 ;
	cin>>n;
	char s[10000];
	int a[27];
	int i,j;
	for(i=0;i<=25;i++)
	{
		a[i]=0;
	}
	cin>>s;
	for(i=0;i<strlen(s);i++)
	{
		a[(int)s[i]-97]++;
	}
	for(i=0;i<=25;i++)
	{
		if(a[i]>0)
			g = gcd(g,a[i]);
	}
	if(n==1)
		cout<<s;
	else if(g%n==0 &&n<=strlen(s) && g!=1)
	{
		while(g>0)
		{
			for(i=0;i<=25;i++)
			{
				for(j=1;j<=a[i]/n;j++)
				{	cout<<(char)(i+97);

				}
			}
			g--;
		}
	}
	else cout<<-1;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int gcd(int a, int b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);

}

int main()
{

	int n;int g=0;
	cin>>n;
	char s[1003];
	char a[27];
	int i,j;
	for(i=0;i<=25;i++)
	{
		a[i]=0;
	}
	cin>>s;
	for(i=0;i<strlen(s);i++)
	{
		a[(int)s[i]-97]++;
	}
	for(i=0;i<=25;i++)
	{
		if(a[i]>0)
			g = gcd(g,a[i]);
	}
	if(n==1)
		cout<<s;
	else if(n%g==0 &&n<=strlen(s) && g!=1)
	{
		while(g>0)
		{
			for(i=0;i<=25;i++)
			{
				for(j=1;j<=a[i]/n;j++)
				{	cout<<(char)(i+97);

				}
			}
			g--;
		}
	}
	else cout<<-1;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int gcd(int a, int b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);

}

int main()
{

	int n;int g=0;
	cin>>n;
	char s[1003];
	char a[27];
	int i,j;
	for(i=0;i<=25;i++)
	{
		a[i]=0;
	}
	cin>>s;
	for(i=0;i<strlen(s);i++)
	{
		a[(int)s[i]-97]++;
	}
	for(i=0;i<=25;i++)
	{
		if(a[i]>0)
			g = gcd(g,a[i]);
	}
	if(n%g==0 &&n<=strlen(s))
	{
		while(g>0)
		{
			for(i=0;i<=25;i++)
			{
				for(j=1;j<=a[i]/n;j++)
				{	cout<<(char)(i+97);

				}
			}
			g--;
		}
	}
	else cout<<-1;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int gcd(int a, int b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);

}

int main()
{

	int n;int g=1;
	cin>>n;
	char s[1003];
	char a[27];
	int i,j;
	for(i=0;i<=25;i++)
	{
		a[i]=0;
	}
	cin>>s;
	for(i=0;i<strlen(s);i++)
	{
		a[(int)s[i]-97]++;
	}
	for(i=0;i<=25;i++)
	{
		if(a[i]>0)
			g = gcd(g,a[i]);
	}
	if(n==1)
		cout<<s;
	else if(n%g==0 &&n<=strlen(s) && g!=1)
	{
		while(g>0)
		{
			for(i=0;i<=25;i++)
			{
				for(j=1;j<=a[i]/n;j++)
				{	cout<<(char)(i+97);

				}
			}
			g--;
		}
	}
	else cout<<-1;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int gcd(int a, int b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);

}

int main()
{

	int n;int g=0 ;
	cin>>n;
	char s[10000];
	int a[27];
	int i,j;
	for(i=0;i<=25;i++)
	{
		a[i]=0;
	}
	cin>>s;
	for(i=0;i<strlen(s);i++)
	{
		a[(int)s[i]-97]++;
	}
	for(i=0;i<=25;i++)
	{
		if(a[i]>0)
			g = gcd(g,a[i]);
	}
	if(n==1)
		cout<<s;
	else if(g%n==0 &&n<=strlen(s) && g!=1)
	{
		while(n>0)
		{
			for(i=0;i<=25;i++)
			{
				for(j=1;j<=a[i]/n;j++)
				{	cout<<(char)(i+97);

				}
			}
			n--;
		}
	}
	else cout<<-1;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int gcd(int a, int b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);

}

int main()
{

	int n;int g=0 ;
	cin>>n;
	char s[10000];
	int a[27];
	int i,j;
	for(i=0;i<=25;i++)
	{
		a[i]=0;
	}
	cin>>s;
	for(i=0;i<strlen(s);i++)
	{
		a[(int)s[i]-97]++;
	}
	for(i=0;i<=25;i++)
	{
		if(a[i]>0)
			g = gcd(g,a[i]);
	}
	int k=n;
	if(n==1)
		cout<<s;
	else if(g%n==0 &&n<=strlen(s) && g!=1)
	{
		while(k>0)
		{
			for(i=0;i<=25;i++)
			{
				for(j=1;j<=a[i]/n;j++)
				{	cout<<(char)(i+97);

				}
			}
			k--;
		}
	}
	else cout<<-1;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int gcd(int a, int b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);

}

int main()
{

	int n;int g=0 ;
	cin>>n;
	char s[10000];
	int a[27];
	int i,j;
	for(i=0;i<=25;i++)
	{
		a[i]=0;
	}
	cin>>s;
	for(i=0;i<strlen(s);i++)
	{
		a[(int)s[i]-97]++;
	}
	for(i=0;i<=25;i++)
	{
		if(a[i]>0)
			g = gcd(g,a[i]);
	}
	if(n==1)
		cout<<s;
	else if(n%g==0 &&n<=strlen(s) && g!=1)
	{
		while(g>0)
		{
			for(i=0;i<=25;i++)
			{
				for(j=1;j<=a[i]/n;j++)
				{	cout<<(char)(i+97);

				}
			}
			g--;
		}
	}
	else cout<<-1;
	return 0;
}


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

using namespace std;

int main()
{
	ll k;
	cin>>k;
	string s;
	cin>>s;
	ll arr[26];
	for(ll i=0;i<26;i++)
	arr[i]=0;
	for(ll i=0;i<s.size();i++)
	{
		int index=s[i]-97;
		arr[index]++;
	}
	int flag=0;
	for(ll i=0;i<26;i++)
	{
		if(arr[i]!=0 && arr[i]!=k)
		{
			flag++;
			break;
		}
	}
	if(flag==0)
	{
		while(k--)
		{
			for(ll i=0;i<26;i++)
			{
				if(arr[i]!=0)
				{
					char c='a'+i;
					cout<<c;
				}
			}
		}
	}
		else
		cout<<-1;
}


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

using namespace std;

int main()
{
	ll k;
	cin>>k;
	string s;
	cin>>s;
	ll arr[26];
	for(ll i=0;i<26;i++)
	arr[i]=0;
	ll n=s.size();
	if(n%k!=0)
	cout<<-1;
	else
	{
		for(ll i=0;i<n;i++)
		{
			int index=s[i]-97;
			arr[index]++;
		}
		int flag=0;
		for(ll i=0;i<26;i++)
		{
			if(arr[i]!=0 && arr[i]%k!=0)
			{
				flag++;
				break;
			}
		}
		if(flag==0)
		{
			while(k--)
			{
				ll i=0;
				ll j=0;
				while(k!=0 && i<n/k)
				{
					if(j==26)
					j=0;
					if(arr[j]!=0)
					{
						char c='a'+j;
						cout<<c;
						i++;
					}
					j++;
				}
			}
		}
		else
		cout<<-1;
	}
}


#include <iostream>
#include <map>
#include <cmath>
#include <string.h>
#include <vector>
#include <algorithm>
using namespace std;
map<int,int>mp;
int n,k;
vector<int>vec;
int mo=1000000007;
int dp[530][530];
bool lucky(int a)
{
    while(a)
    {
        if(a%10!=7 && a%10!=4)
        return 0;
        a/=10;
    }
    return 1;
}
long long po(int a,int b)
{
    if(b==1)
    return a;
    if(!b)return 1;
    long long p=po(a,b/2)%mo;
    if(b%2)
    return (((p*p)%mo)*a)%mo;
    return ((p*p)%mo);
}
int c(int a,int b)
{
    map<int,int>m;
    map<int,int>:: iterator it;
    int l=max(b,a-b);
    int ll=min(b,a-b);
    for(int i=a;i>l;i--)
    {
        int p=i;
        for(int j=2;j<=sqrt(p);j++)
        {
            while(p%j==0)
            {
                m[j]++;
                p/=j;
            }
        }
        if(p > 1)
        m[p]++;
    }
    for(int i=ll;i>=2;i--)
    {
        int p=i;
        for(int j=2;j<=sqrt(p);j++)
        {
            while(p%j==0)
            {
                m[j]--;
                p/=j;
            }
        }
        if(p > 1)
        m[p]--;
    }
    long long sum=1LL;
    for(it =m.begin();it!=m.end();it++)
    {
        sum*=(po((*it).first,(*it).second)%mo);
    }
    return sum%mo;
}
int f(int u,int b)
{
    //cout<<u<<" "<<b<<endl;
    if(b==k)
    return 1;
    if(u==vec.size())
    {
        if(mp[1] >= k-b)
        return c(mp[1],k-b);
        else if(b==k)
        return 1;
        return 0;
    }
    if(dp[u][b] >= 0)
    return dp[u][b];
    long long sum=0;
    sum+=((f(u+1,b+1)*mp[vec[u]])%mo);
    sum+=(f(u+1,b)%mo);
    sum%=mo;
    return dp[u][b]=sum;
}
int main()
{
    cin>>n>>k;
    memset(dp,-1,sizeof dp);
    for(int i=0;i<n;i++)
    {
        int kk;
        cin>>kk;
        bool b=lucky(kk);
        if(mp[kk]==0 && b)
        {
            vec.push_back(kk);
            mp[kk]++;
        }
        else if(!b)
        {
            if(mp[1]==0)
            vec.push_back(1);
            mp[1]++;
        }
        else
        mp[kk]++;
    }
    sort(vec.begin(),vec.end());
    int p=0;
    if(mp[1])
    p++;
    int sum=f(p,0)%mo;
    cout<<sum<<endl;
}


#include <iostream>
#include <map>
#include <cmath>
#include <string.h>
#include <vector>
#include <algorithm>
using namespace std;
map<int,long long>mp;
int n,k;
vector<int>vec;
long long mo=1000000007;
long long dp[2000][2000];
bool lucky(int a)
{
    while(a)
    {
        if(a%10!=7 && a%10!=4)
        return 0;
        a/=10LL;
    }
    return 1;
}
long long po(long long a,long long b)
{
    if(b==1LL)
    return a;
    if(!b)return 1LL;
    long long p=po(a,b/2LL)%mo;
    if(b & 1LL)
    return (((p*a)%mo)*p)%mo;
    return ((p*p)%mo);
}
long long c(long long a,long long b)
{
    if(a==b)
    return 1LL;
    if(a < b)
    return 0LL;
    map<long long,long long>m;
    map<long long,long long>:: iterator it;
    long long l=max(b,a-b);
    long long ll=min(b,a-b);
    for(long long i=a;i>l;i--)
    {
        long long p=i;
        for(long long j=2;j<=sqrt(p);j++)
        {
            while(p%j==0)
            {
                m[j]++;
                p/=j;
            }
        }
        if(p > 1)
        m[p]++;
    }
    for(long long i=ll;i>=2;i--)
    {
        long long p=i;
        for(long long j=2;j<=sqrt(p);j++)
        {
            while(p%j==0)
            {
                m[j]--;
                p/=j;
            }
        }
        if(p > 1)
        m[p]--;
    }
    long long sum=1LL;
    for(it =m.begin();it!=m.end();it++)
    {
        sum*=po((*it).first,(*it).second);
        sum%=mo;
    }
    return sum%mo;
}
long long f(long long u,long long b)
{
    if(b==k)
    return 1LL;
    if(u==vec.size())
    {
        return c(mp[1LL],k-b);
    }
    if(dp[u][b])
    return dp[u][b];
    long long sum=0LL;
    sum+=((f(u+1,b+1)*mp[vec[u]])%mo);
    sum%=mo;
    if(vec.size()-u+mp[1LL]+1LL >= k-b)
    sum+=f(u+1,b);
    sum%=mo;
    return dp[u][b]=sum;
}
int main()
{
    cin>>n>>k;
    //memset(dp,0,sizeof dp);
    for(long long i=0;i<n;i++)
    {
        long long kk;
        cin>>kk;
        bool b=lucky(kk);
        if(mp[kk]==0 && b)
        {
            vec.push_back(kk);
            mp[kk]++;
        }
        else if(!b)
        {
            mp[1]++;
        }
        else
        mp[kk]++;
    }
    long long sum=f(0,0)%mo;
    cout<<sum<<endl;
}


#include <iostream>
#include <map>
#include <cmath>
#include <string.h>
#include <vector>
#include <algorithm>
using namespace std;
map<int,long long>mp;
int n,k;
vector<int>vec;
long long mo=1000000007;
long long dp[2000][2000];
bool lucky(int a)
{
    while(a)
    {
        if(a%10!=7 && a%10!=4)
        return 0;
        a/=10LL;
    }
    return 1;
}
long long po(long long a,long long b)
{
    if(b==1LL)
    return a;
    if(!b)return 1LL;
    long long p=po(a,b/2LL)%mo;
    if(b & 1LL)
    return (((p*a)%mo)*p)%mo;
    return ((p*p)%mo);
}
long long c(long long a,long long b)
{
    if(a==b)
    return 1LL;
    if(a < b)
    return 0LL;
    map<long long,long long>m;
    map<long long,long long>:: iterator it;
    long long l=max(b,a-b);
    long long ll=min(b,a-b);
    for(long long i=a;i>l;i--)
    {
        long long p=i;
        for(long long j=2;j<=sqrt(p);j++)
        {
            while(p%j==0)
            {
                m[j]++;
                p/=j;
            }
        }
        if(p > 1)
        m[p]++;
    }
    for(long long i=ll;i>=2;i--)
    {
        long long p=i;
        for(long long j=2;j<=sqrt(p);j++)
        {
            while(p%j==0)
            {
                m[j]--;
                p/=j;
            }
        }
        if(p > 1)
        m[p]--;
    }
    long long sum=1LL;
    for(it =m.begin();it!=m.end();it++)
    {
        sum*=po((*it).first,(*it).second);
        sum%=mo;
    }
    return sum%mo;
}
long long f(long long u,long long b)
{
    if(b==k)
    return 1LL;
    if(u==vec.size())
    {
        return c(mp[1LL],k-b);
    }
    if(dp[u][b] > -1)
    return dp[u][b];
    long long sum=0LL;
    sum+=((f(u+1,b+1)*mp[vec[u]])%mo);
    sum%=mo;
    if(vec.size()-u+mp[1LL]+1LL >= k-b)
    sum+=f(u+1,b);
    sum%=mo;
    return dp[u][b]=sum;
}
int main()
{
    cin>>n>>k;
    memset(dp,-1,sizeof dp);
    for(long long i=0;i<n;i++)
    {
        long long kk;
        cin>>kk;
        bool b=lucky(kk);
        if(mp[kk]==0 && b)
        {
            vec.push_back(kk);
            mp[kk]++;
        }
        else if(!b)
        {
            mp[1]++;
        }
        else
        mp[kk]++;
    }
    long long sum=f(0,0)%mo;
    cout<<sum<<endl;
}


#include <iostream>
#include <map>
#include <cmath>
#include <string.h>
#include <vector>
#include <algorithm>
using namespace std;
map<int,int>mp;
int n,k;
vector<int>vec;
long long mo=1000000007;
long long dp[530][530];
bool lucky(int a)
{
    while(a)
    {
        if(a%10!=7 && a%10!=4)
        return 0;
        a/=10;
    }
    return 1;
}
long long po(long long a,long long b)
{
    if(b==1LL)
    return a;
    if(!b)return 1LL;
    long long p=po(a,b/2LL)%mo;
    if(b & 1LL)
    return (((p*p)%mo)*a)%mo;
    return ((p*p)%mo);
}
int c(int a,int b)
{
    map<int,int>m;
    map<int,int>:: iterator it;
    long long l=max(b,a-b);
    long long ll=min(b,a-b);
    for(int i=a;i>l;i--)
    {
        int p=i;
        for(int j=2;j<=sqrt(p);j++)
        {
            while(p%j==0)
            {
                m[j]++;
                p/=j;
            }
        }
        if(p > 1)
        m[p]++;
    }
    for(int i=ll;i>=2;i--)
    {
        int p=i;
        for(int j=2;j<=sqrt(p);j++)
        {
            while(p%j==0)
            {
                m[j]--;
                p/=j;
            }
        }
        if(p > 1)
        m[p]--;
    }
    long long sum=1LL;
    for(it =m.begin();it!=m.end();it++)
    {
        sum*=po((*it).first,(*it).second);
        sum%=mo;
    }
    return sum%mo;
}
long long f(int u,int b)
{
    //cout<<u<<" "<<b<<endl;
    if(b==k)
    return 1LL;
    if(u==vec.size())
    {
        if(mp[1] >= k-b)
        return c(mp[1],k-b);
        else if(b==k)
        return 1LL;
        return 0LL;
    }
    if(dp[u][b] >= 0)
    return dp[u][b];
    long long sum=0LL;
    sum+=((f(u+1,b+1)*mp[vec[u]])%mo);
    sum%=mo;
    sum+=(f(u+1,b)%mo);
    sum%=mo;
    return dp[u][b]=sum;
}
int main()
{
    cin>>n>>k;
    memset(dp,-1,sizeof dp);
    for(int i=0;i<n;i++)
    {
        int kk;
        cin>>kk;
        bool b=lucky(kk);
        if(mp[kk]==0 && b)
        {
            vec.push_back(kk);
            mp[kk]++;
        }
        else if(!b)
        {
            if(mp[1]==0)
            vec.push_back(1);
            mp[1]++;
        }
        else
        mp[kk]++;
    }
    sort(vec.begin(),vec.end());
    int p=0;
    if(mp[1])
    p++;
    int sum=f(p,0)%mo;
    cout<<sum<<endl;
}


#include <iostream>
#include <map>
#include <cmath>
#include <string.h>
#include <vector>
#include <algorithm>
using namespace std;
map<int,int>mp;
int n,k;
vector<int>vec;
int mo=1000000007;
int dp[530][530];
bool lucky(int a)
{
    while(a)
    {
        if(a%10!=7 && a%10!=4)
        return 0;
        a/=10;
    }
    return 1;
}
long long po(int a,int b)
{
    if(b==1)
    return a;
    if(!b)return 1;
    long long p=po(a,b/2)%mo;
    if(b%2)
    return (((p*p)%mo)*a)%mo;
    return ((p*p)%mo);
}
int c(int a,int b)
{
    map<int,int>m;
    map<int,int>:: iterator it;
    int l=max(b,a-b);
    int ll=min(b,a-b);
    for(int i=a;i>l;i--)
    {
        int p=i;
        for(int j=2;j<=sqrt(p);j++)
        {
            while(p%j==0)
            {
                m[j]++;
                p/=j;
            }
        }
        if(p > 1)
        m[p]++;
    }
    for(int i=ll;i>=2;i--)
    {
        int p=i;
        for(int j=2;j<=sqrt(p);j++)
        {
            while(p%j==0)
            {
                m[j]--;
                p/=j;
            }
        }
        if(p > 1)
        m[p]--;
    }
    long long sum=1LL;
    for(it =m.begin();it!=m.end();it++)
    {
        sum*=(po((*it).first,(*it).second)%mo);
    }
    return sum%mo;
}
int f(int u,int b)
{
    if(u==vec.size())
    {
        if(mp[1] >= k-b)
        return c(mp[1],k-b);
        else if(b==k)
        return 1;
        return 0;
    }
    if(dp[u][b] >= 0)
    return dp[u][b];
    long long sum=0;
    sum+=((f(u+1,b+1)*mp[vec[u]])%mo);
    sum+=(f(u+1,b)%mo);
    sum%=mo;
    return dp[u][b]=sum;
}
int main()
{
    cin>>n>>k;
    memset(dp,-1,sizeof dp);
    for(int i=0;i<n;i++)
    {
        int kk;
        cin>>kk;
        bool b=lucky(kk);
        if(mp[kk]==0 && b)
        {
            vec.push_back(kk);
            mp[kk]++;
        }
        else if(!b)
        {
            if(mp[1]==0)
            vec.push_back(1);
            mp[1]++;
        }
        else
        mp[kk]++;
    }
    sort(vec.begin(),vec.end());
    int p=0;
    if(mp[1])
    p++;
    int sum=f(p,0)%mo;
    cout<<sum<<endl;
}


#include <iostream>
#include <map>
#include <cmath>
#include <string.h>
#include <vector>
#include <algorithm>
using namespace std;
map<int,long long>mp;
int n,k;
vector<int>vec;
long long mo=1000000007;
long long dp[1000][1000];
bool lucky(int a)
{
    while(a)
    {
        if(a%10!=7 && a%10!=4)
        return 0;
        a/=10LL;
    }
    return 1;
}
long long po(long long a,long long b)
{
    if(b==1LL)
    return a;
    if(!b)return 1LL;
    long long p=po(a,b/2LL)%mo;
    if(b & 1LL)
    return (((p*a)%mo)*p)%mo;
    return ((p*p)%mo);
}
long long c(long long a,long long b)
{
    map<long long,long long>m;
    map<long long,long long>:: iterator it;
    long long l=max(b,a-b);
    long long ll=min(b,a-b);
    for(long long i=a;i>l;i--)
    {
        long long p=i;
        for(long long j=2;j<=sqrt(p);j++)
        {
            while(p%j==0)
            {
                m[j]++;
                p/=j;
            }
        }
        if(p > 1)
        m[p]++;
    }
    for(long long i=ll;i>=2;i--)
    {
        long long p=i;
        for(long long j=2;j<=sqrt(p);j++)
        {
            while(p%j==0)
            {
                m[j]--;
                p/=j;
            }
        }
        if(p > 1)
        m[p]--;
    }
    long long sum=1LL;
    for(it =m.begin();it!=m.end();it++)
    {
        sum*=po((*it).first,(*it).second);
        sum%=mo;
    }
    return sum%mo;
}
long long f(long long u,long long b)
{
    if(b==k)
    return 1LL;
    if(u==vec.size())
    {
        if(mp[1LL] >= k-b)
        return c(mp[1LL],k-b);
        return 0LL;
    }
    if(dp[u][b] >= 0)
    return dp[u][b];
    long long sum=0LL;
    sum+=((f(u+1,b+1)*mp[vec[u]])%mo);
    sum%=mo;
    if(vec.size()-u+mp[1]+1 >= k-b)
    sum+=f(u+1,b);
    sum%=mo;
    return dp[u][b]=sum;
}
int main()
{
    cin>>n>>k;
    memset(dp,-1,sizeof dp);
    for(long long i=0;i<n;i++)
    {
        long long kk;
        cin>>kk;
        bool b=lucky(kk);
        if(mp[kk]==0 && b)
        {
            vec.push_back(kk);
            mp[kk]++;
        }
        else if(!b)
        {
            mp[1]++;
        }
        else
        mp[kk]++;
    }
    long long sum=f(0,0)%mo;
    cout<<sum<<endl;
}


#include <iostream>
#include <map>
#include <string.h>
#include <vector>
#define LL  long long
using namespace std;
LL n,k;
map<LL,int>mp;
LL mo=1000000007LL;
LL fac[100005];
LL count[1024];
LL C[100005];
LL dp[1024][1024];
LL coun=1;
LL cnt;
bool check(LL u)
{
    while(u)
    {
        if(u%10!=7 && u%10!=4)
        return 0;
        u/=10;
    }
    return 1;
}
LL po(LL a, LL b)
{
    if(b==0)
    return 1;
    if(b==1)
    return a;
    LL t=po(a,b/2LL);
    if(b & 1LL)
    return (((t*a)%mo)*t)%mo;
    return (t*t)%mo;
}
LL c(LL a)
{
    if(a > cnt)return 0;
    if(a==cnt)return 1;
    if(C[a])return C[a];
    LL sum=fac[cnt]%mo;
    sum=(sum * po(fac[a],mo-2LL))%mo;
    sum=(sum * po(fac[cnt-a],mo-2LL))%mo;
    return C[a]=sum;
}
LL F(LL u , LL a )
{
    if(a==k)return 1LL;
    if(u==coun)
    {
        return c(k-a);
    }
    if(dp[u][a] > -1)
    return dp[u][a];
    LL sum=(F(u+1,a+1)*count[u])%mo;
    sum+=(F(u+1,a));
    sum%=mo;
    return dp[u][a]=sum;
}
int main()
{
    cin>>n>>k;
    memset(dp,-1,sizeof dp);
    for(int i=0;i<n;i++)
    {
        LL k;
        cin>>k;
        if(check(k))
        {
            if(mp[k]==0)
            {
                mp[k]=coun;
                count[coun]++;
                coun++;
            }
            else
            count[mp[k]]++;
        }
        else
        cnt++;
    }
    fac[0]=1;
    for(int i=1;i<=cnt;i++)
    fac[i]=(fac[i-1]*i)%mo;
    LL sum=F(1LL,0LL);
    cout<<sum<<endl;
}


#include <iostream>
#include <map>
#include <string.h>
#include <vector>
#define LL  long long
using namespace std;
LL n,k;
map<LL,int>mp;
LL mo=;
LL fac[100005];
LL count[1024];
LL C[100005];
LL dp[1024][1024];
LL coun=1;
LL cnt;
bool check(LL u)
{
    while(u)
    {
        if(u%10!=7 && u%10!=4)
        return 0;
        u/=10;
    }
    return 1;
}
LL po(LL a, LL b)
{
    if(b==0)
    return 1;
    if(b==1)
    return a;
    LL t=po(a,b/2LL);
    if(b & 1LL)
    return (((t*a)%mo)*t)%mo;
    return (t*t)%mo;
}
LL c(LL a)
{
    if(a > cnt)return 0;
    if(a==cnt)return 1;
    if(C[a])return C[a];
    LL sum=fac[cnt]%mo;
    sum=(sum * po(fac[a],mo-2LL))%mo;
    sum=(sum * po(fac[cnt-a],mo-2LL))%mo;
    return C[a]=sum;
}
LL F(LL u , LL a )
{
    if(a==k)return 1LL;
    if(u==coun)
    {
        return c(k-a);
    }
    if(dp[u][a] > -1)
    return dp[u][a];
    LL sum=(F(u+1,a+1)*count[u])%mo;
    sum+=(F(u+1,a));
    sum%=mo;
    return dp[u][a]=sum;
}
int main()
{
    cin>>n>>k;
    memset(dp,-1,sizeof dp);
    for(int i=0;i<n;i++)
    {
        LL k;
        cin>>k;
        if(check(k))
        {
            if(mp[k]==0)
            {
                mp[k]=coun;
                count[coun]++;
                coun++;
            }
            else
            count[mp[k]]++;
        }
        else
        cnt++;
    }
    fac[0]=1;
    for(int i=1;i<=cnt;i++)
    fac[i]=(fac[i-1]*i)%mo;
    LL sum=F(1LL,0LL);
    cout<<sum<<endl;
}


#include <iostream>
#include <map>
#include <string.h>
#include <vector>
#define LL  long long
using namespace std;
LL n,k;
map<LL,int>mp;
LL mo=1000000000LL+9LL;
LL fac[100005];
LL count[1024];
LL C[100005];
LL dp[1024][1024];
LL coun=1;
LL cnt;
bool check(LL u)
{
    while(u)
    {
        if(u%10!=7 && u%10!=4)
        return 0;
        u/=10;
    }
    return 1;
}
LL po(LL a, LL b)
{
    if(b==0)
    return 1;
    if(b==1)
    return a;
    LL t=po(a,b/2LL);
    if(b & 1LL)
    return (((t*a)%mo)*t)%mo;
    return (t*t)%mo;
}
LL c(LL a)
{
    if(a > cnt)return 0;
    if(a==cnt)return 1;
    if(C[a])return C[a];
    LL sum=fac[cnt]%mo;
    sum=(sum * po(fac[a],mo-2LL))%mo;
    sum=(sum * po(fac[cnt-a],mo-2LL))%mo;
    return C[a]=sum;
}
LL F(LL u , LL a )
{
    if(a==k)return 1LL;
    if(u==coun)
    {
        return c(k-a);
    }
    if(dp[u][a] > -1)
    return dp[u][a];
    LL sum=(F(u+1,a+1)*count[u])%mo;
    if(coun+cnt-u >= k -a)
    sum+=(F(u+1,a));
    sum%=mo;
    return dp[u][a]=sum;
}
int main()
{
    cin>>n>>k;
    memset(dp,-1,sizeof dp);
    for(int i=0;i<n;i++)
    {
        LL k;
        cin>>k;
        if(check(k))
        {
            if(mp[k]==0)
            {
                mp[k]=coun;
                count[coun]++;
                coun++;
            }
            else
            count[mp[k]]++;
        }
        else
        cnt++;
    }
    fac[0]=1;
    for(int i=1;i<=cnt;i++)
    fac[i]=(fac[i-1]*i)%mo;
    LL sum=F(1LL,0LL);
    cout<<sum<<endl;
}


#include <iostream>
#include <map>
#include <cmath>
#include <string.h>
#include <vector>
#include <algorithm>
using namespace std;
map<int,long long>mp;
int n,k;
vector<int>vec;
long long mo=1000000007;
long long dp[1000][1000];
bool lucky(int a)
{
    while(a)
    {
        if(a%10!=7 && a%10!=4)
        return 0;
        a/=10;
    }
    return 1;
}
long long po(long long a,long long b)
{
    if(b==1LL)
    return a;
    if(!b)return 1LL;
    long long p=po(a,b/2LL)%mo;
    if(b & 1LL)
    return (((p*a)%mo)*p)%mo;
    return ((p*p)%mo);
}
int c(int a,int b)
{
    map<long long,long long>m;
    map<long long,long long>:: iterator it;
    long long l=max(b,a-b);
    long long ll=min(b,a-b);
    for(long long i=a;i>l;i--)
    {
        long long p=i;
        for(long long j=2;j<=sqrt(p);j++)
        {
            while(p%j==0)
            {
                m[j]++;
                p/=j;
            }
        }
        if(p > 1)
        m[p]++;
    }
    for(long long i=ll;i>=2;i--)
    {
        long long p=i;
        for(long long j=2;j<=sqrt(p);j++)
        {
            while(p%j==0)
            {
                m[j]--;
                p/=j;
            }
        }
        if(p > 1)
        m[p]--;
    }
    long long sum=1LL;
    for(it =m.begin();it!=m.end();it++)
    {
        sum*=po((*it).first,(*it).second);
        sum%=mo;
    }
    return sum%mo;
}
long long f(int u,int b)
{
    if(b==k)
    return 1LL;
    if(u==vec.size())
    {
        if(mp[1] >= k-b)
        return c(mp[1],k-b);
        return 0LL;
    }
    if(dp[u][b] >= 0)
    return dp[u][b];
    long long sum=0LL;
    sum+=((f(u+1,b+1)*mp[vec[u]])%mo);
    sum%=mo;
    sum+=f(u+1,b);
    sum%=mo;
    return dp[u][b]=sum;
}
int main()
{
    cin>>n>>k;
    memset(dp,-1,sizeof dp);
    for(int i=0;i<n;i++)
    {
        int kk;
        cin>>kk;
        bool b=lucky(kk);
        if(mp[kk]==0 && b)
        {
            vec.push_back(kk);
            mp[kk]++;
        }
        else if(!b)
        {
            mp[1]++;
        }
        else
        mp[kk]++;
    }
    long long sum=f(0,0)%mo;
    cout<<sum<<endl;
}


#include <iostream>
#include <map>
#include <cmath>
#include <string.h>
#include <vector>
#include <algorithm>
using namespace std;
map<int,long long>mp;
int n,k;
vector<int>vec;
long long mo=1000000007;
long long dp[2000][2000];
long long heh[100004];
bool lucky(int a)
{
    while(a)
    {
        if(a%10!=7 && a%10!=4)
        return 0;
        a/=10LL;
    }
    return 1;
}
long long po(long long a,long long b)
{
    if(b==1LL)
    return a;
    if(!b)return 1LL;
    long long p=po(a,b/2LL)%mo;
    if(b & 1LL)
    return (((p*a)%mo)*p)%mo;
    return ((p*p)%mo);
}
map<long long,long long>m;
long long c(long long a,long long b)
{
    if(a==b)
    return 1LL;
    if(a < b)
    return 0LL;
    if(heh[b] > -1)
    return heh[b];
    map<long long,long long>:: iterator it;
    long long p=b;
    for(long long j=2;j<=sqrt(p);j++)
    {
        while(p%j==0)
        {
            m[j]--;
            p/=j;
        }
    }
    if(p > 1)
    m[p]--;
    p=(a-b+1);
    if(b)
    for(long long j=2;j<=sqrt(p);j++)
    {
        while(p%j==0)
        {
            m[j]++;
            p/=j;
        }
    }
    if(p > 1 && b)
    m[p]++;
    long long sum=1LL;
    for(it =m.begin();it!=m.end();it++)
    {
        sum*=po((*it).first,(*it).second);
        sum%=mo;
       // cout<<(*it).first<<" "<<(*it).second<<" "<<endl;
    }
    return heh[b]=sum%mo;
}
long long f(long long u,long long b)
{
    if(b==k)
    return 1LL;
    if(dp[u][b] > -1)
    return dp[u][b];
    if(u==vec.size())
    {
        return c(mp[1LL],k-b);
    }
    long long sum=0LL;
    sum+=((f(u+1,b+1)*mp[vec[u]])%mo);
    sum%=mo;
    if(vec.size()-u+mp[1LL]+1LL >= k-b)
    sum+=f(u+1,b);
    sum%=mo;
    return dp[u][b]=sum;
}
int main()
{
    cin>>n>>k;
    memset(dp,-1,sizeof dp);
    memset(heh,-1,sizeof heh);
    for(long long i=0;i<n;i++)
    {
        long long kk;
        cin>>kk;
        bool b=lucky(kk);
        if(mp[kk]==0 && b)
        {
            vec.push_back(kk);
            mp[kk]++;
        }
        else if(!b)
        {
            mp[1]++;
        }
        else
        mp[kk]++;
    }
    for(int i=0;i<=k;i++)
    {
        heh[i]=c(mp[1],i);
    //  cout<<heh[i]<<endl;
    }
    long long sum=f(0,0)%mo;
    cout<<sum<<endl;
}


#include <iostream>
#include <map>
#include <cmath>
#include <string.h>
#include <vector>
#include <algorithm>
using namespace std;
map<int,long long>mp;
int n,k;
vector<int>vec;
long long mo=1000000007;
long long dp[2000][2000];
long long heh[100004];
bool lucky(int a)
{
    while(a)
    {
        if(a%10!=7 && a%10!=4)
        return 0;
        a/=10LL;
    }
    return 1;
}
long long po(long long a,long long b)
{
    if(b==1LL)
    return a;
    if(!b)return 1LL;
    long long p=po(a,b/2LL)%mo;
    if(b & 1LL)
    return (((p*a)%mo)*p)%mo;
    return ((p*p)%mo);
}
long long c(long long a,long long b)
{
    if(a==b)
    return 1LL;
    if(a < b)
    return 0LL;
    if(heh[b] > -1)
    return heh[b];
    map<long long,long long>m;
    map<long long,long long>:: iterator it;
    long long l=max(b,a-b);
    long long ll=min(b,a-b);
    for(long long i=a;i>l;i--)
    {
        long long p=i;
        for(long long j=2;j<=sqrt(p);j++)
        {
            while(p%j==0)
            {
                m[j]++;
                p/=j;
            }
        }
        if(p > 1)
        m[p]++;
    }
    for(long long i=ll;i>=2;i--)
    {
        long long p=i;
        for(long long j=2;j<=sqrt(p);j++)
        {
            while(p%j==0)
            {
                m[j]--;
                p/=j;
            }
        }
        if(p > 1)
        m[p]--;
    }
    long long sum=1LL;
    for(it =m.begin();it!=m.end();it++)
    {
        sum*=po((*it).first,(*it).second);
        sum%=mo;
    }
    return heh[b]=sum%mo;
}
long long f(long long u,long long b)
{
    if(b==k)
    return 1LL;
    if(dp[u][b] > -1)
    return dp[u][b];
    if(u==vec.size())
    {
        return c(mp[1LL],k-b);
    }
    long long sum=0LL;
    sum+=((f(u+1,b+1)*mp[vec[u]])%mo);
    sum%=mo;
    if(vec.size()-u+mp[1LL]+1LL >= k-b)
    sum+=f(u+1,b);
    sum%=mo;
    return dp[u][b]=sum;
}
int main()
{
    cin>>n>>k;
    memset(dp,-1,sizeof dp);
    memset(heh,-1,sizeof heh);
    for(long long i=0;i<n;i++)
    {
        long long kk;
        cin>>kk;
        bool b=lucky(kk);
        if(mp[kk]==0 && b)
        {
            vec.push_back(kk);
            mp[kk]++;
        }
        else if(!b)
        {
            mp[1]++;
        }
        else
        mp[kk]++;
    }
    for(int i=0;i<=k;i++)
    heh[i]=c(m[1],i);
    long long sum=f(0,0)%mo;
    cout<<sum<<endl;
}


#include <iostream>
#include <map>
#include <cmath>
#include <string.h>
#include <vector>
#include <algorithm>
using namespace std;
map<int,long long>mp;
int n,k;
vector<int>vec;
long long mo=1000000007;
long long dp[2000][2000];
long long heh[100004];
bool lucky(int a)
{
    while(a)
    {
        if(a%10!=7 && a%10!=4)
        return 0;
        a/=10LL;
    }
    return 1;
}
long long po(long long a,long long b)
{
    if(b==1LL)
    return a;
    if(!b)return 1LL;
    long long p=po(a,b/2LL)%mo;
    if(b & 1LL)
    return (((p*a)%mo)*p)%mo;
    return ((p*p)%mo);
}
long long c(long long a,long long b)
{
    if(a==b)
    return 1LL;
    if(a < b)
    return 0LL;
    if(heh[b] > -1)
    return heh[b];
    map<long long,long long>m;
    map<long long,long long>:: iterator it;
    long long l=max(b,a-b);
    long long ll=min(b,a-b);
    for(long long i=a;i>l;i--)
    {
        long long p=i;
        for(long long j=2;j<=sqrt(p);j++)
        {
            while(p%j==0)
            {
                m[j]++;
                p/=j;
            }
        }
        if(p > 1)
        m[p]++;
    }
    for(long long i=ll;i>=2;i--)
    {
        long long p=i;
        for(long long j=2;j<=sqrt(p);j++)
        {
            while(p%j==0)
            {
                m[j]--;
                p/=j;
            }
        }
        if(p > 1)
        m[p]--;
    }
    long long sum=1LL;
    for(it =m.begin();it!=m.end();it++)
    {
        sum*=po((*it).first,(*it).second);
        sum%=mo;
    }
    return heh[b]=sum%mo;
}
long long f(long long u,long long b)
{
    if(b==k)
    return 1LL;
    if(dp[u][b] > -1)
    return dp[u][b];
    if(u==vec.size())
    {
        return c(mp[1LL],k-b);
    }
    long long sum=0LL;
    sum+=((f(u+1,b+1)*mp[vec[u]])%mo);
    sum%=mo;
    if(vec.size()-u+mp[1LL]+1LL >= k-b)
    sum+=f(u+1,b);
    sum%=mo;
    return dp[u][b]=sum;
}
int main()
{
    cin>>n>>k;
    memset(dp,-1,sizeof dp);
    memset(heh,-1,sizeof heh);
    for(long long i=0;i<n;i++)
    {
        long long kk;
        cin>>kk;
        bool b=lucky(kk);
        if(mp[kk]==0 && b)
        {
            vec.push_back(kk);
            mp[kk]++;
        }
        else if(!b)
        {
            mp[1]++;
        }
        else
        mp[kk]++;
    }
    for(int i=0;i<=k;i++)
    heh[i]=c(mp[1],i);
    long long sum=f(0,0)%mo;
    cout<<sum<<endl;
}


#include <iostream>
#include <map>
#include <cmath>
#include <string.h>
#include <vector>
#include <algorithm>
using namespace std;
map<int,long long>mp;
int n,k;
vector<int>vec;
long long mo=1000000007;
long long dp[1000][1000];
bool lucky(int a)
{
    while(a)
    {
        if(a%10!=7 && a%10!=4)
        return 0;
        a/=10LL;
    }
    return 1;
}
long long po(long long a,long long b)
{
    if(b==1LL)
    return a;
    if(!b)return 1LL;
    long long p=po(a,b/2LL)%mo;
    if(b & 1LL)
    return (((p*a)%mo)*p)%mo;
    return ((p*p)%mo);
}
long long c(long long a,long long b)
{
    if(a==b)
    return 1LL;
    if(a < b)
    return 0LL;
    map<long long,long long>m;
    map<long long,long long>:: iterator it;
    long long l=max(b,a-b);
    long long ll=min(b,a-b);
    for(long long i=a;i>l;i--)
    {
        long long p=i;
        for(long long j=2;j<=sqrt(p);j++)
        {
            while(p%j==0)
            {
                m[j]++;
                p/=j;
            }
        }
        if(p > 1)
        m[p]++;
    }
    for(long long i=ll;i>=2;i--)
    {
        long long p=i;
        for(long long j=2;j<=sqrt(p);j++)
        {
            while(p%j==0)
            {
                m[j]--;
                p/=j;
            }
        }
        if(p > 1)
        m[p]--;
    }
    long long sum=1LL;
    for(it =m.begin();it!=m.end();it++)
    {
        sum*=po((*it).first,(*it).second);
        sum%=mo;
    }
    return sum%mo;
}
long long f(long long u,long long b)
{
    if(b==k)
    return 1LL;
    if(u==vec.size())
    {
        return c(mp[1LL],k-b);
    }
    if(dp[u][b])
    return dp[u][b];
    long long sum=0LL;
    sum+=((f(u+1,b+1)*mp[vec[u]])%mo);
    sum%=mo;
    if(vec.size()-u+mp[1LL]+1LL >= k-b)
    sum+=f(u+1,b);
    sum%=mo;
    return dp[u][b]=sum;
}
int main()
{
    cin>>n>>k;
    //memset(dp,0,sizeof dp);
    for(long long i=0;i<n;i++)
    {
        long long kk;
        cin>>kk;
        bool b=lucky(kk);
        if(mp[kk]==0 && b)
        {
            vec.push_back(kk);
            mp[kk]++;
        }
        else if(!b)
        {
            mp[1]++;
        }
        else
        mp[kk]++;
    }
    long long sum=f(0,0)%mo;
    cout<<sum<<endl;
}