#include <bits/stdc++.h>
using namespace std;
int main () {
long long int x;
cin>>x;
for(long long int i=0;i<x;i++) {
long long int n;
cin>>n;
string a,b;
long long int s[n+1],max,maxans;
cin>>a>>b;
for(long long int k=0;k<=n;k++)
cin>>s[k];
long long int y=0;maxans=0;
for(long long int j=0;j<n;j++){
if(a[j]==b[j]){
y++;
}}
if(y==n)
maxans=s[n];
else{
for(long long int qq=0;qq<=y;qq++){
if(s[qq]>=maxans)
maxans=s[qq];
}
}
cout<<maxans<<endl;
}
}
Be the first to comment
You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.