#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n, k;
    cin >> n >> k;
    int y = n / k;
    int rem = n % k;
    char ch = 'a';
    for (int i = 0; i < k; i++) {
      if (i <= k - 2)
        for (int j = 0; j < y; j++) cout << ch;
      else
        for (int j = 0; j < y + rem; j++) cout << ch;
      ch++;
    }
    cout << endl;
  }
}
