#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  vector<int> n(t);
  vector<int> k(t);
  string s = "abcdefghijklmnopqrstuvwxyz";
  for (int i = 0; i < t; i++) {
    cin >> n[i] >> k[i];
  }
  for (int i = 0; i < t; i++) {
    if (n[i] == k[i]) {
      for (int j = 0; j < n[i]; j++) {
        cout << s[j];
      }
      cout << endl;
    } else if (n[i] % k[i] == 0 && n[i] != k[i]) {
      for (int g = 0; g < (n[i] / k[i]); g++) {
        for (int f = 0; f < k[i]; f++) {
          cout << s[f];
        }
      }
      cout << endl;
    } else {
      for (int g = 0; g < (n[i] / k[i]); g++) {
        for (int f = 0; f < k[i]; f++) {
          cout << s[f];
        }
      }
      for (int j = 0; j < n[i] % k[i]; j++) {
        cout << s[j];
      }
      cout << endl;
    }
  }
  return 0;
}
