#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  for (int i = 0; i < t; i++) {
    int n, k;
    cin >> n >> k;
    int x = n / k;
    int a = 97;
    for (int j = 0; j < x; j++) {
      a = 97;
      for (int h = 0; h < k; h++) {
        cout << char(a);
        a++;
      }
    }
    a = 97;
    x = x * k;
    for (int j = x; j < n; j++) {
      cout << char(a);
      a++;
    }
    cout << endl;
  }
}
