#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  char buf[26];
  for (char i = 'a'; i <= 'z'; ++i) {
    buf[i - 'a'] = i;
  }
  while (t--) {
    int n, k;
    cin >> n >> k;
    for (int i = 0; i < n; ++i) cout << buf[i % k];
    cout << '\n';
  }
}
