#include <bits/stdc++.h>
using namespace std;
long long w, n, i, o = 0, t, j, q, k;
long double s;
int main() {
  cin >> n;
  long long a[n], b[n];
  for (i = 0; i < n; i++) {
    cin >> a[i] >> b[i];
  }
  for (i = 0; i < n; i++) {
    s = a[i] / b[i];
    w = b[i];
    for (o = 0; o < w; o++) {
      for (j = 1; j <= s; j++) {
        cout << (char(o + 97));
      }
    }
    for (o = 1; o <= a[i] - s * b[i]; o++) {
      cout << char((b[i] - 1) + 97);
    }
    cout << endl;
  }
}
