#include <bits/stdc++.h>
using namespace std;
int main() {
  int t, n, k, l, i, j;
  char ch;
  cin >> t;
  for (; t; --t) {
    cin >> n >> k;
    l = n / k;
    for (i = 0, ch = 'a'; i < k; ++i, ++ch) {
      for (j = 0; j < l; ++j) cout << ch;
    }
    for (--ch, i = 0; i < n % (l * k); ++i) cout << ch;
    cout << "\n";
  }
  return 0;
}
