#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  while (n--) {
    int a, b;
    cin >> a >> b;
    int q = a / b;
    int r = a % b;
    for (int i = 0; i < b; i++) {
      for (int j = 0; j < q; j++) {
        char x = 'a' + i;
        cout << x;
      }
    }
    for (int i = 0; i < r; i++) {
      cout << "a";
    }
    cout << endl;
  }
}
