/*
// Sample code to perform I/O:
#include <iostream>
using namespace std;
int main() {
int num;
cin >> num; // Reading input from STDIN
cout << "Input number is " << num << endl; // Writing output to STDOUT
}
// Warning: Printing unwanted or ill-formatted data to output will cause the test cases to fail
*/
// Write your code here
#include<iostream>
#include<string>
using namespace std;
int main()
{
int t,n;
cin>>t;
while(t--)
{ cin>>n;
string s;
cin>>s;
for(int i=0;i<n;i++)
{
int c = int(s[i]);
if(c<=69){s[i]=(char)67;}
if(c>69&&c<=72){s[i]=(char)71;}
if(c>72&&c<=76){s[i]=(char)73;}
if(c>76&&c<=81){s[i]=(char)79;}
if(c>81&&c<=86){s[i]=(char)83;}
if(c>86&&c<=93){s[i]=(char)89;}
if(c>=94&&c<=99){s[i]=(char)97;}
if(c>99&&c<=102){s[i]=(char)101;}
if(c>102&&c<=105){s[i]=(char)103;}
if(c>105&&c<=108){s[i]=(char)107;}
if(c>108&&c<=111){s[i]=(char)109;}
if(c>111){s[i]=(char)113;}
}
cout<<s<<endl;
}
}
Language: C++17