#include <bits/stdc++.h>
using namespace std;
int main() {
  int tc;
  cin >> tc;
  while (tc--) {
    int n, k;
    cin >> n >> k;
    int cur = 0;
    for (int i = 0; i < (n); ++i) {
      cout << (char)(cur + 97);
      cur = (cur + 1) % k;
    }
    cout << '\n';
  }
  return 0;
}
