#include <bits/stdc++.h>
int main() {
  int t;
  scanf("%d", &t);
  for (int i = 0; i < t; i++) {
    int n, k;
    scanf("%d%d", &n, &k);
    char s[n];
    int j = 0;
    while (j < n) {
      int t = 1;
      int p = 97;
      while (t <= k && j < n) {
        s[j] = p;
        j++;
        p++;
        t++;
      }
    }
    for (int a = 0; a < n; a++) {
      printf("%c", s[a]);
    }
    printf("\n");
  }
  return 0;
}
