#include <bits/stdc++.h>
using namespace std;
int main() {
  long long tests;
  cin >> tests;
  long long length, letters;
  long long cur;
  for (int i = 0; i < tests; i++) {
    cin >> length >> letters;
    cur = 0;
    for (int i = 0; i < length; i++) {
      cur %= letters;
      cout << char('a' + cur);
      cur++;
    }
    cout << endl;
  }
}
