#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n, k, c = 0;
    cin >> n >> k;
    for (int i = 0; i < n; i++) {
      cout << char(97 + c);
      c++;
      if (c == k) {
        c = 0;
      }
    }
    cout << "\n";
  }
  return 0;
}
