#include <bits/stdc++.h>
int main() {
  int i, m, n, a, b, c;
  scanf("%d", &i);
  while (i--) {
    scanf("%d%d", &m, &n);
    a = m / n;
    b = m % n;
    for (int q = 0; q < n; q++) {
      if (b) {
        for (int w = 0; w < a + 1; w++) {
          printf("%c", q + 'a');
        }
        b--;
      } else
        for (int w = 0; w < a; w++) printf("%c", q + 'a');
    }
    printf("\n");
  }
  return 0;
}
