#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define MOD 1000000007
#define PI 3.14159265
#define INF 1000000000000000000
#define pll pair<ll,ll>
#define fastio  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define vll vector<ll>
#define all(a) a.begin(),a.end()
#define forl(i,n) for(ll i=0;i<n;i++)
#define fore(i,n) for(ll i=1;i<=n;i++)
ll max(ll a,ll b)
{
    if(a>b)
    return a;
    return b;
}

ll min(ll a,ll b)
{
    return a+b-max(a,b);
}
ll mulmod(ll a, ll b, ll mod)
{
    /*ll res = 0; // Initialize result
    a = a % mod;
    while (b > 0)
    {
        // If b is odd, add 'a' to result
        if (b % 2 == 1)
            res = (res + a) % mod;

        // Multiply 'a' with 2
        a = (a * 2) % mod;

        // Divide b by 2
        b /= 2;
    }

    // Return result
    return res % mod; */
    return ((a%MOD)*(b%MOD)%MOD);
}
ll mod(ll a,ll b)
{
    if(a>b)
    return a-b;
    else
    return b-a;
}
ll power(ll x,ll y, ll p)
{
    ll res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x)%p;
        y = y>>1;
        x = (x*x)%p;
    }
    return res;

}
int bits(ll n)
{
    ll ctr=0;
    while(n)
    {
        n/=10;
        ctr++;
    }
    return ctr;
}
bool cmp(pll p1,pll p2)
{
    if(p1.f<p2.f)
    return true;
    if(p1.f==p2.f)
    return p1.s>p2.s;
    return false;
}
vll bits1(ll n)
{
    vll res;
    while(n)
    {
        res.pb(n%10);
        n/=10;
    }
    reverse(all(res));
    return res;
}
ll get(ll m,ll d,ll s1)
{
    if(mod(0,m-d)<=s1)
    return 0;
    else
    return mod(0,m-d)-s1;
}
void debug(ll x)
{
    if(x)
    cout<<"yes\n";
    else
    cout<<"no\n";

}
vll st;
vector<pll> vec;
vll all_max;
ll m;
void buildST(ll ss,ll se,ll v)
{
    if(ss==se)
    {
        st[v] = ss;
        return;
    }

    ll mid = (ss+se)/2;
    buildST(ss,mid,2*v+1);
    buildST(mid+1,se,2*v+2);
    if(vec[st[2*v+1]].s>=vec[st[2*v+2]].s)
    st[v]  = st[2*v+1];
    else
    st[v] = st[2*v+2];
}
ll query(ll ss,ll se,ll qs,ll qe,ll v)
{
   return all_max[qs];
}
void ex()
{
    cout<<"NO";
    exit(0);
}
bool check(vll vec,ll ctr[])
{
    ll temp[4]={0};
    for(auto it:vec)
    temp[it]++;
    forl(i,4)
    if(ctr[i]!=temp[i])
    return false;
    forl(i,vec.size()-1)
    {
        if(mod(0,vec[i]-vec[i+1])!=1)
        return false;
    }
    return true;
}
int main()
{
    fastio;
    ll ctr[4];
    cin>>ctr[0]>>ctr[1]>>ctr[2]>>ctr[3];
    ll t1[4];
    ll t2[4];
    forl(i,4)
    {
        t1[i]=ctr[i];
        t2[i]=ctr[i];
    }
    vll ans[2];
    forl(i,t1[3])
    {
        ans[0].pb(3);
        ans[0].pb(2);
    }
    if(ctr[2]+1<ctr[3])
    ex();
    if(ctr[2]+1==ctr[3])
    {
        if(ctr[1]==0 && ctr[0]==0)
        {
            cout<<"YES\n";
            forl(i,ctr[2])
            cout<<3<<" "<<2<<" ";
            cout<<3;

        }
        else
        {
            cout<<"NO";
        }
        return 0;
    }

    t1[2]-=t1[3];
    if(ans[0].size())
    {
        forl(i,t1[2])
        {
            ans[0].pb(1);
            ans[0].pb(2);
        }
        if(t1[1]>=(t1[2]+1))
        {
            ans[0].pb(1);
            t1[1]-=(t1[2]+1);
            forl(i,t1[0])
            {
                ans[0].pb(0);
                ans[0].pb(1);
            }
            t1[1]-=t1[0];
            if(t1[1]<0)
            ans[0].pop_back();
            forl(i,t1[1])
            {
                ans[0].pb(1);
            }
        }

    }
    else
    {
        if(t1[1]>t1[0])
        {
            forl(i,t1[0])
            {
                ans[0].pb(1);
                ans[0].pb(0);
            }
            forl(i,t1[1]-t1[0])
            ans[0].pb(1);
        }
        else
        {
            forl(i,t1[1])
            {
                ans[0].pb(0);
                ans[0].pb(1);
            }
            forl(i,t1[0]-t1[1])
            ans[0].pb(0);
        }
    }
    ans[1].pb(2);
    t2[2]--;
    forl(i,t2[3])
    {
        ans[1].pb(3);
        ans[1].pb(2);
    }
    t2[2]-=t2[3];
    if(t2[1])
    {
        t2[1]--;
        ans[1].pb(1);
        forl(i,t2[2])
        {
            ans[1].pb(2);
            ans[1].pb(1);
        }
        t2[1]-=t2[2];
        if(t2[0])
        {
            ans[1].pb(0);
            t2[0]--;
            forl(i,t2[1])
            {
                ans[1].pb(1);
                ans[1].pb(0);
            }

        }
    }

    if(check(ans[0],ctr))
    {
        cout<<"YES\n";
        for(auto it:ans[0])
        cout<<it<<" ";
    }
    else if(check(ans[1],ctr))
    {
        cout<<"YES\n";
        for(auto it:ans[1])
        {
            cout<<it<<" ";
        }
    }
    else
    {
        cout<<"NO";
    }
}


b,k=map(int,input().split())
a=list(map(int,(input().split())))
n=0
if((k%2==0)and(int(a[k-1])%2==0))or((k % 2 != 0)and((sum(a)))%2==0):
    print('even')
else:
    print('odd')


b,k=map(int,input().split())
a=(input().split())
n=0
for i in range(k):
    n+=int(a[i])*b**(k-i-1)
if n%2 == 0:
    print('even')
else:
    print('odd')


str_in = str(input())
b, k = int(str_in.split()[0]), int(str_in.split()[1])

a = input().split()

if (k == 1)and(int(a[0]) == 0):
    print("even")
else:
    if (b % 2 == 0):
        if (int(a[k-1]) % 2 == 0):
            print("even")
        else:
            print("odd")
    else:
        num = 0
        for i in range(k):
            num += int(a[i])
        if (num % 2 == 0):
            print("even")
        else:
            print("odd")


def change(mean):
    if (mean == True):
        return False
    else:
        return True

def task_one():
    str_in = str(input())
    b, k = int(str_in.split()[0]), int(str_in.split()[1])
    str_in = str(input())
    if (k == 1 and int(str_in.split()[0]) == 0):
        return "even"
    if (b % 2 ==  0):
        if (int(str_in.split()[k-1]) % 2 != 0):
            return "odd"
        else:
            return "even"
    else:
        odd = False
        for i in range(k):
            num = int(str_in.split()[i])
            if (num % 2 != 0):
                odd = change(odd)
        if (odd == True):
            return "odd"
        else:
            return "even"

print(task_one())


str_in = str(input())
b, k = int(str_in.split()[0]), int(str_in.split()[1])

str_in = str(input())
num = 0
for i in range(k):
    num += int(str_in.split()[i])*pow(b,k-i-1)

if (num % 2 == 0):
    print("even")
else:
    print("odd")


str_in = str(input())
b, k = int(str_in.split()[0]), int(str_in.split()[1])

str_in = str(input())
if (k == 1)and(int(str_in.split()[0]) == 0):
    print("even")
else:
    if (b % 2 == 0):
        if (int(str_in.split()[k-1]) % 2 == 0):
            print("even")
        else:
            print("odd")
    else:
        num = 0
        for i in range(k):
            num += int(str_in.split()[i])
        if (num % 2 == 0):
            print("even")
        else:
            print("odd")


input_1 = gets.split.map(&:to_i)
input_2 = gets.split.map(&:to_i)

b = input_1[0]
k = input_2[1]

b_flag = 0
k_flag = 0
odd_count = 0

if b % 2 == 0
  b_flag = 0
else
  b_flag = 1
end

input_2.each do |num|
  if num % 2 != 0
    odd_count += 1
  end
end

if b_flag == 0
  puts "even"
else
  if odd_count % 2 == 0
    puts "even"
  else
    puts "odd"
  end
end


input_1 = gets.split.map(&:to_i)
input_2 = gets.split.map(&:to_i)

b = input_1[0]
k = input_1[1]

b_flag = 0
k_flag = 0
odd_count = 0

if b % 2 == 0
  b_flag = 0
else
  b_flag = 1
end

for i in 0..k - 2 do
  if input_2[i] % 2 != 0
    odd_count += 1
  end
end

if b_flag == 0
  if input_2[k - 1] % 2 == 0
    puts "even"
  else
    puts "odd"
  end
else
  if odd_count % 2 == 0
    if input_2[k - 1] % 2 == 0
      puts "even"
    else
      puts "odd"
    end
  else
    if input_2[k - 1] % 2 == 0
      puts "odd"
    else
      puts "even"
    end
  end
end


b,k = gets.split.map(&:to_i)
a = gets.split.map(&:to_i)
ans = 0
if b%2 == 0
    ans ^= a[-1]%2
else
    for i in 0..k-1
        ans ^= a[i]%2
    end
end
puts (ans == 1 ? "odd" : "even")


DBG = true
b,k = gets.split.map{|z| z.to_i}
a = gets.split.map{|z| z.to_i}
if b%2 == 0
  iseven = (a[-1]%2 == 0)
else
  iseven = (a.inject(:+)%2 == 0)
end
puts (iseven ? "even" : "odd")


b,k=map(int,raw_input().split())
a=list(map(int,raw_input().split()))
def f(x,y):
    if x%2==0 or y%2==0:
        return "even"
    else:
        return "odd"
def g(x,y):
    if x==y:
        return "even"
    else:
        return "odd"
u=len(a)
m="even"
for i in xrange(u-1):
    m=g(m,f(a[i],b))
m=g(m,f(a[u-1],1))
print m


b,k = map(int, raw_input().split())
n = map(int, raw_input().split())

if b%2 == 0 :
    if n[k-1]%2 == 0 :
        print "even"
    else :
        print "odd"

else :
    if sum(n)%2 == 0 :
        print "even"
    else :
        print "odd"


b,k = map(int, raw_input().split())
n = map(int, raw_input().split())
print sum(n)

if b%2 == 0 :
    if n[k-1] == 0 :
        print "even"
    else :
        print "odd"

else :
    if sum(n)%2 == 0 :
        print "even"
    else :
        print "odd"


b,k = map(int, raw_input().split())
n = map(int, raw_input().split())

if b%2 == 0 :
    if n[k-1] == 0 :
        print "even"
    else :
        print "odd"

else :
    if sum(n)%2 == 0 :
        print "even"
    else :
        print "odd"


R = lambda: map(int, raw_input().split())

n, m = R()
a = 0
for x in R():
  a = (a * n + x) % 2
print('even', 'odd')[a]


R = lambda: map(int, raw_input().split())

n, m = R()
a = 0
for x in R():
  a = (a * m + x) % 2
print('even', 'odd')[a]


import sys
import heapq
import bisect
import math
import random

INF = 10**9+7
OFFLINE = 0
sys.setrecursionlimit(INF)

def fi():
	return int(sys.stdin.readline())

def fi2():
	return map(int, sys.stdin.readline().split())

def fi3():
	return sys.stdin.readline().rstrip()

def fo(*args):
	for s in args:
		sys.stdout.write(str(s)+" ")
	sys.stdout.write("\n")

##
if OFFLINE:
	sys.stdin = open("fin.txt", "r")
	sys.stdout = open("fout.txt", "w")
##

def fexp(n, m, p):
	if m == 0:
		return 1
	if m%2 == 0:
		return (fexp(n, m/2, p)**2)%p
	else:
		return (n*fexp(n, m-1, p))%p

##main
b, k = fi2()
a = fi2()
a.reverse()

res = 0

for i in range(k):
	res += fexp(a[i], i, 10)

if res%2:
	fo('odd')
else:
	fo('even')


import sys
import heapq
import bisect
import math
import random

INF = 10**9+7
OFFLINE = 0
sys.setrecursionlimit(INF)

def fi():
	return int(sys.stdin.readline())

def fi2():
	return map(int, sys.stdin.readline().split())

def fi3():
	return sys.stdin.readline().rstrip()

def fo(*args):
	for s in args:
		sys.stdout.write(str(s)+" ")
	sys.stdout.write("\n")

##
if OFFLINE:
	sys.stdin = open("fin.txt", "r")
	sys.stdout = open("fout.txt", "w")
##

def fexp(n, m, p):
	if m == 0:
		return 1
	if m%2 == 0:
		return (fexp(n, m/2, p)**2)%p
	else:
		return (n*fexp(n, m-1, p))%p

##main
b, k = fi2()
a = fi2()
a.reverse()

res = 0

for i in range(k):
	res += (a[i]*fexp(b, i, 10))%10

if res%2:
	fo('odd')
else:
	fo('even')


bk= raw_input().split()
bk= map(int,bk)
a= raw_input().split()
a=map(int,a)
var=[]
for i in range(0,len(a)):
  if(a[i]%2!=0):
    var.append(a[i])
if(bk[1]%2==0):
  print "even"
else:
  if(len(var)%2==0):
    print "even"
  else:
    print "odd"


bk= raw_input().split()
bk= map(int,bk)
a= raw_input().split()
a=map(int,a)
var=[]
for i in range(0,len(a)):
  if(a[i]%2!=0):
    var.append(a[i])
if(bk[1]%2==0):
  if(a[-1]%2==0):
    print "even"
  else:
    print"odd"
else:
  if(len(var)%2==0):
    print "even"
  else:
    print "odd"


bk= raw_input().split()
bk= map(int,bk)
a= raw_input().split()
a=map(int,a)
var=[]
for i in range(0,len(a)):
  if(a[i]%2!=0):
    var.append(a[i])
if(bk[0]%2==0):
  if(a[-1]%2==0):
    print "even"
  else:
    print"odd"
else:
  if(len(var)%2==0):
    print "even"
  else:
    print "odd"


b,k = map(int,raw_input().split())
a=map(int,raw_input().split())
f=0

for i in range(k-1):
    if a[i]%2==0 or b%2==0:
        a[i] = 0
    else:
        a[i] =1

a[k-1] = a[k-1]%2

if sum(a)%2==0:
    print "even"
else:
    print "odd"


from sys import stdin
def main():
    b, k = map(int, stdin.readline().split())
    a = map(int, stdin.readline().split())
    b %= 2
    s = a.pop()
    s += sum(x * b % 2 for x in a)
    print "odd" if s % 2 else "even"
main()


b,k = map(int,raw_input().split())
lst = map(int,raw_input().split())
if(b%2==0):
    if(lst[-1]%2==0):
        print 'even'
    else:
        print 'odd'
else:
    p = sum(lst)
    if(p%2==0):
        print 'even'
    else:
        print 'odd'


b,k = map(int, raw_input().split())
list = map(int, raw_input().split())
count = 0
if b%2==1:
    for i in range(len(list)):
        if list[i]%2==1:
            count+=1
elif b%2==0:
    if list[k-1]%2==1:
        count +=1
if count%2==0:
    print 'even'
else:
    print 'odd'


b, k = map(int, raw_input().split())
a = list(map(int, raw_input().split()))
n = 0
if b % 2 == 0:
    n = a[-1]
else:
    n = sum(a)
if n % 2 == 0:
    print "even"
else:
    print "odd"


b, k = map(int, raw_input().split())
a = list(map(int, raw_input().split()))
n = 0
if b % 2 == 0:
    m = 2
else:
    m = 1
for i in xrange(k):
    n += a[i]*m
if n % 2 == 0:
    print "even"
else:
    print "odd"


b, k = map(int, raw_input().split())
a = list(map(int, raw_input().split()))
n = 0
for i in xrange(k):
    n += a[i] * b**(k - i - 1)
if n % 2 == 0:
    print "even"
else:
    print "odd"


b, k = map(int, raw_input().split())
a = list(map(int, raw_input().split()))
n = 0
for i in xrange(k):
    n += a[i] * b**(k - i - 1) % 2
if n % 2 == 0:
    print "even"
else:
    print "odd"


b, k = map(int, raw_input().split())
a = map(int, raw_input().split())

ans = 0
for i in xrange(k-1):
    if b % 2 == 1 and a[i] % 2 == 1:
        ans += 1

if a[k-1] % 2 == 1:
    ans += 1

if ans % 2 == 0:
    print 'even'
else:
    print 'odd'


n,k=map(int,raw_input().split())
a=map(int,raw_input().split())

odd=0
for i in a:
    if i%2==1:
        odd+=1

if n%2==0:
    if a[len(a)-1]%2==0:
        print "even"
    else:
        print "odd"

else:
    if odd%2==0:
        print "even"
    else:
        print "odd"


[b,k] = map(int, raw_input().rstrip().split())
l = map(int, raw_input().rstrip().split())
if b % 2 == 1:
    if sum(l) % 2 == 0:
        print "even"
    else:
        print "odd"
else:
    if l[-1] % 2 == 0:
        print "even"
    else:
        print "odd"


b, k = map(int,raw_input().split())
l = map(int, raw_input().split())
l = l[::-1]
sum = 0
for i in range(k):
    sum += (b**i)*l[i]
if(sum % 2 == 0):
    print "even"
else:
    print "odd"


b, k = map(int,raw_input().split())
l = map(int, raw_input().split())
l = l[::-1]
odd_count = 0
for i in l:
    if(i % 2 == 0):
        odd_count += 1
if(b % 2 == 0):
    if(l[0] % 2 == 0):
        print "even"
    else:
        print "odd"
else:
    if(odd_count % 2 == 0):
        print "even"
    else:
        print "odd"


b, k = map(int,raw_input().split())
l = map(int, raw_input().split())
l = l[::-1]
odd_count = 0
for i in l:
    if(i % 2 == 1):
        odd_count += 1
if(b % 2 == 0):
    if(l[0] % 2 == 0):
        print "even"
    else:
        print "odd"
else:
    if(odd_count % 2 == 0):
        print "even"
    else:
        print "odd"


b,k = map(int,raw_input().split())
b = 1 if b%2==0 else -1
#print b
s = map(lambda x:1 if int(x)%2==0 else -1 ,raw_input().split())
#print s
r = 1
for i in xrange(k-1):
    #print r
    r*=1 if b+s[i]>=0 else -1
print 'even' if r*s[-1]==1 else 'odd'


class Solver:

    def solve(self, b, k, a):
        m, s = 1, a[-1] % 2
        for i in range(k - 2, -1, -1):
            m = (m * b) % 2
            s = (s + m * a[i]) % 2
        return 'even' if s == 0 else 'odd'

if __name__ == "__main__":
    b, k = map(int, raw_input().split(" "))
    a = map(int, raw_input().split(" "))
    sl = Solver()

    print sl.solve(b, k, a)


class Solver:

    def solve(self, b, k, a):
        m, s = 1, a[-1]
        for i in range(k - 2, -1, -1):
            m = (m * b) % 2
            s = (s + m * a[i]) % 2
        return 'even' if s == 0 else 'odd'

if __name__ == "__main__":
    b, k = map(int, raw_input().split(" "))
    a = map(int, raw_input().split(" "))
    sl = Solver()

    print sl.solve(b, k, a)


b, k = map(int, raw_input().split())
a = map(int, raw_input().split())
if (b % 2 == 0):
 	if (a[-1] % 2 == 0):
 		print "even"
 	else:
 		print "odd"
else:
	if (sum(a) % 2 == 0):
		print "even"
	else:
		print "odd"


b, k = map(int, raw_input().split())
a = map(int, raw_input().split())
bb = 1
sum = 0
for x in reversed(a):
	cnt = x * bb
	sum += cnt % 2
	bb = bb * b
	bb %= 2
sum %= 2
if sum == 0:
	print "even"
else:
	print "odd"


n,m=map(int,raw_input().split())
a=map(int,raw_input().split())
sum=0
if(n%2==0):
    if(a[-1]%2==0):
        print "even"
    else:
        print "odd"
else:
    for i in range(len(a)):
        sum+=(a[i])*pow(n,m-i-1)
    if(sum&1):
        print "odd"
    else:
        print "even"


n,m=map(int,raw_input().split())
a=map(int,raw_input().split())
sum=0
if(n%2==0):
    if(a[-1]%2==0):
        print "even"
    else:
        print "odd"
else:
    for i in a:
        if(i&1):
            sum+=1
    if(sum%2==1):
        print "odd"
    else:
        print "even"


import sys
from collections import defaultdict
strInp = lambda : raw_input().strip().split()
intInp = lambda : list(map(int,strInp()))
"""
13 3
3 2 7
"""
b , k = intInp()
arr = intInp()
count_odd = 0

for i in arr[0:k-1]:
    if i*b % 2 != 0:
        count_odd += 1

if arr[k-1] % 2 != 0:
    count_odd += 1

if count_odd % 2 == 0:
    print("even")
else:
    print("odd")


import sys
from collections import defaultdict
strInp = lambda : raw_input().strip().split()
intInp = lambda : list(map(int,strInp()))
"""
13 3
3 2 7
"""
b , k = intInp()
arr = intInp()
s = 0
bpowerk = [1]
for i in range(1,k):
    bpowerk.append(bpowerk[len(bpowerk)-1] * b)
for i in arr:
    k -= 1
    s += i*bpowerk[k]

if(s % 2 == 0):
    print("even")
else:
    print("odd")


import sys
from collections import defaultdict
strInp = lambda : raw_input().strip().split()
intInp = lambda : list(map(int,strInp()))
"""
13 3
3 2 7
"""
b , k = intInp()
is_b_even = True

if(b % 2 != 0):
    is_b_even = False

arr = intInp()
count_odd = 0
for i in arr[0:len(arr)-1]:
    if i % 2 != 0 and is_b_even == False:
        count_odd += 1
if arr[len(arr)-1] % 2 != 0:
    count_odd += 1

if count_odd % 2 == 0:
    print("even")
else:
    print("odd")


import sys
from collections import defaultdict
strInp = lambda : raw_input().strip().split()
intInp = lambda : list(map(int,strInp()))
"""
13 3
3 2 7
"""
b , k = intInp()
arr = intInp()
s = 0
for i in arr:
    k -= 1
    s += i*b**(k)

if(s % 2 == 0):
    print("even")
else:
    print("odd")


b, k = map(int, raw_input().split())
nums = map(int, raw_input().split())

n = 0
for i in xrange(len(nums)):
    n += (nums[i] * pow(b, k-i-1))

if n % 2 == 0: print "even"
else: print "odd"


def bits_of(m):
    n=int(m)
    while n:
        yield n & 1
        n >>= 1

def fast_exp(x,n):
    result = 1
    partial = x

    for bit in bits_of(n):
        if bit:
            result *= partial
        partial ^= 2

    return result

b, k = map(int, raw_input().split())
nums = map(int, raw_input().split())

n = 0
for i in xrange(len(nums)):
    n += (nums[i] * fast_exp(b, k-i-1))

if n % 2 == 0: print "even"
else: print "odd"


data = raw_input().strip().split(" ")
data = map(int,data)
b = data[0]
k = data[1]

data = raw_input().strip().split(" ")
data = map(int,data)
result = 0
for i in range(len(data)):
        result += data[i]*(b**(len(data)-1-i))

if (result % 2 == 0):
        print "even"
else:
        print "odd"


data = raw_input().strip().split(" ")
data = map(int,data)
b = data[0]
k = data[1]

data = raw_input().strip().split(" ")
data = map(int,data)
result = 0
for i in range(len(data)):
        if (b % 2 == 0):
                continue
        else:
                if (data[i] % 2 == 1):
                        result += 1

if (result % 2 == 0):
        print "even"
else:
        print "odd"


data = raw_input().strip().split(" ")
data = map(int,data)
b = data[0]
k = data[1]

data = raw_input().strip().split(" ")
data = map(int,data)
result = 0
for i in range(len(data)-1):
        if (b % 2 == 0):
                continue
        else:
                if (data[i] % 2 == 1):
                        result += 1

result += data[-1]
if (result % 2 == 0):
        print "even"
else:
        print "odd"


data = raw_input().strip().split(" ")
data = map(int,data)
b = data[0]
k = data[1]

data = raw_input().strip().split(" ")
data = map(int,data)
result = 0
for i in range(len(data)):
        result += (data[i]*(b**(len(data)-1-i)) % 2)

if (result % 2 == 0):
        print "even"
else:
        print "odd"


import math
import collections

b, k = map(int, raw_input().split())
a = map(int, raw_input().split())
ans = 0
for x in a:
    ans = ans*b + x
    ans %= 2
if ans==0:
    print('even')
else:
    print('odd')


b, k = map(int, raw_input().strip().split())
arr = map(int, raw_input().strip().split())

if b % 2 == 1:
    print 'even' if sum(arr) % 2 == 0 else 'odd'
else:
    print 'even' if arr[-1] % 2 == 0 else 'odd'


b, k = map(int, raw_input().split())
data = map(int, raw_input().split())

def solve():
    if b%2 == 0:
        return data[-1] % 2
    else:
        return sum(data) % 2

print "odd" if solve() else "even"


#! /usr/bin/python

b, k = [int(inp) for inp in raw_input().split()]
a = [int(inp) % 2 for inp in raw_input().split()]

b = b % 2

if b == 0 and a[k-1] == 0:
	print 'even'
elif b == 1 and sum(a) % 2 == 0:
	print 'even'
else:
	print 'odd'


x=map(int,raw_input().split())
y=map(int,raw_input().split())
c=0
l=x[0]

for i in y:
    x[1]-=1

    c+=i*(l**x[1])

if c%2==0:
    print"even"
else:
    print"odd"


x=map(int,raw_input().split())
y=map(int,raw_input().split())
b=x[0]%10
l=0
jj=len(y)
for i in range(jj-1):
    l+=b*y[i]

l+=y[jj-1]
l%=10
if l%2==0:
    print "even"
else:
    print "odd"


def check(base, number):
	bases = [base**(i-1) for i in range(len(number), 0, -1)]

	total = 0
	for (b, t) in zip(bases, number):
		total += b * t

	if total & 1:
		return 'odd'
	else:
		return 'even'

if __name__ == '__main__':
	b,k = map(int, raw_input().split(' '))
	num = map(int, raw_input().split(' '))

	print check(b, num)


def check(base, number):
	if base & 1:
		return 'even' if sum(number) & 1 == 0 else 'odd'
	else:
		return 'even' if number[-1] & 1 == 0 else 'odd'

if __name__ == '__main__':
	b,k = map(int, raw_input().split(' '))
	num = map(int, raw_input().split(' '))

	print check(b, num)


INF = 999999999999999999L
EPS = 1e-12

def read():
    return raw_input().strip()

def read_ints():
    return map(int,read().split())

b,k = read_ints()
digits = read_ints()
digits.reverse()

ans = 0
for i in range(len(digits)):
    ans += digits[i] * pow(b,i,2)

if ans % 2 == 0:
    print "even"
else:
    print "odd"


b, k = map(int, raw_input().split())

a = [0]+list(map(int, raw_input().split()))

c = 0

b = b&1

for i in range(1, k):

    c += (a[i]&1)*(b)

c += (a[k]&1)

if c&1:

    print "odd"

else:

    print "even"


b, k = raw_input().split(' ')
b, k = int(b), int(k)
a = raw_input().split(' ')
if b % 2 == 0 and int(a[k - 1]) % 2 == 0:
    print 'even'
elif b % 2 == 0 and int(a[k - 1]) % 2 == 1:
    print 'odd'
else:
    s = 0
    for aa in a:
        s += int(aa)
    if(s % 2 == 0):
        print 'even'
    else:
        print 'odd'


b, k = raw_input().split(' ')
b, k = int(b), int(k)
a = raw_input().split(' ')
if b % 2 == 0 and int(a[k - 1]) % 2 == 0:
    print 'even'
elif b % 2 == 0 and int(a[k - 1]) % 2 == 1;
    print 'odd'
else:
    s = 0
    for aa in a:
        s += int(aa)
    if(s % 2 == 0):
        print 'even'
    else
        print 'odd'


#include<stdio.h>

int main()
{

  int x,b,k,i,odd=0;
  scanf("%d %d",&b,&k);

  for(i=0;i<k;i++)
  {
    scanf("%d",&x);
    if(x%2!=0)
      odd++;
  }

  if(odd%2==0&&b%2==1 || x%2==0&&b%2==0)
    printf("Even\n");
  else
    printf("Odd\n");

return 0;
}


#include<stdio.h>
#include<math.h>

int main()
{
    long long int x,n;
    scanf("%lld%lld",&x,&n);
    long long int a[n],i,sum=0;
    for(i=0;i<n;i++)
    {
    scanf("%lld",&a[i]);
    if(a[i]%2==0)
    sum++;
    }

    if(x%2==0)
    {
    if(a[n-1]%2==0)
    printf("even");
    if(a[n-1]%2!=0)
    printf("odd");
    }
    if(x%2!=0)
    {
    if((sum+n)%2==0)
    printf("even");
    else
    printf("odd");
    }

    return 0;
}


#include<stdio.h>
#include<math.h>
#define ll long long int
int main()
{
    ll b,k,n=0;
    scanf("%lld %lld",&b,&k);
    ll a[k];
    for(ll i=0;i<k;i++)
    {
        scanf("%lld",&a[i]);

    }
     for(ll i=0,j=k-1;i<k,j>=0;i++,j--)
    {

        n=n+a[i]*pow(b,j);
    }
    printf("%lld\n",n);
    if(n%2==0)
        printf("even\n");
    else
        printf("odd\n");
    return 0;
}


#include<stdio.h>
#include<math.h>
int main(){
    int a,n,bal;

    scanf("%d%d",&a,&n);
    int sum=0;

    long long int k,lol;
    while(n){
        scanf("%lld",&lol);
        bal=n-1;
        bal=bal%4;
        if(bal==0) bal =4;
      //  if(n>1)
        k=lol*pow((a%10),n-1);
    //    else k=lol;
        if(k&1) sum++;
        n--;
       // printf("%d\t%d\n",n,k);
    }
    if(sum&1) printf("odd\n");
    else printf("even\n");
    return 0;
}


#include<stdio.h>
#include<math.h>
int main(){
    int k,a,n;
    scanf("%d%d",&a,&n);
    int sum=0,lol;
    while(n){
        scanf("%d",&lol);
        k=lol*pow(a,n-1);
        if(k&1) sum++;
        n--;
    }
    if(sum&1) printf("ODD\n");
    else printf("EVEN\n");
    return 0;
}


#include<stdio.h>
#include<math.h>
int main(){
    int a,n,bal;

    scanf("%d%d",&a,&n);
    int sum=0;

    int lol;
    while(n){
        scanf("%d",&lol);
        if(n>1){
        if((a%2==1) && (lol%2==1) ) sum++;
        }
        else {
        	if(lol&1) sum++;
        }
        n--;
      //  printf("%d\t%d\n",n,sum);
    }
    if(sum&1) printf("odd\n");
    else printf("even\n");
    return 0;
}


#include<stdio.h>
#include<math.h>
int main(){
    int a,n,bal;

    scanf("%d%d",&a,&n);
    int sum=0;

    long long int k,lol;
    while(n){
        scanf("%lld",&lol);
        if(n>1){
        bal=n-1;
        bal=bal%4;
        if(bal==0) bal =4;

        }
        else bal=0;
      //  if(n>1)
        k=lol*pow((a%10),bal);
    //    else k=lol;
        if(k&1) sum++;
        n--;
       // printf("%d\t%d\n",n,k);
    }
    if(sum&1) printf("odd\n");
    else printf("even\n");
    return 0;
}


#include<stdio.h>
#include<math.h>
int main(){
    int k,a,n;
    scanf("%d%d",&a,&n);
    int sum=0,lol;
    while(n){
        scanf("%d",&lol);
        if(n>1)
        k=lol*pow(a,n-1);
        else k=lol;
        if(k&1) sum++;
        n--;
    }
    if(sum&1) printf("odd\n");
    else printf("even\n");
    return 0;
}


#include<stdio.h>
#include<math.h>
int main(){
    int a,n;

    scanf("%d%d",&a,&n);
    int sum=0;

    long long int k,lol;
    while(n){
        scanf("%lld",&lol);
        if(n>1)
        k=lol*pow((a%10),n-1);
        else k=lol;
        if(k&1) sum++;
        n--;
       // printf("%d\t%d\n",n,k);
    }
    if(sum&1) printf("odd\n");
    else printf("even\n");
    return 0;
}


#include<stdio.h>
#include<math.h>
int main(){
	int n=0;
	int a,k,b;
	scanf("%d",&b);
	scanf("%d",&k);
	k--;
	for(;k>=0;k--){
		scanf("%d",&a);
		n=+(a*(int)pow(b,k))%2;
	}
	n=n%2;
	if(n=1)
		printf("odd");
	if(n=0)
		printf("even");
	return 0;
}


#include<stdio.h>
#include<math.h>
int main(){
	int n=0;
	int a,k,b;
	scanf("%d",&b);
	scanf("%d",&k);
	for(k--;k>=0;k--){
		scanf("%d",&a);
		n=n+((a%2)*(int)(pow(b,k))%2);
	}
	n=n%2;
	switch(n){
	case 1:printf("odd\n");break;
	case 0:printf("even\n");break;
	}
	return 0;
}


#include<stdio.h>
#include<math.h>
int main(){
	int n=0;
	int a,k,b;
	scanf("%d",&b);
	scanf("%d",&k);
	for(k--;k>=0;k--){
		scanf("%d",&a);
		n+=((a%2)*(int)(pow(b,k))%2);
	}
	n=n%2;
	switch(n){
	case 1:printf("odd\n");break;
	case 0:printf("even\n");break;
	}
	return 0;
}


#include<stdio.h>
#include<math.h>
int main(){
	int n=0;
	int a,k,b;
	scanf("%d",&b);
	scanf("%d",&k);
	for(k--;k>=0;k--){
		scanf("%d",&a);
		n+=(a*(int)pow(b,k));
	}
	n=n%2;
	switch(n){
	case 1:printf("obb");break;
	case 0:printf("even");break;
	}
	return 0;
}


#include<stdio.h>
int main(){
	int n=0;
	int a,k,b;
	scanf("%d",&b);
	scanf("%d",&k);
	for(;k>0;k--){
		scanf("%d",&a);
			n+=a%2;
	}
	n=n%2;
	if(b%2==0){
		n=a%2;
	}
	switch(n){
	case 1:printf("odd\n");break;
	case 0:printf("even\n");break;
	}
	return 0;
}


#include<stdio.h>
#include<math.h>
int main(){
	int n=0;
	int a,k,b;
	scanf("%d",&b);
	scanf("%d",&k);
	for(k--;k>=0;k--){
		scanf("%d",&a);
		n+=((a%2)*((int)pow(b,k)%2));
	}
	n=n%2;
	switch(n){
	case 1:printf("odd\n");break;
	case 0:printf("even\n");break;
	}
	return 0;
}


#include<stdio.h>
#include<math.h>
int main(){
	int n=0;
	int a,k,b;
	scanf("%d",&b);
	scanf("%d",&k);
	for(k--;k>=0;k--){
		scanf("%d",&a);
		n+=((a%2)*((int)pow(b,k)%2));
	}
	n=n%2;
	switch(n){
	case 1:printf("odd");break;
	case 0:printf("even");break;
	}
	return 0;
}


#include<stdio.h>
#include<math.h>
int main(){
	int n=0;
	int a,k,b;
	scanf("%d",&b);
	scanf("%d",&k);
	k--;
	for(;k>=0;k--){
		scanf("%d",&a);
		n=+(a*power(b,k))%2;
	}
	n=n%2;
	if(n=1)
		printf("odd");
	if(n=0)
		printf("even");
	return 0;
}


#include<stdio.h>
int p(int b,int k){
	int r=1;
	for(;k>0;k--){
		r*=b;
	}
	return r;
}
int main(){
	int n=0;
	int a,k,b;
	scanf("%d",&b);
	scanf("%d",&k);
	for(k--;k>=0;k--){
		scanf("%d",&a);
		n+=((a%2)*(p(b,k)%2));
	}
	n=n%2;
	switch(n){
	case 1:printf("odd");break;
	case 0:printf("even");break;
	}
	return 0;
}


#include<stdio.h>
#include<math.h>
int main(){
	int n=0;
	int a,k,b;
	scanf("%d",&b);
	scanf("%d",&k);
	k--;
	for(;k>=0;k--){
		scanf("%d",&a);
		n=+(a*pow(b,k))%2;
	}
	n=n%2;
	if(n=1)
		printf("odd");
	if(n=0)
		printf("even");
	return 0;
}


#include  <stdio.h>
#include <math.h>

int main()
{
    int num,digit,array[100002],i;
    long long int ans=0;
    scanf("%d %d",&num,&digit);
    for(i=1; i<=digit; i++)
    {
        scanf("%d",&array[i]);
        ans=ans+(array[i]*pow(num,(digit-i)));
    }
    if(ans%2==0)
    {
        printf("even\n");
    }
    else
    {
        printf("odd\n");
    }

}


#include<stdio.h>
#include<math.h>
int main(void)
{
    long long int n,m,i,x;
    double result=0;
    scanf("%lld%lld",&n,&m);
    while(m--)
    {
          scanf("ll%d",&x);
          result += (double)x * pow(n,m);
    }
    long long int p;
    p = (long long int)result;
    if(p%2==0)
    {
        printf("even\n");
    }
    else
    {
        printf("odd\n");
    }
    return 0;
}


#include  <stdio.h>
#include <math.h>

int main()
{
    int num,digit,array[100002],i;
    long long int ans=0;
    scanf("%d %d",&num,&digit);
    for(i=1; i<=digit; i++)
    {
        scanf("%d",&array[i]);
        ans=ans+(array[i]*pow(num,(digit-i)));
    }
    if(ans%2==0)
    {
        printf("even\n");
    }
    else
    {
        printf("odd\n");
    }
    return 0;
}


#include  <stdio.h>
#include <math.h>

int main()
{
    int num,digit,array[100002],i;
    long long int ans=0;
    scanf("%d %d",&num,&digit);
    for(i=1; i<=digit; i++)
    {
        scanf("%d",&array[i]);
        ans=ans+(array[i]*pow(num,(digit-i)));
    }
    if(ans%2==0)
    {
        printf("even");
    }
    else
    {
        printf("odd");
    }

}


#include  <stdio.h>
#include <math.h>

int main()
{
    int num,digit,m[10000],i;
    long long int ans=0;
    scanf("%d %d",&num,&digit);
    for(i=1; i<=digit; i++)
    {
        scanf("%d",&m[i]);
        ans=ans+(m[i]*pow(num,(digit-i)));
    }
    if(ans%2==0)
    {
        printf("even");
    }
    else
    {
        printf("odd");
    }

}


#include  <stdio.h>
#include <math.h>

int main()
{
    int num,digit,a[100002],i;
    long long int ans=0;
    scanf("%d %d",&num,&digit);
    for(i=1; i<=digit; i++)
    {
        scanf("%d",&a[i]);
        ans=ans+(a[i]*pow(num,(digit-i)));
    }
    if(ans%2==0)
    {
        printf("even");
    }
    else
    {
        printf("odd");
    }
    return 0;

}


#include  <stdio.h>
#include <math.h>

int main()
{
    int k,n,i;
    scanf("%d %d",&k,&n);
    int ar[n];
    for( i=0;i<n;i++)
    {
        scanf("%d",&ar[i]);
    }
    if(k%2==0)
    {
        if(ar[n-1]%2==0)
        {
            printf("even");
        }
        else
        {
            printf("odd");
        }
    }
    else
    {
        int count=0;
        for(  i=0;i<n;i++)
        {
            if(ar[i]%2==1)
            {
                count++;
            }
        }
        if(count%2==0)
            printf("even");
        else
            printf("odd");
    }
}


#include<stdio.h>
#include<math.h>
int main(void)
{
    int n,m,i,x;
    double result=0;
    scanf("%d%d",&n,&m);
    while(m--)
    {
          scanf("%d",&x);
          result += (double)x * pow(n,m);
    }
    int p;
    p = (int)result;
    if(p%2==0)
    {
        printf("even\n");
    }
    else
    {
        printf("odd\n");
    }
    return 0;
}


#include  <stdio.h>
#include <math.h>

int main()
{
    int num,digit,m,i;
    long long int ans=0;
    scanf("%d %d",&num,&digit);
    for(i=1; i<=digit; i++)
    {
        scanf("%d",&m);
        ans=ans+(m*pow(num,(digit-i)));
    }
    if(ans%2==0)
    {
        printf("even");
    }
    else
    {
        printf("odd");
    }

}


#include<stdio.h>
#include<math.h>
int main( )
{
   int b,k,ak,i,ocount;
   scanf("%d %d",&b,&k);
   for(i=0;i<k;i++)
   {
      scanf("%d",&ak);
      if(ak&1)ocount++;
   }
   if(b&1)
   {
      if(ocount&1)
	   printf("odd\n");
      else
	  {printf("even\n");
	  }
   }
   else
   {
      if(ak&1)
	 {
	  printf("odd\n");}
      else
	  printf("even\n");
   }
return 0;
}


#include<stdio.h>
#include<math.h>
int main()
{
    long long int b,n,k,i,s=0;
    scanf("%lld %lld",&b,&n);
    for(i=n-1;i>=0;i--)
    {
        scanf("%lld",&k);
        if((k%2==1&&b%2==1)||(k%2==1&&i==0))
        {
           s++;
        }
        else
        {
            s+=2;
        }
    }
    if(s%2==0)
    {
        printf("even\n");
    }
    else
    {
        printf("odd\n");
    }
    return 0;
}


#include<stdio.h>
#include<math.h>
int main()
{
    long long int b,n,k,i,j=1,s=0,l;
    scanf("%lld %lld",&b,&n);
    for(i=n-1;i>=0;i--)
    {
        scanf("%lld",&k);
        for(l=1;l<=i;l++)
        {
            j=j*b;
        }
        s=s+k*j;
        j=1;
    }
    if(s%2==0)
    {
        printf("even\n");
    }
    else
    {
        printf("odd\n");
    }
    return 0;
}


#include<stdio.h>
int main()
{
    int b,k,sum=0,i;
    scanf("%d %d",&b,&k);
    long int a[k];
    for(i=0;i<k;i++)
    {
        scanf("%d",&a[i]);
        sum=sum+a[i];
    }
    if(b==0)
        printf("even");
    else if(b%2==0&&k%2==0)
    {
       if(sum%2==0)
            printf("odd");
       else
        printf("even");
    }
    else
    {
        if(sum%2==0)
            printf("even");
        else
            printf("odd");
    }
    return 0;
}


#include<stdio.h>
int main()
{
    int b,k,sum=0,i;
    scanf("%d %d",&b,&k);
    long int a[k];
    for(i=0;i<k;i++)
    {
        scanf("%d",&a[i]);
        sum=sum+a[i];
    }
    if(b%2==0&&k%2==0)
    {
       if(sum%2==0)
            printf("odd");
       else
        printf("even");
    }
    else
    {
        if(sum%2==0)
            printf("even");
        else
            printf("odd");
    }
    return 0;
}


#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>

using namespace std;
int T, X;
char s[4000010];
char tmp[4000010];

#define MOD 1000000007

void paste(char str[], int i, int len, int times) {
    int cut_len = len - i;
    if(times >= 2) {
        strcpy(tmp, str + i);
        strcpy(str + len, tmp);
    }
    if(times == 3) strcpy(str + len + cut_len, tmp);
}

int main(){
    scanf("%d", &T);
    for(int t=0;t<T;t++){
        scanf("%d", &X);
        scanf("%s", s);

        long long int len = strlen(s);
        bool exceed = false;

        for(int i=1;i<=X;i++){
            long long int cut_len = len - i;
            long long int times = s[i-1] - '0';
            if(X >= len && !exceed) paste(s, i, len, times);

            //printf("%s\n", s);
            len += (cut_len * (times - 1));
            if(len > X) exceed = true;
            len %= MOD;
        }
        printf("%lld\n", len);
    }
    return 0;
}


#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>

using namespace std;
int T, X;
char s[4000010];
char tmp[4000010];

#define MOD 1000000007

void paste(char str[], int i, int len, int times) {
    int cut_len = len - i;
    if(times >= 2) {
        strcpy(tmp, str + i);
        strcpy(str + len, tmp);
    }
    if(times == 3) strcpy(str + len + cut_len, tmp);
}

int main(){
    scanf("%d", &T);
    for(int t=0;t<T;t++){
        scanf("%d", &X);
        scanf("%s", s);

        long long int len = strlen(s);
        bool exceed = false;

        for(int i=1;i<=X;i++){
            int cut_len = len - i;
            int times = s[i-1] - '0';
            if(X >= len && !exceed) paste(s, i, len, times);

            //printf("%s\n", s);
            len += (cut_len * (times - 1));
            if(len > X) exceed = true;
            len %= MOD;
        }
        printf("%lld\n", len);
    }
    return 0;
}


#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>

using namespace std;
int T, X;
char s[4000010];
char tmp[4000010];

#define MOD 1000000007

void paste(char str[], int i, int len, int times) {
    int cut_len = len - i;
    if(times >= 2) {
        strcpy(tmp, str + i);
        strcpy(str + len, tmp);
    }
    if(times == 3) strcpy(str + len + cut_len, tmp);
}

int main(){
    scanf("%d", &T);
    for(int t=0;t<T;t++){
        scanf("%d", &X);
        scanf("%s", s);

        long long int len = strlen(s);
        bool exceed = false;

        for(int i=1;i<=X;i++){
            long long int cut_len = len - i;
            long long int times = s[i-1] - '0';
            if(X >= len && !exceed) paste(s, i, len, times);

            //printf("%s\n", s);
            len += (cut_len * (times - 1));
            if(len > X) exceed = true;
            len = (len + MOD) % MOD;
        }
        printf("%lld\n", len);
    }
    return 0;
}


#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>

using namespace std;
int T, X;
char s[4000010];
char tmp[4000010];

#define MOD 1000000007

void paste(char str[], int i, int len, int times) {
    int cut_len = len - i;
    if(times >= 2) {
        strcpy(tmp, str + i);
        strcpy(str + len, tmp);
    }
    if(times == 3) strcpy(str + len + cut_len, tmp);
}

int main(){
    scanf("%d", &T);
    for(int t=0;t<T;t++){
        scanf("%d", &X);
        scanf("%s", s);

        long long int len = strlen(s);
        bool exceed = false;

        for(int i=1;i<=X;i++){
            int cut_len = len - i;
            int times = s[i-1] - '0';
            if(X >= len && !exceed) paste(s, i, len, times);
            if(len > X) exceed = true;
            //printf("%s\n", s);
            len += (cut_len * (times - 1));
            len %= MOD;
        }
        printf("%lld\n", len);
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

const ll mod = 1e9+7;
char a[20000007];
char tmp[3000007];
int t,x;

int main()
{
	scanf("%d",&t);
	while(t--)
	{
		scanf("%d%s",&x,a);
		ll len = strlen(a);
		for(int i=0;i<x;i++)
		{
			if(len < x)
			{
				strcpy(tmp, a + i + 1);
				ll sum = a[i] - '0';
				for(int j=1;j<sum;j++)
					strcat(a, tmp);
				len = (len + (len - i - 1) * (sum - 1) % mod) % mod;
			}
			else
			{
				ll sum = a[i] - '0';
				len = (len + (len - i - 1) * (sum - 1) % mod) % mod;
			}
		}
		cout<<len<<endl;
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

const ll mod = 1e9+7;
string a;
string tmp;
int t,x;

inline string StringRead()
{
    string str;
    char s = getchar();
    //处理多余回车或空格
    while (s == ' ' || s == '\n' || s == '\r')
    {
        s = getchar();
    }
    //不断读入直到遇到回车或空格
    while (s != ' ' && s != '\n' && s != '\r')
    {
        str += s;
        s = getchar();
    }
    return str;
}

int main()
{
	scanf("%d",&t);
	while(t--)
	{
		scanf("%d",&x);
		a = StringRead();
		ll len = a.length();
		for(int i=0;i<x;i++)
		{
			if(len < x)
			{
				tmp = a.substr(i + 1, len - i - 1);
				ll sum = a[i] - '0';
				for(int j=1;j<sum;j++)
					a = a + tmp;
				len = (len + (len - i - 1) * (sum - 1) % mod) % mod;
			}
			else
			{
				ll sum = a[i] - '0';
				len = (len + (len - i - 1) * (sum - 1) % mod) % mod;
			}
		}
		cout<<len<<endl;
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

const ll mod = 1e9+7;
string a;
string tmp;
int t,x;

inline string StringRead()
{
    string str;
    char s = getchar();
    //处理多余回车或空格
    while (s == ' ' || s == '\n' || s == '\r')
    {
        s = getchar();
    }
    //不断读入直到遇到回车或空格
    while (s != ' ' && s != '\n' && s != '\r')
    {
        str += s;
        s = getchar();
    }
    return str;
}

int main()
{
	scanf("%d",&t);
	while(t--)
	{
		scanf("%d",&x);
		a = StringRead();
		ll len = a.length();
		for(int i=0;i<x;i++)
		{
			if(len < x)
			{
				tmp = a.substr(i + 1, len - 1);
				ll sum = a[i] - '0';
				ll L = len - i - 1;
				int j;
				for(j=1;j<sum;j++)
				{
					if(len >= x)
					{
						len = (len + L * (sum - j) % mod) % mod;
						break;
					}
					a += tmp;
					len = a.size();
				}
			}
			else
			{
				ll sum = a[i] - '0';
				len = (len + (len - i - 1) * (sum - 1) % mod) % mod;
			}
		}
		printf("%lld\n",len);
		a.clear();
		tmp.clear();
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

const ll mod = 1e9+7;
char a[10000007];
char tmp[10000007];
int t,x;

int main()
{
	scanf("%d",&t);
	while(t--)
	{
		scanf("%d%s",&x,a);
		ll len = strlen(a);
		for(int i=0;i<x;i++)
		{
			if(len < x)
			{
				strcpy(tmp, a + i + 1);
				ll sum = a[i] - '0';
				for(int j=1;j<sum;j++)
					strcat(a, tmp);
				len = (len + (len - i - 1) * (sum - 1) % mod) % mod;
			}
			else
			{
				ll sum = a[i] - '0';
				len = (len + (len - i - 1) * (sum - 1) % mod) % mod;
			}
		}
		cout<<len<<endl;
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

const ll mod = 1e9+7;
string a;
ll t,x;

inline string StringRead()
{
    string str;
    char s = getchar();
    //处理多余回车或空格
    while (s == ' ' || s == '\n' || s == '\r')
    {
        s = getchar();
    }
    //不断读入直到遇到回车或空格
    while (s != ' ' && s != '\n' && s != '\r')
    {
        str += s;
        s = getchar();
    }
    return str;
}

int main()
{
	scanf("%lld",&t);
	while(t--)
	{
		scanf("%lld",&x);
		getline(cin, a);
		ll len = a.size();
		for(int i=0;i<x;i++)
		{
			if(len < x)
			{
				string tmp = a.substr(i + 1, len - 1);
				for(int j=1;j<a[i] - '0';j++)
					a += tmp;
				len = a.size();
			}
			else
			{
				ll sum = a[i] - '0';
				len = (len + (len - i - 1 + mod) % mod * (sum - 1) % mod) % mod;
			}
		}
		printf("%lld\n",len % mod);
		a.clear();
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

const ll mod = 1e9+7;
char a[20000007];
char tmp[20000007];
int t,x;

int main()
{
	scanf("%d",&t);
	while(t--)
	{
		scanf("%d%s",&x,a);
		ll len = strlen(a);
		for(int i=0;i<x;i++)
		{
			if(len < x)
			{
				strcpy(tmp, a + i + 1);
				ll sum = a[i] - '0';
				for(int j=1;j<sum;j++)
					strcat(a, tmp);
				len = (len + (len - i - 1) * (sum - 1) % mod) % mod;
			}
			else
			{
				ll sum = a[i] - '0';
				len = (len + (len - i - 1) * (sum - 1) % mod) % mod;
			}
		}
		cout<<len<<endl;
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

const ll mod = 1e9+7;
string a;
string tmp;
int t,x;

inline string StringRead()
{
    string str;
    char s = getchar();
    //处理多余回车或空格
    while (s == ' ' || s == '\n' || s == '\r')
    {
        s = getchar();
    }
    //不断读入直到遇到回车或空格
    while (s != ' ' && s != '\n' && s != '\r')
    {
        str += s;
        s = getchar();
    }
    return str;
}

int main()
{
	scanf("%d",&t);
	while(t--)
	{
		scanf("%d",&x);
		a = StringRead();
		ll len = a.size();
		for(int i=0;i<x;i++)
		{
			if(len < x)
			{
				tmp = a.substr(i + 1, len - 1);
				ll sum = a[i] - '0';
				ll L = len - i - 1;
				int j;
				for(j=1;j<sum;j++)
					a += tmp;
				len = (len + L * (sum - 1) % mod) % mod;
			}
			else
			{
				ll sum = a[i] - '0';
				len = (len + (len - i - 1) * (sum - 1) % mod) % mod;
			}
		}
		printf("%lld\n",len);
		a.clear();
		tmp.clear();
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

const ll mod = 1e9+7;
string a;
string tmp;
int t,x;

inline string StringRead()
{
    string str;
    char s = getchar();
    //处理多余回车或空格
    while (s == ' ' || s == '\n' || s == '\r')
    {
        s = getchar();
    }
    //不断读入直到遇到回车或空格
    while (s != ' ' && s != '\n' && s != '\r')
    {
        str += s;
        s = getchar();
    }
    return str;
}

int main()
{
	scanf("%d",&t);
	while(t--)
	{
		scanf("%d",&x);
		a = StringRead();
		ll len = a.length();
		for(int i=0;i<x;i++)
		{
			if(len < x)
			{
				tmp = a.substr(i + 1, len - i - 1);
				ll sum = a[i] - '0';
				ll L = len - i - 1;
				int j;
				for(j=1;j<sum;j++)
				{
					if(len >= x)
					{
						len = (len + L * (sum - j) % mod) % mod;
						break;
					}
					a = a + tmp;
					len += L;
				}
			}
			else
			{
				ll sum = a[i] - '0';
				len = (len + (len - i - 1) * (sum - 1) % mod) % mod;
			}
		}
		printf("%lld\n",len);
		a.clear();
		tmp.clear();
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

const ll mod = 1e9+7;
ll t,x;

int main()
{
	string a;
	scanf("%lld",&t);
	while(t--)
	{
		scanf("%lld",&x);getchar();
		getline(cin, a);
		ll len = a.size();
		for(int i=0;i<x;i++)
		{
			if(len < x)
			{
				string tmp = a.substr(i + 1, len - 1);
				for(int j=1;j<a[i] - '0';j++)
					a += tmp;
				len = a.size();
			}
			else
			{
				ll sum = a[i] - '0';
				len = (len + (len - i - 1 + mod) % mod * (sum - 1) % mod) % mod;
			}
		}
		printf("%lld\n",len % mod);
		a.clear();
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

const ll mod = 1e9+7;
string a;
string tmp;
int t,x;

inline string StringRead()
{
    string str;
    char s = getchar();
    //处理多余回车或空格
    while (s == ' ' || s == '\n' || s == '\r')
    {
        s = getchar();
    }
    //不断读入直到遇到回车或空格
    while (s != ' ' && s != '\n' && s != '\r')
    {
        str += s;
        s = getchar();
    }
    return str;
}

int main()
{
	scanf("%d",&t);
	while(t--)
	{
		scanf("%d",&x);
		a = StringRead();
		ll len = a.length();
		for(int i=0;i<x;i++)
		{
			if(len < x)
			{
				tmp = a.substr(i + 1, len - i - 1);
				ll sum = a[i] - '0';
				ll L = len - i - 1;
				int j;
				for(j=1;j<sum;j++)
				{
					if(len >= x)
					{
						len = (len + L * (sum - j) % mod) % mod;
						break;
					}
					a += tmp;
					len = a.length();
				}
			}
			else
			{
				ll sum = a[i] - '0';
				len = (len + (len - i - 1) * (sum - 1) % mod) % mod;
			}
		}
		printf("%lld\n",len);
		a.clear();
		tmp.clear();
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

const ll mod = 1e9+7;
ll t,x;

int main()
{
	string a;
	scanf("%lld",&t);
	while(t--)
	{
		scanf("%lld",&x);getchar();
		getline(cin, a);
		ll len = a.size();
		for(int i=0;i<x;i++)
		{
			if(len < x)
			{
				string tmp = a.substr(i + 1, len - 1);
				for(int j = a[i] - '0' - 1;j >= 1 ;j--)
					a += tmp;
				len = a.size();
			}
			else
			{
				ll sum = a[i] - '0';
				len = (len + (len - i - 1 + mod) % mod * (sum - 1) % mod) % mod;
			}
		}
		printf("%lld\n",len % mod);
		a.clear();
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

const ll mod = 1e9+7;
string a;
string tmp;
int t,x;

inline string StringRead()
{
    string str;
    char s = getchar();
    //处理多余回车或空格
    while (s == ' ' || s == '\n' || s == '\r')
    {
        s = getchar();
    }
    //不断读入直到遇到回车或空格
    while (s != ' ' && s != '\n' && s != '\r')
    {
        str += s;
        s = getchar();
    }
    return str;
}

int main()
{
	scanf("%d",&t);
	while(t--)
	{
		scanf("%d",&x);
		a = StringRead();
		ll len = a.length();
		for(int i=0;i<x;i++)
		{
			if(len < x)
			{
				tmp = a.substr(i + 1, len - i - 1);
				ll sum = a[i] - '0';
				ll L = len - i - 1;
				int j;
				for(j=1;j<sum;j++)
				{
					if(len >= x)
					{
						len = (len + L * (sum - j) % mod) % mod;
						break;
					}
					a = a + tmp;
					len = a.length();
				}
			}
			else
			{
				ll sum = a[i] - '0';
				len = (len + (len - i - 1) * (sum - 1) % mod) % mod;
			}
		}
		printf("%lld\n",len);
		a.clear();
		tmp.clear();
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

const ll mod = 1e9+7;
ll t,x;

int main()
{
	string a;
	scanf("%lld",&t);
	while(t--)
	{
		scanf("%lld",&x);getchar();
		getline(cin, a);
		ll len = a.size();
		ll i = 0;
		while(len < x)
		{
			string tmp = a.substr(i + 1, len - 1);
			for(int j = a[i] - '0' - 1;j >= 1 ;j--)
				a += tmp;
			i++;
			len = a.size();
		}
		for(;i<x;i++)
		{
			ll sum = a[i] - '0';
			len = (len + (len - i - 1 + mod) % mod * (sum - 1) % mod) % mod;
		}
		printf("%lld\n",len % mod);
		a.clear();
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

const ll mod = 1e9+7;
string a;
string tmp;
int t,x;

inline string StringRead()
{
    string str;
    char s = getchar();
    //处理多余回车或空格
    while (s == ' ' || s == '\n' || s == '\r')
    {
        s = getchar();
    }
    //不断读入直到遇到回车或空格
    while (s != ' ' && s != '\n' && s != '\r')
    {
        str += s;
        s = getchar();
    }
    return str;
}

int main()
{
	scanf("%d",&t);
	while(t--)
	{
		scanf("%d",&x);
		a = StringRead();
		ll len = a.length();
		for(int i=0;i<x;i++)
		{
			if(len < x)
			{
				tmp = a.substr(i + 1, len - i - 1);
				ll sum = a[i] - '0';
				ll L = len - i - 1;
				int j;
				for(j=1;j<sum;j++)
				{
					if(len >= x)
					{
						len = (len + L * (sum - j) % mod) % mod;
						break;
					}
					a = a + tmp;
					len += L;
				}
			}
			else
			{
				ll sum = a[i] - '0';
				len = (len + (len - i - 1) * (sum - 1) % mod) % mod;
			}
		}
		cout<<len<<endl;
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

const ll mod = 1e9+7;
string a;
int t,x;

inline string StringRead()
{
    string str;
    char s = getchar();
    //处理多余回车或空格
    while (s == ' ' || s == '\n' || s == '\r')
    {
        s = getchar();
    }
    //不断读入直到遇到回车或空格
    while (s != ' ' && s != '\n' && s != '\r')
    {
        str += s;
        s = getchar();
    }
    return str;
}

int main()
{
	scanf("%d",&t);
	while(t--)
	{
		scanf("%d",&x);
		a = StringRead();
		ll len = a.size();
		for(int i=0;i<x;i++)
		{
			if(len < x)
			{
				string tmp = a.substr(i + 1, len - 1);
				ll sum = a[i] - '0';
				ll L = len - i - 1;
				int j;
				for(j=1;j<sum;j++)
					a += tmp;
				len = (len + L * (sum - 1) % mod) % mod;
			}
			else
			{
				ll sum = a[i] - '0';
				len = (len + (len - i - 1) * (sum - 1) % mod) % mod;
			}
		}
		printf("%lld\n",len);
		a.clear();
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

const ll mod = 1e9+7;
string a;
int t,x;

inline string StringRead()
{
    string str;
    char s = getchar();
    //处理多余回车或空格
    while (s == ' ' || s == '\n' || s == '\r')
    {
        s = getchar();
    }
    //不断读入直到遇到回车或空格
    while (s != ' ' && s != '\n' && s != '\r')
    {
        str += s;
        s = getchar();
    }
    return str;
}

int main()
{
	scanf("%d",&t);
	while(t--)
	{
		scanf("%d",&x);
		a = StringRead();
		ll len = a.size();
		for(int i=0;i<x;i++)
		{
			if(len < x)
			{
				string tmp = a.substr(i + 1, len - 1);
				ll sum = a[i] - '0';
				ll L = len - i - 1;
				int j;
				for(j=1;j<sum;j++)
					a += tmp;
				len = (len + L * (sum - 1) % mod) % mod;
			}
			else
			{
				ll sum = a[i] - '0';
				len = (len + (len - i - 1 + mod) % mod * (sum - 1) % mod) % mod;
			}
		}
		printf("%lld\n",len);
		a.clear();
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

const ll mod = 1e9+7;
string a;
int t,x;

inline string StringRead()
{
    string str;
    char s = getchar();
    //处理多余回车或空格
    while (s == ' ' || s == '\n' || s == '\r')
    {
        s = getchar();
    }
    //不断读入直到遇到回车或空格
    while (s != ' ' && s != '\n' && s != '\r')
    {
        str += s;
        s = getchar();
    }
    return str;
}

int main()
{
	scanf("%d",&t);
	while(t--)
	{
		scanf("%d",&x);
		a = StringRead();
		ll len = a.size();
		for(int i=0;i<x;i++)
		{
			if(len < x)
			{
				string tmp = a.substr(i + 1, len - 1);
				for(int j=1;j<a[i] - '0';j++)
					a += tmp;
				len = a.size();
			}
			else
			{
				ll sum = a[i] - '0';
				len = (len + (len - i - 1 + mod) % mod * (sum - 1) % mod) % mod;
			}
		}
		printf("%lld\n",len);
		a.clear();
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

const ll mod = 1e9+7;
ll t,x;

int main()
{
	string a;
	scanf("%lld",&t);
	while(t--)
	{
		scanf("%lld",&x);getchar();
		getline(cin, a);
		ll len = a.size();
		for(ll i=0;i<x;i++)
		{
			if(len < x)
			{
				string tmp = a.substr(i + 1, len - 1);
				for(int j = a[i] - '0' - 1;j >= 1 ;j--)
					a += tmp;
				len = a.size();
			}
			else
			{
				ll sum = a[i] - '0';
				len = (len + (len - i - 1 + mod) % mod * (sum - 1) % mod) % mod;
			}
		}
		printf("%lld\n",len % mod);
		a.clear();
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

const ll mod = 1e9+7;
string a;
int t,x;

inline string StringRead()
{
    string str;
    char s = getchar();
    //处理多余回车或空格
    while (s == ' ' || s == '\n' || s == '\r')
    {
        s = getchar();
    }
    //不断读入直到遇到回车或空格
    while (s != ' ' && s != '\n' && s != '\r')
    {
        str += s;
        s = getchar();
    }
    return str;
}

int main()
{
	scanf("%d",&t);
	while(t--)
	{
		scanf("%d",&x);
		a = StringRead();
		ll len = a.size();
		for(int i=0;i<x;i++)
		{
			if(len < x)
			{
				string tmp = a.substr(i + 1, len - 1);
				for(int j=1;j<a[i] - '0';j++)
					a += tmp;
				len = a.size();
			}
			else
			{
				ll sum = a[i] - '0';
				len = (len + (len - i - 1 + mod) % mod * (sum - 1) % mod) % mod;
			}
		}
		printf("%lld\n",len % mod);
		a.clear();
	}
	return 0;
}


#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#define int long long
#define gmax(x,y) x=max(x,y)
#define gmin(x,y) x=min(x,y)
#define F first
#define S second
#define P pair
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define rep(i,a,b) for(int i=a;i<b;i++)
#define V vector
#define RE return
#define ALL(a) a.begin(),a.end()
#define MP make_pair
#define PB emplace_back
#define PF push_front
#define FILL(a,b) memset(a,b,sizeof(a))
#define lwb lower_bound
#define upb upper_bound
using namespace std;
int mod=1e9+7;
void solve(){
	string s;
	int x;
	cin>>x>>s;
	int len=s.size();
	rep(i,0,x){
		if(s.size()<x){
			if(s[i]=='2'){
				s+=s.substr(i+1);
			}else if(s[i]=='3'){
				s+=s.substr(i+1)+s.substr(i+1);
			}
			len=s.size();
		}else len=((len-i-1+mod)%mod*(s[i]-'1')+len)%mod;
	}
	cout<<len<<'\n';
}
signed main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t;
	cin>>t;
	while(t--)solve();
	RE 0;
}


#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#define int long long
#define gmax(x,y) x=max(x,y)
#define gmin(x,y) x=min(x,y)
#define F first
#define S second
#define P pair
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define rep(i,a,b) for(int i=a;i<b;i++)
#define V vector
#define RE return
#define ALL(a) a.begin(),a.end()
#define MP make_pair
#define PB emplace_back
#define PF push_front
#define FILL(a,b) memset(a,b,sizeof(a))
#define lwb lower_bound
#define upb upper_bound
using namespace std;
int mod=1e9+7;
void solve(){
	string s;
	int x;
	cin>>x>>s;
	int len=s.size();
	rep(i,0,x){
		if(s.size()<x){
			if(s[i]=='2'){
				s+=s.substr(i+1);
			}else if(s[i]=='3'){
				s+=s.substr(i+1)+s.substr(i+1);
			}
			len=s.size();
		}else len=((s[i]-'1')*(len-i-1)+len)%mod;
	}
	cout<<len<<'\n';
}
signed main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t;
	cin>>t;
	while(t--)solve();
	RE 0;
}


#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#define int long long
#define gmax(x,y) x=max(x,y)
#define gmin(x,y) x=min(x,y)
#define F first
#define S second
#define P pair
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define rep(i,a,b) for(int i=a;i<b;i++)
#define V vector
#define RE return
#define ALL(a) a.begin(),a.end()
#define MP make_pair
#define PB emplace_back
#define PF push_front
#define FILL(a,b) memset(a,b,sizeof(a))
#define lwb lower_bound
#define upb upper_bound
using namespace std;
int mod=1e9+7;
void solve(){
	string s;
	int x;
	cin>>x>>s;
	int len=s.size();
	rep(i,0,x){
		if(s.size()<x){
			if(s[i]=='2'){
				s+=s.substr(i+1);
			}else if(s[i]=='3'){
				s+=s.substr(i+1)+s.substr(i+1);
			}
		}
		len=((s[i]-'1')*(len-i-1)+len)%mod;
	}
	cout<<len<<'\n';
}
signed main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t;
	cin>>t;
	while(t--)solve();
	RE 0;
}


#include<bits/stdc++.h>
#define ll long long
#define R register
using namespace std;
const int N =2e6+200;
const ll mod = 1e9+7;
template <class Ruby_Rose> inline void read(Ruby_Rose &x)
{
 	x=0;
	char ch=getchar(), w=0;
	while(!isdigit(ch))w=(ch=='-'), ch=getchar();
	while(isdigit(ch))x=(x<<1)+(x<<3)+(ch^48), ch=getchar();
	x=w?-x:x;
}
int T, n, x;
char s[N];
int main()
{
	read(T);
	while(T--)
	{
		read(x);
		scanf("%s", s+1); int n=strlen(s+1);
		ll ans=n;
		for(R int i=1; i<=x; i++)
		{
			ans=(ans+(s[i]-'0'-1)*(n-i)%mod)%mod; int now=n, tmp=n;
			n=ans;
//			cout<<ans<<endl;
			for(R int j=2; j<=s[i]-'0'; j++)
			{
				for(R int k=i+1; tmp<x && k<=now; k++)s[++tmp]=s[k];
			}
		}
		cout<<(ans%mod+mod)%mod<<endl;
	}
	return 0;
}


#include<bits/stdc++.h>
#define ll long long
#define R register
#define int long long
using namespace std;
const int N =2e6+200;
const ll mod = 1e9+7;
template <class Ruby_Rose> inline void read(Ruby_Rose &x)
{
 	x=0;
	char ch=getchar(), w=0;
	while(!isdigit(ch))w=(ch=='-'), ch=getchar();
	while(isdigit(ch))x=(x<<1)+(x<<3)+(ch^48), ch=getchar();
	x=w?-x:x;
}
int T, n, x;
char s[N];
signed main()
{
	read(T);
	while(T--)
	{
		read(x);
		scanf("%s", s+1); int n=strlen(s+1);
		ll ans=n;
		for(R int i=1; i<=x; i++)
		{
			ans=(ans+(s[i]-'0'-1)*(n-i)%mod)%mod; int now=n, tmp=n;
			n=ans;
//			cout<<ans<<endl;
			for(R int j=2; j<=s[i]-'0'; j++)
			{
				for(R int k=i+1; tmp<x && k<=now; k++)s[++tmp]=s[k];
			}
		}
		cout<<(ans%mod+mod)%mod<<endl;
	}
	return 0;
}


#include<bits/stdc++.h>
#define ll long long
#define R register
#define int long long
using namespace std;
const int N =2e6+200;
const ll mod = 1e9+7;
template <class Ruby_Rose> inline void read(Ruby_Rose &x)
{
 	x=0;
	char ch=getchar(), w=0;
	while(!isdigit(ch))w=(ch=='-'), ch=getchar();
	while(isdigit(ch))x=(x<<1)+(x<<3)+(ch^48), ch=getchar();
	x=w?-x:x;
}
int T, n, x;
char s[N];
signed main()
{
	read(T);
	while(T--)
	{
		read(x); int flag=0; int wcnm=0;
		scanf("%s", s+1); int n=strlen(s+1);
		ll ans=n;
		for(R int i=1; i<=x; i++)
		{
			ans=(ans+(s[i]-'0'-1)*(n-i));
			if(ans>=x)flag=1; ans=(ans%mod+mod)%mod;
			int now=n, tmp=n;
			n=ans;
			for(R int j=2; j<=s[i]-'0'; j++)
			{
				if(!wcnm)
				for(R int k=i+1; tmp<x; k++)
				{
					if(!flag && k>now)break;
					s[++tmp]=s[k];
				}
				if(tmp==x)wcnm=1;
			}
		}
		cout<<(ans%mod+mod)%mod<<endl;
	}
	return 0;
}


#include<bits/stdc++.h>
#define ll long long
#define R register
#define int long long
using namespace std;
const int N =2e6+200;
const ll mod = 1e9+7;
template <class Ruby_Rose> inline void read(Ruby_Rose &x)
{
 	x=0;
	char ch=getchar(), w=0;
	while(!isdigit(ch))w=(ch=='-'), ch=getchar();
	while(isdigit(ch))x=(x<<1)+(x<<3)+(ch^48), ch=getchar();
	x=w?-x:x;
}
int T, n, x;
char s[N];
signed main()
{
	read(T);
	while(T--)
	{
		read(x);
		scanf("%s", s+1); int n=strlen(s+1);
		ll ans=n;
		for(R int i=1; i<=x; i++)
		{
			if(i>n)break;
			ans=(ans+(s[i]-'0'-1)*(n-i)%mod)%mod; int now=n, tmp=n;
			n=ans;
//			cout<<ans<<endl;
			for(R int j=2; j<=s[i]-'0'; j++)
			{
				for(R int k=i+1; tmp<x && k<=now; k++)s[++tmp]=s[k];
			}
		}
		cout<<(ans%mod+mod)%mod<<endl;
	}
	return 0;
}


#include<bits/stdc++.h>
#define ll long long
#define R register
#define int long long
using namespace std;
const int N =2e6+200;
const ll mod = 1e9+7;
template <class Ruby_Rose> inline void read(Ruby_Rose &x)
{
 	x=0;
	char ch=getchar(), w=0;
	while(!isdigit(ch))w=(ch=='-'), ch=getchar();
	while(isdigit(ch))x=(x<<1)+(x<<3)+(ch^48), ch=getchar();
	x=w?-x:x;
}
int T, n, x;
char s[N];
signed main()
{
	read(T);
	while(T--)
	{
		read(x); int flag=0;
		scanf("%s", s+1); int n=strlen(s+1);
		ll ans=n;
		for(R int i=1; i<=x; i++)
		{
			ans=(ans+(s[i]-'0'-1)*(n-i));
			if(ans>=x)flag=1; ans%=mod;
			int now=n, tmp=n;
			if(flag)now=x;
			n=ans;
			for(R int j=2; j<=s[i]-'0'; j++)
			{
				for(R int k=i+1; tmp<x && k<=now; k++)s[++tmp]=s[k];
			}
		}
		cout<<(ans%mod+mod)%mod<<endl;
	}
	return 0;
}


//besmellah
#include <bits/stdc++.h>
using namespace std;

//#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")

#define int long long
const int mod = 1e9 + 7;

int32_t main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int t;
	cin >> t;
	while (t--) {
		int x;
		cin >> x;
		string s;
		cin >> s;
		int len = s.size();
		for (int i = 0; i < x; i++) {
			int y = len;
			if (y < x) {
				for (int j = 0; j < s[i] - '1' && s.size() <= 2 * x; j++)
					s += s.substr(i + 1, y - i - 1);
			}
			len += 1ll * (s[i] - '1') * (y - i - 1) % mod;
			//if (t == 3) cout << len << ' ' << s << endl;
			len %= mod;
		}
		cout << len << '\n';
	}
}


//besmellah
#include <bits/stdc++.h>
using namespace std;

//#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")

#define int long long
const int mod = 1e9 + 7;

int32_t main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int t;
	cin >> t;
	while (t--) {
		int x;
		cin >> x;
		string s;
		cin >> s;
		int len = s.size();
		for (int i = 0; i < x; i++) {
			if (len < x) {
				for (int j = 0; j < s[i] - '1'; j++)
					for (int k = 0; k < len - i - 1; k++)
						s += s[k + i + 1];
			}
			len += 1ll * (s[i] - '1') * (len - i - 1) % mod;
//			cout << len << ' ' << s << endl;
			len %= mod;
		}
		cout << len << '\n';
	}
}


//besmellah
#include <bits/stdc++.h>
using namespace std;

//#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")

#define int long long
const int mod = 1e9 + 7;

int32_t main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int t;
	cin >> t;
	while (t--) {
		int x;
		cin >> x;
		string s;
		cin >> s;
		int len = s.size();
		for (int i = 0; i < x; i++) {
			int y = len;
			if (y < x) {
				for (int j = 0; j < s[i] - '1' && s.size() < x; j++)
					s += s.substr(i + 1, y - i - 1);
			}
			len += 1ll * (s[i] - '1') * (y - i - 1) % mod;
			//if (t == 3) cout << len << ' ' << s << endl;
			len %= mod;
		}
		cout << len << '\n';
	}
}


//besmellah
#include <bits/stdc++.h>
using namespace std;

//#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")

#define int long long
const int mod = 1e9 + 7;

int32_t main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int t;
	cin >> t;
	while (t--) {
		int x;
		cin >> x;
		string s;
		cin >> s;
		int len = s.size();
		for (int i = 0; i < x; i++) {
			int y = len;
			if (s.size() < x) {
				for (int j = 0; j < s[i] - '1'; j++)
					s += s.substr(i + 1, y - i - 1);
			}
			len += (s[i] - '1') * (y - i - 1) % mod;
			//if (t == 3) cout << len << ' ' << s << endl;
			len %= mod;
		}
		cout << len << '\n';
	}
}


//besmellah
#include <bits/stdc++.h>
using namespace std;

//#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")

#define int long long
const int mod = 1e9 + 7;

int32_t main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int t;
	cin >> t;
	while (t--) {
		int x;
		cin >> x;
		string s;
		cin >> s;
		int len = s.size();
		for (int i = 0; i < x; i++) {
			int y = len;
			if (y < x) {
				for (int j = 0; j < s[i] - '1'; j++)
					s += s.substr(i + 1, y - i - 1);
			}
			len += 1ll * (s[i] - '1') * (y - i - 1) % mod;
			//if (t == 3) cout << len << ' ' << s << endl;
			len %= mod;
		}
		cout << len << '\n';
	}
}


//besmellah
#include <bits/stdc++.h>
using namespace std;

//#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")

#define int long long
const int mod = 1e9 + 7;

int32_t main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int t;
	cin >> t;
	while (t--) {
		int x;
		cin >> x;
		string s;
		cin >> s;
		int len = s.size();
		for (int i = 0; i < x; i++) {
			if (len <= x) {
				for (int j = 0; j < (s[i] - '1'); j++)
					for (int k = 0; k < len - i - 1 && s.size() <= x; k++)
						s += s[k + i + 1];
			}
			len += (int)(s[i] - '1') * (len - i - 1) % mod;
//			cout << len << ' ' << s << endl;
			len += mod;
			len %= mod;
		}
		cout << len << '\n';
	}
}


//besmellah
#include <bits/stdc++.h>
using namespace std;

//#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")

#define int long long
const int mod = 1e9 + 7;

int32_t main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int t;
	cin >> t;
	while (t--) {
		int x;
		cin >> x;
		string s;
		cin >> s;
		int len = s.size();
		for (int i = 0; i < x; i++) {
			if (len <= x) {
				for (int j = 0; j < (s[i] - '1'); j++)
					for (int k = 0; k < len - i - 1; k++)
						s += s[k + i + 1];
			}
			len += (int)(s[i] - '1') * (len - i - 1) % mod;
//			cout << len << ' ' << s << endl;
			len %= mod;
		}
		cout << len << '\n';
	}
}


//besmellah
#include <bits/stdc++.h>
using namespace std;

//#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")

#define int long long
const int mod = 1e9 + 7;

int32_t main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int t;
	cin >> t;
	while (t--) {
		int x;
		cin >> x;
		string s;
		cin >> s;
		int len = s.size();
		for (int i = 0; i < x; i++) {
			if (len < x) {
				string tmp = s.substr(i + 1, len - i - 1);
				for (int j = 0; j < s[i] - '1' && s.size() <= 2 * x; j++)
					s += tmp;
			}
			len += 1ll * (s[i] - '1') * (len - i - 1) % mod;
//			cout << len << ' ' << s << endl;
			len %= mod;
		}
		cout << len << '\n';
	}
}


#include <iostream>

using namespace std;

void solve()
{
    int no_of_steps;
    cin >> no_of_steps;

    string S;
    cin >> S;

    const int MAX = 1e6, MOD = 1e9 + 7;
    long long length = S.size();

    for(int i = 0; i < no_of_steps; i++)
    {
        long long suffix = (length - 1) - i;

        if(S[i] == '1')
        {
            continue;
        }
        else if(S[i] == '2')
        {
            length = (length + suffix)%MOD;

            for(int j = 1; j <= suffix && S.size() <= min(MAX, no_of_steps); j++)
            {
                S += S[i + j];
            }
        }
        else if(S[i] == '3')
        {
            length = (length + 2*suffix)%MOD;

            for(int k = 1; k <= 2; k++)
            {
                for(int j = 1; j <= suffix && S.size() <= min(MAX, no_of_steps); j++)
                {
                    S += S[i + j];
                }
            }
        }
    }

    cout << length << "\n";
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int no_of_test_cases;
    cin >> no_of_test_cases;

    while(no_of_test_cases--)
        solve();

    return 0;
}


#include <iostream>

using namespace std;

void solve()
{
    int no_of_steps;
    cin >> no_of_steps;

    string S;
    cin >> S;

    const int MAX = 1e6, MOD = 1e9 + 7;
    long long length = S.size();

    for(int i = 0; i < no_of_steps; i++)
    {
        long long suffix = (length - 1) - i;

        if(S[i] == '1')
        {
            continue;
        }
        else if(S[i] == '2')
        {
            length = (length + suffix + MOD)%MOD;

            for(int j = 1; j <= suffix && S.size() <= min(MAX, no_of_steps); j++)
            {
                S += S[i + j];
            }
        }
        else if(S[i] == '3')
        {
            length = (length + 2*suffix)%MOD;

            for(int k = 1; k <= 2; k++)
            {
                for(int j = 1; j <= suffix && S.size() <= min(MAX, no_of_steps); j++)
                {
                    S += S[i + j];
                }
            }
        }
    }

    cout << length << "\n";
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int no_of_test_cases;
    cin >> no_of_test_cases;

    while(no_of_test_cases--)
        solve();

    return 0;
}


#include <iostream>

using namespace std;

void solve()
{
    int no_of_steps;
    cin >> no_of_steps;

    string S;
    cin >> S;

    const int MAX = 1e6, MOD = 1e9 + 7;
    long long length = S.size();

    for(int i = 0; i < no_of_steps; i++)
    {
        long long suffix = ((length - 1) - i + MOD)%MOD;

        if(S[i] == '1')
        {
            continue;
        }
        else if(S[i] == '2')
        {
            length = (length + suffix)%MOD;

            for(int j = 1; j <= suffix && S.size() <= min(MAX, no_of_steps); j++)
            {
                S += S[i + j];
            }
        }
        else if(S[i] == '3')
        {
            length = (length + 2*suffix)%MOD;

            for(int k = 1; k <= 2; k++)
            {
                for(int j = 1; j <= suffix && S.size() <= min(MAX, no_of_steps); j++)
                {
                    S += S[i + j];
                }
            }
        }
    }

    cout << length << "\n";
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int no_of_test_cases;
    cin >> no_of_test_cases;

    while(no_of_test_cases--)
        solve();

    return 0;
}


#include <iostream>

using namespace std;

void solve()
{
    int no_of_steps;
    cin >> no_of_steps;

    string S;
    cin >> S;

    const int MAX = 1e6, MOD = 1e9 + 7;
    long long length = S.size();

    for(int i = 0; i < no_of_steps; i++)
    {
        long long suffix = (length - 1) - i + MOD;

        if(S[i] == '1')
        {
            continue;
        }
        else if(S[i] == '2')
        {
            length = (length + suffix)%MOD;

            for(int j = 1; j <= suffix && S.size() <= min(MAX, no_of_steps); j++)
            {
                S += S[i + j];
            }
        }
        else if(S[i] == '3')
        {
            length = (length + 2*suffix)%MOD;

            for(int k = 1; k <= 2; k++)
            {
                for(int j = 1; j <= suffix && S.size() <= min(MAX, no_of_steps); j++)
                {
                    S += S[i + j];
                }
            }
        }
    }

    cout << length << "\n";
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int no_of_test_cases;
    cin >> no_of_test_cases;

    while(no_of_test_cases--)
        solve();

    return 0;
}


#include <iostream>

using namespace std;

void solve()
{
    int no_of_steps;
    cin >> no_of_steps;

    string S;
    cin >> S;

    const int MAX = 1e6, MOD = 1e9 + 7;
    long long length = S.size();

    for(int i = 0; i < no_of_steps; i++)
    {
        long long suffix = (length - 1) - i;

        if(S[i] == '1')
        {
            continue;
        }
        else if(S[i] == '2')
        {
            length = (length + suffix + MOD)%MOD;

            for(int j = 1; j <= suffix && S.size() <= min(MAX, no_of_steps); j++)
            {
                S += S[i + j];
            }
        }
        else if(S[i] == '3')
        {
            length = (length + 2*suffix + MOD)%MOD;

            for(int k = 1; k <= 2; k++)
            {
                for(int j = 1; j <= suffix && S.size() <= min(MAX, no_of_steps); j++)
                {
                    S += S[i + j];
                }
            }
        }
    }

    cout << length << "\n";
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int no_of_test_cases;
    cin >> no_of_test_cases;

    while(no_of_test_cases--)
        solve();

    return 0;
}


#include<bits/stdc++.h>
#define ts cout<<"ok"<<endl
#define int long long
#define hh puts("")
#define pc putchar
#define mo 1000000007
//#define getchar() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++)
//char buf[1<<21],*p1=buf,*p2=buf;
using namespace std;
const int N=100005;
string s;
inline int read(){
    int ret=0,ff=1;char ch=getchar();
    while(!isdigit(ch)){if(ch=='-') ff=-1;ch=getchar();}
    while(isdigit(ch)){ret=ret*10+(ch^48);ch=getchar();}
    return ret*ff;
}
void write(int x){if(x<0){x=-x,pc('-');}if(x>9) write(x/10);pc(x%10+48);}
void writeln(int x){write(x),hh;}
void writesp(int x){write(x),pc(' ');}
signed main(){
	int T=read();
	ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	while(T--){
		int x=read();
		cin>>s;
		s=' '+s;
		int len=s.size()-1;
		int i=1;
		for(;i<=x;i++){
			if(len>x) break;
			if(s[i]-'0'==2){
				string t=s.substr(i+1);
				s=s+t;
			}
			else if(s[i]-'0'==3){
				string t=s.substr(i+1);
				s=s+t;s=s+t;
			}
			len=s.size()-1;
		}
		for(;i<=x;i++){
			if(s[i]-'0'==2) len=len+len-i;
			else if(s[i]-'0'==3) len=len+(len-i)*2;
			len=(len%mo+mo)%mo;
		}
		writeln(len);
	}
    return 0;
}


#include<bits/stdc++.h>
#define ts cout<<"ok"<<endl
#define int long long
#define hh puts("")
#define pc putchar
#define mo 1000000007
//#define getchar() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++)
//char buf[1<<21],*p1=buf,*p2=buf;
using namespace std;
const int N=100005;
string s;
inline int read(){
    int ret=0,ff=1;char ch=getchar();
    while(!isdigit(ch)){if(ch=='-') ff=-1;ch=getchar();}
    while(isdigit(ch)){ret=ret*10+(ch^48);ch=getchar();}
    return ret*ff;
}
void write(int x){if(x<0){x=-x,pc('-');}if(x>9) write(x/10);pc(x%10+48);}
void writeln(int x){write(x),hh;}
void writesp(int x){write(x),pc(' ');}
signed main(){
	int T=read();
	while(T--){
		int x=read();
		cin>>s;
		s=' '+s;
		int len=s.size()-1,i=1;
		for(;i<=x;i++){
			if(len>x) break;
			if(s[i]-'0'==2){
				string t=s.substr(i+1);
				s=s+t;
			}
			if(s[i]-'0'==3){
				string t=s.substr(i+1);
				s=s+t;s=s+t;
			}
			len=s.size()-1;
		}
		for(;i<=x;i++){
			if(s[i]-'0'==2) len=len+len-i;
			if(s[i]-'0'==3) len=len+(len-i)*2;
			len=(len%mo+mo)%mo;
		}
		writeln(len);
	}
    return 0;
}


#pragma GCC optimize(3)
#pragma GCC optimize(2)
#include<bits/stdc++.h>
#define ts cout<<"ok"<<endl
#define int long long
#define hh puts("")
#define pc putchar
#define mo 1000000007
//#define getchar() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++)
//char buf[1<<21],*p1=buf,*p2=buf;
using namespace std;
const int N=100005;
string s;
inline int read(){
    int ret=0,ff=1;char ch=getchar();
    while(!isdigit(ch)){if(ch=='-') ff=-1;ch=getchar();}
    while(isdigit(ch)){ret=ret*10+(ch^48);ch=getchar();}
    return ret*ff;
}
void write(int x){if(x<0){x=-x,pc('-');}if(x>9) write(x/10);pc(x%10+48);}
void writeln(int x){write(x),hh;}
void writesp(int x){write(x),pc(' ');}
signed main(){
	ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	int T;
	cin>>T;
	while(T--){
		int x;
		cin>>x>>s;
		s=' '+s;
		int len=s.size()-1,i=1;
		for(;i<=x;i++){
			if(len>x) break;
			if(s[i]-'0'==2){
				string t=s.substr(i+1);
				s+=t;
			}
			if(s[i]-'0'==3){
				string t=s.substr(i+1);
				s+=t;s+=t;
			}
			len=s.size()-1;
		}
		for(;i<=x;i++){
			if(s[i]-'0'==2) len+=(len-i);
			if(s[i]-'0'==3) len+=(len-i)*2;
			len=(len%mo+mo)%mo;
		}
		writeln(len);
	}
    return 0;
}


/*mjytxdy!*/
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fir first
#define sec second
#define all(x) x.begin(),x.end()
#define size(x) ((int)x.size())
#define pii pair<int,int>
#define pil pair<int,ll>
#define pli pair<ll,int>
#define pll pair<ll,ll>
#define inl inline
#define rep(i,l,r) for(int i=(l);i<=(r);i++)
#define per(i,r,l) for(int i=(r);i>=(l);i--)
#define travel(i,u) for(int i=head[u];i;i=e[i].next)
#define lb(x) ((x)&(-(x)))
#define lson root<<1
#define rson root<<1|1
#define Mid (l+r>>1)
#define debug(x) cout<<#x":"<<x<<'\n'
#define myput puts("QaQ")
#define file(x) freopen(#x".in","r",stdin),freopen(#x".out","w",stdout);
typedef long long ll;
const int MAXN = 1e6+10;
const int Mod = 1e9+7;
int T,x,n;ll f[MAXN];
char s[MAXN*3];
template<class T>inl void ylmin(T &a,T b){a=min(a,b);}
template<class T>inl void ylmax(T &a,T b){a=max(a,b);}
inl char read(){
	static const int IO_LEN=1024*1024;
	static char buf[IO_LEN],*ioh,*iot;
	if(ioh==iot){
		iot=(ioh=buf)+fread(buf,1,IO_LEN,stdin);
		if(ioh==iot) return -1;
	}
	return *ioh++;
}
template<class T>inl void read(T &x){
	static int iosig;static char ioc;
	for(iosig=0,ioc=read();!isdigit(ioc);ioc=read()) if(ioc=='-') iosig=1;
	for(x=0;isdigit(ioc);ioc=read())x=(x<<1)+(x<<3)+(ioc^'0');
	if(iosig) x=-x;
}
int main(){
//	freopen("in.txt","r",stdin);
	for(scanf("%d",&T);T;T--){
		memset(s,'\0',sizeof(s));
		memset(f,0,sizeof(f));
		scanf("%d%s",&x,s+1);
		n=strlen(s+1);
		int now=1,N=n;
		while(n<x){
			int quq=s[now]-'0',m=n;
			rep(i,1,quq-1) rep(j,now+1,n) s[++m]=s[j];
			n=m;now++;
		}
		f[0]=N;
		rep(i,1,x){
			f[i]=(f[i-1]-i)*(s[i]-'0')+i;
			f[i]%=Mod;
		}
		printf("%lld\n",f[x]);
	}
	return 0;
}


/*mjytxdy!*/
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fir first
#define sec second
#define all(x) x.begin(),x.end()
#define size(x) ((int)x.size())
#define pii pair<int,int>
#define pil pair<int,ll>
#define pli pair<ll,int>
#define pll pair<ll,ll>
#define inl inline
#define rep(i,l,r) for(int i=(l);i<=(r);i++)
#define per(i,r,l) for(int i=(r);i>=(l);i--)
#define travel(i,u) for(int i=head[u];i;i=e[i].next)
#define lb(x) ((x)&(-(x)))
#define lson root<<1
#define rson root<<1|1
#define Mid (l+r>>1)
#define debug(x) cout<<#x":"<<x<<'\n'
#define myput puts("QaQ")
#define file(x) freopen(#x".in","r",stdin),freopen(#x".out","w",stdout);
typedef long long ll;
const int MAXN = 1e6+10;
const int Mod = 1e9+7;
int T,x,n;ll f[MAXN];
char s[MAXN*5];
template<class T>inl void ylmin(T &a,T b){a=min(a,b);}
template<class T>inl void ylmax(T &a,T b){a=max(a,b);}
inl char read(){
	static const int IO_LEN=1024*1024;
	static char buf[IO_LEN],*ioh,*iot;
	if(ioh==iot){
		iot=(ioh=buf)+fread(buf,1,IO_LEN,stdin);
		if(ioh==iot) return -1;
	}
	return *ioh++;
}
template<class T>inl void read(T &x){
	static int iosig;static char ioc;
	for(iosig=0,ioc=read();!isdigit(ioc);ioc=read()) if(ioc=='-') iosig=1;
	for(x=0;isdigit(ioc);ioc=read())x=(x<<1)+(x<<3)+(ioc^'0');
	if(iosig) x=-x;
}
int main(){
	freopen("in.txt","r",stdin);
	for(scanf("%d",&T);T;T--){
		memset(s,'\0',sizeof(s));
		memset(f,0,sizeof(f));
		scanf("%d%s",&x,s+1);
		n=strlen(s+1);
		int now=1,N=n;
		while(n<x){
			int quq=s[now]-'0',m=n;
			rep(i,1,quq-1) rep(j,now+1,n) s[++m]=s[j];
			n=m;now++;
		}
		f[0]=N;
		rep(i,1,x){
			f[i]=1ll*(f[i-1]-i+Mod)*(s[i]-'0')%Mod+i;
			f[i]%=Mod;
		}
		printf("%lld\n",f[x]);
	}
	return 0;
}


/*mjytxdy!*/
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fir first
#define sec second
#define all(x) x.begin(),x.end()
#define size(x) ((int)x.size())
#define pii pair<int,int>
#define pil pair<int,ll>
#define pli pair<ll,int>
#define pll pair<ll,ll>
#define inl inline
#define rep(i,l,r) for(int i=(l);i<=(r);i++)
#define per(i,r,l) for(int i=(r);i>=(l);i--)
#define travel(i,u) for(int i=head[u];i;i=e[i].next)
#define lb(x) ((x)&(-(x)))
#define lson root<<1
#define rson root<<1|1
#define Mid (l+r>>1)
#define debug(x) cout<<#x":"<<x<<'\n'
#define myput puts("QaQ")
#define file(x) freopen(#x".in","r",stdin),freopen(#x".out","w",stdout);
typedef long long ll;
const int MAXN = 1e6+10;
const int Mod = 1e9+7;
int T,x,n;ll f[MAXN];
char s[MAXN*5];
template<class T>inl void ylmin(T &a,T b){a=min(a,b);}
template<class T>inl void ylmax(T &a,T b){a=max(a,b);}
inl char read(){
	static const int IO_LEN=1024*1024;
	static char buf[IO_LEN],*ioh,*iot;
	if(ioh==iot){
		iot=(ioh=buf)+fread(buf,1,IO_LEN,stdin);
		if(ioh==iot) return -1;
	}
	return *ioh++;
}
template<class T>inl void read(T &x){
	static int iosig;static char ioc;
	for(iosig=0,ioc=read();!isdigit(ioc);ioc=read()) if(ioc=='-') iosig=1;
	for(x=0;isdigit(ioc);ioc=read())x=(x<<1)+(x<<3)+(ioc^'0');
	if(iosig) x=-x;
}
int main(){
//	freopen("in.txt","r",stdin);
	for(scanf("%d",&T);T;T--){
		memset(s,'\0',sizeof(s));
		memset(f,0,sizeof(f));
		scanf("%d%s",&x,s+1);
		n=strlen(s+1);
		int now=1,N=n;
		while(n<x){
			int quq=s[now]-'0',m=n;
			rep(i,1,quq-1) rep(j,now+1,n) s[++m]=s[j];
			n=m;now++;
		}
		f[0]=N;
		rep(i,1,x){
			f[i]=1ll*(f[i-1]-i+Mod)*(s[i]-'0')%Mod+i;
			f[i]%=Mod;
		}
		printf("%lld\n",f[x]);
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define 		ll 					long long
#define			pr					pair<ll, ll >
#define			pp1					pair<pair<ll,ll> , ll >
#define			pp2					pair<ll, pair<ll,ll> >
#define 		vl 					vector<ll>
#define 		vll 				vector<pair<ll,ll> >
#define 		vvl 				vector<vector <ll> >
#define 		rep(i,x,n,a) 		for(ll i=x;i<n;i=i+a)
#define 		rep1(i,n,x,a) 		for(ll i=n;i>=x;i=i-a)
#define 		printa(v) 			for(ll i=0;i<v.size();i++){cout<<v[i]<<" ";}cout<<endl
#define		 	inputa(v,n) 		for(ll i=0;i<n;i++)cin>>v[i]
#define 		vsort(v) 			sort(v.begin(),v.end())
#define 		bug 				cout<<"Bitch"<<endl
#define 		debug(x) 			cout<<x<<"*"<<endl
#define 		print0(a) 			cout<<a<<" "
#define 		print1(a) 			cout<<a<<endl
#define 		print2(a,b) 		cout<<a<<" "<<b<<endl
#define 		print3(a,b,c) 		cout<<a<<" "<<b<<" "<<c<<endl
#define 		l_b(v,val) 			lower_bound(v.begin(),v.end(),val)
#define 		u_b(v,val) 			upper_bound(v.begin(),v.end(),val)
#define 		nl 					cout<<endl
#define 		p_b 				push_back
#define			m_p 				make_pair
#define		 	max3(a,b,c) 		max(a,max(b,c))
#define 		min3(a,b,c) 		min(a,min(b,c))
#define 		T() 				ll T;cin>>T;while(T--)
#define 		rev(s) 				reverse(s.begin(),s.end())
#define 		mem(dp,val) 		memset(dp,val,sizeof(dp))
#define 		fast 				ios_base::sync_with_stdio(false);cin.tie(NULL)
//n & (1 << (k - 1))
//for(auto f : some_set)
//ll power(ll n,ll k){ll res=1;while(k>0){if(k%2!=0)res=res*n;n=n*n;k=k/2;}return res;}
//ll power_mod(ll x,ll y, ll p){ll res = 1;x = x % p; while (y > 0) {if (y & 1) res = (res*x) % p; y = y>>1;x = (x*x) % p;}return res;}

//int t;
//cin>>t;
//cin.ignore();
//while(t--)
//{
//	string text;
//	getline(cin, text);
//}

ll BIG = 1e5;
ll mod=1e9+7;

int main()
{
	T()
	{
		ll x;
		cin>>x;

		string s;
		cin>>s;

		ll l=-1;
		string str_upto=s;

		ll max_len=1000000;
		ll ans=s.length();

		while(true)
		{
			l++;
			ll k=str_upto[l]-'0';
			if(str_upto.length() < x)
				{
					string temp = str_upto.substr(l+1,str_upto.length()-l-1);
					for(int i=1;i<k;i++)
						{
							str_upto+=temp;
							if(str_upto.length()>=max_len)
								break;
						}
				}
			ll lol = ((k-1)*(ans-l-1)+mod)%mod;
			ans=(ans + lol + mod)%mod;
			if(l==x-1)
				{
					// cout<<l<<endl;
					cout<<(ans+mod)%mod<<endl;
					break;
				}

		}
	}
}


#include<bits/stdc++.h>
using namespace std;
#define 		ll 					long long
#define			pr					pair<ll, ll >
#define			pp1					pair<pair<ll,ll> , ll >
#define			pp2					pair<ll, pair<ll,ll> >
#define 		vl 					vector<ll>
#define 		vll 				vector<pair<ll,ll> >
#define 		vvl 				vector<vector <ll> >
#define 		rep(i,x,n,a) 		for(ll i=x;i<n;i=i+a)
#define 		rep1(i,n,x,a) 		for(ll i=n;i>=x;i=i-a)
#define 		printa(v) 			for(ll i=0;i<v.size();i++){cout<<v[i]<<" ";}cout<<endl
#define		 	inputa(v,n) 		for(ll i=0;i<n;i++)cin>>v[i]
#define 		vsort(v) 			sort(v.begin(),v.end())
#define 		bug 				cout<<"Bitch"<<endl
#define 		debug(x) 			cout<<x<<"*"<<endl
#define 		print0(a) 			cout<<a<<" "
#define 		print1(a) 			cout<<a<<endl
#define 		print2(a,b) 		cout<<a<<" "<<b<<endl
#define 		print3(a,b,c) 		cout<<a<<" "<<b<<" "<<c<<endl
#define 		l_b(v,val) 			lower_bound(v.begin(),v.end(),val)
#define 		u_b(v,val) 			upper_bound(v.begin(),v.end(),val)
#define 		nl 					cout<<endl
#define 		p_b 				push_back
#define			m_p 				make_pair
#define		 	max3(a,b,c) 		max(a,max(b,c))
#define 		min3(a,b,c) 		min(a,min(b,c))
#define 		T() 				ll T;cin>>T;while(T--)
#define 		rev(s) 				reverse(s.begin(),s.end())
#define 		mem(dp,val) 		memset(dp,val,sizeof(dp))
#define 		fast 				ios_base::sync_with_stdio(false);cin.tie(NULL)
//n & (1 << (k - 1))
//for(auto f : some_set)
//ll power(ll n,ll k){ll res=1;while(k>0){if(k%2!=0)res=res*n;n=n*n;k=k/2;}return res;}
//ll power_mod(ll x,ll y, ll p){ll res = 1;x = x % p; while (y > 0) {if (y & 1) res = (res*x) % p; y = y>>1;x = (x*x) % p;}return res;}

//int t;
//cin>>t;
//cin.ignore();
//while(t--)
//{
//	string text;
//	getline(cin, text);
//}

ll BIG = 1e5;
ll mod=1e9+7;

int main()
{
	T()
	{
		ll x;
		cin>>x;

		string s;
		cin>>s;

		ll l=-1;
		string str_upto=s;

		ll max_len=1000000;
		ll ans=s.length();

		while(true)
		{
			l++;
			ll k=str_upto[l]-'0';
			if(str_upto.length() < max_len)
				{
					string temp = str_upto.substr(l+1,str_upto.length()-l-1);
					for(int i=1;i<k;i++)
						{
							str_upto+=temp;
							if(str_upto.length()>=max_len)
								break;
						}
				}
			ll lol = ((k-1)*(ans-l-1)+mod)%mod;
			ans=(ans + lol + mod)%mod;
			if(l==x-1)
				{
					// cout<<l<<endl;
					cout<<(ans+mod)%mod<<endl;
					break;
				}

		}
	}
}


#include<bits/stdc++.h>
using namespace std;
#define 		ll 					long long
#define			pr					pair<ll, ll >
#define			pp1					pair<pair<ll,ll> , ll >
#define			pp2					pair<ll, pair<ll,ll> >
#define 		vl 					vector<ll>
#define 		vll 				vector<pair<ll,ll> >
#define 		vvl 				vector<vector <ll> >
#define 		rep(i,x,n,a) 		for(ll i=x;i<n;i=i+a)
#define 		rep1(i,n,x,a) 		for(ll i=n;i>=x;i=i-a)
#define 		printa(v) 			for(ll i=0;i<v.size();i++){cout<<v[i]<<" ";}cout<<endl
#define		 	inputa(v,n) 		for(ll i=0;i<n;i++)cin>>v[i]
#define 		vsort(v) 			sort(v.begin(),v.end())
#define 		bug 				cout<<"Bitch"<<endl
#define 		debug(x) 			cout<<x<<"*"<<endl
#define 		print0(a) 			cout<<a<<" "
#define 		print1(a) 			cout<<a<<endl
#define 		print2(a,b) 		cout<<a<<" "<<b<<endl
#define 		print3(a,b,c) 		cout<<a<<" "<<b<<" "<<c<<endl
#define 		l_b(v,val) 			lower_bound(v.begin(),v.end(),val)
#define 		u_b(v,val) 			upper_bound(v.begin(),v.end(),val)
#define 		nl 					cout<<endl
#define 		p_b 				push_back
#define			m_p 				make_pair
#define		 	max3(a,b,c) 		max(a,max(b,c))
#define 		min3(a,b,c) 		min(a,min(b,c))
#define 		T() 				ll T;cin>>T;while(T--)
#define 		rev(s) 				reverse(s.begin(),s.end())
#define 		mem(dp,val) 		memset(dp,val,sizeof(dp))
#define 		fast 				ios_base::sync_with_stdio(false);cin.tie(NULL)
//n & (1 << (k - 1))
//for(auto f : some_set)
//ll power(ll n,ll k){ll res=1;while(k>0){if(k%2!=0)res=res*n;n=n*n;k=k/2;}return res;}
//ll power_mod(ll x,ll y, ll p){ll res = 1;x = x % p; while (y > 0) {if (y & 1) res = (res*x) % p; y = y>>1;x = (x*x) % p;}return res;}

//int t;
//cin>>t;
//cin.ignore();
//while(t--)
//{
//	string text;
//	getline(cin, text);
//}

ll BIG = 1e5;
ll mod=1e9+7;

int main()
{
	T()
	{
		ll x;
		cin>>x;

		string s;
		cin>>s;

		ll l=-1;
		string str_upto=s;

		ll max_len=1000000;
		ll ans=s.length();

		while(true)
		{
			l++;
			ll k=str_upto[l]-'0';
			if(str_upto.length() < max_len)
				{
					string temp = str_upto.substr(l+1,str_upto.length()-l-1);
					for(int i=1;i<k;i++)
						{
							str_upto+=temp;
							if(str_upto.length()>=max_len)
								break;
						}
				}
			ans=ans + ((k-1)*(ans-l-1))%mod;
			ans=ans%mod;
			if(l==x-1)
				{
					// cout<<l<<endl;
					cout<<ans<<endl;
					break;
				}

		}
	}
}


//
// Created by Edward on 6/2/2020.
//

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef vector<ll> vi;
typedef pair<ll,ll> pii;
typedef pair<ll,ll> pll;

namespace c{
    ll t;
    ll mod = 1000000007;

    int main() {
        ios::sync_with_stdio(0);
        cin.tie(0);
        cin >>t;
        while(t--) {
            ll x;
            cin >> x;
            string s;
            cin >> s;
            ll len = s.size();
            ll a[x];
            for(ll i = 0; i < min(len, (ll)x); i++){
                a[i] = s[i] - '1';
            }
            bool exceeded = (len >= x);
            ll idx = 0;
            while(idx < x){
                ll d = a[idx];
                idx++;
                if(!exceeded){
                    for(ll i = len; i < min((ll)x, len + d * (len - idx)); i++){
                        a[i] = a[i - len + idx];
                    }
                }
                len += d * (len - idx);
                len %= mod;
                if(!exceeded){
                    exceeded = (len >= x);
                }
            }
            cout << len << endl;
        }
        return 0;
    }

}
int main(){    c::main();    return 0;}


//
// Created by Edward on 6/2/2020.
//

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

namespace c{
    int t;
    ll mod = 1000000007;

    int main() {
        ios::sync_with_stdio(0);
        cin.tie(0);
        cin >>t;
        while(t--) {
            int x;
            cin >> x;
            string s;
            cin >> s;
            ll len = s.size();
            int a[x];
            for(int i = 0; i < min(len, (ll)x); i++){
                a[i] = s[i] - '1';
            }
            bool exceeded = (len >= x);
            int idx = 0;
            while(idx < x){
                int d = a[idx];
                idx++;
                if(!exceeded){
                    for(int i = len; i < min((ll)x, len + d * (len - idx)); i++){
                        a[i] = a[i - len + idx];
                    }
                }
                len += d * (len - idx);
                len %= mod;
                if(!exceeded){
                    exceeded = (len >= x);
                }
            }
            cout << len << endl;
        }
        return 0;
    }

}
int main(){    c::main();    return 0;}


//
// Created by Edward on 6/2/2020.
//

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef vector<ll> vi;
typedef pair<ll,ll> pii;
typedef pair<ll,ll> pll;

namespace c{
    ll t;
    ll mod = 1000000007;

    int main() {
        ios::sync_with_stdio(0);
        cin.tie(0);
        cin >>t;
        while(t--) {
            ll x;
            cin >> x;
            string s;
            cin >> s;
            ll len = s.size();
            ll a[x];
            for(ll i = 0; i < min(len, (ll)x); i++){
                a[i] = s[i] - '1';
            }
            bool exceeded = (len >= x);
            ll idx = 0;
            while(idx < x){
                ll d = a[idx];
                idx++;
                if(!exceeded){
                    for(ll i = len; i < min((ll)x, len + d * (len - idx)); i++){
                        a[i] = a[i - len + idx];
                    }
                }
                len += d * (len - idx);
                len %= mod;
                len = (len + mod)% mod;
                if(!exceeded){
                    exceeded = (len >= x);
                }
            }
            cout << len << endl;
        }
        return 0;
    }

}
int main(){    c::main();    return 0;}


#include<bits/stdc++.h>
using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    const unsigned int Mod = 1000000007;
    int testCases;
    cin >> testCases;

    for(int t=0; t<testCases; t++){
    long long x, l = 0;
    cin >> x;
    char s[100000];
    cin >> s;
    long long length = strlen(s);
    //cout << length << "\n";

    for(long long times=0; times<x; times++)
    {
        long long index = strlen(s) - 1;
        long long limit = (s[times] - '0') - 1;
        long long stringLength = strlen(s);

        while(limit--)
        {
            for(long long i=times+1; i<stringLength; i++)
            {
                s[++index] = s[i];
                if(index >= x - 1)
                {
                    break;
                }
            }
            if(index >= x - 1)
            {
                break;
            }
        }

        s[index + 1] = '\0';

        if(index >= x - 1)
        {
            break;
        }
    }
    //cout << s << "\n" << strlen(s) << "\n";
    for(long long j=0; j<x; j++)
    {
        //cout << length << " + (" << length << " - " << j + 1 << ") x ( " << s[j] << " - 1) = ";
        length += (((length - j - 1) % Mod) * (((s[j] - '0') - 1) % Mod));
        length %= Mod;
        //cout << length << "\n";
    }
    cout << length << "\n";}
    return 0;
}


#include<bits/stdc++.h>
using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    const unsigned int Mod = 1000000007;
    int testCases;
    cin >> testCases;

    for(int t=0; t<testCases; t++){
    long long x, l = 0;
    cin >> x;
    string s;
    cin >> s;
    long long length = s.size();
    //cout << length << "\n";

    for(long long times=0; times<x; times++)
    {
        long long index = s.size() - 1;
        long long limit = (s[times] - '0') - 1;
        long long stringLength = s.length();

        while(limit--)
        {
            for(long long i=times+1; i<stringLength; i++)
            {
                s += s[i];
                index++;
                if(index >= x - 1)
                {
                    break;
                }
            }
            if(index >= x - 1)
            {
                break;
            }
        }
        if(index >= x - 1)
        {
            //cout << index << " index\n";
            break;
        }
    }

    for(long long j=0; j<x; j++)
    {
        //cout << length << " + (" << length << " - " << j + 1 << ") x ( " << s[j] << " - 1) = ";
        length += (((((length - j - 1) % Mod) + Mod) % Mod) * (((((s[j] - '0') - 1) % Mod) + Mod) % Mod));
        length %= Mod;
        //cout << length << "\n";
    }
    cout << length << "\n";}
    return 0;
}


#include<bits/stdc++.h>
using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    const unsigned int Mod = 1000000007;
    int testCases;
    cin >> testCases;

    for(int t=0; t<testCases; t++){
    long long x, l = 0;
    cin >> x;
    char s[100000];
    cin >> s;
    long long length = strlen(s);
    //cout << length << "\n";

    for(long long times=0; times<x; times++)
    {
        long long index = strlen(s) - 1;
        long long limit = (s[times] - '0') - 1;
        long long stringLength = strlen(s);

        while(limit--)
        {
            for(long long i=times+1; i<stringLength; i++)
            {
                s[++index] = s[i];
                if(index >= x - 1)
                {
                    break;
                }
            }
        }

        s[index + 1] = '\0';

        if(index >= x - 1)
        {
            break;
        }
    }
    //cout << s << "\n" << strlen(s) << "\n";
    for(long long j=0; j<x; j++)
    {
        //cout << length << " + (" << length << " - " << j + 1 << ") x ( " << s[j] << " - 1) = ";
        length += (((length - j - 1) % Mod) * (((s[j] - '0') - 1) % Mod));
        length %= Mod;
        //cout << length << "\n";
    }
    cout << length << "\n";}
    return 0;
}


#include<bits/stdc++.h>
using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    const unsigned int Mod = 1000000007;
    int testCases;
    cin >> testCases;

    for(int t=0; t<testCases; t++){
    long long x, l = 0;
    cin >> x;
    char s[100000];
    cin >> s;
    long long length = strlen(s);
    //cout << length << "\n";

    for(long long times=0; times<x; times++)
    {
        long long index = strlen(s) - 1;
        long long limit = (s[times] - '0') - 1;
        long long stringLength = strlen(s);

        while(limit--)
        {
            for(long long i=times+1; i<stringLength; i++)
            {
                s[++index] = s[i];
                if(index >= x - 1)
                {
                    break;
                }
            }
            if(index >= x - 1)
            {
                break;
            }
        }

        s[index + 1] = '\0';

        if(index >= x - 1)
        {
            break;
        }
    }
    //cout << s << "\n" << strlen(s) << "\n";
    for(long long j=0; j<x; j++)
    {
        //cout << length << " + (" << length << " - " << j + 1 << ") x ( " << s[j] << " - 1) = ";
        length += ((((length - j - 1) % Mod) % Mod) * (((s[j] - '0') - 1) % Mod));
        length %= Mod;
        //cout << length << "\n";
    }
    cout << length << "\n";}
    return 0;
}


#include<bits/stdc++.h>
using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    const unsigned int Mod = 1000000007;
    int testCases;
    cin >> testCases;

    for(int t=0; t<testCases; t++){
    long long x, l = 0;
    cin >> x;
    char s[100000];
    cin >> s;
    long long length = strlen(s);
    //cout << length << "\n";

    for(long long times=0; times<x; times++)
    {
        l++;
        char c[100000], temp[100000];
        long long c_index = -1, temp_index = -1;
        for(long long i=0; i<l; i++)
        {
            temp[++temp_index] = s[i];
            //cout << "inserted in temp\n";
        }
        for(long long i=l; i<strlen(s); i++)
        {
            c[++c_index] = s[i];
            //cout << "inserted in c\n";
        }
        temp[temp_index + 1] = '\0';
        c[c_index + 1] = '\0';
        //cout << temp << " " << c << "\n";
        //cout << temp_index << " " << c_index << "\n";
        /*for(int i=0; i<=temp_index; i++)
        {
            cout << temp[i];
            //cout << "here temp";
        }
        cout << " ";
        for(int i=0; i<=c_index; i++)
        {
            cout << c[i];
            //cout << "here c";
        }
        cout << "\n";*/
        long long sl = temp[temp_index] - '0';
        for(long long i=0; i<sl; i++)
        {
            strcat(temp, c);
            temp_index += (c_index + 1);
            if(temp_index + 1 >= x)
            {
                break;
            }
        }
        //strcat(temp, c);
        //strcat(temp, c);
        //strcat(temp, c);
        //cout << sl << "\n";
        /*for(int i=0; i<=temp_index; i++)
        {
            cout << temp[i];
            //cout << "here temp";
        }
        cout << "\n";*/
        temp[temp_index + 1] = '\0';
        //cout << temp << "\n";
        strcpy(s, temp);
        //length = temp_index + 1;
        //cout << s << "\n";
        //cout << temp_index << "\n";
    }
    //cout << s << "\n" << strlen(s) << "\n";
    for(long long j=0; j<x; j++)
    {
        //cout << length << " + (" << length << " - " << j + 1 << ") x ( " << s[j] << " - 1) = ";
        length += (((length - j - 1) % Mod) * (((s[j] - '0') - 1) % Mod));
        length %= Mod;
        //cout << length << "\n";
    }
    cout << length << "\n";}
    return 0;
}