from sys import stdin
from sys import stdout

mod=1000000007
for i in range(int(stdin.readline())):
	x=int(stdin.readline())
	s=input()
	ans=len(s)
	l=1
	if(len(s)<x):
		while(l<=x):
			c=s[l:]
			if(s[l-1]=='2'):
				s=s+c
				if(len(s)>=x):
					break
			elif(s[l-1]=='3'):
				s=s+c
				if(len(s)>=x):
					break
				s=s+c
				if(len(s)>=x):
					break
			l+=1
	
	l=1
	while(l<=x):
		cc=ans-l
		if(s[l-1]=='2'):
			ans=(ans+cc)%mod
		elif(s[l-1]=='3'):
			ans=(ans+cc)%mod
			ans=(ans+cc)%mod
		l+=1
	stdout.write(str(ans)+'\n')
	stdout.flush()