#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  while (n--) {
    int a, b, p = 0, c = 0;
    cin >> a >> b;
    string s = "abcdefghijklmnopqrstuvwxyz";
    for (int i = 0; i < a; i++) {
      cout << s[p];
      c++;
      if (c == a / b) {
        p++;
        c = 0;
        if (p == b) {
          p = 0;
        }
      }
    }
    cout << endl;
  }
}
