#include <bits/stdc++.h>
using namespace std;
int main() {
  int t, n, k;
  scanf("%d", &t);
  while (t--) {
    scanf("%d%d", &n, &k);
    int fre = n / k;
    char ch = 'a' - 1;
    for (int i = 1; i <= k; i++) {
      ch++;
      for (int i = 1; i <= fre; i++) cout << ch;
    }
    int rest = n % k;
    for (int i = 1; i <= rest; i++) cout << ch;
    cout << endl;
  }
  return 0;
}
