#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  for (int j = 0; j < t; j++) {
    int n, k;
    cin >> n >> k;
    int i = 0;
    while (i < n) {
      int curr = i % k;
      char ch = 97 + curr;
      cout << ch;
      i++;
    }
    cout << endl;
  }
}
