#include <bits/stdc++.h>
using namespace std;
int main() {
  int t, n, k;
  cin >> t;
  while (t--) {
    cin >> n >> k;
    int p = n / k;
    string s;
    for (int i = 0; i < k; ++i) s += (i + 'a');
    string ans;
    for (int i = 0; i < p; ++i) ans += s;
    if (n % k == 0)
      cout << ans << endl;
    else {
      for (int i = 0; i < k && i < (n - k * (n / k)); ++i) ans += (i + 'a');
      cout << ans << endl;
    }
  }
  return 0;
}
