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