#include <bits/stdc++.h>
using namespace std;
int t;
int d;
int g;
int y;
int pos;
char s[1000][1000];
int a[1000];
int main() {
  cin >> t;
  for (int i = 0; i < t; i++) {
    int n, k;
    cin >> n >> k;
    a[i] = n;
    d = n / k;
    g = n - (d * k);
    y = 0;
    pos = 0;
    while (pos < n) {
      if (y == k - 1) {
        for (int j = 0; j < d + g; j++) {
          s[i][j + pos] = 'a' + y;
        }
        pos = pos + d + g;
      } else {
        for (int j = 0; j < d; j++) {
          s[i][j + pos] = 'a' + y;
        }
        pos = pos + d;
      }
      y++;
    }
  }
  for (int i = 0; i < t; i++) {
    for (int j = 0; j < a[i]; j++) {
      cout << s[i][j];
    }
    cout << endl;
  }
  return 0;
}
