#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int t, n, k;
  cin >> t;
  while (t-- > 0) {
    string out = "";
    cin >> n >> k;
    for (int i = 0; i < n; i++) out += char(i % k + 97);
    cout << out << endl;
  }
  return 0;
}
