#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    float n, k;
    cin >> n >> k;
    int s;
    s = (n / k);
    int q;
    int l = (int)n;
    int m = (int)k;
    q = l % m;
    for (int i = 0; i < k; i++) {
      for (int j = 0; j < s; j++) {
        cout << (char)(i + 97);
      }
    }
    for (int i = 0; i < q; i++) {
      cout << (char)(97 + i);
    }
    cout << endl;
  }
  return 0;
}
