Harryxun/stf_run huggingface dataset:
S = input()
n = False
for i in range(len(S) + 1):
    for j in range(i, len(S) + 1):
        rest_str = S[:i] + S[j:]
        if rest_str == keyence:
            n = True
            break
    if n:
        break
if n:
	print("YES")
else:
    print("NO")

### FIXED CODE ###

S = input()
keyence = 'keyence'
n = False
for i in range(len(S) + 1):
    for j in range(i, len(S) + 1):
        rest_str = S[:i] + S[j:]
        if rest_str == keyence:
            n = True
            break
    if n:
        break
if n:
	print("YES")
else:
    print("NO")
n = int(intput())
s = int(intput())

ans = 0
i = j= 0

while j <= n-1:
    if s[i:j] in s[j:]:
        ans = max(ans, j-i)
        j += 1
    else:
        i += 1
print(ans)

### FIXED CODE ###

n = int(input())
s = input()

ans = 0
i = j= 0

while j <= n-1:
    if s[i:j] in s[j:]:
        ans = max(ans, j-i)
        j += 1
    else:
        i += 1
print(ans)
N = input()
N = N % 10
if N in [2, 4, 5, 7, 9]:
    print('hon')

elif N in [0, 1, 6, 8]:
    print('pon')

else:
    print('bon')

### FIXED CODE ###

N = int(input())
N = N % 10
if N in [2, 4, 5, 7, 9]:
    print('hon')

elif N in [0, 1, 6, 8]:
    print('pon')

else:
    print('bon')
N, M, X, Y = map(int, input().split())
x = list(map(int, input().split()))
y = list(map(int, input().split()))

zx = list(range(max(x)+1,101))
zy = list(range(-100, min(y)+1))
kanou = set(zx) & set(zy)
if len(kanou) == 0:
    print('War')
else:
    for i in kanou:
        if X < i <= Y:
            print('No War')
            break
    else:
        print(War)


### FIXED CODE ###

N, M, X, Y = map(int, input().split())
x = list(map(int, input().split()))
y = list(map(int, input().split()))
ans = 1

if X >= Y:
    ans = 1
elif X < Y:
    z = list(range(X+1, Y+1))

for i in z:
    if max(x) < i and i <= min(y):
        ans = 0
        
if ans == 0:
     print('No War')
        
else:
    print('War')
N = int(input())

xyh = []

for i in range(N):
    x,y,h = map(int,input().split())
    xyh.append([x,y,h])

for i in range(101):
    for j in range(101):

        Cx = i
        Cy = j
        ans = True
        flag_h = True

        for x,y,h in xyh:

            if h>0 and flag_h:
                H = h+abs(Cx-x)+abs(Cy-y)
                flag_h = False

            elif h>0:
                tmp_h = h+abs(Cx-x)+abs(Cy-y)
                if tmp_h != H:
                    ans = False
                    ##break

        elif ans:
            print(Cx,Cy,H)
            exit() 

### FIXED CODE ###

N = int(input())

xyh = []
not_zero = -100
flag_zero = True

for i in range(N):
    x,y,h = map(int,input().split())
    if h > 0 and flag_zero:
        not_zero = i
        flag_zero = False
    xyh.append([x,y,h])

for i in range(101):
    for j in range(101):

        Cx = i
        Cy = j
        H = xyh[not_zero][2] + abs(Cx-xyh[not_zero][0]) + abs(Cy-xyh[not_zero][1])
        ans = True

        for x,y,h in xyh:
            tmp_h = h+abs(Cx-x)+abs(Cy-y)
            if h>0:
                if tmp_h != H:
                    ans = False
                    break
            else:
                if H - abs(Cx-x) -abs(Cy-y) > 0:
                    ans = False
                    break
            
        if ans:
            print(Cx,Cy,H)
            exit()
import sys
sys.setrecursionlimit(10**8)
input = sys.stdin.readline 
n,q=map(int,input().split())
Graph=[[] for _ in range(n+1)]
ans=[0 for _ in range(n+1)]
seen=[False for _ in range(n+1)]

for _ in range(n-1):
    a,b=map(int,input().split())
    Graph[a].append(b)
    Graph[b].append(a)

for _ in range(q):
    p,x=map(int,input().split())
    ans[p]+=x

def dfs(v):
    seen[v]=True
    for nv in Graph[v]:
        if seen[nv]:
            continue
        else:
            ans[nv]+=ans[v]
            dfs(nv)

dfs(1)
print(*ans[1:])

### FIXED CODE ###

a=int(input())
s=input()

if a>=3200:
    print(s)
else:
    print("red")
n,k = map(int,input().split())
s = input()

sp = []
if s[0]=='1':
  sp.append(0)

count=0
for si in s:
  if count==0:
    flag = si
    count=1
  elif flag == si:
    count+=1
  else:        
    sp.append(count)
    flag = si
    count=1
if count>0:
  sp.append(count)
if s[-1]=='1' and flag=='1':
  sp.append(0)
  
ss=[]
for i in range(len(sp)-2*k+1):
  if i%2==0:    
    ss.append(sum(sp[i:i+2*k]))
  else:
    ss.append(sum(sp[i:i+2*k+1]))
print(max(ss))      

### FIXED CODE ###

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

sp = []
if s[0]=='0':
  sp.append(0)

count=0
for si in s:
  if count==0:
    flag = si
    count=1
  elif flag == si:
    count+=1
  else:        
    sp.append(count)
    flag = si
    count=1
if count>0:
  sp.append(count)
if s[-1]=='0':
  sp.append(0)

ss=[0]
ss.append(sp[0])
count = 0
for spi in sp[1:]:
  ss.append(ss[-1]+spi)  

ans = 0
for left in range(0,len(ss),2):
  right = left+2*k+1
  if right >= len(ss): #!!
    right = len(ss)-1
  ans = max(ans,ss[right]-ss[left])    

print(ans)
x = int(input())
k = x//100
print(1) if 100*k <= x and x<= 105*k else print(0)

### FIXED CODE ###

m1,d1 = map(int,input().split())
m2,d2 = map(int,input().split())
print(1) if d2 == 1 else print(0)
N, M = map(int, input().split())

road_num = list(map(int, input().split()))
road_num = len(road_num)

way_list = []
goal_list = []

for i in range(road_num - 1):
    way, goal = map(int, input().split())
    if not(way in way_list):
        way_list.append(way)
    if not(goal in way_list) and not(goal in goal_list):
        goal_list.append(goal)

print(len(goal_list))

### FIXED CODE ###

n,m=map(int,input().split())
arr=[0]+list(map(int,input().split()))
g=[[] for _ in range(n+1)]
for _ in range(m):
 a,b=map(int,input().split())
 g[a].append(b)
 g[b].append(a)
ans=0
for v in range(1,n+1):
 for u in g[v]: #i番目の展望台から1本の道を通っていけるすべての展望台と高さを比較する
   if arr[u]>=arr[v]:
     break
 else: #i番目の展望台の高さが他のすべての展望台の高さより真に大きければ答えを1増やす
   ans+=1
print(ans)
N, D = map(int, input().split())
ans = 0
for in range(N):
  X, Y = map(int, input().split())
  if x**2 + y**2 <= D**2:
    ans += 1

print(ans)

### FIXED CODE ###

N, D = map(int, input().split())
ans = 0
for i in range(N):
  X, Y = map(int, input().split())
  if X**2 + Y**2 <= D**2:
    ans += 1
 
print(ans)
import sys

def ans(index, array, k):
    r = right(index, array, k)
    l =  left(index, array, k)
    return min(r, l)


def right(index, array, k):
    start = max(0, k-(index-1)) + index
    count = sys.maxsize
    for i in range(start, min(len(array), k+index+1)):
        tmp = array[i]
        tmp += array[i] - array[k -(i - index + 1)]
        count = count if count < tmp else tmp

    if len(array) > (index + k - 1):
        count = count if count < array[index + k - 1] else array[index + k - 1]
    
    return count

def left(index, array, k):
    n = len(array)
    start = min(0, n-index-k) + index
    count = sys.maxsize
    
    for i in range(max(0, start - k), start):
        tmp = -array[i]
        tmp += -array[i] + array[k + i - 1]
        count = count if count < tmp else tmp

    if index >= k:
        count = count if count < -array[index-k] else -array[index-k]
    
    return count

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

x = [int(i) for i in input().split()] 

for i in range(n):
    if x[i] >= 0:
        index = i
        break

print(ans(index, x, k))




### FIXED CODE ###

import sys

def ans(index, array, k):
    r = right(index, array, k)
    l =  left(index, array, k)
    return min(r, l)


def right(index, array, k):
    start = max(index, k-1)
    count = sys.maxsize
    for i in range(start, min(len(array), k+index)):
        tmp = array[i]
        j = index - (k - (i - index + 1))
        tmp += array[i] - array[j]
        count = count if count < tmp else tmp

    if len(array) > (index + k - 1):
        count = count if count < array[index + k - 1] else array[index + k - 1]
    
    return count

def left(index, array, k):
    n = len(array)
    start = min(index, n - k + 1)
    count = sys.maxsize
    
    for i in range(max(0, start - k), start):
        tmp = -array[i]
        j = k + i - 1
        tmp += -array[i] + array[j]
        count = count if count < tmp else tmp

    if index >= k:
        count = count if count < -array[index-k] else -array[index-k]
    
    return count

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

x = [int(i) for i in input().split()] 

index = n
for i in range(n):
    if x[i] >= 0:
        index = i
        break

print(ans(index, x, k))
import itertools

l = [1,2,3,4,5,6,7,8,9]

while True:
    try:
        N = int(raw_input())
        res = 0
        for element in itertools.combinations_with_replacement(l,5):
          if sum(element) == N:
          res += 1
        print res
    except EOFError:
        break

### FIXED CODE ###

import itertools

l = [0,1,2,3,4,5,6,7,8,9]

while True:
    try:
        N = int(raw_input())
        res = 0
        for element in itertools.product(l,repeat=4):
            if sum(element) == N:
                res += 1
        print res
    except EOFError:
        break
n = int(input())
ans = 0
for i in range(1, int(n**0.5)+1):
    if n % i == 0:
        m = n//i - 1
        if n // m == n % m:
            ans += n//i - 1
print(ans)

### FIXED CODE ###

n = int(input())
ans = 0
for i in range(1, int(n**0.5)+1):
    if n % i == 0:
        m = n//i - 1
        if m != 0 and n // m == n % m:
            ans += n//i - 1
print(ans)
def calc(X,ls):
    _sum = 0
    for i in ls:
        _sum +=  int(bin(X^i), 0)
    return _sum


N, K = map(int, input().split())
A_ls = [int(i) for i in input().split()]
if len(A_ls) == 1:
    print(A_ls[0])
else:
    _max = 0
    for i in range(K):
        result = calc(i, A_ls)
        if _max < result:
            _max = result
    print(_max)

### FIXED CODE ###

T, X = map(int, input().split())
print(T / X)
import numpy as np
from itertools import combinations
N,D=map(int,input().split())
X=[list(map(int,input().split())) for i in range(N)]
count=0
for x,y in combinations(X,2):
    r = np.sqrt(abs(x[0]-y[0])**2 + abs(x[1]-y[1])**2)
    if r.is_integer() == True:
        count += 1
print(count)

### FIXED CODE ###

import numpy as np
from itertools import combinations
N,D=map(int,input().split())
X=[list(map(int,input().split())) for i in range(N)]
count=0
for x,y in combinations(X,2):
    r = np.sqrt(sum(abs(np.array(x)-np.array(y))**2))
    if r.is_integer() == True:
        count += 1
print(count)
import math
from collections import deque
def main():
    
    t = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
    a = int(input())
    
    print(t[a+1])


if __name__ == "__main__":
    main()

### FIXED CODE ###

import math
from collections import deque
def main():
    
    t = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
    a = int(input())
    
    print(t[a-1])


if __name__ == "__main__":
    main()
s = input()
d = {}
for e in s:
  if e in d:
    d[e] += 1
  else:
    d[e] = 1

if len(d) == 2 and set(d.values()) = {2}:
  print("Yes")
else:
  print("No")

### FIXED CODE ###

s = input()
d = {}
for e in s:
  if e in d:
    d[e] += 1
  else:
    d[e] = 1

if len(d) == 2 and set(d.values()) == {2}:
  print("Yes")
else:
  print("No")
x = int(input())

def f(x,b):
    return int((x+b**5)**(1/5))

b=0
plus=1
while True:
    ans = f(x,b)
    print(ans)
    if ans**5-b**5 == x:
        print(ans, b)
        break
    elif plus == 1:
        b=b*(-1)
        plus = 0
    elif plus == 0:
        b=b*(-1)
        b+=1
        plus = 1

### FIXED CODE ###

def solve():
   x = int(input())
   for a in range(-500,500):
      for b in range(-500,500):
         n = a**5 - b**5
         if n == x:
            print(a,end=" ")
            print(b)
            return
solve()
# -*- coding: utf-8 -*-
"""
Created on Wed Jun  3 14:11:35 2020

@author: NEC-PCuser
"""
def gcd(a, b):
    
    if (a % b == 0):
        return b
    return gcd(b, a % b)

def factorize(num):
    i = 2
    factorize_list = []
    num_tmp = num
    while i * i <= num_tmp:
        count = 0
        if num % i == 0:
            while num % i == 0:
                count += 1
                num /= i
            factorize_list.append([i, count])
        i += 1
    return factorize_list 
                


if __name__ == "__main__":
    A, B =  map(int, input().split())
    big_num = max(A, B)
    short_num = min(A, B)
    gcd_num = gcd(big_num, short_num)
    print(len(factorize(gcd_num) + 1))
            

### FIXED CODE ###

# -*- coding: utf-8 -*-
"""
Created on Wed Jun  3 14:11:35 2020

@author: NEC-PCuser
"""
def gcd(a, b):
    
    if (a % b == 0):
        return b
    return gcd(b, a % b)

def factorize(num):
    i = 2
    factorize_list = []
    num_tmp = num
    while i * i <= num_tmp:
        count = 0
        if num % i == 0:
            while num % i == 0:
                count += 1
                num //= i
            factorize_list.append([i, count])
        i += 1
    if num != 1:
        factorize_list.append([num, 1])
    return factorize_list 
                


if __name__ == "__main__":
    A, B =  map(int, input().split())
    big_num = max(A, B)
    short_num = min(A, B)
    gcd_num = gcd(big_num, short_num)
    print(len(factorize(gcd_num)) + 1)
n,k = map(int,input().split())
mod = 10**9+7
gr = [set() for _ in range(n+1)]
for _ in range(n-1):
    a,b = map(int,input().split())
    gr[a].add(b)
    gr[b].add(a)
par = [0]*(n+1)
ans = [0]*(n+1)
done = [0]*(n+1)
done[1] = -1
done[0] = -2
def dfs2(gr,p,v,done,ans):
    ans[v] = k-2-done[p]
    for x in gr[v]:
        if x == p:
            continue
        dfs2(gr,v,x,done,ans)
        done[v] += 1
    return
dfs2(gr,0,1,done,ans)
m = 1
for x in ans[1:]:
    m = m*x%mod
print(m)

### FIXED CODE ###

import sys
sys.setrecursionlimit(200000)
n,k = map(int,input().split())
mod = 10**9+7
gr = [set() for _ in range(n+1)]
for i in range(n-1):
    a,b = map(int,input().split())
    gr[a].add(b)
    gr[b].add(a)
ans = [0]*(n+1)
done = [0]*(n+1)
done[1] = -1
done[0] = -2
def dfs2(gr,p,v,done,ans):
    ans[v] = k-2-done[p]
    for x in gr[v]:
        if x == p:
            continue
        dfs2(gr,v,x,done,ans)
        done[v] += 1
    return
dfs2(gr,0,1,done,ans)
m = 1
for x in ans[1:]:
    m = m*x%mod
print(m)
N, M = map(int, input().split())

for i in range(M):
  L, R = map(int, input().split())
  pass_card = [i for i in range(L, R+1)]
  if  i == 0:
    ans = pass_card
  elif i > 0:
    ans = list(set(pass_card[i - 1]) & set(pass_card[i]))

print(len(ans))

### FIXED CODE ###

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

L_list = []
R_list = []
for i in range(M):
  L, R = map(int, input().split())
  L_list.append(L)
  R_list.append(R)

L = max(L_list)
R = min(R_list)

if R < L:
  print(0)
else:
  print(R - L + 1)
import math
n,d,a=map(int,input().split())
XH=[]
for _ in range(n):
    x,h=map(int,input().split())
    h=math.ceil(h/a)
    XH.append([x,h])
XH.sort()
l=0
r=0
left=XH[0][0]
right=left+2*d
ans=XH[0][1]
c=XH[0][1]
L=[c]
while l<=n-1:
    left=XH[l][0]
    right=left+2*d
    if XH[r+1][0]<=right:
        cc=max(0,XH[r+1][1]-c)
        L.append(cc)
        c+=cc
        ans+=cc
        r+=1
        if r>=n-1:
            r-=1
            l+=1
    else:
        c-=L[l]
        l+=1
print(ans)

### FIXED CODE ###

import math
n,d,a=map(int,input().split())
XH=[]
for _ in range(n):
    x,h=map(int,input().split())
    h=math.ceil(h/a)
    XH.append([x,h])
XH.sort()
if n==1:
    print(XH[0][1])
    exit()
l=0
r=0
ans=XH[0][1]
c=XH[0][1]
L=[c]
while l<=n-1:
    left=XH[l][0]
    right=left+2*d
    if XH[r+1][0]<=right:
        cc=max(0,XH[r+1][1]-c)
        L.append(cc)
        c+=cc
        ans+=cc
        r+=1
        if r>=n-1:
            r-=1
            l+=1
    else:
        c-=L[l]
        l+=1
print(ans)
abcd=int(input().split())
a=abcd[0]
b=abcd[1]
c=abcd[2]
d=abcd[3]
if a+b==c+d:
  print('Balanced')
  else:
    if a+b>c+d:
      print('Left')
      else:
        print('Right')
        

### FIXED CODE ###

abcd=input().split()
a=int(abcd[0])
b=int(abcd[1])
c=int(abcd[2])
d=int(abcd[3])
if a+b==c+d:
  print('Balanced')
else:
    if a+b>c+d:
      print('Left')
    else:
        print('Right')
n, m = map(int, input().split())
l = [list(map(int, input().split())) for i in range(m)]
r = [[] for i in range(n + 1)]
ans = 0
for i in range(m):
    r[l[i][0]].append(l[i][1])
    r[l[i][1]].append(l[i][0])
p = []
for i in range(n):
    p.append(i + 1)
p = list(itertools.permutations(p))
for i in range(len(p)):
    check = True
    t = list(p[i])
    if t[0] != 1:
        check = False
    for j in range(len(t)-1):
        if not t[j + 1] in r[t[j]]:
            check = False
    if check:
        ans += 1
print(ans)

### FIXED CODE ###

import itertools
n, m = map(int, input().split())
l = [list(map(int, input().split())) for i in range(m)]
r = [[] for i in range(n + 1)]
ans = 0
for i in range(m):
    r[l[i][0]].append(l[i][1])
    r[l[i][1]].append(l[i][0])
p = []
for i in range(n):
    p.append(i + 1)
p = list(itertools.permutations(p))
for i in range(len(p)):
    check = True
    t = list(p[i])
    if t[0] != 1:
        check = False
    for j in range(len(t)-1):
        if not t[j + 1] in r[t[j]]:
            check = False
    if check:
        ans += 1
print(ans)
c = list()
for i in range(6):
  c.append(int(input()))
if coo[4] - coo[0] > coo[5]:
  print(":(")
else:
  print("Yay!")

### FIXED CODE ###

c = list()
for i in range(6):
  c.append(int(input()))
if c[4] - c[0] > c[5]:
  print(":(")
else:
  print("Yay!")
N = int(input())
g = [ [] for i in range(N)]
for _ in range(N-1):
  a, b = map(int, input().split())
  g[b-1].append(a-1)
  g[a-1].append(b-1)
visit = [0]*N
e = []
a = [0]*N
b = [0]*N
def tansakuf(i):
  visit[i] = 1
  for j in g[i]:
    if visit[j] == 0:
      a[j] = a[i] + 1
      e.append(j)
  if len(e) != 0:
    f = e[0]
    e.pop(0)
    return tansakuf(f)
tansakuf(0)
def tansakus(i):
  visit[i] = 0
  for j in g[i]:
    if visit[j] == 1:
      b[j] = b[i] + 1
      e.append(j)
  if len(e) != 0:
    f = e[0]
    e.pop(0)
    return tansakus(f)
tansakus(N-1)
cnt = 0
for i in range(N):
  if a[i] <= b[i]:
    cnt += 1
  else:
    cnt -= 1
if cnt > 0:
  print('Fennec')
else:
  print('Snuke')
    

### FIXED CODE ###

from collections import deque
N = int(input())
g = [[] for i in range(N)]
for _ in range(N-1):
  a, b = map(int, input().split())
  g[b-1].append(a-1)
  g[a-1].append(b-1)
a = [-1]*N
b = [-1]*N
def bfs(n):
  q=deque()
  q.append(n)
  a[n] = 0
  while len(q):
    x=q.popleft()
    for i in g[x]:
      if a[i]==-1: 
        a[i]=a[x]+1
        q.append(i)
bfs(0)
def bfs2(n):
  q=deque()
  q.append(n)
  b[n] = 0
  while len(q):
    x=q.popleft()
    for i in g[x]:
      if b[i]==-1: 
        b[i]=b[x]+1
        q.append(i)
bfs2(N-1)
cnt = 0
for i in range(N):
  if a[i] <= b[i]:
    cnt += 1
  else:
    cnt -= 1
if cnt > 0:
  print('Fennec')
else:
  print('Snuke')
def noboru(i, a2, a1):
    if (i == 0 or i == 1):
        return a1
    elif (i == 2):
        return a2
    else:
        return noboru(i-1, a2+a1, a2)


def func(N, M, a):
    ans = 1
    pos = 0
    for i in range(M):
        if (pos == a[i]):
            return 0
        else:
            ans = (ans * noboru(a[i] - pos - 1, 2, 1)) % 1000000007
            pos = a[i] + 1
    ans = (ans * noboru(N - pos, 2, 1)) % 1000000007
    return ans

N, M = map(int, input().split(" "))
a = [int(input()) for _ in range(M)]
print(func(N, M, a))

### FIXED CODE ###

CONST = 1000000007

def noboru(n):
    a1 = 1
    a2 = 2
    ans = 0
    if (n == 0 or n == 1): return a1
    elif (n == 2): return a2
    else:
        for i in range(1, n-1):
            ans = a2 + a1
            a1 = a2
            a2 = ans
        return a2

def func(N, M, a):
    ans = 1
    pos = 0
    for i in range(M):
        if (pos == a[i]):
            return 0
        else:
            ans = (ans * noboru(a[i] - pos - 1)) % CONST
            pos = a[i] + 1
    ans = (ans * noboru(N - pos)) % CONST
    return ans

N, M = map(int, input().split(" "))
a = [int(input()) for _ in range(M)]
print(func(N, M, a))
n, W = map(int, input().split())
MAX_V = 100000
dp = [0] + [10**18]*MAX_V
tmp_dp = [0]*(MAX_V+1)
for _ in range(n):
    w, v = map(int, input().split())
    for sum_v in range(MAX_V+1):
        if sum_v >= v:
            tmp_dp[sum_v] = min(dp[sum_v], dp[sum_v - v] + w)
        else:
            tmp_dp[sum_v] = min(dp[sum_v], w)
    dp = tmp_dp
    tmp_dp = [0]*(MAX_V+1)

ans = 0
while dp[ans+1] <= W:
    ans +=1
print(ans)

### FIXED CODE ###

N, W = map(int, input().split())
MAX_V = 10**5+1
dp = [float('inf')] * MAX_V
dp[0] = 0
for _ in range(N):
    w, v = map(int, input().split())
    for sum_v in range(MAX_V)[::-1]:
        if sum_v >= v:
            dp[sum_v] = min(dp[sum_v - v] + w, dp[sum_v])
        else:
            dp[sum_v] = min(dp[sum_v], w)
ans = 0
for v in range(MAX_V)[:: -1]:
    if dp[v] <= W:
        ans = v
        break
print(ans)
import sys
input = sys.stdin.readline

N=int(input())
S=input().strip()+"E"

mod=998244353


FACT=[1]
for i in range(1,2*10**5+1):
    FACT.append(FACT[-1]*i%mod)

FACT_INV=[pow(FACT[-1],mod-2,mod)]
for i in range(2*10**5,0,-1):
    FACT_INV.append(FACT_INV[-1]*i%mod)

FACT_INV.reverse()

def Combi(a,b):
    if 0<=b<=a:
        return FACT[a]*FACT_INV[b]*FACT_INV[a-b]%mod
    else:
        return 0


S2=[]
NOW=1
C=S[0]
for i in range(1,3*N+1):
    if S[i]==C:
        NOW+=1
    else:
        S2.append((C,NOW))
        NOW=1
        C=S[i]

from collections import deque
Q=deque(S2)


ANS=1
INV=1
while Q:
    x0,x1=Q.popleft()
    y0,y1=Q.popleft()
    z0,z1=Q.popleft()

    ANS=(ANS*x1*y1*z1)%mod
    INV=INV*pow(x1,mod-2,mod)

    if Q and Q[0][0]==z0:
        w0,w1=Q.popleft()

        Q.appendleft(w0,w1+z1-1)

    elif z1!=1:
        Q.appendleft((z0,z1-1))
        
    if y1!=1:
        Q.appendleft((y0,y1-1))
    if x1!=1:
        Q.appendleft((x0,x1-1))

print(ANS*INV*FACT[N]%mod)
    



### FIXED CODE ###

import sys
input = sys.stdin.readline

N=int(input())
S=input().strip()

mod=998244353

NOW=dict()
NOW["R"]=0
NOW["G"]=0
NOW["B"]=0

ANS=1
for i in range(1,N+1):
    ANS=ANS*i%mod

for s in S:
    k,l,m=sorted((NOW["R"],NOW["G"],NOW["B"]))
    
    if NOW[s]==m:
        NOW[s]+=1

    elif NOW[s]==l:
        NOW[s]+=1
        ANS=ANS*(m-l)%mod

    else:
        NOW[s]+=1
        ANS=ANS*l%mod
    
    if NOW["R"]>=1 and NOW["G"]>=1 and NOW["B"]>=1:
        NOW["R"]-=1
        NOW["G"]-=1
        NOW["B"]-=1

print(ANS)
N, M = map(int, input().split())
pLst = [list(map(int, input().split())) for i in range(M)]

for i in range(len(pLst)):
    pLst[i].append(i)
nLst = [''] * N

for i in range(N):
    nLst[i] = str(i + 1).zfill(6)
tLst = sorted(pLst, key=lambda x: (x[0], x[1]))
ansLst = [''] * M
tmp = nLst[tLst[i][0] - 1]
index = 1

### FIXED CODE ###

N, M = map(int, input().split())
pLst = [list(map(int, input().split())) for i in range(M)]

for i in range(len(pLst)):
    pLst[i].append(i)
nLst = [''] * N

for i in range(N):
    nLst[i] = str(i + 1).zfill(6)
tLst = sorted(pLst, key=lambda x: (x[0], x[1]))
ansLst = [''] * M
tmp = nLst[tLst[0][0] - 1]
index = 1
for i in range(M):
    if tmp == nLst[tLst[i][0] - 1]:
        ansLst[tLst[i][2]] = nLst[tLst[i][0] - 1] + str(index).zfill(6)
        index += 1
    else:
        index = 1
        tmp = nLst[tLst[i][0] - 1]
        ansLst[tLst[i][2]] = nLst[tLst[i][0] - 1] + str(index).zfill(6)
        index += 1

for i in ansLst:
    print(i)
a, b = map(int, input().split())
lists = []
for i in range(a):
  lists.add(input())

print(lists.sort.join(''))


### FIXED CODE ###

n, l = map(int, input().split())
s = [input().rstrip() for i in range(n)]
print(''.join(sorted(s)))