#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n, k, x;
    cin >> n >> k;
    char s;
    string str;
    int p = n / k, q = n % k;
    for (int i = 0; i < k; ++i) {
      x = i + 97;
      s = x;
      if (i == k - 1) p = p + q;
      for (int j = 0; j < p; ++j) str += s;
    }
    cout << str << endl;
  }
}
