#include <bits/stdc++.h>
using namespace std;
int main() {
  long long T, n, a, b, i, j, k;
  string s;
  cin >> T;
  while (T--) {
    cin >> n;
    cin >> k;
    a = n / k;
    j = 0;
    b = 0;
    s = "";
    for (i = 0; i < n; i++) {
      if (b < k - 1) {
        if (j == a) {
          j = 0;
          b++;
        }
        j++;
      }
      s += (char)(b + 'a');
    }
    cout << s;
    cout << endl;
  }
}
