【CF 1092A】Uniform String

                                     A. Uniform String

You are given two integers nn and kk.

Your task is to construct such a string ss of length nn that for each ii from 11 to kk there is at least one ii-th letter of the Latin alphabet in this string (the first letter is 'a', the second is 'b' and so on) and there are no other letters except these. You have to maximize the minimal frequency of some letter (the frequency of a letter is the number of occurrences of this letter in a string). If there are several possible answers, you can print any.

You have to answer tt independent queries.

Input

The first line of the input contains one integer tt (1≤t≤1001≤t≤100) — the number of queries.

The next tt lines are contain queries, one per line. The ii-th line contains two integers nini and kiki (1≤ni≤100,1≤ki≤min(ni,26)1≤ni≤100,1≤ki≤min(ni,26)) — the length of the string in the ii-th query and the number of characters in the ii-th query.

Output

Print tt lines. In the ii-th line print the answer to the ii-th query: any string sisi satisfying the conditions in the problem statement with constraints from the ii-th query.

Example

input

3
7 3
4 4
6 2

output

cbcacab
abcd
baabab

代码:

#include<iostream>
#include<algorithm>
#include<cstring>
#include<string>
#include<cstdio>
#include<cmath>
#include<set>
#include<map>
using namespace std;
#define ll long long
#define inf 0x3f3f3f3f
#define mem(a,b) memset(a,b,sizeof(a))
#define closeio std::ios::sync_with_stdio(false)
 
int main()
{
	int t,n,m,i,j;
	char x;
	cin>>t;
	while(t--)
	{
		cin>>n>>m;
		for(i=0;i<n%m;i++)
			cout<<"a";
		for(i=0;i<m;i++)
		{
			x='a'+i;
			for(j=0;j<n/m;j++)
			{
				cout<<x;
			}
		}
		cout<<endl;
	}
	return 0;
}

 

全部评论

相关推荐

zygg:拼多多挂是不是过一两天就挂的呀
点赞 评论 收藏
分享
牛客10001:G了+1,被前端/客户端给捞起来了,不太想面
投递美团等公司6个岗位 美团求职进展汇总
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务