错误信息是A=3,B=2.
#include<bits/stdc++.h>
#define int long long
using namespace std;
int t,n,k,a,b,sum1,sum2,x;
bool f=0;
signed main(){
cin>>t;
for(int i=1;i<=t;i++){
cin>>n>>k>>a>>b;f=0;
if(k>n){
cout<<0<<endl;
for(int j=1;j<=n;j++){
if(j%2)cout<<'a';
else cout<<'b';
}
cout<<endl;
}
else{
if(min(b*(n-k+1),(int)(a*(ceil(n*1.0/(k-1))-1)))==b*(n-k+1)){
cout<< b*(n-k+1)<<endl;
for(int j=1;j<=n;j++)cout<<(j%2)?'a':'b';
cout<<endl;
}
else{
cout << (int)(a*(ceil(n*1.0/(k-1))-1))<<endl;x=1;
for(int j=1;j<=n;j++){
if(x>=k-1){
if(k==2)cout<<'z';
else{
if(f){
f=0;
if(j!=n)cout<<"yy";
else cout<<'y';
}
else{
f=1;
if(j!=n)cout<<"zz";
else cout<<'z';
}
j++;
x=1;
}
}
else{
f=0;
if(j%2)cout<<'a';
else cout<<'b';
}
x++;
}
cout<<endl;
}
}
}
return 0;
}