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

MOD = 1000000007

S = input()

a = 0
ab = 0
abc = 0
all_s = 1

for s in S:
    if s == "A":
        a += all_s
    elif s == "B":
        ab += a
    elif s == "C":
        abc += ab
    elif s == "?":
        abc = abc * 3 + ab % MOD
        ab = ab * 3 + a % MOD
        a = a * 3 + all_s % MOD
        all_s = all_s * 3 % MOD

print(abc % MOD)


### FIXED CODE ###

MOD = 1000000007

S = input()

a, ab, abc, all_s = 0, 0, 0, 1

for s in S:
    if s == "A":
        a = (a + all_s) % MOD
    elif s == "B":
        ab = (ab + a) % MOD
    elif s == "C":
        abc = (abc + ab) % MOD
    elif s == "?":
        abc = (abc * 3 + ab) % MOD
        ab = (ab * 3 + a) % MOD
        a = (a * 3 + all_s) % MOD
        all_s = (all_s * 3) % MOD

print(abc)
### BUGGY CODE ###


def parse():
  H, W = map(int, input().split(" "))
  grid = []
  for y in range(H):
    grid.append(list(input()))
  return H, W, grid

def print_grid(grid):
  H = len(grid)
  print("grid:")
  for line in grid:
    for c in line:
      print(c, end="")
    print("")

def main():
  H, W, grid = parse()
  # print(H, W)
  # print_grid(grid)

  visited = [[W * H if grid[y][x] == "." else 0 for x in range(W)] for y in range(H)]
  # for y in range(H):
  #   visited.append([])
  #   for x in range(W):
  #     if grid[y][x] == ".":
  #       visited[y].append(H * W)
  #     else:
  #       visited[y].append(0)
    # print(visited[y])
  
  for y in range(H):  # ↓
    for x in range(1, W):  # →
      visited[y][x] = min(visited[y][x - 1] + 1, visited[y][x])
  for y in range(H):  # ↓
    for x in range(W - 2, -1, -1):  # ←
      visited[y][x] = min(visited[y][x], visited[y][x + 1] + 1)
  for x in range(W):  # →
    for y in range(1, H):  # ↓
      visited[y][x] = min(visited[y - 1][x] + 1, visited[y][x])
  for x in range(W):  # →
    for y in range(H - 2, -1, -1):  # ↑
      visited[y][x] = min(visited[y][x], visited[y + 1][x] + 1)
  
  max_len = 0
  for y in range(H):
    max_len = max_len if max_len > max(visited[y]) else max(visited[y])
  print(max_len)

if __name__ == "__main__":
  main()

### FIXED CODE ###


import numpy as np

def parse():
  H, W = map(int, input().split(" "))
  grid = [list(input()) for y in range(H)]
  return H, W, grid

def print_grid(grid):
  H = len(grid)
  print("grid:")
  for line in grid:
    for c in line:
      print(c, end="")
    print("")

def main():
  H, W, grid = parse()
  # print(H, W)
  # print_grid(grid)

  # visited = [[W * H if grid[y][x] == "." else 0 for x in range(W)] for y in range(H)]
  visited = np.zeros((H, W), int)
  for y in range(H):
    # visited.append([])
    for x in range(W):
      if grid[y][x] == ".":
        visited[y][x] = H * W

  for y in range(1, H):  # ↓
    # 要素ごとの処理
    # print(visited)
    visited[y][:] = np.minimum(visited[y][:], visited[y - 1][:] + 1)
    # print(visited)
    # input()
    # print(visited[y])
    # exit(0)

  for y in range(H - 2, -1, -1):
    visited[y, :] = np.minimum(visited[y, :], visited[y + 1][:] + 1)

  for x in range(1, W):
    visited[:, x] = np.minimum(visited[:, x], visited[:, x - 1] + 1)

  for x in range(W - 2, -1, -1):
    visited[:, x] = np.minimum(visited[:, x], visited[:, x + 1] + 1)

  # print(visited)
  # exit(0)

  # max_len = 0
  # for y in range(H):
  #   max_val = max(visited[y])
  #   max_len = max_len if max_len > max_val else max_val
  # print(max_len)
  print(np.max(visited))

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

n, k = map(int, input().split())
p = list(map(int, input().split()))
c = list(map(int, input().split()))
ans = -10**9
for i in range(n):
    scores = [0]
    seen = set([i])
    now = i
    loop = False
    for _ in range(k):
        now = p[now]-1
        scores.append(c[now])
        if now in seen:
            loop = True
            break
        seen.add(now)
    for i in range(len(scores)-1):
        scores[i+1] += scores[i]
    tmp = max(scores[1:])
    ans = max(ans, tmp)
    if not loop or scores[-1]<=0:
        continue
    tmp = scores[-1]*(k//(len(scores)-1))
    rem = k%(len(scores)-1)
    tmp += max(scores[:rem+1])
    ans = max(ans, tmp)
print(ans)

### FIXED CODE ###

n, k = map(int, input().split())
p = list(map(int, input().split()))
c = list(map(int, input().split()))
ans = -10**9
for i in range(n):
    scores = [0]
    seen = set([i])
    now = i
    loop = False
    for _ in range(k):
        now = p[now]-1
        scores.append(c[now])
        if now in seen:
            loop = True
            break
        seen.add(now)
    for i in range(len(scores)-1):
        scores[i+1] += scores[i]
    tmp = max(scores[1:])
    ans = max(ans, tmp)
    if (not loop) or scores[-1]<=0:
        continue
    tmp = scores[-1]*(k//(len(scores)-1))
    rem = k%(len(scores)-1)
    tmp += max(scores[:rem+1])
    ans = max(ans, tmp)
    tmp = scores[-1]*(k//(len(scores)-1)-1)
    tmp += max(scores)
    ans = max(ans, tmp)
print(ans)
### BUGGY CODE ###

k = int(input())
num = 7 
s = set()
cnt = 1
while(1):
    m = num%k
    if m == 0:
        print(cnt)
        break
    elif m in s:
        print(-1)
        break
    else:
        s.add(m)
    num = num*10+7
    cnt += 1

### FIXED CODE ###

k = int(input())
m = 7 % k 
s = set()
cnt = 1
while(1):
    if m == 0:
        print(cnt)
        break
    elif m in s:
        print(-1)
        break
    else:
        s.add(m)
    m = ((m * (10 % k)) % k + 7 % k) % k
    cnt += 1
### BUGGY CODE ###

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

aa = A[:]
aa.sort()
num = []
for i in range(N-1):
    aa.remove(A[i])
    num.append(aa[-1]-A[i])
    
print(num.count(max(num)))

### FIXED CODE ###

from bisect import bisect_left

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

aa = A[:]
aa.sort()

ans = 0
num = []

for i in range(N-1):
    ind = bisect_left(aa, A[i])
    del aa[ind]
    
    num.append(aa[-1]-A[i])

print(num.count(max(num)))
### BUGGY CODE ###

import copy

s = input()
t = input()

dp = [[0]*(len(t)+1) for _ in range(len(s)+1)]
key = [[[0, 0] for _ in range(len(t)+1)] for _ in range(len(s)+1)]
for i in range(len(s)+1):
  for j in range(len(t)+1):
    if i == 0 and j == 0:
      continue
    if i == 0:
      dp[i][j] = dp[i][j-1]
      continue
    if j == 0:
      dp[i][j] = dp[i-1][j]
      continue
    if s[i-1] == t[j-1]:
      dp[i][j] = dp[i-1][j-1] + 1
      key[i][j] = [i-1, j-1]
    else:
      if dp[i-1][j] > dp[i][j-1]:
        dp[i][j] = dp[i-1][j]
        key[i][j] = copy.deepcopy(key[i-1][j])
      else:
        dp[i][j] = dp[i][j-1]
        key[i][j] = copy.deepcopy(key[i][j-1])

ans = []
i, j = len(s), len(t)
while True:
  i, j = map(int, key[i][j])
  if s[i] == t[j]:
    ans.append(s[i])
  if i == 0 or j == 0:
    break

ans.reverse()
print("".join(ans))

### FIXED CODE ###

s = input()
t = input()

inf = pow(10, 4)
dp = [[0]*(len(t)+1) for _ in range(len(s)+1)]
key = [[0]*(len(t)+1) for _ in range(len(s)+1)]
for i in range(len(s)+1):
  for j in range(len(t)+1):
    if i == 0 and j == 0:
      continue
    if i == 0:
      dp[i][j] = dp[i][j-1]
      continue
    if j == 0:
      dp[i][j] = dp[i-1][j]
      continue
    if s[i-1] == t[j-1]:
      dp[i][j] = dp[i-1][j-1] + 1
      key[i][j] = (i-1)*inf+(j-1)
    else:
      if dp[i-1][j] > dp[i][j-1]:
        dp[i][j] = dp[i-1][j]
        key[i][j] = key[i-1][j]
      else:
        dp[i][j] = dp[i][j-1]
        key[i][j] = key[i][j-1]

ans = []
i, j = key[len(s)][len(t)]//inf, key[len(s)][len(t)]%inf
while True:
  if s[i] == t[j]:
    ans.append(s[i])
  if i == 0 or j == 0:
    break
  i, j = key[i][j]//inf, key[i][j]%inf

ans.reverse()
print("".join(ans))
### BUGGY CODE ###

x = int(input())
a, b = 0,0
done = False
for i in range(0,20000):
    for l in range(0, -20000, -1):
        if((i**5)-(l**5)==x):
            a = i
            b = l
            done  = True
            break
    if(done):
        break
print(a,b)


### FIXED CODE ###

x = int(input())
a, b = 0,0
done = False
for i in range(-2000, 2000):
    for l in range(2000,-2000, -1):
        if((i**5)-(l**5)==x):
            a = i
            b = l
            print(a,b)
            done  = True
            break
    if(done):
        break
### BUGGY CODE ###

n,k=map(int,input().split())
p=list(map(float,input().split()))
exp=tuple([(pi+1)/2 for pi in p])
ans=0
for i in range(0,n-k+1):
  ans=max(ans,sum(exp[i:i+k]))
print(ans)

### FIXED CODE ###

import numpy as np
n,k=map(int,input().split())
exp=tuple(map(lambda x: (int(x)+1)/2,input().split()))
l=np.cumsum(exp)

ans=l[k-1]
for i in range(0,n-k):
  x=l[i+k]-l[i]
  ans=max(ans,x)
print(ans)
### BUGGY CODE ###

k,s = map(int,input().split())

ans = 0

for i in range(k+1):
    for j in range(i,k+1):
        for c in range(j,k+1):
            if i + j + c == s:
                if i == j and j == c:
                    ans += 1
                elif i!=j and j!=c and c!=j:
                    ans += 6
                else:
                    ans += 3
print(ans)


### FIXED CODE ###

k,s = map(int,input().split())

ans = 0

for i in range(k+1):
    for j in range(i,k+1):
        c = s-i-j
        if k >= c and c >=j:
            if i == j and j == c:
                ans += 1
            elif i!=j and j!=c and c!=j:
                ans += 6
            else:
                ans += 3
        
print(ans)
### BUGGY CODE ###

from collections import deque
def bfs(A,H,W,D):
    que = deque(D)
    cnt = 0
    d = [-1,1]
    tmp = set()
    flag = 0
    while que:
        u = que.popleft()
        
        y,x = u
        for k in range(2):
            s = y + d[k]
            t = x + d[k]
            if 0 <= s < H:
                if A[s][x] == '.':
                    A[s][x] = '#'
                    tmp.add((s,x))
                    flag = 1
              
            if 0 <= t < W:
                if A[y][t] == '.':
                    A[y][t] = '#'
                    tmp.add((y,t))
                    flag = 1

            
        if not que:
            que = deque(tmp) 
            tmp = set()
            if flag:
                cnt += 1
            flag = 0
    return cnt

def main():
    H,W = map(int,input().split(" "))
    A = []
    D = []
    D_append = D.append
    for i in range(H):
        tmp = []
        for j,s in enumerate(input()):
            tmp.append(s)
            if s == '#':
                D_append((i,j))
        A.append(tmp)

    ans = bfs(A,H,W,D)
    print(ans)


if __name__ == "__main__":
    main()
            

### FIXED CODE ###

from collections import deque
def bfs(A,H,W,D):
    que = deque(D)
    cnt = 0
    d = [-1,1]
    tmp = set()
    flag = 0
    while que:
        u = que.popleft()
        
        y,x = u
        for k in range(2):
            s = y + d[k]
            t = x + d[k]
            if 0 <= s < H:
                if A[s][x] == '.':
                    A[s][x] = '#'
                    tmp.add((s,x))
                    flag = 1
              
            if 0 <= t < W:
                if A[y][t] == '.':
                    A[y][t] = '#'
                    tmp.add((y,t))
                    flag = 1

            
        if not que:
            que = deque(tmp) 
            tmp = set()
            if flag:
                cnt += 1
            flag = 0
    return cnt

def main():
    H,W = map(int,input().split(" "))
    A = []
    D = []
    D_append = D.append
    for i in range(H):
        tmp = []
        for j,s in enumerate(input()):
            tmp.append(s)
            if s == '#':
                D_append((i,j))
        A.append(tmp)

    ans = bfs(A,H,W,D)
    print(ans)


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

def need(A, p):
    if max(A) > p:
        return 100001
    count = 0
    track = 0
    for x in A:
        if count + x <= p:
            count += x
        else:
            track += 1
            count = x
    if count > 0:
        return track + 1
    else:
        return track

n, k = map(int, raw_input().split())
W = [int(raw_input()) for i in xrange(n)]

left = 1
right = sum(W) + 1
while left < right:
    mid = (left + right) / 2
    track = need(W, mid)
    if k == track:
        while k == need(W, mid-1):
            mid -= 1
        print mid
        quit()
    elif k > track:
        right = mid
    else:
        left = mid + 1
if left == right:
    print left

### FIXED CODE ###

def maxStack(k, p, W):
    nw = 0
    count = 0
    t = 1
    for x in W:
        if x > p:
            return count
        if nw + x <= p:
            nw += x
            count += 1
        else:
            if t == k:
                return count
            else:
                t += 1
                nw = x
                count += 1
    return count


n, k = map(int, raw_input().split())
W = [int(raw_input()) for i in xrange(n)]

left = 1
right = sum(W)
while left < right:
    mid = (left + right) / 2
    v = maxStack(k, mid, W)
    if v >= n:
        right = mid
    else:
        left = mid + 1
print left
### BUGGY CODE ###

from sys import stdin
input = stdin.readline
import numpy as np
from collections import deque
H,W = map(int, input().rstrip().split())
CH,CW = map(int, input().rstrip().split())
DH,DW = map(int, input().rstrip().split())
[CH,CW,DH,DW] = [CH-1,CW-1,DH-1,DW-1]
S = np.array([list(input().rstrip()) for i in range(H)])
M = 10 ** 9
Distance = np.ones((H,W))*M
Distance[CH,CW] = 0
[nowH,nowW] = [CH,CW]
q0 = deque([])
q0.append([nowH,nowW])
q1 = deque([])
for n in range(0,M):
  if len(q0) != 0:
    [nowH,nowW] = q0.popleft()
  elif len(q1) != 0:
    [nowH,nowW] = q1.popleft()
  else:
    break
  if [nowH,nowW] == [DH,DW]:
    break
  for i in range(-2,3):
    for j in range(-2,3):
      if nowH+i >= 0 and nowW+j >= 0 and nowH+i < H and nowW+j < W:
        if (abs(i) + abs(j)) == 1:
          if S[nowH+i,nowW+j] == '.':
            if Distance[nowH+i,nowW+j] == M:
              q0.append([nowH+i,nowW+j])
            elif [nowH+i,nowW+j] in q1:
              q0.append([nowH+i,nowW+j])
              q1.remove([nowH+i,nowW+j])
            Distance[nowH+i,nowW+j] = min(Distance[nowH,nowW],Distance[nowH+i,nowW+j])
        elif (abs(i) + abs(j)) >= 2:
          if S[nowH+i,nowW+j] == '.':
            if Distance[nowH+i,nowW+j] == M:
              q1.append([nowH+i,nowW+j])
            Distance[nowH+i,nowW+j] = min(Distance[nowH,nowW]+1,Distance[nowH+i,nowW+j])       
if Distance[DH,DW] == M:
  print(-1)
else:
  print(int(Distance[DH,DW]))  

### FIXED CODE ###

from collections import deque
H,W = map(int, input().split())
CH,CW = map(lambda x: int(x) - 1, input().split())
DH,DW = map(lambda x: int(x) - 1, input().split())
S = [input() for i in range(H)]
INF = 10 ** 9
walk = [(0, 1), (0, -1), (-1, 0), (1, 0)]
warp = [(i, j) for i in range(-2, 3) for j in range(-2, 3) if (i, j) not in [(0, 0)] + walk]
h = CH
w = CW
Distance = [[INF] * W for _ in range(H)]
Distance[h][w] = 0
q = deque(())
q.append((h,w))
while q:
  h,w = q.popleft()
  if [h,w] == [DH,DW]:
    break
  for i,j in walk:
    hwalk = h + i
    wwalk = w + j
    if 0 <= hwalk < H and 0 <= wwalk < W and S[hwalk][wwalk] == '.' and Distance[h][w] < Distance[hwalk][wwalk]:
      Distance[hwalk][wwalk] = Distance[h][w]
      q.appendleft((hwalk,wwalk))
  for i,j in warp:
    hwalk = h + i
    wwalk = w + j
    if 0 <= hwalk < H and 0 <= wwalk < W and S[hwalk][wwalk] == '.' and Distance[h][w] + 1 < Distance[hwalk][wwalk]:
      Distance[hwalk][wwalk] = Distance[h][w] + 1
      q.append((hwalk,wwalk))
print(int(Distance[DH][DW]) if Distance[DH][DW] != INF else -1)
### BUGGY CODE ###

print("Yes")
N, M = map(int, input().split())
path = [[] for _ in range(N)]
ind = [0 for _ in range(N)]
lis = set()
for o in range(N):
    lis.add(o)
for i in range(M):
    A, B = map(int, input().split())
    path[A-1].append(B-1)
    path[B-1].append(A-1)
que = path[0]
for p in que:
    lis.discard(p)
for l in que:
    U = lis & set(path[l])
    for m in U:
        ind[m] = l
        lis.discard(m)
    que.extend(list(U))
    if lis == {}:
        break
for z in range(1,N):
    ind[z] += 1
    print(ind[z])

### FIXED CODE ###

print("Yes")
N, M = map(int, input().split())
path = [[] for _ in range(N)]
ind = [0 for _ in range(N)]
lis = [0] + [1 for _ in range(N-1)]
for i in range(M):
    A, B = map(int, input().split())
    path[A-1].append(B-1)
    path[B-1].append(A-1)
que = path[0]
for p in que:
    lis[p] = 0
for l in que:
    U = path[l]
    for m in U:
        if lis[m] ==1:
            ind[m] = l
            lis[m] = 0
            que.append(m)
    if lis == {}:
        break
for z in range(1,N):
    ind[z] += 1
    print(ind[z])
### BUGGY CODE ###

from sys import stdin


def mod(val):
    res = val % (10 ** 9 + 7)
    if (res < 0):
        res += (10 ** 9 + 7)
    return res


def main():
    _in = [_.rstrip() for _ in stdin.readlines()]
    N = int(_in[0])  # type:int
    A_arr = list(map(int, _in[1].split(' ')))  # type:list(int)
    # vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
    A_arr_mod = [0] * len(A_arr)
    for i, a in enumerate(A_arr):
        A_arr_mod[i] = mod(a)

    ans = 0
    for i in range(N-1):
        ans += A_arr_mod[i] * sum(A_arr_mod[i+1:])
        ans = mod(ans)
    # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    print(ans)


if __name__ == "__main__":
    main()


### FIXED CODE ###

from sys import stdin


def mod(val):
    res = val % (10 ** 9 + 7)
    if (res < 0):
        res += (10 ** 9 + 7)
    return res


def main():
    _in = [_.rstrip() for _ in stdin.readlines()]
    N = int(_in[0])  # type:int
    A_arr = list(map(int, _in[1].split(' ')))  # type:list(int)
    # vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
    A_arr_mod = [0] * len(A_arr)
    for i, a in enumerate(A_arr):
        A_arr_mod[i] = mod(a)

    ans = 0
    cache = sum(A_arr_mod)
    for i in range(N-1):
        cache -= A_arr_mod[i]
        ans += A_arr_mod[i] * cache
        ans = mod(ans)
    # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    print(ans)


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

L,R=map(int,input().split())
X=2019
for i in range (R-L):
    for j in range(R-L-i):
        if X >(L+i)*(L+i+j+1)%2019:
            X=(L+i)*(L+i+j+1)%2019
        elif (L+i)*(L+i+j+1)%2019==0:
            X=0
            break
print(X)


### FIXED CODE ###

L,R=map(int,input().split())
X=2019
for i in range (R-L):
    for j in range(R-L-i):
        if (L+i)*(L+i+j+1)%2019==0:
            X=0
            break
        elif X >(L+i)*(L+i+j+1)%2019:
            X=(L+i)*(L+i+j+1)%2019
    if X==0:
        break        
print(X)
### BUGGY CODE ###

L, R = map(int,input().split(" "))

m = 2018
for l in range(L,R):
    for r in range(l+1,R+1):
        m = min(m,l*r%2019)

print(m)


### FIXED CODE ###

L, R = map(int,input().split(" "))

m = 2018

if R-L>=2019:
    print(0)
    exit()

for l in range(L,R):
    for r in range(l+1,R+1):
        m = min(m,l*r%2019)

print(m)
### BUGGY CODE ###

N = int(input())
a = list(map(int,input().split(' ')))
for i in range(1,N+1):
    print(a.count(i))

### FIXED CODE ###

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

ans = [0]*N

for i in A:
    ans[i - 1] += 1
print('\n'.join(map(str,ans)))
### BUGGY CODE ###

N=int(input())
T=1e18
arr=[int(i) for i in input().split()]
A=1
for a in arr:
    A*=a

print(A if A<=T else -1)


### FIXED CODE ###

N=int(input())
T=1e18
arr=[int(i) for i in input().split()]
A=1
for a in arr:
    A*=a
    if A<0:
        A=-1
    if A>T:
        A=-1
print(A)
### BUGGY CODE ###

#from fractions import gcd
N = int(input())
A = list(map(int,input().split()))
lcm = A[0]
def gcd(a,b):
    while b!=0:
        a,b=b,a%b
    return a

for i in range(1,N):
    lcm = (lcm*A[i])//gcd(lcm,A[i])
MOD = 10**9+7
ans = 0
for a in A:
    b = lcm//a
    ans += b
    ans %= MOD
print(ans)

### FIXED CODE ###

from fractions import gcd
n=int(input())
a=list(map(int,input().split()))
lcm = a[0]
for i in range(1,n):
  lcm = lcm*a[i] // gcd(lcm,a[i])
mod=pow(10,9)+7
lcm%=mod
ans=0
for x in a:
  ans+=pow(x,mod-2,mod)
  ans%=mod
print(ans*lcm%mod)
### BUGGY CODE ###

# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

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

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a
ans=True

next=[]

f=False
MIN_A=INF
for x in A:
    if x==1:
        f=True
    else:
        next.append(x)
        MIN_A=min(MIN_A,x)
A=next
next=[]

while A:
    prime=prime_factorize(MIN_A)
    MIN_A=INF
    for p in prime:
        cnt=0
        for i,x in enumerate(A):
            if x%p==0:
                cnt+=1
                while x%p==0:
                    x//=p
                if x!=1:
                    next.append(x)
                    MIN_A=min(MIN_A,x)
            else:
                next.append(x)
                MIN_A=min(MIN_A,x)
                
        if cnt>=2:
            ans=False
        if cnt==N and not f:
            print('not coprime')
            exit()
        A=next
        next=[]

if ans:
    print('pairwise coprime')
else:
    print('setwise coprime')

### FIXED CODE ###

# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1
from math import gcd

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

M=10**6

D=[-1]*(M+1)
D[0]=D[1]=1
for i in range(2,int(M**0.5)+1):
    if D[i]!=-1:
        continue
    for j in range(i*2,M+1,i):
        if D[j]==-1:
            D[j]=i

f=[False]*(M+1)

for x in A:
    l=[]
    while x>1:
        if f[x]==True:
            break
        if D[x]>1:
            l.append(D[x])
            x//=D[x]
        else:
            l.append(x)
            x=1
    else:
        for y in l:
            f[y]=True
        continue
    break
else:
    print('pairwise coprime')
    exit()

tmp=A[0]
for x in A[1:]:
    tmp=gcd(tmp,x)
    if tmp==1:
        print('setwise coprime')
        exit()
else:
    print('not coprime')
### BUGGY CODE ###

S = input()
N = len(S)

MOD = 10**9 + 7
dp = [[0 for _ in range(13)] for _ in range(N)]  # dp[i][j]: S[i]までみて13で割ってjあまるものの個数

# 初期値
if S[0] == "?":
    for j in range(10):
        dp[0][j] = 1
else:
    dp[0][int(S[0])] = 1

# dpテーブル更新式
for i in range(1, N):
    if S[i] == "?":
        for si in range(10):
            for j in range(13):
                dp[i][(j*10 + si)%13] += dp[i-1][j]
                dp[i][(j*10 + si)%13] %= MOD
    else:
        si = int(S[i])
        for j in range(13):
            dp[i][(j*10 + si)%13] += dp[i-1][j]
            dp[i][(j*10 + si)%13] %= MOD

print(dp[N-1][5])


### 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

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

n,k,q = map(int, input().split())
A = [int(input()) for i in range(q)]
ANS = [k] * n

for i in range(q):
  for j in range(n):
    ANS[j] += -1
  ANS[A[i]-1] += 1

for i in range(n):
  if ANS[i] <= 0:
    print("No")
  else:
    print("Yes")

### FIXED CODE ###

n,k,q = map(int, input().split())
A = [int(input()) for i in range(q)]
S = [k] * n
for i in range(q):
  S[A[i]-1] += 1
  
ANS = [S[i]- q for i in range(n)]
for i in range(n):
  if ANS[i] <= 0:
    print("No")
  else:
    print("Yes")