#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  while (n--) {
    int a, k;
    cin >> a >> k;
    string s;
    for (int i = 0; i < k; i++) s += char('a' + i);
    string ss;
    int aa = a / k;
    while (aa--) {
      ss += s;
    }
    for (int i = 0; i < a % k; i++) ss += s[i];
    cout << ss << "\n";
  }
  return 0;
}
