#include <bits/stdc++.h>
int pu(int b, int c) {
  char p = 'a';
  int s = 0;
  while (b) {
    printf("%c", p);
    p++;
    b = b - 1;
    s = s + 1;
    if (s == c) {
      s = 0;
      p = 'a';
    }
  }
  return 0;
}
int main() {
  int t, b, c;
  scanf("%d", &t);
  while (t--) {
    scanf("%d%d", &b, &c);
    int oo = pu(b, c);
    printf("\n");
  }
}
