#include <set>
#include <cstring>
#include <iostream>
#include <cstdio>
#define REP(i,n) for(int i=0; i<(int)(n); i++)

inline int getInt(){ int s; scanf("%d", &s); return s; }

using namespace std;

int dp[101][101];
int memo[101][101];
int item[100];
int nm[100];
int memo2[101][10000];

int main(){
  int n = getInt();
  int m = getInt();

  REP(i,n){
    int nn = nm[i] = getInt();

    REP(j,nn) item[j] = getInt();

    memset(dp, 0, sizeof(dp));
    REP(j,nn + 1){
      REP(left, j + 1){
        int right = nn - 1 - (j - left);
        dp[left + 1][right] = max(dp[left + 1][right], dp[left][right] + item[left]);
        memo[i][j + 1] = max(memo[i][j + 1], dp[left + 1][right]);
        if(right){
          dp[left][right - 1] = max(dp[left][right - 1], dp[left][right] + item[right]);
          memo[i][j + 1] = max(memo[i][j + 1], dp[left][right - 1]);
        }
      }
    }

    // REP(j, nn + 1) printf("%d ", memo[i][j]); puts("");
  }

  REP(i,n) REP(j,m + 1){
    REP(k,nm[i] + 1){
      if(j + k <= m){
        memo2[i + 1][j + k] = max(memo2[i + 1][j + k],
                                  memo2[i][j] + memo[i][k]);
      }else{
        break;
      }
    }
  }
  int ans = 0;
  REP(i,m+1) ans = max(ans, memo2[n][i]);

  printf("%d\n", ans);

  return 0;
}


#include <set>
#include <cstring>
#include <iostream>
#include <cstdio>
#define REP(i,n) for(int i=0; i<(int)(n); i++)

inline int getInt(){ int s; scanf("%d", &s); return s; }

using namespace std;

int dp[101][101];
int memo[100][101];
int item[100];
int nm[100];
int memo2[100][10000];

int main(){
  int n = getInt();
  int m = getInt();

  REP(i,n){
    int nn = nm[i] = getInt();

    REP(j,nn) item[j] = getInt();

    memset(dp, 0, sizeof(dp));
    REP(j,nn + 1){
      REP(left, j + 1){
        int right = nn - 1 - (j - left);
        dp[left + 1][right] = max(dp[left + 1][right], dp[left][right] + item[left]);
        memo[i][j + 1] = max(memo[i][j + 1], dp[left + 1][right]);
        if(right){
          dp[left][right - 1] = max(dp[left][right - 1], dp[left][right] + item[right]);
          memo[i][j + 1] = max(memo[i][j + 1], dp[left][right - 1]);
        }
      }
    }

    // REP(j, nn + 1) printf("%d ", memo[i][j]); puts("");
  }

  REP(i,n) REP(j,m){
    REP(k,nm[i] + 1){
      if(j + k <= m){
        memo2[i + 1][j + k] = max(memo2[i + 1][j + k],
                                  memo2[i][j] + memo[i][k]);
      }else{
        break;
      }
    }
  }

  printf("%d\n", memo2[n][m]);

  return 0;
}


#include <set>
#include <cstring>
#include <iostream>
#include <cstdio>
#define REP(i,n) for(int i=0; i<(int)(n); i++)

inline int getInt(){ int s; scanf("%d", &s); return s; }

using namespace std;

int dp[101][101];
int memo[101][101];
int item[100];
int nm[100];
int memo2[101][10001];

int main(){
  int n = getInt();
  int m = getInt();

  REP(i,n){
    int nn = nm[i] = getInt();

    REP(j,nn) item[j] = getInt();

    memset(dp, 0, sizeof(dp));
    REP(j,nn + 1){
      REP(left, j + 1){
        int right = nn - 1 - (j - left);
        if(right < left) break;
        dp[left + 1][right] = max(dp[left + 1][right], dp[left][right] + item[left]);
        memo[i][j + 1] = max(memo[i][j + 1], dp[left + 1][right]);
        if(right){
          dp[left][right - 1] = max(dp[left][right - 1], dp[left][right] + item[right]);
          memo[i][j + 1] = max(memo[i][j + 1], dp[left][right - 1]);
        }
      }
    }

    // REP(j, nn + 1) printf("%d ", memo[i][j]); puts("");
  }

  REP(i,n) REP(j,m + 1){
    REP(k,nm[i] + 1){
      if(j + k <= m){
        memo2[i + 1][j + k] = max(memo2[i + 1][j + k],
                                  memo2[i][j] + memo[i][k]);
      }else{
        break;
      }
    }
  }

  printf("%d\n", memo2[n][m]);

  return 0;
}


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

#define fi(i,a,b)   for(long long i=a;i<=b;i++)
#define fr(i,a)     for(long long i=0;i<a;i++)
#define fd(i,a,b)   for(long long i=b;i>=a;i--)
#define clr(x)      memset(x,0,sizeof(x))
#define cln(x)      memset(x,-1,sizeof(x))
#define __          printf(" ")
#define _           printf("\n")
#define _o          printf("1\n")
#define stree       long long lft=node<<1,rht=(node<<1)|1,mid=(s+e)>>1
#define mod         1000000007
#define read()      freopen("in.txt","r",stdin)
#define write()     freopen("out.txt","w",stdout)

long long x[110][110];
long long a[110][110];
long long cnt[110];
long long n;

void cal(){
    fi(i,1,n) {
        long long lft=0,rht;
        fi(j,0,cnt[i]) {
            lft+=a[i][j];
            rht=0;
            fd(k,j+1,cnt[i]+1){
               rht+=a[i][k];
               x[i][cnt[i]-(k-j-1)]=max(lft+rht,x[i][cnt[i]-(k-j-1)]);
            }
        }

    }
    return;
}

long long mem[110][10010];

long long dp(long long cur,long long need){
    if(need<0) return -mod;
    if(need==0) return 0;
    if(cur>n) return -mod;
    long long &ret=mem[cur][need];
    if(ret!=-1) return ret;ret=0;
    fi(i,0,cnt[cur]) ret=max(ret,x[cur][i]+dp(cur+1,need-i));
    return ret;
}

main(){
    long long m;
    scanf("%lld %lld",&n,&m);
    fi(i,1,n) {
       scanf("%lld",cnt+i);
       fi(j,1,cnt[i]) scanf("%lld",&a[i][j]);
    }
    cal();
    cln(mem);
    printf("%lld\n",dp(1,m));
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision;
//cpp_int
typedef long long  ll;
typedef vector< pair<long long,long long> > vpll;
typedef vector< pair<int,int> > vpii;
#define max3(a,b,c)     max(a,max(b,c))
#define min3(a,b,c)     min(a,min(b,c))
#define max4(a,b,c,d)   max3(a,b,max(c,d))
#define f(i,a,b) 		for(i=a;i<b;i++)
#define sf(x)           scanf("%lld",&x)
#define pf(x)           printf("%lld",x)
#define tle(x)          ios_base::sync_with_stdio(x),cin.tie(NULL),cout.tie(NULL)
#define add(x,y)        accumulate(x, y, 0);  //v.begin(),v.end()
#define stacki          stack<int>
#define stackll         stack<long long>
#define queuei          queue<int >
#define queuell         queue<long long >
#define pr_qi           priority_queue<int >
#define pr_qll          priority_queue<long long >
#define mapi            map<int,int>
#define mapll           map<long long,long long>
#define fi              first
#define se              second
#define pb              push_back
#define mp              make_pair
#define mod             1000000007
#define m5              (int)1e5+5

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

int main()
{
    tle(0);
    ll n,i,k,t;
    cin>>t;
    while(t--)
    {
        cin>>n>>k;
        string st="";
        for(i=0;i<k;i++)
        {
            st+=(char)('a'+i);
        }
        ll dif=n/k-1;
        string pa=st;
        while(dif>0 && dif--)
            st+=pa;
        dif=n%k;
        for(i=0;i<dif;i++)
        st+=st[i];
        cout<<st<<"\n";
    }

    return 0;

}


#include <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision;
//cpp_int
typedef long long  ll;
typedef vector< pair<long long,long long> > vpll;
typedef vector< pair<int,int> > vpii;
#define max3(a,b,c)     max(a,max(b,c))
#define min3(a,b,c)     min(a,min(b,c))
#define max4(a,b,c,d)   max3(a,b,max(c,d))
#define f(i,a,b) 		for(i=a;i<b;i++)
#define sf(x)           scanf("%lld",&x)
#define pf(x)           printf("%lld",x)
#define tle(x)          ios_base::sync_with_stdio(x),cin.tie(NULL),cout.tie(NULL)
#define add(x,y)        accumulate(x, y, 0);  //v.begin(),v.end()
#define stacki          stack<int>
#define stackll         stack<long long>
#define queuei          queue<int >
#define queuell         queue<long long >
#define pr_qi           priority_queue<int >
#define pr_qll          priority_queue<long long >
#define mapi            map<int,int>
#define mapll           map<long long,long long>
#define fi              first
#define se              second
#define pb              push_back
#define mp              make_pair
#define mod             1000000007
#define m5              (int)1e5+5

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

int main()
{
    tle(0);
    ll n,i,k,t;
    cin>>t;
    while(t--)
    {
        cin>>n>>k;
        for(i=0;i<k;i++)
        {
            cout<<(char)('a'+i);
        }
        ll dif=n-k;
        while(dif--)
        cout<<"a";
        cout<<"\n";
    }

    return 0;

}


#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
#define ll long long
#define pll pair<ll,ll>
#define vpll vector<pll>
#define vppll vector< pair<ll , pll> >
#define pb push_back
#define vll vector<ll>
#define mp make_pair
#define ff first
#define ss second
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL)
#define bc(x) __builtin_popcountll(x)
#define init(x) memset(x,-1,sizeof(x))
#define clr(x) memset(x,0,sizeof(x))
#define forn(i,x,n) for(i=x; i<n; ++i)
#define inp(x) scanf("%lld",&x)
#define inp2(x,y) scanf("%lld %lld",&x, &y)
#define inp3(x,y,z) scanf("%lld %lld %lld",&x, &y, &z)
#define out(x) printf("%lld ",x)
#define MOD 1000000007

//namespace mp = boost::multiprecision;
using namespace std;
//using namespace __gnu_pbds;
//typedef tree<ll, null_type, less_equal<ll>, rb_tree_tag, tree_order_statistics_node_update> newdataset;
ll modpow(ll a,ll b){ ll r=1; while(b>0) { if(b&1) r=(r*a); a=(a*a); b>>=1;} return r; }
/*ll moduloMultiplication(ll a,
                               ll b,
                              ll mod)
{
   ll res = 0;a %= mod;while (b){if (b & 1)
            res = (res + a) % mod;a = (2 * a) % mod;b >>= 1;}return res;}*/

bool sortbysec(const pair<int,int> &a,
              const pair<int,int> &b)
{
    if(a.ff==b.ff)return(a.ss>b.ss);
    else if(a.ss==b.ss) return(a.ff<b.ff);
    else return (a.ff<b.ff);
}
/*ll freq[1111111]={0},answer=0,a[311111],ans[311111]={0},block,cnt=0,sum=0;
struct node {
	ll L, R, i;
}q[311111];
bool cmp2(node x, node y) {
	if(x.L/block != y.L/block) {
		// different blocks, so sort by block.
		return x.L/block < y.L/block;
	}
	// same block, so sort by R value
	return x.R < y.R;
}
void add(ll position) {
	sum+=a[position];
	}

void remove(ll position) {
	sum-=a[position];

	}
*/
/*ll getsum(ll index)
{
    ll sum = 0; // Initialize result
    //cout<<index<<endl;

    // Traverse ancestors of BITree[index]
    while (index > 0)
    {
        // Add current element of BITree to sum
        sum += bit[index];
ll
        // Move index to parent node in getSum View
        index -= index & (-index);
    }
    return sum;
}*/
/*void update(ll n, ll index, ll val)
{
    // Traverse all ancestors and add 'val'
    while (index <= n)
    {
       // Add 'val' to current node of BI Tree
       bit[index] += val;

       // Update index to that of parent in update View
       index += index & (-index);
    }
}*/

/*  ll rootf(ll k,ll arr[])
    {

        while(arr[k]!=k)
            {arr[k]=arr[arr[k]];
            k=arr[k];}
        return k;
    }
    bool find(ll arr[],ll k,ll l)
    {
        if(rootf(k,arr)==rootf(l,arr))return true;
        else return false;
    }
    void unionf(ll arr[],ll size[],ll n,ll k,ll l)
    {

        ll rk=rootf(k,arr);
        ll rl=rootf(l,arr);
        if(rl==rk) return;
        if(size[rk]<size[rl])
        {
            arr[rk]=arr[rl];
            size[rl]+=size[rk];
        }
        else
        {
            arr[rl]=arr[rk];
            size[rk]+=size[rl];
        }
    }

  map<string,vector<string> >m1;
     int dfs(string s, int cnt)
    {int ct=cnt;
        for(ll i=0;i<m1[s].size();i++)
        {
            cnt=max(cnt,dfs(m1[s][i],ct)+1);
        }
        return cnt;

    }*/
int main()
{
fast;
int t,i,j,k,l,m,n;
char a[26];
    a[1]='a';
    a[2]='b';
    a[3]='c';
    a[4]='d';
    a[5]='e';
    a[6]='f';
    a[7]='g';
    a[8]='h';
    a[9]='i';
    a[10]='j';
    a[11]='k';
    a[12]='l';
    a[13]='m';
    a[14]='n';
    a[15]='o';
    a[16]='p';
    a[17]='q';
    a[18]='r';
    a[19]='s';
    a[20]='t';
    a[21]='u';
    a[22]='v';
    a[23]='w';
    a[24]='x';
    a[25]='y';
    a[26]='z';
cin>>t;
while(t--)
{
    cin>>n>>k;
    int ab=n/k;
    int b=n%k;
    for(i=1;i<=k;i++)
    {
        for(j=1;j<=ab;j++)cout<<a[i];
    }
    for(i=0;i<b;i++)cout<<a[k];
    cout<<endl;

}}


#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
#define ll long long
#define pll pair<ll,ll>
#define vpll vector<pll>
#define vppll vector< pair<ll , pll> >
#define pb push_back
#define vll vector<ll>
#define mp make_pair
#define ff first
#define ss second
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL)
#define bc(x) __builtin_popcountll(x)
#define init(x) memset(x,-1,sizeof(x))
#define clr(x) memset(x,0,sizeof(x))
#define forn(i,x,n) for(i=x; i<n; ++i)
#define inp(x) scanf("%lld",&x)
#define inp2(x,y) scanf("%lld %lld",&x, &y)
#define inp3(x,y,z) scanf("%lld %lld %lld",&x, &y, &z)
#define out(x) printf("%lld ",x)
#define MOD 1000000007

//namespace mp = boost::multiprecision;
using namespace std;
//using namespace __gnu_pbds;
//typedef tree<ll, null_type, less_equal<ll>, rb_tree_tag, tree_order_statistics_node_update> newdataset;
ll modpow(ll a,ll b){ ll r=1; while(b>0) { if(b&1) r=(r*a); a=(a*a); b>>=1;} return r; }
/*ll moduloMultiplication(ll a,
                               ll b,
                              ll mod)
{
   ll res = 0;a %= mod;while (b){if (b & 1)
            res = (res + a) % mod;a = (2 * a) % mod;b >>= 1;}return res;}*/

bool sortbysec(const pair<int,int> &a,
              const pair<int,int> &b)
{
    if(a.ff==b.ff)return(a.ss>b.ss);
    else if(a.ss==b.ss) return(a.ff<b.ff);
    else return (a.ff<b.ff);
}
/*ll freq[1111111]={0},answer=0,a[311111],ans[311111]={0},block,cnt=0,sum=0;
struct node {
	ll L, R, i;
}q[311111];
bool cmp2(node x, node y) {
	if(x.L/block != y.L/block) {
		// different blocks, so sort by block.
		return x.L/block < y.L/block;
	}
	// same block, so sort by R value
	return x.R < y.R;
}
void add(ll position) {
	sum+=a[position];
	}

void remove(ll position) {
	sum-=a[position];

	}
*/
/*ll getsum(ll index)
{
    ll sum = 0; // Initialize result
    //cout<<index<<endl;

    // Traverse ancestors of BITree[index]
    while (index > 0)
    {
        // Add current element of BITree to sum
        sum += bit[index];
ll
        // Move index to parent node in getSum View
        index -= index & (-index);
    }
    return sum;
}*/
/*void update(ll n, ll index, ll val)
{
    // Traverse all ancestors and add 'val'
    while (index <= n)
    {
       // Add 'val' to current node of BI Tree
       bit[index] += val;

       // Update index to that of parent in update View
       index += index & (-index);
    }
}*/

/*  ll rootf(ll k,ll arr[])
    {

        while(arr[k]!=k)
            {arr[k]=arr[arr[k]];
            k=arr[k];}
        return k;
    }
    bool find(ll arr[],ll k,ll l)
    {
        if(rootf(k,arr)==rootf(l,arr))return true;
        else return false;
    }
    void unionf(ll arr[],ll size[],ll n,ll k,ll l)
    {

        ll rk=rootf(k,arr);
        ll rl=rootf(l,arr);
        if(rl==rk) return;
        if(size[rk]<size[rl])
        {
            arr[rk]=arr[rl];
            size[rl]+=size[rk];
        }
        else
        {
            arr[rl]=arr[rk];
            size[rk]+=size[rl];
        }
    }

  map<string,vector<string> >m1;
     int dfs(string s, int cnt)
    {int ct=cnt;
        for(ll i=0;i<m1[s].size();i++)
        {
            cnt=max(cnt,dfs(m1[s][i],ct)+1);
        }
        return cnt;

    }*/
int main()
{
fast;
int t,i,j,k,l,m,n;
vector<char>v;
v.pb('a');
v.pb('b');
v.pb('c');
v.pb('d');
v.pb('e');
v.pb('f');
v.pb('g');
v.pb('h');
v.pb('i');
v.pb('j');
v.pb('k');
v.pb('l');
v.pb('m');
v.pb('n');
v.pb('o');
v.pb('p');
v.pb('q');
v.pb('r');
v.pb('s');
v.pb('t');
v.pb('u');
v.pb('v');
v.pb('w');
v.pb('x');
v.pb('y');
v.pb('z');
cin>>t;
while(t--)
{
    cin>>n>>k;
    ll zz=n/k;
    ll yy=n%k;
    for(i=0;i<k;i++)
    {
        for(j=0;j<zz;j++)cout<<v[i];
    }
    for(i=0;i<yy;i++)cout<<"a";
    cout<<endl;
}
}


#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
#define ll long long
#define pll pair<ll,ll>
#define vpll vector<pll>
#define vppll vector< pair<ll , pll> >
#define pb push_back
#define vll vector<ll>
#define mp make_pair
#define ff first
#define ss second
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL)
#define bc(x) __builtin_popcountll(x)
#define init(x) memset(x,-1,sizeof(x))
#define clr(x) memset(x,0,sizeof(x))
#define forn(i,x,n) for(i=x; i<n; ++i)
#define inp(x) scanf("%lld",&x)
#define inp2(x,y) scanf("%lld %lld",&x, &y)
#define inp3(x,y,z) scanf("%lld %lld %lld",&x, &y, &z)
#define out(x) printf("%lld ",x)
#define MOD 1000000007

//namespace mp = boost::multiprecision;
using namespace std;
//using namespace __gnu_pbds;
//typedef tree<ll, null_type, less_equal<ll>, rb_tree_tag, tree_order_statistics_node_update> newdataset;
ll modpow(ll a,ll b){ ll r=1; while(b>0) { if(b&1) r=(r*a); a=(a*a); b>>=1;} return r; }
/*ll moduloMultiplication(ll a,
                               ll b,
                              ll mod)
{
   ll res = 0;a %= mod;while (b){if (b & 1)
            res = (res + a) % mod;a = (2 * a) % mod;b >>= 1;}return res;}*/

bool sortbysec(const pair<int,int> &a,
              const pair<int,int> &b)
{
    if(a.ff==b.ff)return(a.ss>b.ss);
    else if(a.ss==b.ss) return(a.ff<b.ff);
    else return (a.ff<b.ff);
}
/*ll freq[1111111]={0},answer=0,a[311111],ans[311111]={0},block,cnt=0,sum=0;
struct node {
	ll L, R, i;
}q[311111];
bool cmp2(node x, node y) {
	if(x.L/block != y.L/block) {
		// different blocks, so sort by block.
		return x.L/block < y.L/block;
	}
	// same block, so sort by R value
	return x.R < y.R;
}
void add(ll position) {
	sum+=a[position];
	}

void remove(ll position) {
	sum-=a[position];

	}
*/
/*ll getsum(ll index)
{
    ll sum = 0; // Initialize result
    //cout<<index<<endl;

    // Traverse ancestors of BITree[index]
    while (index > 0)
    {
        // Add current element of BITree to sum
        sum += bit[index];
ll
        // Move index to parent node in getSum View
        index -= index & (-index);
    }
    return sum;
}*/
/*void update(ll n, ll index, ll val)
{
    // Traverse all ancestors and add 'val'
    while (index <= n)
    {
       // Add 'val' to current node of BI Tree
       bit[index] += val;

       // Update index to that of parent in update View
       index += index & (-index);
    }
}*/

/*  ll rootf(ll k,ll arr[])
    {

        while(arr[k]!=k)
            {arr[k]=arr[arr[k]];
            k=arr[k];}
        return k;
    }
    bool find(ll arr[],ll k,ll l)
    {
        if(rootf(k,arr)==rootf(l,arr))return true;
        else return false;
    }
    void unionf(ll arr[],ll size[],ll n,ll k,ll l)
    {

        ll rk=rootf(k,arr);
        ll rl=rootf(l,arr);
        if(rl==rk) return;
        if(size[rk]<size[rl])
        {
            arr[rk]=arr[rl];
            size[rl]+=size[rk];
        }
        else
        {
            arr[rl]=arr[rk];
            size[rk]+=size[rl];
        }
    }

  map<string,vector<string> >m1;
     int dfs(string s, int cnt)
    {int ct=cnt;
        for(ll i=0;i<m1[s].size();i++)
        {
            cnt=max(cnt,dfs(m1[s][i],ct)+1);
        }
        return cnt;

    }*/
int main()
{
fast;
ll t,i,j,k,l,m,n; char a[26];
    a[1]='a';
    a[2]='b';
    a[3]='c';
    a[4]='d';
    a[5]='e';
    a[6]='f';
    a[7]='g';
    a[8]='h';
    a[9]='i';
    a[10]='j';
    a[11]='k';
    a[12]='l';
    a[13]='m';
    a[14]='n';
    a[15]='o';
    a[16]='p';
    a[17]='q';
    a[18]='r';
    a[19]='s';
    a[20]='t';
    a[21]='u';
    a[22]='v';
    a[23]='w';
    a[24]='x';
    a[25]='y';
    a[26]='z';
cin>>t;
while(t--)
{
    cin>>n>>k;
    if(k>n)k=n;

    j=1;

    for(i=0;i<n;i++)
    {
        cout<<a[j];
        j++;
        if(j==k+1)j=1;
    }
cout<<endl;

}}


#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
#define ll long long
#define pll pair<ll,ll>
#define vpll vector<pll>
#define vppll vector< pair<ll , pll> >
#define pb push_back
#define vll vector<ll>
#define mp make_pair
#define ff first
#define ss second
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL)
#define bc(x) __builtin_popcountll(x)
#define init(x) memset(x,-1,sizeof(x))
#define clr(x) memset(x,0,sizeof(x))
#define forn(i,x,n) for(i=x; i<n; ++i)
#define inp(x) scanf("%lld",&x)
#define inp2(x,y) scanf("%lld %lld",&x, &y)
#define inp3(x,y,z) scanf("%lld %lld %lld",&x, &y, &z)
#define out(x) printf("%lld ",x)
#define MOD 1000000007

//namespace mp = boost::multiprecision;
using namespace std;
//using namespace __gnu_pbds;
//typedef tree<ll, null_type, less_equal<ll>, rb_tree_tag, tree_order_statistics_node_update> newdataset;
ll modpow(ll a,ll b){ ll r=1; while(b>0) { if(b&1) r=(r*a); a=(a*a); b>>=1;} return r; }
/*ll moduloMultiplication(ll a,
                               ll b,
                              ll mod)
{
   ll res = 0;a %= mod;while (b){if (b & 1)
            res = (res + a) % mod;a = (2 * a) % mod;b >>= 1;}return res;}*/

bool sortbysec(const pair<int,int> &a,
              const pair<int,int> &b)
{
    if(a.ff==b.ff)return(a.ss>b.ss);
    else if(a.ss==b.ss) return(a.ff<b.ff);
    else return (a.ff<b.ff);
}
/*ll freq[1111111]={0},answer=0,a[311111],ans[311111]={0},block,cnt=0,sum=0;
struct node {
	ll L, R, i;
}q[311111];
bool cmp2(node x, node y) {
	if(x.L/block != y.L/block) {
		// different blocks, so sort by block.
		return x.L/block < y.L/block;
	}
	// same block, so sort by R value
	return x.R < y.R;
}
void add(ll position) {
	sum+=a[position];
	}

void remove(ll position) {
	sum-=a[position];

	}
*/
/*ll getsum(ll index)
{
    ll sum = 0; // Initialize result
    //cout<<index<<endl;

    // Traverse ancestors of BITree[index]
    while (index > 0)
    {
        // Add current element of BITree to sum
        sum += bit[index];
ll
        // Move index to parent node in getSum View
        index -= index & (-index);
    }
    return sum;
}*/
/*void update(ll n, ll index, ll val)
{
    // Traverse all ancestors and add 'val'
    while (index <= n)
    {
       // Add 'val' to current node of BI Tree
       bit[index] += val;

       // Update index to that of parent in update View
       index += index & (-index);
    }
}*/

/*  ll rootf(ll k,ll arr[])
    {

        while(arr[k]!=k)
            {arr[k]=arr[arr[k]];
            k=arr[k];}
        return k;
    }
    bool find(ll arr[],ll k,ll l)
    {
        if(rootf(k,arr)==rootf(l,arr))return true;
        else return false;
    }
    void unionf(ll arr[],ll size[],ll n,ll k,ll l)
    {

        ll rk=rootf(k,arr);
        ll rl=rootf(l,arr);
        if(rl==rk) return;
        if(size[rk]<size[rl])
        {
            arr[rk]=arr[rl];
            size[rl]+=size[rk];
        }
        else
        {
            arr[rl]=arr[rk];
            size[rk]+=size[rl];
        }
    }

  map<string,vector<string> >m1;
     int dfs(string s, int cnt)
    {int ct=cnt;
        for(ll i=0;i<m1[s].size();i++)
        {
            cnt=max(cnt,dfs(m1[s][i],ct)+1);
        }
        return cnt;

    }*/
int main()
{
fast;
ll t,i,j,k,l,m,n; char a[26];
    a[1]='a';
    a[2]='b';
    a[3]='c';
    a[4]='d';
    a[5]='e';
    a[6]='f';
    a[7]='g';
    a[8]='h';
    a[9]='i';
    a[10]='j';
    a[11]='k';
    a[12]='l';
    a[13]='m';
    a[14]='n';
    a[15]='o';
    a[16]='p';
    a[17]='q';
    a[18]='r';
    a[19]='s';
    a[20]='t';
    a[21]='u';
    a[22]='v';
    a[23]='w';
    a[24]='x';
    a[25]='y';
    a[26]='z';
cin>>t;
while(t--)
{
    cin>>n>>k;

    j=1;

    for(i=0;i<n;i++)
    {
        cout<<a[j];
        j++;
        if(j==k+1)j=1;
    }
cout<<endl;

}}


#include <bits/stdc++.h>

using namespace std;

int main()
{
    int n,t, k;
    cin >> t;
    int y = 0;
    while(t--) {
        cin >> n >> k;
        int rew = k;
        bool check = 1;
        string str;
        while (true) {
            while(k--) {

                str.push_back ((char)('a' + y));
                y++;
                if (y > rew - 1) {
                    y = 0;
                }
                n--;
                if (n == 0) {
                    check = false;
                    break;
                }

            }
            if (!check) {
                    y = 0;
                    sort (str.begin(), str.end());
                    cout << str;
                break;
            }

        }
    }

}


#include <bits/stdc++.h>

using namespace std;

int main()
{
    int n,t, k;
    cin >> t;
    int y = 0;
    while(t--) {
        cin >> n >> k;
        int rew = k;
        bool check = 1;
        while (true) {
            while(k--) {

                cout << (char)('a' + y);
                y++;
                if (y > rew - 1) {
                    y = 0;
                }
                n--;
                if (n == 0) {
                    check = false;
                    break;
                }

            }
            if (!check) {
                    y = 0;
                break;
            }

        }
    }

}


#include <bits/stdc++.h>

using namespace std;

int main()
{
    int n,t, k;
    cin >> t;
    int y = 0;
    while(t--) {
        cin >> n >> k;
        while(n--) {
            cout << 'a';
        }
        cout << '\n';

    }

}


#include <bits/stdc++.h>

using namespace std;

int main()
{
    int n,t, k;
    cin >> t;
    int y = 0;
    while(t--) {
        cin >> n >> k;
        int rew = k;
        bool check = 1;
        while (true) {
            while(k--) {

                cout << (char)('a' + y);
                y++;
                if (y > rew - 1) {
                    y = 0;
                }
                n--;
                if (n == 0) {
                    check = false;
                    break;
                }

            }
            if (!check) {
                    y = 0;
                break;
            }

        }
        cout << '\n';
    }

}


#include <bits/stdc++.h>

using namespace std;

int main()
{
    int n,t, k;
    cin >> t;
    int y = 0;
    while(t--) {
        cin >> n >> k;
        int rew = k;
        bool check = 1;
        string str;
        while (true) {
            while(k--) {

                str.push_back ((char)('a' + y));
                y++;
                if (y > rew - 1) {
                    y = 0;
                }
                n--;
                if (n == 0) {
                    check = false;
                    break;
                }

            }
            if (!check) {
                    y = 0;
                    sort (str.begin(), str.end());
                    if (str[0] == str[1]) {
                        for (int i = 1; i < str.size(); i++) {
                            cout << str[i];
                        }
                        cout << str[str.size() - 1];
                    } else {
                        cout << str;
                    }

                break;
            }

        }
    }

}


#include <bits/stdc++.h>

using namespace std;

int main()
{
    int n,t, k;
    cin >> t;
    int y = 0;
    while(t--) {
        cin >> n >> k;
        int rew = k;
        bool check = 1;
        string str;
        while (true) {
            while(k--) {

                str.push_back ((char)('a' + y));
                y++;
                if (y > rew - 1) {
                    y = 0;
                }
                n--;
                if (n == 0) {
                    check = false;
                    break;
                }

            }
            if (!check) {
                    y = 0;
                    sort (str.begin(), str.end());
                    reverse(str.begin(), str.end());
                    cout << str;
                break;
            }

        }
    }

}


#include<iostream>
using namespace std;
int main(){
    int t;
    cin>>t;
    while(t--){
        int n,k;
        cin>>n>>k;
        int occur=n/k;
        char *s=new char[n];
        int l=1;
        int counter=1;
        int pos=0;
        for(int i=0;i<k;i++)
        {
            for(int j=0;j<occur;j++)
            {
                s[pos]=char(counter+96);
                pos++;
            }
            counter++;
        }
        if(n%k!=0)
        {
            int p=occur*k;
            while(p<n){
                s[p]='a';
                p++;
            }
        }
        cout<<s<<endl;
        delete []s;
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main(){
    int t;
    cin>>t;
    while(t--){
        int n,k;
        cin>>n>>k;
        int occur=n/k;
        char *s=new char[n];
        int l=1;
        int counter=1;
        int pos=0;
        for(int i=0;i<k;i++)
        {
            for(int j=0;j<occur;j++)
            {
                s[pos]=char(counter+96);
                pos++;
            }
            counter++;
        }
        if(n%k!=0)
        {
            int p=occur*k;
            while(p<n){
                s[p]='a';
                p++;
            }
        }
        cout<<s<<endl;
        delete []s;
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main(){
    int t;
    cin>>t;
    while(t--){
        int n,k;
        cin>>n>>k;
        int maxoccur=n/k,occur=1;
        int counter=97;
        char s[100];
        int pos=0;
        for(int i=0;i<k;i++){
            while(occur<=maxoccur){
                s[pos]=char(counter);
                pos++;
                occur++;
            }
                occur=1;
                counter++;
        }
        if(n%k!=0){
            while(pos<n){
                s[pos]='a';
                pos++;
            }
        }
        s[pos]='\0';
        cout<<s<<endl;
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main(){
    int t;
    cin>>t;
    while(t--){
        int n,k;
        cin>>n>>k;
        int occur=n/k;
        char *s=new char[n];
        int l=1;
        int counter=1;
        int pos=0;
        for(int i=0;i<k;i++)
        {
            for(int j=0;j<occur;j++)
            {
                s[pos]=char(counter+96);
                pos++;
            }
            counter++;
        }
        if(n%k!=0)
        {
            int p=occur*k;
            while(p<n){
                s[p]='a';
                p++;
            }
        }
        cout<<s<<endl;

    }
}


#include<iostream>

using namespace std;

int main() {
    int t;
    cin>>t;
    while(t--) {
        int i,n,k,count=1;
        string s;
        cin>>n>>k;
        for(i=97;;) {
            s = s + (char)i;
            if(count == n || (count==n-(n%k) && k%2))
                break;
            if(count % (n/k) == 0)
                i++;
            count++;
        }
        if(k%2) {
            for(int j=0;j<(n%k);j++)
                s=s+(char)i;
        }
        cout<<s<<'\n';
    }
    return 0;
}


#include<iostream>

using namespace std;

int main() {
    int t;
    cin>>t;
    while(t--) {
        int i,n,k,count=1;
        string s;
        cin>>n>>k;
        for(i=97;;) {
            s = s + (char)i;
            if(count == n || (count==n-(n%k) && n%2))
                break;
            if(count % (n/k) == 0)
                i++;
            count++;
        }
        if(n%2)
        s=s+(char)i;
        cout<<s<<'\n';
    }
    return 0;
}


#include<iostream>

using namespace std;

int main() {
    int t;
    cin>>t;
    while(t--) {
        int i,n,k,count=1;
        string s;
        cin>>n>>k;
        for(i=97;;) {
            s = s + (char)i;
            if(count == n || (count==n-(n%k) && n%2))
                break;
            if(count % (n/k) == 0)
                i++;
            count++;
        }
        if(n%2) {
            for(int j=0;j<(n%k);j++)
                s=s+(char)i;
        }
        cout<<s<<'\n';
    }
    return 0;
}


#include<iostream>

using namespace std;

int main() {
    int t;
    cin>>t;
    while(t--) {
        int i,j,n,k,count=1;
        string s;
        cin>>n>>k;
        for(j=0;j<n/k;j++) {
            for(i=97;i<97+k;i++)
                s+=(char)i;
        }
        for(j=0;j<(n%k);j++) {
            s+=(char)(i-1);
        }
        cout<<s<<'\n';
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
int main()
{
	int t;
	cin>>t;
	for(int i=0;i<t;i++)
	{
		int n;
		int k;
		cin>>n>>k;
		string d="abcdefghijklmnopqrstuvwxyz";
	    string s;
		for(int j=0;j<k;j++)
		{
          s=s+d[j];
		}
		int f=n%k;
		int h=n/k;
		string a;
		for(int i=0;i<h;i++)
		{
          a=a+s;
		}

		for(int j=0;j<f;j++)
			a=a+d[j];
		cout<<a<<endl;
	}
   	return 0;
}


#include <bits/stdc++.h>
using namespace std;
int main()
{
	int y;
	cin>>t;
	for(int i=0;i<t;i++)
	{
		int n;
		int k;
		cin>>n>>k;
		string d="abcdefghijklmnopqrstuvxyz";
	    string s;
		for(int j=0;j<k;j++)
		{
          s=s+d[j];
		}
		int f=n%k;
		int h=n/k;
		string str;
		for(int i=0;i<h;i++)
		{
          str=str+s;
		}
		string st;
		for(int j=0;j<f;j++)
		{
			st=st+d[j];
		}
		cout<<str+st<<endl;
	}
   	return 0;
}


#include <bits/stdc++.h>
using namespace std;
int main()
{
	int t;
	cin>>t;
	for(int i=0;i<t;i++)
	{
		int n;
		int k;
		cin>>n>>k;
		string d="abcdefghijklmnopqrstuvxyz";
	    string s;
		for(int j=0;j<k;j++)
		{
          s=s+d[j];
		}
		int f=n%k;
		int h=n/k;
		string str;
		for(int i=0;i<h;i++)
		{
          str=str+s;
		}
		string st;
		for(int j=0;j<f;j++)

			st=st+d[j];
		}
		cout<<str+st<<endl;
	}
   	return 0;
}


#include <bits/stdc++.h>
using namespace std;
int main()
{
	int t;
	cin>>t;
	for(int i=0;i<t;i++)
	{
		int n;
		int k;
		cin>>n>>k;
		string d="abcdefghijklmnopqrstuvxyz";
	    string s;
		for(int j=0;j<k;j++)
		{
          s=s+d[j];
		}
		int f=n%k;
		int h=n/k;
		string a;
		for(int i=0;i<h;i++)
		{
          a=a+s;
		}

		for(int j=0;j<f;j++)
			a=a+d[j];
		cout<<a<<endl;
	}
   	return 0;
}


#include<bits/stdc++.h>
#define fast std::ios::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define ll long long
#define test cout<<"archit\n"
#define debug(x) cout<<x<<" "
#define debug1(x) cout<<x<<"\n"
#define debug2(x,y) cout<<x<<" "<<y<<"\n"
#define pb push_back
#define pi pair<int,int>
#define fi first
#define si second
#define mod (ll)1000000007
using namespace std;
int main()
{
    fast;
    int t,n,k,i; cin>>t;
    while(t--){
        cin>>n>>k;
        char arr[n];
        i=0;
        for(i=0;i<k;i++){
            arr[i] = char(i)+97;
        }
        int k1=0;
        while(i < n){
            arr[i] = arr[k1++];
            k1 = (k1%k);
            i++;
        }
        for(i=0;i<n;i++){
            cout<<arr[i];
        }
        cout<<endl;
    }
    return 0;
}


#include<bits/stdc++.h>
#define fast std::ios::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define ll long long
#define test cout<<"archit\n"
#define debug(x) cout<<x<<" "
#define debug1(x) cout<<x<<"\n"
#define debug2(x,y) cout<<x<<" "<<y<<"\n"
#define pb push_back
#define pi pair<int,int>
#define fi first
#define si second
#define mod (ll)1000000007
using namespace std;
int main()
{
    fast;
    int tst; cin>>tst;
    while(tst--){
    int n,k; cin>>n>>k;
    string ans="";
    int cnt = n/k;
    int i=0;
    string arr[26];
    int k1=0;
    for(int i=0;i<26;i++){
        arr[i] = (i+97);
    }
    int j=0;
    while(i < n){
       // string last = 'a'+i+1;
        string last = arr[j];
        int temp=cnt;
        int temp1 = min(temp, n-i);
        if(temp1 < cnt){
            break;
        }
        while(temp>0 && i<n){
            i++;
            ans += last;
            --temp;
        }
        j++;

    }
    if(ans.length() < n){
        while(ans.length() < n){
            ans+=arr[j-1];
        }
    }
    debug1(ans);
    }
    return 0;
}


#include<bits/stdc++.h>
#define fast std::ios::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define ll long long
#define test cout<<"archit\n"
#define debug(x) cout<<x<<" "
#define debug1(x) cout<<x<<"\n"
#define debug2(x,y) cout<<x<<" "<<y<<"\n"
#define pb push_back
#define pi pair<int,int>
#define fi first
#define si second
#define mod (ll)1000000007
using namespace std;
int main()
{
    fast;
    int tst; cin>>tst;
    int n,k,i,j,cnt;
    string* arr = new string[26]();
    for(int i=0;i<26;i++){
        arr[i] = (i+97);
    }
    while(tst--){
    cin>>n>>k;
    string ans="";
     i=j=0;
    //int j=0;
    while(i < n){
        string last = arr[j];
        cnt = n/k;
        int temp1 = min(cnt, n-i);
        if(temp1 < cnt){
            break;
        }
        while(cnt > 0 && i<n){
            i++;
            ans += last;
            --cnt;
        }
        j++;

    }
    if(ans.length() < n){
        while(ans.length() < n){
            ans+=arr[j-1];
        }
    }
    debug1(ans);
}
    //delete [] arr;
    return 0;
}


#include<bits/stdc++.h>
#define fast std::ios::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define ll long long
#define test cout<<"archit\n"
#define debug(x) cout<<x<<" "
#define debug1(x) cout<<x<<"\n"
#define debug2(x,y) cout<<x<<" "<<y<<"\n"
#define pb push_back
#define pi pair<int,int>
#define fi first
#define si second
#define mod (ll)1000000007
using namespace std;
int main()
{
    fast;
    int tst; cin>>tst;
    int n,k,i,j,cnt;
    string* arr = new string[26]();
    for(int i=0;i<26;i++){
        arr[i] = (i+97);
    }
    while(tst--){
    cin>>n>>k;
    string ans="";
     i=j=0;
    //int j=0;
    while(i < n){
        string last = arr[j];
        cnt = n/k;
        int temp1 = min(cnt, n-i);
        if(temp1 < cnt){
            break;
        }
        while(cnt > 0 && i<n){
            i++;
            ans += last;
            --cnt;
        }
        j++;

    }
    if(ans.length() < n){
        while(ans.length() < n){
            ans+=arr[j-1];
        }
    }
    debug1(ans);
}
    delete [] arr;
    return 0;
}


#include<bits/stdc++.h>
#define fast std::ios::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define ll long long
#define test cout<<"archit\n"
#define debug(x) cout<<x<<" "
#define debug1(x) cout<<x<<"\n"
#define debug2(x,y) cout<<x<<" "<<y<<"\n"
#define pb push_back
#define pi pair<int,int>
#define fi first
#define si second
#define mod (ll)1000000007
using namespace std;
int main()
{
    fast;
    int tst; cin>>tst;
    int n,k,i,j,cnt;
    string arr[26];
    for(int i=0;i<26;i++){
        arr[i] = (i+97);
    }
    while(tst--){
    cin>>n>>k;
    string ans="";
     i=j=0;
    //int j=0;
    while(i < n){
        string last = arr[j];
        cnt = n/k;
        int temp1 = min(cnt, n-i);
        if(temp1 < cnt){
            break;
        }
        while(cnt > 0 && i<n){
            i++;
            ans += last;
            --cnt;
        }
        j++;

    }
    if(ans.length() < n){
        while(ans.length() < n){
            ans+=arr[j-1];
        }
    }
    debug1(ans);
}
    //delete [] arr;
    return 0;
}


#include<bits/stdc++.h>
#define fast std::ios::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define ll long long
#define test cout<<"archit\n"
#define debug(x) cout<<x<<" "
#define debug1(x) cout<<x<<"\n"
#define debug2(x,y) cout<<x<<" "<<y<<"\n"
#define pb push_back
#define pi pair<int,int>
#define fi first
#define si second
#define mod (ll)1000000007
using namespace std;
int main()
{
    fast;
    int tst; cin>>tst;
    int n,k,i,j,cnt;
    while(tst--){
    cin>>n>>k;
    char ans[n];
     i=j=0;
    //int j=0;
    while(i < n){
        char last = char(j)+97;
        cnt = n/k;
        int temp1 = min(cnt, n-i);
        if(temp1 < cnt){
            break;
        }
        while(cnt > 0 && i<n){
            ans[i++] = last;
            --cnt;
        }
        j++;

    }

    if(i < n){
        while(i < n){
            ans[i++] = char(j-1)+97;
        }
    }
    for( i=0;i<n;i++){
        cout<<ans[i];
    }
    cout<<endl;
}
    //delete [] arr;
    return 0;
}


/// In the name of God ///
#include<bits/stdc++.h>
#define PRIME bool ok(ll x) {ll i ;for(i = 2 ; i * i <= x ; i ++){if(x % i == 0){return 0;}}return 1 ;}
#define MYPOW ll f(ll x, ll y){ll i, s = 1 ;for(i = 1 ; i <= y ; ++ i){s *= x ;}return s ;}
#define DFS vector < ll > v[cs] ; ll us[cs], k ;void dfs(ll x){us[x] = 1 ;k ++ ;for(auto to : v[x]){if(!us[to]){dfs(to) ;}}}
#define ll long long
#define ld long double
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define sz size
#define se second
#define fr first
#define cs 1001000
#define stt string
#define INF 1000000007
#define sc 300200
#define LETS_GO_TEST PRIME  MYPOW  DFS
#define ios ios_base::sync_with_stdio(false);
using namespace std ;

/**-------**////LETS_GO_TEST////**-------**/

ll n, i, k ,kk, ks, kp, sh, j, t;
int main()
{
    ios
    cin >> t;
    while(t > 0)
    {
        cin >> n >> k ;
        string ss = "" ;
        char x = 'a' ;
        for(i = 1 ; i <= k ; ++ i)
        {
            ss += x ;
            x ++ ;
        }
        kk = n / k ;
        n %= k ;
        for(i = 1 ; i <= kk ; ++ i)
        {
            cout << ss ;
        }
        for(i = 1 ; i <= n ; ++ i)
        {
            cout << 'a' ;
        }
        if(t > 1)
        cout << '\n' ;
        -- t ;
    }
    return false ;
}


/// In the name of God ///
#include<bits/stdc++.h>
#define PRIME bool ok(ll x) {ll i ;for(i = 2 ; i * i <= x ; i ++){if(x % i == 0){return 0;}}return 1 ;}
#define MYPOW ll f(ll x, ll y){ll i, s = 1 ;for(i = 1 ; i <= y ; ++ i){s *= x ;}return s ;}
#define DFS vector < ll > v[cs] ; ll us[cs], k ;void dfs(ll x){us[x] = 1 ;k ++ ;for(auto to : v[x]){if(!us[to]){dfs(to) ;}}}
#define ll long long
#define ld long double
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define sz size
#define se second
#define fr first
#define cs 1001000
#define stt string
#define INF 1000000007
#define MOD 998244353
#define sc 300200
#define LETS_GO_TEST PRIME  MYPOW  DFS
#define ios ios_base::sync_with_stdio(false);
using namespace std ;

/**-------**////LETS_GO_TEST////**-------**/

ll a, b, f, k, i, gas, ans ;

int main()
{
    ios
    ll t ;
    cin >> t ;
    while(t > 0)
    {
        ll n ;
        cin >> n >> k ;
        for(i = 1 ; i <= n ; ++ i)
        {
            cout << 'a' ;
        }
        cout << '\n' ;
        t -- ;
    }
    return false ;
}


/// In the name of God ///
#include<bits/stdc++.h>
#define PRIME bool ok(ll x) {ll i ;for(i = 2 ; i * i <= x ; i ++){if(x % i == 0){return 0;}}return 1 ;}
#define MYPOW ll f(ll x, ll y){ll i, s = 1 ;for(i = 1 ; i <= y ; ++ i){s *= x ;}return s ;}
#define DFS vector < ll > v[cs] ; ll us[cs], k ;void dfs(ll x){us[x] = 1 ;k ++ ;for(auto to : v[x]){if(!us[to]){dfs(to) ;}}}
#define ll long long
#define ld long double
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define sz size
#define se second
#define fr first
#define cs 1001000
#define stt string
#define INF 1000000007
#define MOD 998244353
#define sc 300200
#define LETS_GO_TEST PRIME  MYPOW  DFS
#define ios ios_base::sync_with_stdio(false);
using namespace std ;

/**-------**////LETS_GO_TEST////**-------**/

ll a, b, f, k, i, gas, ans ;

int main()
{
    ios
    ll t ;
    cin >> t ;
    while(t > 0)
    {
        ll n ;
        char x = 'a' ;
        cin >> n >> k ;
        for(i = 1 ; i <= n ; ++ i)
        {
            cout << x ;
            x ++ ;
            if(x > 'z')
                x = 'a' ;
        }
        cout << '\n' ;
        t -- ;
    }
    return false ;
}


//Competetive Programming
//By - @ImKaka
//Anyone can use it and customize it for yourself!!

#include<bits/stdc++.h>
using namespace std;
#define ln pf("\n")
#define SSTR( x ) static_cast< std::ostringstream & >( \
                                                      ( std::ostringstream() << std::dec << x ) ).str()
#define I inr()
#define CC inc()
#define SS ins()
#define sp pf(" ")
#define loop(i,a,b) for(int i=a;i<b;i++)
#define pool(i,a,b) for(int i=a;i>=b;i--)
#define pb push_back
#define NORM(x) if(x>=MOD)x-=MOD
#define CLR(x,y) memset(x,y,sizeof(x))
#define mp make_pair
#define um unordered_map
#define ppb pop_back()
#define pf printf
#define pi pair<int,int>
#define sf scanf
#define swi switch
#define vec vector
#define veci vector<int>
#define vecs vector<string>
typedef long long ll;
ll MOD = 1e9+7;
typedef unsigned long long ull;
typedef string str;
void ins(string &s){getline(cin,s);}
int to_num(string s){return atoi(s.c_str());}
ll power(ll x, ll y){ll temp;if( y == 0)return 1;temp = power(x, y/2)%MOD;if (y%2 == 0)return (temp%MOD*temp%MOD)%MOD;else{if(y > 0)return (x%MOD*temp%MOD*temp%MOD)%MOD;else return (temp*temp)/x;}}
void to_binary(ll n){if(n==1){cout<<1; return;}to_binary(n>>1);cout<<n%2;}
ll inr(){ll V;cin>>V;return V;}
str ins(){str s;cin>>s;return s;}
char inc(){char c;cin>>c;return c;}

//======================================
//======================================

bool allSame(string s){
  return (s.find_first_not_of(s[0]) == string::npos);
}

int main(){
  //=================================
   ios_base::sync_with_stdio(false);
   cin.tie(NULL);
  //================================
 int t;
 cin >> t;

 while(t--){
    int n, k;
    cin >> n >> k;
    string temp = "";
    int i = 0;
    for(; i <= k; i++){
        temp+=(char)i;
    }
    while(i!=n) {
        temp+='a';
        i++;
    }

    cout << temp <<endl;
 }

return 0;
}


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

int main(){
  //=================================
   ios_base::sync_with_stdio(false);
   cin.tie(NULL);
  //================================
 int t;
 cin >> t;

 while(t--){
    int n, k;
    cin >> n >> k;
    string temp = "";
    int i = 0;
    for(; i <= k; i++){
        temp+=(char)i;
    }
    while(i!=n) {
        temp+='a';
        i++;
    }

    cout << temp <<endl;
 }
return 0;
}


#include<bits/stdc++.h>

using namespace std;

int main(){
	int t,n,k;
	cin>>t;
	while(t--){
		int x=0, iter=0;
		cin>>n>>k;
		int count= n/k;
		while(x+count<n){
			if(iter > 25) iter=0;
			char ch = 'a'+iter;
			for(int i=0;i<count;i++) cout<<ch;
			x+=count;
			iter++;
		}
		while(x<n){
			char ch = 'a'+(k-1);
			cout<<ch;
			x++;
		}
		cout<<"\n";
	}
	return 0;
}


#include<bits/stdc++.h>

using namespace std;

int main(){
	int t,n,k;
	cin>>t;
	while(t--){
		int x=0, iter=0;
		cin>>n>>k;
		int count= n/k;
		while(x+count<n){
			char ch = 'a'+iter;
			for(int i=0;i<count;i++) cout<<ch;
			iter++;
		x+=count;
		}
		while(x<n){
			char ch = 'a'+(iter-1);
			cout<<ch;
			x++;
		}
		cout<<"\n";
	}
	return 0;
}


#include<bits/stdc++.h>

using namespace std;

int main(){
	int t,n,k;
	cin>>t;
	while(t--){
		int x=0, iter=0;
		cin>>n>>k;
		int count= n/k;
		while(x+count<n){
			char ch = 'a'+iter;
			for(int i=0;i<count;i++) cout<<ch;
			x+=count;
			iter++;
		}
		while(x<n){
			char ch = 'a'+(k-1);
			cout<<ch;
			x++;
		}
		cout<<"\n";
	}
	return 0;
}


#include<bits/stdc++.h>

using namespace std;

int main(){
	int t,n,k;
	cin>>t;
	while(t--){
		int x=0, iter=0;
		cin>>n>>k;
		int count= n/k;
		while(x+count<n){
			if(iter >=k ) iter=0;
			char ch = 'a'+iter;
			for(int i=0;i<count;i++) cout<<ch;
			x+=count;
			iter++;
		}
		while(x<n){
			char ch = 'a'+(k-1);
			cout<<ch;
			x++;
		}
		cout<<"\n";
	}
	return 0;
}


#include<iostream>
using namespace std;
int  main()
{
	int tc;
	cin>>tc;
	 while(tc--)
	 {
	 	 int n,k,i=0;
	 	 cin>>n>>k;
	 	    char str[n];
	 	       if(n<=k)
	 	   {
	 	   	  str[0]='a';
			for(i=1;i<n;i++)
	 	   	   str[i]=str[i-1]+1;
	 	    cout<<str<<endl;
	    }
	        else
	       {
	       	 str[0]='a';
	       	   for(i=1;i<n;i++)
	       	   {
	       	   	   if(i<k)
	       	   	   str[i]=str[i-1]+1;
	       	   	    else if(i%k==0)
	       	   	    str[i]=str[i%k];
	       	   	    else if(i>k)
	       	   	    str[i]=str[(i-1)%k]+1;
				  }
				cout<<str<<endl;
		   }
	 }
}


#include<iostream>
using namespace std;
int  main()
{
	int tc;
	cin>>tc;
	 while(tc--)
	 {
	 	 int n,k,i=0;
	 	 cin>>n>>k;
	 	       if(n<=k)
	 	   {
	 	   	 char x='a';
	 	   	  cout<<x;
			for(i=1;i<n;i++)
	          {
	          	 x=x+1;
	          	 cout<<x;
			  }
			  cout<<endl;
	    }
	        else
	       {
	       	   char y='a';
	       	   cout<<y;
	       	   for(i=1;i<n;i++)
	       	   {
	       	   	   if(i<k)
	       	   	{
	       	   		y=y+1;
						cout<<y;
					  }
	       	   	    else if(i%k==0)
	       	   	    {
	       	   	    	y='a';
	       	   	    	cout<<y;
						  }
	       	   	    else if(i>k && i%k!=0)
	       	   	    {
	       	   	    	y=y+1;
	       	   	    	cout<<y;
						  }
				  }
				  cout<<endl;
		   }
	 }
}


#include<iostream>
using namespace std;
int  main()
{
	int tc;
	cin>>tc;
	 while(tc--)
	 {
	 	 int n,k,i=0;
	 	 cin>>n>>k;
	 	       if(n<=k)
	 	   {
	 	   	 char x='a';
	 	   	  cout<<x;
			for(i=1;i<n;i++)
	          {
	          	 x=x+1;
	          	 cout<<x;
			  }
	    }
	        else
	       {
	       	   char y='a';
	       	   cout<<y;
	       	   for(i=1;i<n;i++)
	       	   {
	       	   	   if(i<k)
	       	   	{
	       	   		y=y+1;
						cout<<y;
					  }
	       	   	    else if(i%k==0)
	       	   	    {
	       	   	    	y='a';
	       	   	    	cout<<y;
						  }
	       	   	    else if(i>k && i%k!=0)
	       	   	    {
	       	   	    	y=y+1;
	       	   	    	cout<<y;
						  }
				  }
		   }
	 }
}


#include<iostream>
using namespace std;
int  main()
{
	int tc;
	cin>>tc;
	 while(tc--)
	 {
	 	 int n,k,i;
	 	 cin>>n>>k;
	 	    char str[n];
	 	      str[0]='a';
	 	       if(n==k)
	 	   {
			for(i=1;i<n;i++)
	 	   	   str[i]=str[i-1]+1;
	 	    cout<<str<<endl;
	    }
	        else
	       {
	       	   for(i=1;i<n;i++)
	       	   {
	       	   	   if(i<k)
	       	   	   str[i]=str[i-1]+1;
	       	   	    else if(i%k==0)
	       	   	    str[i]=str[i%k];
	       	   	    else if(i>k)
	       	   	    str[i]=str[(i-1)%k]+1;
				  }
				cout<<str<<endl;
		   }
	 }
}


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

using namespace std;
char all[105];
int main()
{
    int i,N,M,T;
    scanf("%d",&T);
    while(T--)
    {

        scanf("%d %d",&N,&M);
        for(i=0;i<N;i++)
        {
            printf("%c",'a'+i%M);
        }
        printf("\n");
    }
    return 0;
}


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

using namespace std;
char all[105];
int main()
{
    int i,N,M,T;
    scanf("%d",&T);
    while(T--)
    {

        scanf("%d %d",&N,&M);
        for(i=0;i<N;i++)
        {
            printf("%c",'a'+i%M);
        }
    }
    return 0;
}


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

using namespace std;
char all[105];
int main()
{
    int i,N,M,T;
    scanf("%d",&T);
    while(T--)
    {

        scanf("%d %d",&N,&M);
        for(i=0;i<N;i++)
        {
            printf("%c",'a'+i%M);

        printf("\n");
    }
    return 0;
}


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

using namespace std;
char all[105];
int main()
{
    int i,N,M;
    scanf("%d %d",&N,&M);
    for(i=0;i<N;i++)
    {
        printf("%c",'a'+i%M);
    }
    return 0;
}


#include <iostream>
#include<vector>
#include<set>
#include<deque>
#include<algorithm>
#include<map>
#define ll long long
#define pb push_back
#define mp make_pair

using namespace std;
ll minm(ll a,ll b){
    if(a>=b) return b;
    else return a;
}
ll minm(ll,ll);

int main(){
    int t;
    cin>>t;
    while(t--){
        int n,k;cin>>n>>k;
        int count=0;
        int temp=0;
        while(count<=n){
            int temp=0;
            for(int i=97;i<97+k;i++){
                cout<<char(i);
                count=count+1;
                if(count>=n){
                    temp=1;break;
                }
            }
            if(temp==1) break;
        }
    }
}


#include <iostream>
#include<vector>
#include<set>
#include<deque>
#include<algorithm>
#include<map>
#define ll long long
#define pb push_back
#define mp make_pair

using namespace std;
ll minm(ll a,ll b){
    if(a>=b) return b;
    else return a;
}
ll minm(ll,ll);

int main(){
    int t;
    while(t--){
        int n,k;cin>>n>>k;
        int count=0;
        int temp=0;
        while(count<=n){
            int temp=0;
            for(int i=97;i<97+k;i++){
                cout<<char(i);
                count=count+1;
                if(count>=n){
                    temp=1;break;
                }
            }
            if(temp==1) break;
        }
    }
}


#include <iostream>
#include<vector>
#include<set>
#include<deque>
#include<algorithm>
#include<map>
#define ll long long
#define pb push_back
#define mp make_pair

using namespace std;
ll minm(ll a,ll b){
    if(a>=b) return b;
    else return a;
}
ll minm(ll,ll);

int main(){
    int t;
    cin>>t;
    while(t--){
        int n,k;cin>>n>>k;
        int count=0;
        while(count<=n){
            int temp=0;
            for(int i=97;i<97+k;i++){
                char c=i;
                cout<<c;
                count=count+1;
                if(count>=n){
                    temp=1;break;
                }
            }
            if(temp==1) break;
        }
    }

}


#include <iostream>
#include<vector>
#include<set>
#include<deque>
#include<algorithm>
#include<map>
#define ll long long
#define pb push_back
#define mp make_pair

using namespace std;
ll minm(ll a,ll b){
    if(a>=b) return b;
    else return a;
}
ll minm(ll,ll);

int main(){
    int t;
    cin>>t;
    while(t--){
        int n,k;cin>>n>>k;
        int count=0;
        int temp=0;
        while(count<=n){
            int temp=0;
            for(int i=97;i<97+k;i++){
                cout<<char(i);
                count=count+1;
                if(count>=n){
                    temp=1;break;
                }
            }
            if(temp==1) break;
        }
        cout<<endl;
    }
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    long long int k,n,d,l;
    cin>>n>>k;
   d=n/k;
   l=n%k;
   int f=0;
   if(n==k)
   {
      char h='a';
      for(int i=0;i<n;i++)
      {
          cout<<h;
          h++;
      }
   }
   else{
   for(int i=(97+k-1);i>=97;i--)
   {

       for(int j=0;j<d;j++)
       {
           printf("%c",i);
       }
   }
   int h=(97+d);
   for(int i=0;i<l;i++)
   {
     printf("%c",h);
     h++;
   }
   }
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    int test;
    cin>>test;
    while(test--)
    {
        long long int k,n,d,l;
    cin>>n>>k;
    int f=0;
    if(n<k)
    {
       k=n;
       d=1;
    }
    else
     {
         d=n/k;
      }
      l=n%k;
    for(char i='a';i<='z';i++)
    {  f++;
        for(int j=0;j<d;j++)
        {
            cout<<i;
        }
        if(f==k)
        {
            break;
        }
    }

    if(n%k!=0)
    { char d='a';
     for(int i=0;i<l;i++)
     {

        cout<<d;
        d++;
     }
    }
    cout<<endl;
    }
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    long long int k,n,d,l;
    cin>>n>>k;
    int f=0;
    if(n<k)
    {
       k=n;
       d=1;
    }
    else
     {
         d=n/k;
      }
      l=n%k;
    for(char i='a';i<='z';i++)
    {  f++;
        for(int j=0;j<d;j++)
        {
            cout<<i;
        }
        if(f==k)
        {
            break;
        }
    }

    if(n%k!=0)
    { char d='a';
     for(int i=0;i<l;i++)
     {

        cout<<d;
        d++;
     }
    }
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    long long int k,n,d,l;
    cin>>n>>k;
   d=n/k;
   l=n%k;
   int f=0;
   if(n==k)
   {
      char h='a';
      for(int i=0;i<n;i++)
      {
          cout<<h;
          h++;
      }
   }
   else{
   for(int i=(97+k-1);i>=97;i--)
   {

       for(int j=0;j<d;j++)
       {
           printf("%c",i);
       }
   }
   int h=97;
   for(int i=0;i<l;i++)
   {
     printf("%c",h);
     h++;
   }
   }
}


#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
using namespace std;
int main()
{
 int t,x,y;
 cin>>t;
 string s="";
 char z='a';
 for(int i=0;i<t;i++){
    cin>>x>>y;
    for(int j=0;j<x;j++){
        s+=z;
      if(s.length()<y)z++;
    }
    cout<<s<<endl;
    s="";
    z='a';
 }

    return 0;
}


#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
using namespace std;
int main()
{
 int t,x,y,a;
 cin>>t;
 string s="",s1="";
 char z='a';
 for(int i=0;i<t;i++){
    cin>>x>>y;
    a=x/y;
    for(int j=0;j<y;j++){
        s+=z;
         z++;
    }
    z--;
    for(int k=0;k<a;k++)s1+=s;
    for(int f=s1.length();f<x;f++)s1+=z;
cout<<s1<<endl;
    s="";
    s1="";
    z='a';
 }

    return 0;
}


#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
using namespace std;
int main()
{
 int t,x,y,a;
 cin>>t;
 string s="",s1="";
 char z='a';
 for(int i=0;i<t;i++){
    cin>>x>>y;
    a=x/y;
    for(int j=0;j<y;j++){
        s+=z;
         z++;
    }
    z--;
    for(int k=0;k<a;k++)s1+=s;
    for(int f=s1.length();f<x;f++)s1+=z;
    s="";
    s1="";
    z='a';
 }

    return 0;
}


#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
using namespace std;
int main()
{
 int t,x,y,a;
 cin>>t;
 string s="",s1="";
 char z='a';
 for(int i=0;i<t;i++){
    cin>>x>>y;
    a=x/y;
    for(int j=0;j<y;j++){
        s+=z;
         z++;
    }
   z='a';
    for(int k=0;k<a;k++)s1+=s;
    for(int f=s1.length();f<x;f++)s1+=z;
    cout<<s1<<endl;
    s="";
    s1="";
 }

    return 0;
}


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

typedef unsigned long long int ulli;
typedef long long int lli;
typedef unsigned int ui;

int main() {
    ui t, n, k;

    string s;
    cin >> t;
    while(t--){
        cin >> n >> k;
        s = "";
        for (ui i = 0; i < n; i += k){
            char c = 'a';
            for (ui i = 0; i < k; ++i){
                s += c + i;
            }
            if(n - s.length() == 1 and n % k != 0){
                s +=c;
                break;
            }
        }
        cout << s << endl;
    }
    return 0;
}


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

typedef unsigned long long int ulli;
typedef long long int lli;
typedef unsigned int ui;

int main() {
    ui t, n, k;

    string s;
    cin >> t;
    while(t--){
        cin >> n >> k;
        s = "";
        for (ui i = 0; i < n; i += k){
            char c = 'a';
            for (ui i = 0; i < k; ++i)
                s += c + i;
            if(n - s.length() < k){

                //cout << n - s.length() << endl;
                c = 'a';
                ui r = (n - s.length());
                for (int i = 0; i < r; i++){
                    //cout << i << endl;
                    s += c + i;
                }

                //cout << s.length() << endl;
                break;
            }
        }
        cout << s << endl;
    }
    return 0;
}


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

typedef unsigned long long int ulli;
typedef long long int lli;
typedef unsigned int ui;

int main() {
    ui t, n, k;

    string s;
    cin >> t;
    while(t--){
        cin >> n >> k;
        s = "";
        for (ui i = 0; i < n; i += k){
            char c = 'a';
            for (ui i = 0; i < k; ++i){
                s += c + i;
            }
            if(n - s.length() == 1){
                s += c;
                break;
            }
        }
        cout << s << endl;
    }
    return 0;
}


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

typedef unsigned long long int ulli;
typedef long long int lli;
typedef unsigned int ui;

int main() {
    ui t, n, k;

    string s;
    cin >> t;
    while(t--){
        cin >> n >> k;
        s = "";
        char c = 'a';
        ui f = n / k;
        for (ui i = 0; i < n; i += f){
            for (ui i = 0; i < f; ++i){
                s += c;
            }
            if(n - s.length() == 1 and n % f != 0){
                s +=c;
                break;
            }
            c = c + 1;
            if(c == 'z' + 1)
                c = 'a';
        }
        cout << s << endl;
    }
    return 0;
}


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

int main()
{
    int t;
    int n,k;
    cin >> t;
    while(n--)
    {
        cin >> n >> k;
        for(int i = 1;i <= n;i++)
        {
            cout << (char)((i%k+'a'));
        }
        cout << endl;
    }
    return 0;
}


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

int main()
{
    int t;
    int n,k;
    cin >> t;
    while(n--)
    {
        cin >> n >> k;
        for(int i = 1;i <= n;i++)
        {
            cout << (char)((i-1)%k+'a');
        }
        cout << endl;
    }
    return 0;
}


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

int main()
{
    int t;
    int n,k;
    cin >> t;
    while(n--)
    {
        cin >> n >> k;
        for(int i = 1;i <= n;i++)
        {
            cout << (char)((i-1)%min(k,26)+'a');
        }
        cout << endl;
    }
    return 0;
}


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

int main()
{
    int t;
    int n,k;
    cin >> t;
    while(t--)
    {
        cin >> n >> k;
        for(int i = 1;i <= n;i++)
        {
            cout << (char)((i-1)%min(k,26)+'a');
        }
        cout << endl;
    }
    return 0;
}


//author-micheal corleone
//the godfather
#include <bits/stdc++.h>
#include <set>
#include<algorithm>

#include <set>
#include<algorithm>
#define ll long long int
#define endl "\n"
const int MOD = 1e9+7;
#define f(i,a,n) for(int i=a;i<n;i++)
#define pb push_back

using namespace std;

bool sortcol( const vector<int>& v1,
               const vector<int>& v2 ) {
 return v1[1] < v2[1];
}
 ll mod_pow(int a,int b,int M = MOD)
{
    int res = 1;

    while(b)
    {
        if(b&1) res=(res*a)%M;
        a=(a*a)%M;
        b>>=1;
    }

    return res;
}

ll ncr(ll n,ll r){if(n==1 || r==0)return 1;if(r>n/2)r=n-r;
	ll ans=1;for(ll i=1;i<=r;i++){ans=((ans * n )/i);n--;}return ans;
}
ll ncrsum(ll n,ll r, ll mod){
    if(n==1 || r==0)return 1;
  //  ll ans=1,sum=1;for(ll i=1;i<=r;i++){ans=((((ans * n)%MOD )*modinv(i,MOD))%mod);n--;sum+=ans;sum%=mod;}return sum;
}

 ll freq[200009]={0};

int main()
{
	ios_base::sync_with_stdio(0);
   cin.tie(0);
    cout.tie(0);

     ll t;
     cin>>t;
     //t=1;
   while(t--)
    {
        ll n,i1,i2,k,m,j,j1,a1,f,i31,i3,j2,i5,i4,i6,i7,i;
        ll x=0,y;
        ll cnt=0,total=0,sum1=0;

        y=0;
    	ll res,res1,ans,res2;
        ans=1,res=1;
        res1=0;
        ll s1,s2,s3;
        s2=0;
        s1=0;
        string s,aa;
         cin>>n>>k;
         for(i=0;i<n;i++)
         {
         	printf("%c",i%k+'a');
		 }
    	cout<<endl;
	}
}


//author-micheal corleone
//the godfather
#include <bits/stdc++.h>
#include <set>
#include<algorithm>

#include <set>
#include<algorithm>
#define ll long long int
#define endl "\n"
const int MOD = 1e9+7;
#define f(i,a,n) for(int i=a;i<n;i++)
#define pb push_back

using namespace std;

bool sortcol( const vector<int>& v1,
               const vector<int>& v2 ) {
 return v1[1] < v2[1];
}
 ll mod_pow(int a,int b,int M = MOD)
{
    int res = 1;

    while(b)
    {
        if(b&1) res=(res*a)%M;
        a=(a*a)%M;
        b>>=1;
    }

    return res;
}

ll ncr(ll n,ll r){if(n==1 || r==0)return 1;if(r>n/2)r=n-r;
	ll ans=1;for(ll i=1;i<=r;i++){ans=((ans * n )/i);n--;}return ans;
}
ll ncrsum(ll n,ll r, ll mod){
    if(n==1 || r==0)return 1;
  //  ll ans=1,sum=1;for(ll i=1;i<=r;i++){ans=((((ans * n)%MOD )*modinv(i,MOD))%mod);n--;sum+=ans;sum%=mod;}return sum;
}

 ll freq[200009]={0};

int main()
{
	ios_base::sync_with_stdio(0);
   cin.tie(0);
    cout.tie(0);

     ll t;
     cin>>t;
     //t=1;
   while(t--)
    {
        ll n,i1,i2,k,m,j,j1,a1,f,i31,i3,j2,i5,i4,i6,i7,i;
        ll x=0,y;
        ll cnt=0,total=0,sum1=0;

        y=0;
    	ll res,res1,ans,res2;
        ans=1,res=1;
        res1=0;
        ll s1,s2,s3;
        s2=0;
        s1=0;
        string s,aa;
         cin>>n>>k;
         for(i=0;i<n;i++)
         {
         	printf("%c",i%k+'a');
		 }

	}
}


#include <iostream>
#include <vector>
#include <string.h>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <sstream>
#include <stack>
#include <iomanip>
#include <fstream>
#include <assert.h>
#include <cmath>
#include <climits>
#include <functional>
#include <complex>
#include <cmath>
#define fi first
#define se second
#define th second
#define FI first
#define SE second.first
#define TH second.second

using namespace std;

typedef long long ll;
typedef pair<int, int> ii;
typedef pair<ll, ii> iii;
typedef long double ld;
typedef complex<double> cd;

const int maxN = 1e3 + 9, lg = 19, MOD = 0 , maxV = 1e2 + 9, lim = 900, INF = 1e9;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    int t;
    cin >> t;
    while(t--){
        int n, k;
        cin >> n >> k;

        for(int i = 0; i < n; i++){
            cout << char('a' + i % k);
        }cout << '\n';

    }

}

/*
 5 2 3
 1 -1 1 -1 2

 3 2 3
 1 -1 1
 */


//author-micheal corleone
//the godfather
#include <bits/stdc++.h>
#include <set>
#include<algorithm>

#include <set>
#include<algorithm>
#define ll long long int
#define endl "\n"
const int MOD = 1e9+7;
#define f(i,a,n) for(int i=a;i<n;i++)
#define pb push_back

using namespace std;

bool sortcol( const vector<int>& v1,
               const vector<int>& v2 ) {
 return v1[1] < v2[1];
}
 ll mod_pow(int a,int b,int M = MOD)
{
    int res = 1;

    while(b)
    {
        if(b&1) res=(res*a)%M;
        a=(a*a)%M;
        b>>=1;
    }

    return res;
}

ll ncr(ll n,ll r){if(n==1 || r==0)return 1;if(r>n/2)r=n-r;
	ll ans=1;for(ll i=1;i<=r;i++){ans=((ans * n )/i);n--;}return ans;
}
ll ncrsum(ll n,ll r, ll mod){
    if(n==1 || r==0)return 1;
  //  ll ans=1,sum=1;for(ll i=1;i<=r;i++){ans=((((ans * n)%MOD )*modinv(i,MOD))%mod);n--;sum+=ans;sum%=mod;}return sum;
}

 ll freq[200009]={0};

int main()
{
	ios_base::sync_with_stdio(0);
   cin.tie(0);
    cout.tie(0);

     ll t;
     //cin>>t;
     t=1;
   while(t--)
    {
        ll n,i1,i2,k,m,j,j1,a1,f,i31,i3,j2,i5,i4,i6,i7,i;
        ll x=0,y;
        ll cnt=0,total=0,sum1=0;

        y=0;
    	ll res,res1,ans,res2;
        ans=1,res=1;
        res1=0;
        ll s1,s2,s3;
        s2=0;
        s1=0;
        string s,aa;
         cin>>n>>k;
         for(i=0;i<n;i++)
         {
         	printf("%c",i%k+'a');
		 }

	}
}


#include <bits/stdc++.h>
#define ll long long
#define N int(1e5+10)
#define MOD int(1e9+7)
using namespace std;
int s,k;
long long a[N];
set<long long>se;
vector<long long>ans;
long long sum=0;
int main() {
  //Parparosa
  #ifndef ONLINE_JUDGE
  freopen("input.txt","r",stdin);
  freopen("output.txt","w",stdout);
  #endif
  int t;
  cin>>t;
  while(t--)
  {
    int n,k;
    cin>>n>>k;
    int a=0;
    for(int i=0;i<n;i++)
      cout<<char((i%k)+'a');
    cout<<endl;
  }
}


#include <bits/stdc++.h>
#define ll long long
#define N int(1e5+10)
#define MOD int(1e9+7)
using namespace std;
int s,k;
long long a[N];
set<long long>se;
vector<long long>ans;
long long sum=0;
int main() {
  //Parparosa
  #ifndef ONLINE_JUDGE
  freopen("input.txt","r",stdin);
  freopen("output.txt","w",stdout);
  #endif
  int t;
  cin>>t;
  while(t--)
  {
    int n,k;
    cin>>n>>k;
    int a=0;
    for(int i=0;i<n;i++)
      if(i<k){cout<<char(i+'a');a=i+1;}
      else cout<<char(a+'a');
    cout<<endl;
  }
}


#include <bits/stdc++.h>
#define ll long long
#define N int(1e5+10)
#define MOD int(1e9+7)
using namespace std;
int s,k;
long long a[N];
set<long long>se;
vector<long long>ans;
long long sum=0;
int main() {
  //Parparosa
  #ifndef ONLINE_JUDGE
  freopen("input.txt","r",stdin);
  freopen("output.txt","w",stdout);
  #endif
  int t;
  cin>>t;
  while(t--)
  {
    int n,k;
    cin>>n>>k;
    for(int i=0;i<n;i++)
      if(i%2==0)cout<<'a';
    else cout<<'b';
    cout<<endl;
  }
}


#include <bits/stdc++.h>
#define ll long long
#define N int(1e5+10)
#define MOD int(1e9+7)
using namespace std;
int s,k;
long long a[N];
set<long long>se;
vector<long long>ans;
long long sum=0;
int main() {
  //Parparosa
  #ifndef ONLINE_JUDGE
  freopen("input.txt","r",stdin);
  freopen("output.txt","w",stdout);
  #endif
  int t;
  cin>>t;
  while(t--)
  {
    int n,k;
    cin>>n>>k;
    for(int i=0;i<n;i++)
      cout<<char((i%'a')+'a');
    cout<<endl;
  }
}


#include <bits/stdc++.h>
#define ll long long
#define N int(1e5+10)
#define MOD int(1e9+7)
using namespace std;
int s,k;
long long a[N];
set<long long>se;
vector<long long>ans;
long long sum=0;
int main() {
  //Parparosa
  #ifndef ONLINE_JUDGE
  freopen("input.txt","r",stdin);
  freopen("output.txt","w",stdout);
  #endif
  int t;
  cin>>t;
  while(t--)
  {
    int n,k;
    cin>>n>>k;
    int a=0;
    for(int i=0;i<n;i++)
      if(i<k-1){cout<<char(i+'a');a=i;}
      else cout<<char(a+'a');
    cout<<endl;
  }
}


#include <bits/stdc++.h>
#define ll long long
#define N int(1e5+10)
#define MOD int(1e9+7)
using namespace std;
int s,k;
long long a[N];
set<long long>se;
vector<long long>ans;
long long sum=0;
int main() {
  //Parparosa
  #ifndef ONLINE_JUDGE
  freopen("input.txt","r",stdin);
  freopen("output.txt","w",stdout);
  #endif
  int t;
  cin>>t;
  while(t--)
  {
    int n,k;
    cin>>n>>k;
    for(int i=0;i<n;i++)
      cout<<'a';
    cout<<endl;
  }
}


#include <bits/stdc++.h>
#define ll long long
#define N int(1e5+10)
#define MOD int(1e9+7)
using namespace std;
int s,k;
long long a[N];
set<long long>se;
vector<long long>ans;
long long sum=0;
int main() {
  //Parparosa
  #ifndef ONLINE_JUDGE
  freopen("input.txt","r",stdin);
  freopen("output.txt","w",stdout);
  #endif
  int t;
  cin>>t;
  while(t--)
  {
    int n,k;
    cin>>n>>k;
    int a=0;
    for(int i=0;i<n;i++)
      if(i<=k-1){cout<<char(i+'a');a=i;}
      else cout<<char(a+'a');
    cout<<endl;
  }
}


#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <unordered_map>
#define lld long long int
#define DBG1(vari1) cerr<<#vari1<<" = "<<(vari1)<<endl;
#define DBG2(vari1,vari2) cerr<<#vari1<<" = "<<(vari1)<<" "<<#vari2<<" = "<<(vari2)<<endl;
#define DBG3(vari1,vari2,vari3) cerr<<#vari1<<" = "<<(vari1)<<" "<<#vari2<<" = "<<(vari2)<<" "<<#vari3<<" = "<<(vari3)<<endl;
using namespace std;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
	//Haan hoon mai chutiya, khush?
	int t;
	cin >> t;
	while(t--)
	{
		int n,k;
		cin >> n >> k;
		int rem = n%k;
		string temp="";
		char ch = 'a';
		if(rem==0)
		{
			for(int i=0;i<n;i+=(n/k))
			{
				int a=0;
				while(a<(n/k))
				{
					temp+=(ch);
					a++;
				}
				ch++;
			}
		}
		else
		{
			for(int i=0;i<n-1;i+=(n/k))
			{
				int a=0;
				while(a<(n/k))
				{
					temp+=(ch);
					a++;
				}
				ch++;
			}
			ch--;
			temp+=ch;
		}
		cout << temp << endl;
	}
}


#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <unordered_map>
#define lld long long int
#define DBG1(vari1) cerr<<#vari1<<" = "<<(vari1)<<endl;
#define DBG2(vari1,vari2) cerr<<#vari1<<" = "<<(vari1)<<" "<<#vari2<<" = "<<(vari2)<<endl;
#define DBG3(vari1,vari2,vari3) cerr<<#vari1<<" = "<<(vari1)<<" "<<#vari2<<" = "<<(vari2)<<" "<<#vari3<<" = "<<(vari3)<<endl;
using namespace std;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
	//Haan hoon mai chutiya, khush?
	int t;
	cin >> t;
	while(t--)
	{
		int n,k;
		cin >> n >> k;
		int rem = n%k;
		string temp="";
		char ch = 'a';
		if(rem==0)
		{
			for(int i=0;i<n;i+=(n/k))
			{
				int a=0;
				while(a<(n/k))
				{
					temp+=(ch);
					a++;
				}
				ch++;
			}
		}
		else
		{
			for(int i=0;i<n-1;i+=(n/k))
			{
				int a=0;
				while(a<(n/k))
				{
					temp+=(ch);
					a++;
				}
				ch++;
			}
			temp+=ch;
		}
		cout << temp << endl;
	}
}


#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <unordered_map>
#define lld long long int
#define DBG1(vari1) cerr<<#vari1<<" = "<<(vari1)<<endl;
#define DBG2(vari1,vari2) cerr<<#vari1<<" = "<<(vari1)<<" "<<#vari2<<" = "<<(vari2)<<endl;
#define DBG3(vari1,vari2,vari3) cerr<<#vari1<<" = "<<(vari1)<<" "<<#vari2<<" = "<<(vari2)<<" "<<#vari3<<" = "<<(vari3)<<endl;
using namespace std;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
	//Haan hoon mai chutiya, khush?
	int t;
	cin >> t;
	while(t--)
	{
		int n,k;
		cin >> n >> k;
		int rem = n%k;
		string temp="";
		char ch = 'a';
		if(rem==0)
		{
			for(int i=0;i<n;i+=(n/k))
			{
				int a=0;
				while(a<(n/k))
				{
					temp+=(ch);
					a++;
				}
				ch++;
			}
		}
		else
		{
			for(int i=0;i<n-rem;i+=(n/k))
			{
				int a=0;
				while(a<(n/k))
				{
					temp+=(ch);
					a++;
				}
				ch++;
			}

				int i=0;
				ch--;
				while(i<rem)
				{
					temp+=ch;
					i++;
				}
		}
		cout << temp << endl;
	}
}


#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <unordered_map>
#define lld long long int
#define DBG1(vari1) cerr<<#vari1<<" = "<<(vari1)<<endl;
#define DBG2(vari1,vari2) cerr<<#vari1<<" = "<<(vari1)<<" "<<#vari2<<" = "<<(vari2)<<endl;
#define DBG3(vari1,vari2,vari3) cerr<<#vari1<<" = "<<(vari1)<<" "<<#vari2<<" = "<<(vari2)<<" "<<#vari3<<" = "<<(vari3)<<endl;
using namespace std;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
	//Haan hoon mai chutiya, khush?
	int t;
	cin >> t;
	while(t--)
	{
		int n,k;
		cin >> n >> k;
		int rem = n%k;
		string temp="";
		char ch = 'a';
		if(rem==0)
		{
			for(int i=0;i<n;i+=(n/k))
			{
				int a=0;
				while(a<(n/k))
				{
					temp+=(ch);
					a++;
				}
				ch++;
			}
		}
		else
		{
			for(int i=0;i<n-rem;i+=(n/k))
			{
				int a=0;
				while(a<(n/k))
				{
					temp+=(ch);
					a++;
				}
				ch++;
			}
			if(rem==1)
			{
			ch--;
			temp+=ch;
			}
			else
			{
				int i=0;
				while(i<rem)
				{
					temp+=ch;
					i++;
				}
			}
		}
		cout << temp << endl;
	}
}


#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <unordered_map>
#define lld long long int
#define DBG1(vari1) cerr<<#vari1<<" = "<<(vari1)<<endl;
#define DBG2(vari1,vari2) cerr<<#vari1<<" = "<<(vari1)<<" "<<#vari2<<" = "<<(vari2)<<endl;
#define DBG3(vari1,vari2,vari3) cerr<<#vari1<<" = "<<(vari1)<<" "<<#vari2<<" = "<<(vari2)<<" "<<#vari3<<" = "<<(vari3)<<endl;
using namespace std;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
	//Haan hoon mai chutiya, khush?
	int t;
	cin >> t;
	while(t--)
	{
		int n,k;
		cin >> n >> k;
		int rem = n%k;
		string temp="";
		char ch = 'a';
		if(rem==0)
		{
			for(int i=0;i<n;i+=(n/k))
			{
				int a=0;
				while(a<(n/k))
				{
					temp+=(ch);
					a++;
				}
				ch++;
			}
		}
		else
		{
			for(int i=0;i<n-rem;i+=(n/k))
			{
				int a=0;
				while(a<(n/k))
				{
					temp+=(ch);
					a++;
				}
				ch++;
			}
			if(rem==1)
			{
			ch--;
			temp+=ch;
			}
			else
			{
				int i=0;
				while(i<rem)
				{
					temp+=ch;
					i++;
					if(i%(n/k)==0)
						ch++;
				}
			}
		}
		cout << temp << endl;
	}
}


#include <bits/stdc++.h>
#define endl '\n'
#define all(c) c.begin(), c.end()

using namespace std;

typedef long long int ll;
typedef long double ld;

const ll mod = 1e9 + 7;
const ld PI = 3.141592653589793;
const long long INF=pow(2,32);

main(){
    ios_base::sync_with_stdio(false);
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif

    int t;
    cin>>t;
    for (int i=0; i<t; i++) {
        int n,k;
        cin>>n>>k;
        vector <int> v(k,n/k);
        for (int j=0; j<k; j++) {
            char s=(j%k)+'a';
         for (int k=0; k<v[j]; k++) cout<<s;
        }
    for (int j=0; j<n%k; j++) {
        char s=(j%k)+'a';
        cout<<s;
    }
    cout<<endl;
    }
    cerr<<"Time Lapsed : "<<1.0*clock()/CLOCKS_PER_SEC<<endl;
    return 0;
       }


#include <bits/stdc++.h>
#define endl '\n'
#define all(c) c.begin(), c.end()

using namespace std;

typedef long long int ll;
typedef long double ld;

const ll mod = 1e9 + 7;
const ld PI = 3.141592653589793;
const long long INF=pow(2,32);

main(){
    ios_base::sync_with_stdio(false);
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif

    int t;
    cin>>t;
    for (int i=0; i<t; i++) {
        int n,k;
        cin>>n>>k;
        vector <int> v(k,n/k);
        if (n%k!=0) v[0]++;
        for (int j=0; j<k; j++) {
            char s=(j%k)+'a';
         for (int k=0; k<v[j]; k++) cout<<s;
        }
    cout<<endl;
    }
    cerr<<"Time Lapsed : "<<1.0*clock()/CLOCKS_PER_SEC<<endl;
    return 0;
       }


#include <bits/stdc++.h>
#define endl '\n'
#define all(c) c.begin(), c.end()

using namespace std;

typedef long long int ll;
typedef long double ld;

const ll mod = 1e9 + 7;
const ld PI = 3.141592653589793;
const long long INF=pow(2,32);

main(){
    ios_base::sync_with_stdio(false);
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif

    int t;
    cin>>t;
    for (int i=0; i<t; i++) {
        int n,k;
        cin>>n>>k;
        vector <int> v(26,n/k);
        if (n%k!=0) v[0]++;
        for (int j=0; j<k; j++) {
            char s=j+'a';
         for (int k=0; k<v[j]; k++) cout<<s;
        }
    cout<<endl;
    }
    cerr<<"Time Lapsed : "<<1.0*clock()/CLOCKS_PER_SEC<<endl;
    return 0;
       }


#include <bits/stdc++.h>
#define endl '\n'
#define all(c) c.begin(), c.end()

using namespace std;

typedef long long int ll;
typedef long double ld;

const ll mod = 1e9 + 7;
const ld PI = 3.141592653589793;
const long long INF=pow(2,32);

main(){
    ios_base::sync_with_stdio(false);
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif

    int t;
    cin>>t;
    for (int i=0; i<t; i++) {
        int n,k;
        cin>>n>>k;
        vector <int> v(26,n/k);
        if (n%k!=0) v[0]++;
        for (int j=0; j<k; j++) {
            char s=(j%26)+'a';
         for (int k=0; k<v[j]; k++) cout<<s;
        }
    cout<<endl;
    }
    cerr<<"Time Lapsed : "<<1.0*clock()/CLOCKS_PER_SEC<<endl;
    return 0;
       }


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ll t,n,m,x,i;
    cin>>t;
    char j;

    while(t--)
    {
        cin>>n>>m;

        x=n/m;
        if(n%m==0)
        {
            for(j='a';j<'a'+m;j++){
            for(i=0;i<x;i++)
            {
                cout<<j;
            }
            }
            cout<<endl;
        }

        else
        {
            for(j='a';j<'a'+x;j++)
            {
            for(i=0;i<x;i++)
               {
                   cout<<j;
               }
            }
            cout<<'a'<<endl;
        }
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ll t,n,m,x,i;
    cin>>t;
    char j;

    while(t--)
    {
        cin>>n>>m;

        x=n/m;
        if(n%m==0)
        {
            for(j='a';j<'a'+m;j++){
            for(i=0;i<x;i++)
            {
                cout<<j;
            }
            }
            cout<<endl;
        }

        else
        {
            for(j='a';j<'a'+m;j++)
            {
            for(i=0;i<x;i++)
               {
                   cout<<j;
               }
            }
            cout<<'a'<<endl;
        }
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int t,n,m,i;
    cin>>t;

    while(t--)
    {
        cin>>n>>m;

        for(i=0;i<n;i++)
        {
            cout<<char('a'+i%m);
        }
        cout<<endl;
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ll t,n,m,x,i;
    cin>>t;
    char j;

    while(t--)
    {
        cin>>n>>m;

        while(n>0)
        {
            for(j='a';j<'a'+m;j++){
                n--;
                cout<<j;
               if(n==0)
               {
                   cout<<endl;
                   break;
               }
            }
        }
    }

    return 0;
}


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

int main(){
      int t;

      while(t--)
      {
		  int n,k;
		  cin>>n>>k;

		  int c = n/k;
		  string st="";
		  while(c--)
		  {
			  st += 'a';
		  }

		  c = n-n/k;

		  while(c--)
		  st += 'z';
	  }
	  return 0;

}


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

int main(){
      int t;

      while(t--)
      {
		  int n,k;
		  cin>>n>>k;

		  int c = n/k;
		  string st="";
		  while(c--)
		  {
			  st += 'a';
		  }

		  c = n-n/k;

		  while(c--)
		  st += 'z';

		  cout<<st<<endl;
	  }
	  return 0;

}


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

int main(){
      int t;
      cin>>t;

     // cout<<(char)97;
      while(t--)
      {
		  int n,k;
		  cin>>n>>k;

		  int c = k,a = (int)'a';
		  string st="",ans="";

		  while(c--)
		  {
			  st += (char)a;
			  ++a;
		  }

		  c = n/k;

		  while(c--)
		  ans += st;

		  a = (int)'a';

		  c = n%k;

		  while( c-- )
		  {
			  ans += (char)a;
			  ++a;
		  }

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

}


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

int main(){
	long long n,count=1;
	cin>>n;
	long long arr[n+1];
	for(long long i=1;i<=n;i++){
		cin>>arr[i];
	}
	long long min=arr[1], t=1;
	for (long long i=2;i<=n;i++){
		if(arr[i]<min){
			min=arr[i];
			t=i;
		}
		else if(arr[i]=min)
			count++;
	}
	if (count>1)
		cout<<"Still Rozdil";
	else cout<<t;

	return 0;
}


#include <iostream>
#include <vector>
#include <sstream>
#include <cmath>
#include <string>

using namespace std;

int main(){
    int n;
    cin>>n;

    int dist;
    int mn= INT_MAX;
    int freq= 0;

    int town= -1;

    for(int i= 0; i<n; i++){
        cin>>dist;

        if(dist < mn){
            mn = dist;
            freq = 1;
            town= i+1;
        }
        else if(dist == mn){
            freq++;
        }
    }

    if(freq == 1){
        cout<< town <<endl;
    }
    else{

        cout<< "Still Rozdil" <<endl;
    }

    return 0;
}


Skip to content

    Why GitHub?

Enterprise
Explore

Marketplace
Pricing

Sign in
Sign up
SH-anonta /
Competitive-Programming-Solutions

3
12

    17

Code
Pull requests 1
Actions
Security
Insights
Join GitHub today

GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.
Competitive-Programming-Solutions/Code Forces/Code forces Div 2/Code forces 205A - Little Elephant and Rozdil.cpp
@SH-anonta SH-anonta CF and UVA entry b933c68 on Oct 6, 2018
44 lines (33 sloc) 596 Bytes
// author: Sofen Hoque Anonta

#include <iostream>
#include <vector>
#include <sstream>
#include <cmath>
#include <string>

using namespace std;

int main(){
    int n;
    cin>>n;

    int dist;
    int mn= INT_MAX;
    int freq= 0;

    int town= -1;

    for(int i= 0; i<n; i++){
        cin>>dist;

        if(dist < mn){
            mn = dist;
            freq = 1;
            town= i+1;
        }
        else if(dist == mn){
            freq++;
        }
    }

    if(freq == 1){
        cout<< town <<endl;
    }
    else{

        cout<< "Still Rozdil" <<endl;
    }

    return 0;
}

    © 2020 GitHub, Inc.
    Terms
    Privacy
    Security
    Status
    Help

    Contact GitHub
    Pricing
    API
    Training
    Blog
    About


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

int main(){
	int n,count=1;
	cin>>n;
	int arr[n+1];
	for(int i=1;i<=n;i++){
		cin>>arr[i];
	}
	int min=arr[1], t=1;
	for (int i=2;i<=n;i++){
		if(arr[i]<min){
			min=arr[i];
			t=i;
		}
		else if(arr[i]=min)
			count++;
	}
	if (count>1)
		cout<<"Still Rozdil";
	else cout<<t;

	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
   int n;cin>>n;int a[n],b[n];
   for(int i=0;i<n;i++)
   {cin>>a[i];b[i]=a[i];}
   sort(a,a+n);
   if(a[0]==a[1])
   cout<<"Still Rozdil";
   else
   {
      for(int i=0;i<n;i++)
      {
         if(a[0]==b[i])
         cout<<i+1;
      }
   }
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;cin>>n;
    int a[n],b[n];
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        b[i]=a[i];
    }

    sort(a,a+n);
    int p=a[0];

    if(a[0]==a[1]) cout<<"Still Rozdil";
    else
    {
        for(int i=0;i<n;i++)
        if(b[i]==p)
        {
            cout<<i+1;
            break;
        }
    }
}


#include<iostream>
using namespace std;
int main()
{
   int n;cin>>n;int a[n];
   for(int i=0;i<n;i++)
   cin>>a[i];
   sort(a,a+n);
   if(a[0]==a[1)
   cout<<"Still Rozdil";
   else cout<<a[0];
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
   int n;cin>>n;int a[n];
   for(int i=0;i<n;i++)
   cin>>a[i];
   sort(a,a+n);
   if(a[0]==a[1])
   cout<<"Still Rozdil";
   else cout<<a[0];
}


#include<iostream>
using namespace std;
int main()
{
   int n;cin>>n;
   for(int i=0;i<n;i++)
   cin>>a[i];
   sort(a,a+n);
   if(a[0]==a[1)
   cout<<"Still Rozdil";
   else cout<<a[0];
}


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

 int main ()
 {

   int n ;
   cin >>n ;
   int mn = 1<<30;
   int in ;
   multiset<int>s ;
   int a;
   for(int i = 1; i<=n ; i++)
   {
   	 cin>>a;
   	 s.insert(a);
   	 if(a<mn){
   	 mn = a ;
     in = i ;
	  }
   }

  if( s.count(mn)==1 )cout<<in;
  else {
  	cout<<"Still Rozdil";

  }

 	return 0 ;
 }


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

 int main ()
 {

   int n ;
   cin >>n ;
   int mn = 1<<20;
   int in ;
   multiset<int>s ;
   int a ;
   for(int i = 1; i<=n ;i ++)
   {
   	 cin>>a;
   	 s.insert(a);
   	 if(a<=mn){
   	 mn = a ;
     in = i ;
	  }
   }

  if( s.count(mn)!=1 ) cout<<"Still Rozdil";
  else {
  	cout<<in;

  }

 	return 0 ;
 }


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

 int main ()
 {

   int n ;
   cin >>n ;
   int mn = 1<<30;
   int in ;
   multiset<int>s ;
   int a;
   for(int i = 1; i<=n ; i++)
   {
   	 cin>>a;
   	 s.insert(a);
   	 if(a<mn){
   	 mn = a ;
     in = i ;
	  }
   }

  if( s.count(mn)==1 )cout<<in;
  else {
  	cout<<"Still Rozdill";

  }

 	return 0 ;
 }


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

 int main ()
 {

   int n ;
   cin >>n ;
   int mn = 1<<20;
   int in ;
   multiset<int>s ;
   int a ;
   for(int i = 1; i<=n ;i ++)
   {
   	 cin>>a;
   	 s.insert(a);
   	 if(a<mn){
   	 mn = a ;
     in = i ;
	  }
   }

  if( s.count(mn)!=1 ) cout<<"Still Rozdil";
  else {
  	cout<<in;

  }

 	return 0 ;
 }


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

 int main ()
 {

   int n ;
   cin >>n ;
   int mn = 1<<30;
   int in ;
   multiset<int>s ;

   for(int i = 1; i<=n ; i++)
   {
   	 cin>>a;
   	 s.insert(a);
   	 if(a<mn){
   	 mn = a ;
     in = i ;
	  }
   }

  if( s.count(mn)==1 )cout<<in;
  else {
  	cout<<"Still Rozdill";

  }

 	return 0 ;
 }


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

 int main ()
 {

   int n ;
   cin >>n ;
   int mn = 1<<20;
   int in ;
   multiset<int>s ;
   int a ;
   for(int i = 1; i<=n ;i ++)
   {
   	 cin>>a;
   	 s.insert(a);
   	 if(a<mn){
   	 mn = a ;
     in = i ;
	  }
   }

  if( s.count(mn)!=1 ) cout<<"Still Rozdill";
  else {
  	cout<<in;

  }

 	return 0 ;
 }


#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
int main(){
   fast
   ll n;
   cin>>n;
   vector<ll> v(n),x;
   for(ll i=0;i<n;i++)
   {
       cin>>v[i];
   }
   x=v;

   sort(v.begin(),v.end());
   ll result=1,minValue=x[0];
   bool b=false;
   if(v[0]==v[1]) cout<<"Still Rozdil\n";
   else {
        for(ll i=1;i<n;i++)
        {
            if(x[i]<minValue) {
                minValue=x[i];
                result=i+1;
                b=true;
            }
        }
   }
   if(b)
   cout<<result<<endl;
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
int main(){
   fast
   ll n;
   cin>>n;
   vector<ll> v(n),x;
   for(ll i=0;i<n;i++)
   {
       cin>>v[i];
   }
   x=v;

   sort(v.begin(),v.end());
   ll result=1,minValue=1000000000;
   bool b=false;
   if(v[0]==v[1]) cout<<"Still Rozdil\n";
   else {
        for(ll i=0;i<n;i++)
        {
            if(x[i]<minValue) {
                minValue=x[i];
                result=i+1;
                b=true;
            }
        }
   }
   if(b)
   cout<<result<<endl;
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
int main(){
   fast
   ll n;
   cin>>n;
   vector<ll> v(n),x;
   for(ll i=0;i<n;i++)
   {
       cin>>v[i];
   }
   x=v;

   sort(v.begin(),v.end());
   ll result=1,minValue=1000000;
   bool b=false;
   if(v[0]==v[1]) cout<<"Still Rozdil\n";
   else {
        for(ll i=0;i<n;i++)
        {
            if(x[i]<minValue) {
                minValue=x[i];
                result=i+1;
                b=true;
            }
        }
   }
   if(b)
   cout<<result<<endl;
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
int main(){
   fast
   ll n;
   cin>>n;
   vector<ll> v(n);
   for(ll i=0;i<n;i++)
   {
       cin>>v[i];
   }
   sort(v.begin(),v.end());
   if(v[0]==v[1]) cout<<"Still Rozdil\n";
   else cout<<v[0]<<endl;
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
int main(){
   fast
   ll n;
   cin>>n;
   vector<ll> v(n),x;
   for(ll i=0;i<n;i++)
   {
       cin>>v[i];
   }
   x=v;

   sort(v.begin(),v.end());
   ll result=1,minValue=1000000000;
   bool b=false;
   if(n==1) cout<<1<<endl;
  else if(v[0]==v[1]) cout<<"Still Rozdil\n";
   else {
        for(ll i=0;i<n;i++)
        {
            if(x[i]<minValue) {
                minValue=x[i];
                result=i+1;
                b=true;
            }
        }
   }
   if(b)
   cout<<result<<endl;
}


#include <bits/stdc++.h>

using namespace std;

int main()
{
    int n;cin>>n; int chk=0;

    int  time[n];

    for(int i=0;i<n;i++)
    {
        cin>>time[i];
    }

    for(int i=0;i<n;i++)
    {
        for(int j=i+1;j<n;j++)
        {
            if(time[i]==time[j])
            {
                chk=1;
                break;
            }
        }

    }
    if(chk==1)
        cout<<"Still Rozdil";
    else
        cout<<n;

}


#include <bits/stdc++.h>

using namespace std;

int main()
{
    int n;cin>>n; int chk=0;

    int  time[n];

    for(int i=0;i<n;i++)
    {
        cin>>time[i];
    }

    for(int i=0;i<n;i++)
    {
        for(int j=i+1;j<n;j++)
        {
            if(time[i]==time[j])
            {
                chk=1;
                break;
            }
        }
        if(chk==1)
        {
            break;
        }

    }
    if(chk==1)
        cout<<"Still Rozdil";
    else
        cout<<*min_element (time, time+n);

}


#include<bits/stdc++.h>

using namespace std;

int main{

    int n, time, min_time(1000000001), min_index(0), count(1);
    scanf("%d", &n);
    for (int i = 1; i <= n; ++i)
    {
        scanf("%d", &time);
        if (time < min_time)
        {
            min_time = time;
            min_index = i;
            count = 1;
        }
        else if (time == min_time)
        {
            count += 1;
        }
    }
    if (count == 1)
    {
        printf("%d\n", min_index);
    }
    else
    {
        printf("Still Rozdil\n");
    }
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

int main()
{
    int n;cin>>n; int chk=0;

    int  time[n];

    for(int i=0;i<n;i++)
    {
        cin>>time[i];
    }

    for(int i=0;i<n;i++)
    {
        for(int j=i+1;j<n;j++)
        {
            if(time[i]==time[j])
            {
                chk=1;
                break;
            }
        }
        if(chk==1)
        {
            break;
        }

    }
    if(chk==1)
        cout<<"Still Rozdil";
    else
        cout<<n;

}


#include <bits/stdc++.h>

using namespace std;

int main()
{

    int n, time, min_time(1000000001), min_index(0), count(1);
    scanf("%d", &n);
    for (int i = 1; i <= n; ++i)
    {
        scanf("%d", &time);
        if (time < min_time)
        {
            min_time = time;
            min_index = i;
            count = 1;
        }
        else if (time == min_time)
        {
            count += 1;
        }
    }
    if (count == 1)
    {
        printf("%d\n", min_index);
    }
    else
    {
        printf("Still Rozdil\n");
    }
    return 0;

}


#include <bits/stdc++.h>

using namespace std;

int main()
{
    int n;
    cin>>n;
    long long int a[n],min=1000000000+3;
    int mini=0,c=0;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        if(a[i]<min)
        {
            min=a[i];

        }
    }
    for(int i=0;i<n;i++)
    {
        if(a[i]==min)
        {
            c++;
            mini=i;
        }

    }
    if(c==1)
    cout<<mini+1;
    else
    cout<<"Still Rozdil";

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

int main()
{
    int n;
    cin>>n;
    long long int a[n],min=1000000000+3;
    int mini,c=0;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        if(a[i]<min)
        {
            min=a[i];
            mini==i;
        }
    }
    for(int i=0;i<n;i++)
    {
        if(a[i]==min)
        c++;
    }
    if(c==1)
    cout<<(mini+1);
    else
    cout<<"Still Rozdil";

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

int main()
{
    int n;
    cin>>n;
    long long int a[n],min=1000000000+3;
    int mini,c=0;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        if(a[i]<min)
        {
            min=a[i];
            mini==i+1;
        }
    }
    for(int i=0;i<n;i++)
    {
        if(a[i]==min)
        c++;
    }
    if(c==1)
    cout<<mini;
    else
    cout<<"Still Rozdil";

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

int main()
{
    int n;
    cin>>n;
    long long int a[n],min=1000000000+3;
    int mini,c=0;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        if(a[i]<min)
        {
            min=a[i];
            mini==i+1;
        }
    }
    for(int i=0;i<n;i++)
    {
        if(a[i]==min)
        c++;
    }
    if(c==1)
    cout<<mini+1;
    else
    cout<<"Still Rozdil";

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

int main()
{
    int n;
    cin>>n;
    long long int a[n],min=1000000000+3;
    int mini,c=0;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        if(a[i]<min)
        {
            min=a[i];
            mini==i;
        }
    }
    for(int i=0;i<n;i++)
    {
        if(a[i]==min)
        c++;
    }
    if(c==1)
    cout<<mini+1;
    else
    cout<<"Still Rozdil";

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long n,t,min,count=0;
	cin>>n;
	long long a[n];
	for(int i=0;i<n;i++)
		{
			cin>>a[i];
		}
		min=a[0];
		for(int i=0;i<n;i++)
		{
			if(a[i]<min)
				min=a[i];
			t=i;
		}
		for(int i=0;i<n;i++)
		{
			if((min==a[i])&&(i!=t))
			{
				count++;
				break;
			}
		}
		if(count)
		{
			cout<<"Still Rozdil";
		}
		else
			cout<<(t+1);
		return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,t,min,count=0;
	cin>>n;
	int a[n];
	for(int i=0;i<n;i++)
		{
			cin>>a[i];
		}
		min=a[0];
		for(int i=0;i<n;i++)
		{
			if(a[i]<min)
				min=a[i];
			t=i;
		}
		for(int i=0;i<n;i++)
		{
			if((min==a[i])&&(i!=t))
			{
				count++;
				break;
			}
		}
		if(count)
		{
			cout<<"Still Rozdil";
		}
		else
			cout<<(t+1);
		return 0;
}


#include<bits/stdc++.h>
#define mkp make_pair
#define pb push_back
#define fr(i,a,b) for(int i =a ; i < b; i++)
#define all(x)           x.begin(), x.end()

using namespace std;
int main()
{
		int n;
		cin>>n;
		vector<pair<int,int> > v;
		fr(i,0,n){
			int x;cin>>x;v.pb(mkp(x,i+1));
		}
		sort(all(v));

		if(n!=1 && v[1].first==v[0].first)
			cout<<"Still Rozdil"<<endl;
		else
			cout<<v[0].second<<endl;

}


#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long n,t,min,count=0;
	cin>>n;
	long long a[n];
	for(long long i=0;i<n;i++)
		{
			cin>>a[i];
		}
		min=a[0];
		for(long long i=0;i<n;i++)
		{
			if(a[i]<min)
				min=a[i];
			t=i;
		}
		for(long long i=0;i<n;i++)
		{
			if((min==a[i])&&(i!=t))
			{
				count++;
				break;
			}
		}
		if(count)
		{
			cout<<"Still Rozdil";
		}
		else
			cout<<(t+1);
		return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long n,min,count=0;
	cin>>n;
	long long a[n];
	for(long long i=0;i<n;i++)
		{
			cin>>a[i];
		}
		min=a[0];
		int t =0;
		for(long long i=0;i<n;i++)
		{
			if(a[i]<min){
				min=a[i];
				t=i;
			}
		}
		for(long long i=0;i<n;i++)
		{
			if((min==a[i])&&(i!=t))
			{
				count++;
				break;
			}
		}
		if(count)
		{
			cout<<"Still Rozdil";
		}
		else
			cout<<(t+1);
		return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long n,t,min,count=0;
	cin>>n;
	long long a[n];
	for(long long i=0;i<n;i++)
		{
			cin>>a[i];
		}
		min=a[0];
		for(long long i=0;i<n;i++)
		{
			if(a[i]<min){
				min=a[i];
				t=i;
			}
		}
		for(long long i=0;i<n;i++)
		{
			if((min==a[i])&&(i!=t))
			{
				count++;
				break;
			}
		}
		if(count)
		{
			cout<<"Still Rozdil";
		}
		else
			cout<<(t+1);
		return 0;
}


#include <iostream>
#include <cmath>
using namespace std;
int main()
{   int nom;
    int aa;
    cin >> aa;
    int a[aa];
    for ( int z = 0 ; z < aa ; z++) {
        cin >> a[z];
    }
    if ( aa == 1 ) {
        cout << 1;
    }
    else {
    int num = a[0];
    for ( int y = 1 ; y < aa ; y++) {
        if ( num > a[y] ) {
            num = a[y];
            nom = y;
        }
    }
    // cout << num << " ";
    int nim = 0;
    for ( int x = 0 ; x < aa ; x++) {
        if ( num == a[x] ) {
            nim = nim + 1;
        }
    }
    //cout << nim << " ";
    if ( nim == 1 ) {
        nom = nom + 1;
        cout << nom;
    }
    else {
        cout << "Still Rozdil";
    }
    }
    return 0;

}


#include <iostream>
#include <cmath>
using namespace std;
int main()
{   int nom;
    int aa;
    cin >> aa;
    int a[aa];
    for ( int z = 0 ; z < aa ; z++) {
        cin >> a[z];
    }
    int num = a[0];
    for ( int y = 1 ; y < aa ; y++) {
        if ( num > a[y] ) {
            num = a[y];
            nom = y;
        }
    }
    // cout << num << " ";
    int nim = 0;
    for ( int x = 0 ; x < aa ; x++) {
        if ( num == a[x] ) {
            nim = nim + 1;
        }
    }
    //cout << nim << " ";
    if ( nim == 1 ) {
        cout << nom + 1;
    }
    else {
        cout << "Still Rodzil";
    }
    return 0;

}