#include<stdio.h>
#include<stdlib.h>
typedef struct node
{
char data;/*数据域*/
struct node *next;/*指针域*/
} Node,*Link;
void destroy(Link head)
{
Link p;
while (head!=NULL)/*当还有头结点存在时*/
{
p=head;/*头结点是待删除结点*/
head=head->next;/*先连*/
free(p);/*后断*/
}
}
int main()
{
int t,i,j,n,count;
scanf("%d",&t);
int *rt = (int *)malloc(sizeof(int) * t); /* 申请一个用来记录结果数据的数组。*/
for(i =0;i<t;i++) /*多组输入*/
{
count=0;
scanf("%d",&n);
Link head1,head2,c1,c2,l;
head1=NULL;
head2=NULL;
for(j=0; j<n; j++)/*创建后续节点*/
{
l=(Link)malloc(sizeof(Node));
l->next=NULL;
scanf("%c",&(l->data));
if(head1==NULL){
head1=l;
c1=head1;
}else{
c1->next=l;
c1=l;
}
}
getchar();
for(j=0; j<n; j++)/*创建后续节点*/
{
l=(Link)malloc(sizeof(Node));
l->next=NULL;
scanf("%c",&(l->data));
if(head2==NULL){
head2=l;
c1=head2;
}else{
c1->next=l;
c1=l;
}
}
c1=head1;
c2=head2;
while(c1!=NULL)/*因为中奖号码和兑奖号码一样长,当c1不为空时,c2也不为空*/
{
if(c1->data==c2->data)/*他们相等时*/
count++;
c1=c1->next;/*往后移*/
c2=c2->next;
}
rt[i]=count;
destroy(head1);
destroy(head2);
}
for(i=0;i<t;i++){
printf("%d\n",rt[i]);
}
return 0;
}