#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 u;
    u = n / k;
    for (int j = 0; j < k; j++) {
      for (int k = 0; k < u; k++) {
        char c = j + 97;
        cout << c;
      }
    }
    int h;
    h = n % k;
    for (int l = 0; l < h; l++) {
      char v = 96 + k;
      cout << v;
    }
    cout << endl;
  }
}
