#include <bits/stdc++.h>
using namespace std;
long long abs(long long, long long);
void solve() {
  long long n, k;
  cin >> n >> k;
  char s[n];
  long long z = 0;
  for (long long i = 0; i < k; i++) {
    for (long long j = 0; j < n / k; j++) {
      s[z] = 97 + i;
      z++;
    }
  }
  char x = s[(n / k) * k - 1];
  for (long long i = (n / k) * k; i < n; i++) s[i] = x;
  for (long long i = 0; i < n; i++) cout << s[i];
  cout << "\n";
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long TESTS = 1;
  cin >> TESTS;
  while (TESTS--) {
    solve();
  }
  return 0;
}
long long abs(long long a, long long b) {
  if (a > b)
    return a - b;
  else
    return b - a;
}
