Harryxun/sft_time huggingface dataset:
### BUGGY CODE ###

from bisect import bisect_left, bisect_right
def main():
    N, Q = map(int, input().split())
    kouji = [list(map(int, input().split())) for _ in range(N)]
    D = [int(input()) for _ in range(Q)]
    ans = [[-1, i+1] for i in range(Q)]
    kouji.sort(key=lambda x: (x[2], x[0]))
    for i in range(N):
        S, T, X = kouji[i]
        L = S-X
        R = T-X-1
        L_idx = bisect_left(D, L)
        R_idx = bisect_right(D, R)
        p = L_idx
        while p < Q and p < R_idx:
            if ans[p][0] == -1:
                ans[p][0] = X
            pre = p
            p = ans[p][1]
            if ans[pre][1] < R_idx:
                ans[pre][1] = R_idx
    for i in range(Q):
        print(ans[i][0])


if __name__ == "__main__":
    main()

### FIXED CODE ###

from bisect import bisect_left
import sys
input = sys.stdin.readline
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n
    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if self.parents[x] > self.parents[y]:
            x, y = y, x
        self.parents[x] += self.parents[y]
        self.parents[y] = x
    def same(self, x, y):
        return self.find(x) == self.find(y)
def main():
    N, Q = map(int, input().split())
    kouji = [list(map(int, input().split())) for _ in range(N)]
    D = [int(input()) for _ in range(Q)]
    ans = [-1]*Q
    nxt = [i+1 for i in range(Q)]
    uf = UnionFind(Q)
    kouji.sort(key=lambda x: x[2])
    for i in range(N):
        S, T, X = kouji[i]
        L = S-X
        R = T-X-1
        L_idx = bisect_left(D, L)
        R_idx = bisect_left(D, R+1)
        p = L_idx
        while p < R_idx:
            if ans[p] == -1:
                ans[p] = X
                uf.union(L_idx, p)
                nxt[p] = R_idx
                p += 1
            else:
                par = uf.find(p)
                p = nxt[par]
                uf.union(L_idx, par)
                par = uf.find(par)
                if nxt[par] < R_idx:
                    nxt[par] = R_idx
                if nxt[par] < p:
                    nxt[par] = p
    for i in range(Q):
        print(ans[i])

if __name__ == "__main__":
    main()
### BUGGY CODE ###

import sys

import numpy as np

readline = sys.stdin.buffer.readline


def main():
    N = int(readline())
    A = [0] + list(map(int, readline().split()))
    A = np.array(A)
    C = np.zeros(N + 1, dtype=np.int32)

    if A[-1] == 1:
        C[-1] == 1

    for j in range(N, 0, -1):
        cnt = np.count_nonzero(C[j::j] == 1)
        a = cnt % 2
        C[j] = a ^ A[j]

    ans = np.sum(C)
    print(ans)
    if ans != 0:
        for i, c in enumerate(C):
            if c == 1:
                print(i)


main()


### FIXED CODE ###

import sys

import numpy as np

readline = sys.stdin.buffer.readline


def main():
    N = int(readline())
    A = [0] + list(map(int, readline().split()))
    A = np.array(A)
    C = np.zeros(N + 1, dtype=np.int32)

    if A[-1] == 1:
        C[-1] == 1

    for j in range(N, 0, -1):
        cnt = np.count_nonzero(C[j::j])
        C[j] = (cnt % 2) ^ A[j]

    ans = np.sum(C)
    print(ans)
    if ans != 0:
        B = np.arange(N + 1)
        li = B[C == 1]
        print(*li, sep='\n')


main()
### BUGGY CODE ###

H, W = map(int, input().split())
state = [[0 if a == '.' else 1 for a in list(input())] for _ in range(H)]

checked = [[False for _ in range(W)] for _ in range(H)]
qs = []
for h in range(H):
    for w in range(W):
        if state[h][w] == 1:
            checked[h][w] = True
            qs.append((h, w))

c = -1
while qs:
    qqs = []
    for h, w in qs:
        nexts = [(h+1, w), (h-1, w), (h, w+1), (h, w-1)]
        for nh, nw in nexts:
            if 0 <= nh <= H-1 and 0 <= nw <= W-1:
                if not checked[nh][nw]:
                    qqs.append((nh, nw))
                    checked[nh][nw] = True
    qs = qqs
    c += 1
print(c)

### FIXED CODE ###

import sys
input = sys.stdin.readline

B = int(1E8)

def main():

    H, W = map(int, input().split())
    
    l = 0
    q = []
    checked = []
    for h in range(H):
        S = input()
        L = []
        for w in range(W):
            if S[w] == '#':
                l += 1
                L.append(True)
                q.append(B*h+w)
            else:
                L.append(False)
        checked.append(L)

    Next = [[[] for _ in range(W)] for _ in range(H)]
    for h in range(H):
        for w in range(W):
            if h != 0:
                Next[h][w].append(B*(h-1) + w)
            if h != H-1:
                Next[h][w].append(B*(h+1) + w)
            if w != 0:
                Next[h][w].append(B*h + w-1)
            if w != W-1:
                Next[h][w].append(B*h + w+1)

    c = -1
    for _ in range(H+W+2):
        qq = []
        if len(q) == 0:
            break
        for hw in q:
            h, w = hw//B, hw%B
            for nhw in Next[h][w]:
                nh, nw = nhw//B, nhw%B
                if not checked[nh][nw]:
                    qq.append(B*nh + nw)
                    checked[nh][nw] = True
        q = qq
        c += 1

    print(c)


if __name__ == "__main__":
    main()
### BUGGY CODE ###

import sys
input = sys.stdin.readline
n = int(input())
a = list(map(int, input().split()))
a.sort(reverse=True)
used = [False] * n
ans = 0

def judge(x):
    while x % 2 == 0:
        x //= 2
    return x == 1

for i in range(n):
    if used[i]:
        continue
    else:
        for j in range(i+1, n):
            if used[j]:
                continue
            if judge(a[i] + a[j]):
                used[i] = True
                used[j] = True
                ans += 1
                break

print(ans)

### FIXED CODE ###

from collections import Counter
n = int(input())
a = list(map(int, input().split()))
a.sort(reverse=True)
cnt = Counter(a)
ans = 0

def make(x):
    num = 1
    while num <= x:
        num *= 2
    return num

for i in range(n):
    x = make(a[i])
    if cnt[x - a[i]] > 0 and cnt[a[i]] > 0 and x != 2 * a[i]:
        ans += 1
        cnt[x - a[i]] -= 1
        cnt[a[i]] -= 1
    elif x == 2 * a[i] and cnt[a[i]] > 1:
        ans += 1
        cnt[a[i]] -= 2

print(ans)
### BUGGY CODE ###

# coding: utf-8
# Your code here!
n = int(input())

tree= [[] for i in range(n+1)]
cost=[[0 for i in range(n+1)]for j in range(n+1)]
color=[-1 for i in range(n+1)]
que=[]
for i in range(n-1):
    u,v,w=map(int,input().split(' '))
    tree[u].append(v)
    tree[v].append(u)
    cost[u][v]=w
    cost[v][u]=w

que.append(1)
color[1]=0


while(len(que)!=0): 
    node = que.pop()
    for next_node in tree[node]:
        if color[next_node]==-1:
            # print((color[node]+cost[node][next_node])%2)
            color[next_node]=(color[node]+cost[node][next_node])%2
            que.append(next_node)
            # print(color)
for i in range(1,len(color)):
    print(color[i])


### FIXED CODE ###

# coding: utf-8
# Your code here!
n = int(input())

tree= [[] for i in range(n+1)]
color=[-1 for i in range(n+1)]
que=[]
for i in range(n-1):
    u,v,w=map(int,input().split(' '))
    tree[u].append([v,w])
    tree[v].append([u,w])

que.append(1)
color[1]=0


while(len(que)!=0): 
    node = que.pop()
    for next_node,w in tree[node]:
        if color[next_node]==-1:
            # print((color[node]+cost[node][next_node])%2)
            color[next_node]=(color[node]+w)%2
            que.append(next_node)
            # print(color)
for i in range(1,len(color)):
    print(color[i])
### BUGGY CODE ###

N = int(input())
A = [int(input()) for i in range(N)]
for i in range(N):
    tmp = A[i]
    A[i] = 0
    print(max(A))
    A[i] = tmp

### FIXED CODE ###

N = int(input())
A = [int(input()) for i in range(N)]
maximum = max(A)
if A.count(maximum) != 1:
    for i in range(N):
        print(maximum)
else:
    B = A[:]
    B.remove(maximum)
    maximum_ne = max(B)
    for i in range(N):
        if A[i] == maximum:
            print(maximum_ne)
        else:
            print(maximum)
### BUGGY CODE ###

N,C=map(int,input().split())
List=[[int(i) for i in input().split()] for i in range(N)]
Time=[[0]*(10**5+1)]*C
for i in range(N):
  c=List[i][2]
  s=List[i][0]
  t=List[i][1]
  T_c=list(Time[c-1])
  T_c[s-1:t]=[1]*(t-s+1)
  Time[c-1]=list(T_c)
T=0
T_max=0
for t in range(10**5+1):
  for c in range(C):
    T+=Time[c][t]
  if T_max<T:
    T_max=T
  T=0
print(T_max)



### FIXED CODE ###

N,C=map(int,input().split())
Time=[[0]*(10**5+1) for c in range(C)]
for i in range(N):
  s,t,c=map(int,input().split())  
  Time[c-1][s-1:t] = [1]*(t-s+1)
Times=max(map(sum,zip(*Time)))
print(Times)
### BUGGY CODE ###

#!/usr/bin/python
import sys
#if sys.version_info[0]>=3:raw_input=input

from scipy.sparse import*
g=[]
n=int(raw_input())
for _ in xrange(n-1):
	a,b=map(int,raw_input().split())
	g+=[(a-1,b-1,1)]
	g+=[(b-1,a-1,1)]
z=[-1]*n
for _ in xrange(int(raw_input())):
	a,b=map(int,raw_input().split())
	g+=[(n,a-1,b)]
	z[a-1]=b
a,b,c=zip(*g)
a=map(int,csgraph.dijkstra(csc_matrix((c,(a,b)),[n+1]*2),1,n))
for i in xrange(n):
	if z[i]>=0 and z[i]!=a[i]:
		print('No')
		sys.exit()
for e in g:
	if e[0]<e[1] and abs(a[e[0]]-a[e[1]])!=1:
		print('No')
		sys.exit()
print('Yes')
print("\n".join(map(str,a[:n])))

### FIXED CODE ###

#!/usr/bin/python
def shortestPath(g,s,dist,prev):
	n = len(g)-1
	Q=[]
	heapq.heappush(Q,(0,-2,s))
	while Q:
		e = heapq.heappop(Q)
		if prev[e[2]]!=-1: continue
		prev[e[2]] = e[1]
		for f in g[e[2]]:
			if dist[f[2]] > e[0] + f[0]:
				dist[f[2]] = e[0] + f[0]
				heapq.heappush(Q,(e[0]+f[0],f[1],f[2]))

import sys,heapq
#if sys.version_info[0]>=3:raw_input=input

n=int(raw_input())
g=[[] for _ in range(n+1)]
for _ in xrange(n-1):
	a,b=map(int,raw_input().split())
	g[a-1]+=[(1,a-1,b-1)]
	g[b-1]+=[(1,b-1,a-1)]
z=[-1]*n
for _ in xrange(int(raw_input())):
	a,b=map(int,raw_input().split())
	g[n]+=[(b,n,a-1)]
	z[a-1]=b
a=[1e9]*n+[0]
shortestPath(g,n,a,[-1]*(n+1))
for i in xrange(n):
	if z[i]>=0 and z[i]!=a[i]:
		print('No')
		sys.exit()
for _ in g:
	for e in _:
		if e[1]<e[2] and abs(a[e[1]]-a[e[2]])!=1:
			print('No')
			sys.exit()
print('Yes')
print("\n".join(map(str,a[:n])))
### BUGGY CODE ###

import sys
input = sys.stdin.readline


class BIT:
    def __init__(self, a, func=int.__add__, one=0):
        self.n = len(a)
        self.func = func
        self.one = one
        self.a = [0] * (self.n + 1)

        for i, j in enumerate(a):
            self.update(i, j)

    def update(self, i, x):
        i += 1
        while i <= self.n:
            self.a[i] = self.func(self.a[i], x)
            i += i & (-i)

    def get(self, i):
        s = self.one
        i += 1
        while i != 0:
            s = self.func(s, self.a[i])
            i -= i & (-i)
        return s

def inmin(x):
    return int(x)-1

if __name__ == "__main__":
    n, q = map(int, input().split())
    c = list(map(inmin, input().split()))
    que = [[i, list(map(inmin, input().split())), 0] for i in range(q)]
    que.sort(key=lambda x: x[1][1])

    last = [-1] * n
    bit = BIT([0]*(n+10))
    j = 0
    for i in range(n):
        if last[c[i]] >= 0:
            bit.update(last[c[i]]+5, -1)
        bit.update(i+5, 1)
        last[c[i]] = i
        while j < q and que[j][1][1] == i:
            que[j][2] = bit.get(i+5) - bit.get(que[j][1][0]+4)
            j += 1
    que.sort()
    for i in que:
        print(i[-1])


### FIXED CODE ###

import sys
input = sys.stdin.readline


class BIT:
    def __init__(self, a):
        self.n = len(a)
        self.a = [0] * (self.n + 1)

        for i, j in enumerate(a):
            self.update(i, j)

    def update(self, i, x):
        i += 1
        while i <= self.n:
            self.a[i] = self.a[i] + x
            i += i & (-i)

    def get(self, i):
        s = 0
        i += 1
        while i != 0:
            s = s + self.a[i]
            i -= i & (-i)
        return s


def inmin(x):
    return int(x)-1


if __name__ == "__main__":
    n, q = map(int, input().split())
    c = list(map(inmin, input().split()))
    que = [[i, list(map(inmin, input().split()))] for i in range(q)]
    que.sort(key=lambda x: x[1][1])
    ans = [0] * q

    last = [-1] * n
    bit = BIT([0]*(n+10))
    j = 0
    for i in range(n):
        if last[c[i]] >= 0:
            bit.update(last[c[i]]+5, -1)
        bit.update(i+5, 1)
        last[c[i]] = i
        while j < q and que[j][1][1] == i:
            ans[que[j][0]] = bit.get(i+5) - bit.get(que[j][1][0]+4)
            j += 1
    print(*ans)
### BUGGY CODE ###

n=int(input())
s = [0]*n
dic = []
count = 1
for i in range(n):
    s[i] = input()

sorted(s)
for i in range(n):
    sw = 0
    if i == 0:
        dic.append(s[0])
    else:
        for name in dic:
            if str(name) == str(s[i]):
                sw = 1
                break
        if sw == 0:
            dic.append(s[i])
            count += 1
print(count)

### FIXED CODE ###

n=int(input())
s = [0]*n
for i in range(n):
    s[i] = input()
print(len(set(s)))
### BUGGY CODE ###

n = int(input())
s = list()
for i in range(n):
    s.append(list(input()))
c = 0
for i in range(len(s)):
    s[i].sort()
    if i == 0:
        continue

    for j in range(i):
        if s[i] == s[j]:
            c+=1

print(c)

### FIXED CODE ###

n = int(input())
s = list()
for i in range(n):
    s.append(list(input()))

t = dict()
l = 0

for i in range(len(s)):
    s[i].sort()
    k = "".join(s[i])
    if not k in t.keys():
        t[k] = 1
    else:
        t[k] += 1
        l += t[k] - 1

print(l)
### BUGGY CODE ###

def main():
    s=input()
    n = len(s)
    cum = [0] * (n+1)
    sr = s[::-1]
    for i in range(n-1):
        if sr[i] == 'C' and sr[i+1] == 'B':
            cum[i+1] = cum[i] + 1
        elif sr[i] == 'A' or sr[i:i+2] in ['BC'] or (0 < i and sr[i-1:i+2] == 'CBA'):
            cum[i+1] = cum[i]
        else:
            cum[i+1] = 0
    cum[n] = cum[n-1]
    ans = 0
    for i in range(n):
        if s[i] != 'A':
            continue
        ans += cum[n-i-1]

    if n < 1000:
        print(ans)
        return

    flag = True
    s = [i for i in s]
    ans = 0
    while flag:
        flag = False
        for i in range(n-2):
            if s[i:i+3] == ['A', 'B', 'C']:
                s[i] = 'B'
                s[i+1] = 'C'
                s[i+2] = 'A'
                flag = True
                ans += 1

    print(ans)
    
main()

### FIXED CODE ###

def main(s):
    n = len(s)
    l = []
    i = 0
    while i < n:
        if s[i] == 'A':
            i += 1
            l.append('a')
        elif i < n-1 and s[i] == 'B' and s[i+1] == 'C':
            l.append('bc')
            i += 2
        else:
            l.append('b')
            i += 1
    n = len(l)
    cum = [0] * (n+1)
    ans = 0
    for i in range(n):
        if l[i] == 'a':
            cum[i+1] = cum[i] + 1
        elif l[i] == 'bc':
            cum[i+1] = cum[i]
            ans += cum[i]
        else:
            cum[i+1] = 0
    print(ans)
    # ans = 0
    # flag = True
    # s = [i for i in s]
    # while flag:
    #     flag = False
    #     for i in range(n-2):
    #         if s[i:i+3] == ['A', 'B', 'C']:
    #             s[i] = 'B'
    #             s[i+1] = 'C'
    #             s[i+2] = 'A'
    #             flag = True
    #             ans += 1
    # 
    # print(ans)

s=input()
main(s)
# import random
# for i in range(1000):
#     s = [''] * random.randint(1, 100)
#     for j in range(len(s)):
#         s[j] = 'ABC'[random.randint(0, 2)]
#         a,b=main(''.join(s))
#         if a != b:
#             print(''.join(s))
#             print(a, b)
### BUGGY CODE ###

N=int(input())
A=list(map(int,input().split()))

L=0
C=[]
for i in range(N):
    C.append(A.count(i+1))
    L+=int(C[i]*(C[i]-1)/2)
    
for i in range(N):
    print(L-C[A[i]-1]+1)

### FIXED CODE ###

N=int(input())
A=list(map(int,input().split()))

L=0
C=[0]*N

for i in range(N):
    C[A[i]-1]+=1

for i in range(N):
    L+=int(C[i]*(C[i]-1)/2)
    
for i in A:
    print(L-C[i-1]+1)
### BUGGY CODE ###

n = int(input())
p = list(map(int,input().split()))
c = 0

for i in range(n):
    s = p[:i+1]
#sの最小値とsの末尾が一致するかどうか
    if s[-1] == min(s):
        c += 1
        
print(c)

### FIXED CODE ###

n = int(input())
p = list(map(int,input().split()))
c = 0
m = 10**9
for i in range(n):
    if p[i] < m:
        m = p[i]
        c += 1
        
print(c)
### BUGGY CODE ###

n=int(input())
a=list(map(int,input().split()))
 
b=list(set(a))
c=0
for i in b:
    er = a.count(i) - i
    if er<0:
        c+= er+i
    else:
        c+=er
print(c)

### FIXED CODE ###

from collections import Counter

n=int(input())
a=list(map(int,input().split()))
counter=Counter(a)
b=list(set(a))
c=0
for i in b:
    k =  counter[i]
    c+= k-i if k-i>=0 else k
print(c)
### BUGGY CODE ###

N, M, K = map(int, input().split())
out = 0
mod = 998244353

def comb(n,k,p):
  from math import factorial
  if n<0 or k<0 or n<k: return 0
  if n==0 or k==0: return 1
  a=factorial(n) %p
  b=factorial(k) %p
  c=factorial(n-k) %p
  return (a*power_func(b,p-2,p)*power_func(c,p-2,p))%p
def power_func(a,b,p):
  if b==0: return 1
  if b%2==0:
    d=power_func(a,b//2,p)
    return d*d %p
  if b%2==1:
    return (a*power_func(a,b-1,p ))%p

for k in range(K+1):
  out += M * pow(M-1, N-k-1, mod) * comb(N-1, k, mod)
  out %= mod
print(out)

### FIXED CODE ###

N, M, K = map(int, input().split())
out = 0
mod = 998244353

c = 1

for k in range(K+1):
  out += M * pow(M-1, N-k-1, mod) * c
  out %= mod
  c *= (N-k-1) * pow(k+1, mod-2, mod)
  c %= mod
print(out)
### BUGGY CODE ###

import sys
input = sys.stdin.readline
N, Q = map(int,input().split())
S = input()[:-1]
for i in range(Q):
    l, r = map(int, input().split())
    tmp = S[l-1:r]
    print(len(tmp.split("AC"))-1)

### FIXED CODE ###

import sys
input = sys.stdin.readline
N, Q = map(int,input().split())
S = list(input())[:-1]
list_Sum = [0]*(N+1)
for i in range(1, N):
    list_Sum[i+1] = list_Sum[i]
    if S[i-1] == "A" and S[i] == "C":
        list_Sum[i+1] += 1
for i in range(Q):
    l, r = map(int,input().split())
    print(list_Sum[r]-list_Sum[l])
### BUGGY CODE ###

# https://atcoder.jp/contests/arc097/tasks/arc097_a

s = input()
K = int(input())
k = K
done = set()
for i in range(26):
    w = chr(i + ord('a'))
    for j in range(len(s)):
        if s[j] == w:
            for m in range(j, len(s)):
                t = s[j:m + 1]
                if t not in done:
                    k -= 1
                    done.add(t)
    if k < 1:
        done = list(done)
        done.sort()
        print(done[K - 1])
        import sys;sys.exit()

### FIXED CODE ###

# https://atcoder.jp/contests/arc097/tasks/arc097_a

s = input()
k = int(input())
ans = set()

for i in range(len(s)):
    for j in range(k):
        ans.add(s[i:i + j + 1])
print(sorted(list(ans))[k - 1])
### BUGGY CODE ###

from collections import Counter
import sys
input = sys.stdin.readline


def main():
    mod = 10 ** 9 + 7
    n = int(input())
    a = list(map(int, input().split()))
    ans = 0
    for i in range(n):
        a_sub = a[i+1:]
        a_sub_dict = Counter(a_sub)
        for j in a_sub_dict:
            ans += a_sub_dict[j] * (a[i] ^ j)
    print(ans % mod)


if __name__ == '__main__':
    main()


### FIXED CODE ###

n = int(input())
a = map(int, input().split())
mod = 10**9 + 7
p=[0] * 60
for a_ in a:
  for i in range(60):
    p[i] += (a_ >> i) & 1
ans = 0
for i in range(60):
  sn = (n - p[i]) * p[i]
  ans = (ans + (sn << i)) % mod
print(ans)
### BUGGY CODE ###

def solve():
    input()
    s = input()
    ans = 0
    for i in range(1000):
        t = str(i)
        while(len(t)<3):
            t = '0'+t
        it = 0
        for i in s:
            if it==3:
                break
            if i==t[it]:
                it+=1
        if it==3:
            ans+=1
    print(ans)
if __name__ == "__main__":
    solve()

### FIXED CODE ###

def solve():
    input()
    s = input()
    ans = 0
    for i in range(1000):
        t = str(i)
        while(len(t)<3):
            t = '0'+t
        it = 0
        for i in s:
            if it==3:
                break
            if i==t[it]:
                it+=1
        if it==3:
            ans+=1
    print(ans)
if __name__ == "__main__":
    solve()
### BUGGY CODE ###

n = int(input())

ans = 0
for c in range(1,n):
    if ((n-c)**(1/2)).is_integer():
        ans+=1
    for ab in range(1,int(1+(n-c+1)**(1/2))):
        if ((n-c)/(ab)).is_integer() and ((n-c)/(ab))!=(ab):
            ans+=2
print(ans)

### FIXED CODE ###

n = int(input())
ans = 0
for a in range(1, n):
  ans += (n - 1) // a
print(ans)
### BUGGY CODE ###

# -*- coding: utf-8 -*-
"""
Created on Mon Dec 31 14:30:45 2018

@author: Yamazaki Kenichi
"""

N,P = map(int, input().split())

limit = int(pow(P,1/N)//1+1)

if N == 1:
    ans = P
else:
    ans = 1
    for i in range(1,limit+1):
        if P % pow(i,N) == 0:
            ans = i
    
print(ans)


### FIXED CODE ###

# -*- coding: utf-8 -*-
"""
Created on Mon Dec 31 14:30:45 2018

@author: Yamazaki Kenichi
"""

N,P = map(int, input().split())

limit = int(pow(P,1/N)//1)

if N == 1:
    ans = P
elif limit == 1:
    ans = 1
else:
    ans = 1
    for i in range(2,limit+2):
        if P % pow(i,N) == 0:
            ans = i
            
print(ans)
### BUGGY CODE ###

s=input()
l=len(s)
mod = pow(10,9)+7

dp = [[0 for _ in range(13)] for _ in range(l+1)]
dp[0][0] = 1

for i in range(1,l+1):
	num = s[-i]
	keta = pow(10,i-1)  % 13
	if num == '?':
		for j in range(10):
			for k in range(13):
				dp[i][(j * keta + k) % 13] += dp[i-1][k] % mod
	else:
		num = int(num)
		for k in range(13):
			dp[i][(num * keta + k) % 13] += dp[i-1][k] % mod
print(dp[l][5] % mod)

### FIXED CODE ###

INF = 10 ** 9 + 7

S = input()
# dp[i][j]はうしろからi桁を13で割った余りがjであるものの個数
dp = [[0] * 13 for _ in range(len(S) + 1)]
dp[0][0] = 1
mul = 1

for i in range(len(S)):
    x = S[-(i + 1)]
    if x == "?":
        for k in range(10):
            for j in range(13):
                dp[i + 1][(mul * k + j) % 13] += dp[i][j]
                dp[i + 1][(mul * k + j) % 13] %= INF
    else:
        k = int(x)
        for j in range(13):
            dp[i + 1][(mul * k + j) % 13] += dp[i][j]
            dp[i + 1][(mul * k + j) % 13] %= INF
    mul = mul * 10 % 13  # 計算量削減のためここで13で割っている

print(dp[len(S)][5])
### BUGGY CODE ###

n = int(input())
c = list(input())
sc = reversed(c)
ans = 0
flg = True

if 'W' not in set(c) or 'R' not in set(c):
    flg = False


while(flg):

    for i, r in enumerate(c):
        if not flg:
            break

        if r == 'W':
            for j, l in enumerate(sc):
                if l == 'R':
                    if len(c) >= i+j+2:
                        c[i] = 'R'
                        c[-1*j-1] = 'W'
                        ans += 1
                        sc = reversed(c)
                        break
                    else:
                        flg = False
                        break


print(ans)



### FIXED CODE ###

n = int(input())
c = list(input())
sc = list(reversed(c))
ans = 0
r = 0
flg  = False

if 'W' not in set(c) or 'R' not in set(c):
    print(ans)


else:
    for i in range(n):
        if flg:
            break
        if c[i] == 'W':
            for j in range(r, n):
                r += 1
                if sc[j] == 'R':
                    if n >= i+j+2:
                        c[i] = 'R'
                        c[-1*j-1] = 'W'
                        ans += 1
                        break
                    else:
                        flg = True
                        break

                
            

    print(ans)