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

fact_list=[None]*300001
inv_fact_list=[None]*300001
fact_list[0]=1
inv_fact_list[0]=1
def inv(n):
    if inv_fact_list[n]!=None:
        return inv_fact_list[n]
    m=fact_list[n]
    s=1
    for i in range(30):
        if i!=23 and i!=26:
            s=(s*m)%998244353
        m=(m**2)%998244353
    inv_fact_list[n]=s
    return s

def comb(n,r):
    if r==0 or r==n:
        return 1
    if r==1 or r==n-1:
        return n
    return (((fact_list[n]*inv(n-r))%998244353)*inv(r))%998244353

for i in range(1,300001):
    fact_list[i]=(fact_list[i-1]*i)%998244353

s=input().split()
n,a,b,k=int(s[0]),int(s[1]),int(s[2]),int(s[3])
res=0
for i in range(n+1):
    if k-a*i<0:
        break
    if (k-a*i)%b==0 and 0<=(k-a*i)//b<=n:
        res=(res+comb(n,i)*comb(n,(k-a*i)//b))%998244353
print(res)


### FIXED CODE ###

fact_list=[None]*300001
inv_fact_list=[None]*300001
fact_list[0]=1
inv_fact_list[0]=1
"""
def inv(n):
    if inv_fact_list[n]!=None:
        return inv_fact_list[n]
    m=fact_list[n]
    s=1
    for i in range(30):
        if i!=23 and i!=26:
            s=(s*m)%998244353
        m=(m**2)%998244353
    inv_fact_list[n]=s
    return s
def enc(n):
    if n==0:
        return "("
    s=""
    while n>0:
        s+=chr(n%86+40)
        n//=86
    return s
 
def dec(s):
    n=0
    for i in range(len(s)):
        n+=(86**i)*(ord(s[i])-40)
    return n
"""
def comb(n,r):
    if r==0 or r==n:
        return 1
    if r==1 or r==n-1:
        return n
    if inv_fact_list[n-r]!=None:
        invnr=inv_fact_list[n-r]
    else:
        m=fact_list[n-r]
        invnr=1
        for i in range(30):
            if i!=23 and i!=26:
                invnr=(invnr*m)%998244353
            m=(m**2)%998244353
        inv_fact_list[n-r]=invnr
    if inv_fact_list[r]!=None:
        invr=inv_fact_list[r]
    else:
        m=fact_list[r]
        invr=1
        for i in range(30):
            if i!=23 and i!=26:
                invr=(invr*m)%998244353
            m=(m**2)%998244353
        inv_fact_list[r]=invr
    return (((fact_list[n]*invnr)%998244353)*invr)%998244353
 
for i in range(1,300001):
    fact_list[i]=(fact_list[i-1]*i)%998244353
 
s=input().split()
n,a,b,k=int(s[0]),int(s[1]),int(s[2]),int(s[3])
res=0
for i in range(n+1):
    if k-a*i<0:
        break
    if (k-a*i)%b==0 and 0<=(k-a*i)//b<=n:
        res=(res+comb(n,i)*comb(n,(k-a*i)//b))%998244353
print(res)
### BUGGY CODE ###

N, M = [int(elm) for elm in input().split(" ")] 

As = [int(elm) for elm in input().split(" ")] 

dic = {}
keys= []
for A in As:
    if A not in keys:
        dic[A] = 1
        keys.append(A)
    else:
        dic[A] += 1

Bs = []
Cs = []
for i in range(M):
    B, C = [int(elm) for elm in input().split(" ")] 

    if C not in keys:
        dic[C] = B
        keys.append(C)
    else:
        dic[C] += B

    #Bs.append(B)
    #Cs.append(C)

keys = sorted(keys, reverse=True)

count = 0
out = 0

for key in keys:
    b = dic[key]
    if b < N - count:
        out += (key * b) 
        count += b
    else:
        out += (key * (N-count))
        break

print(out)

### FIXED CODE ###

N, M = [int(elm) for elm in input().split(" ")] 

As = sorted([int(elm) for elm in input().split(" ")], reverse=True)


BCs = []
for i in range(M):
    B, C = [int(elm) for elm in input().split(" ")] 
    BCs.append([B, C])

BCs = sorted(BCs, key=lambda x: -x[1])

out = 0
bc_i = 0
count = 0
B, C = BCs[bc_i]

for A in As:
    if C >= A and bc_i < M:
        while C >= A: 
            #print("plus", B, C, "A", A)
            out += (B*C)

            count += B
            bc_i += 1
            if bc_i == M or count > N:
                break
            B, C = BCs[bc_i]
            
    if count > N:
        out -= C * (count-N)
        break
    elif count == N:
        break

    out += A
    #print("plus", A)
    count += 1

print(out)
### BUGGY CODE ###

def main():
    from itertools import product
    h, w, K = map(int, input().split())
    grid = [list(input()) for _ in [0]*h]
    m = 10**9
    for i in range(2**h):
        i = (("0"*h)+bin(i)[2:])[-h:]+"2"
        memo = [0]
        for j in range(h):
            if i[j] == i[j+1]:
                pass
            else:
                memo.append(j+1)
        ans = len(memo)-1
        ans2 = [0]
        memo2 = [0]*ans
        j = 0
        flag = False
        while j < w:
            if flag:
                break
            for k in range(ans):
                memo2[k] += [grid[l][j]
                             for l in range(memo[k], memo[k+1])].count("1")
                if memo2[k] > K:
                    ans2.append(j)
                    memo2 = [0]*ans
                    if ans2[-1] == ans2[-2]:
                        flag = True
                    break
            else:
                j += 1
        if flag == False:
            m = min(m, ans+(len(ans2)-2))
    print(m)


main()


### FIXED CODE ###

def main():
    from itertools import product
    h, w, K = map(int, input().split())
    grid = [list(input()) for _ in [0]*h]
    m = 10**9
    for i in range(2**h):
        i = (("0"*h)+bin(i)[2:])[-h:]+"2"
        memo = [0]
        for j in range(h):
            if i[j] == i[j+1]:
                pass
            else:
                memo.append(j+1)
        ans = len(memo)-1
        ans2 = [0]
        memo2 = [0]*ans
        j = 0
        flag = False
        while j < w:
            if flag:
                break
            for k in range(ans):
                memo2[k] += [grid[l][j]
                             for l in range(memo[k], memo[k+1])].count("1")
                if memo2[k] > K:
                    ans2.append(j)
                    memo2 = [0]*ans
                    if ans2[-1] == ans2[-2]:
                        flag = True
                    break
            else:
                j += 1
        if flag == False:
            m = min(m, ans+(len(ans2)-2))
    print(m)


main()
### BUGGY CODE ###

N, K = map(int, input().split())
XY = [tuple(map(int, input().split())) for _ in range(N)]

ans = 10 ** 20

for x1 in range(N):
    for x2 in range(x1, N):
        for y1 in range(N):
            for y2 in range(y1, N):
                u = max(XY[x1][0], XY[x2][0])
                d = min(XY[x1][0], XY[x2][0])
                r = max(XY[y1][1], XY[y2][1])
                l = min(XY[y1][1], XY[y2][1])
                c = sum([d <= x <= u and l <= y <= r for x, y in XY])
                ans = min(ans, (u - d) * (r - l)) if c >= K else ans

print(ans)


### FIXED CODE ###

N, K = map(int, input().split())
XY = sorted([tuple(map(int, input().split())) for _ in range(N)])

ans = 10 ** 20
for xl in range(N):
    for xr in range(xl + 1, N):
        Ysub = sorted([y for x, y in XY[xl:xr + 1]])
        for i in range(xr - xl - K + 2):
            Yk = Ysub[i:i + K] + [XY[xr][1], XY[xl][1]]
            ans = min(ans, (XY[xr][0] - XY[xl][0]) * (max(Yk) - min(Yk)))

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

from queue import PriorityQueue
from collections import defaultdict

n, m, s = map(int, input().split())
graph = defaultdict(dict)
for i in range(m):
    u, v, a, b = map(int, input().split())
    graph[u][v] = (a, b)
    graph[v][u] = (a, b)

town = [None]*(n+1)
for i in range(n):
    c, d = map(int, input().split())
    town[i+1] = (c, d)

if s >= 2501:
    s = 2501
x = (1, s)
cost = 0
visit = set()
pq = PriorityQueue()
pq.put((cost, x), block=False)
ans = [1000000000000000]*(n+1)
while not pq.empty():
    cost, x = pq.get_nowait()
    if x in visit:
        continue
    visit.add(x)
    p, m = x
    ans[p] = min(ans[p], cost)
    c, d = town[p]
    if m <= 2501:
        pq.put((cost+d, (p, m+c)), block=False)
    for q, edge in graph[p].items():
        a, b = edge
        if m-a >= 0:
            pq.put((cost+b, (q, m-a)), block=False)
for i in range(2, n+1):
    print(ans[i])

### FIXED CODE ###

from queue import PriorityQueue
from collections import defaultdict
from heapq import heappush, heappop

n, m, s = map(int, input().split())
graph = defaultdict(dict)
for i in range(m):
    u, v, a, b = map(int, input().split())
    graph[u][v] = (a, b)
    graph[v][u] = (a, b)

town = [None]*(n+1)
for i in range(n):
    c, d = map(int, input().split())
    town[i+1] = (c, d)

if s >= 2501:
    s = 2501
x = (1, s)
cost = 0
visit = set()
heap = []
heappush(heap, (cost, x))
ans = [None]*(n+1)
check = 0
while len(heap) > 0:
    cost, x = heappop(heap)
    if x in visit:
        continue
    visit.add(x)
    p, m = x
    if ans[p] is None:
        ans[p] = cost
        check += 1
        if check >= n:
            break
    c, d = town[p]
    if m <= 2501:
        heappush(heap, (cost+d, (p, m+c)))
    for q, edge in graph[p].items():
        a, b = edge
        if m-a >= 0:
            heappush(heap, (cost+b, (q, m-a)))
for i in range(2, n+1):
    print(ans[i])
### BUGGY CODE ###

N, K = map(int, input().split())
H = list(map(int, input().split()))

DP = [10**9]*N
DP[0] = 0
DP[1] = abs(H[1]-H[0])

for k in range(2,N+1):
    for l in range(1,K+1):
        if k-l < 0 or k > N-1:
            break
        DP[k] = min(DP[k], DP[k-l]+abs(H[k]-H[k-l]))

print(DP[-1])

### FIXED CODE ###

n,k=map(int,input().split())
h=list(map(int,input().split()))
dp=[0]*n

for i in range(1,n):
    dp[i]=min(dp[j] + abs(h[j]-h[i]) for j in range(max(0,i-k),i))

print(dp[-1])
### BUGGY CODE ###

N,K = map(int, input().split())
dp = [0]*(K+1)
MOD = 10**9+7
ans = 0
for X in range(K,0,-1):
  m = (K//X)**N%MOD
  x = 2*X
  while x<=K:
    m -= dp[x]
    m %= MOD
    x += X
  ans += X*m
  ans %= MOD
  dp[X] = m
print(ans)
  

### FIXED CODE ###

import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
MOD = 10**9 + 7

N, K = map(int, read().split())

A = [0] * (K + 1)
for d in range(1, K + 1):
    A[d] = pow(K // d, N, MOD)

for d in range(K, 0, -1):
    for i in range(2, K // d + 1):
        A[d] -= A[d * i]

answer = sum(d * x for d, x in enumerate(A))
print(answer % MOD)
### BUGGY CODE ###

S=input()
N=int(len(S))
for j in range(int(N/2)):
    S=S.replace("10","")
    S=S.replace("01","")
print(N-int(len(S)))

### FIXED CODE ###

S=input()
print(min(S.count("0"),S.count("1"))*2)
### BUGGY CODE ###

printn = lambda x: print(x,end='')
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
DBG = True # and False
BIG = 10**18
R = 10**9 + 7

def ddprint(x):
  if DBG:
    print(x)

def foo(i):
    print(i,flush=True)
    s = ins()
    a[i] = h[s]
    if h[s]==1:
        exit()

h = {'Vacant':1, 'Male':2, 'Female':3}
n = inn()
a = [0]*(n+1)
foo(0)
a[n] = a[0]
p = 0
q = n
while True:
    r = (p+q)//2
    foo(r)
    if a[r]==a[p] and (r-p)%2==1 or a[r]!=a[p] and (r-p)%2==0:
        q = r
    else:
        p = r
        #ddprint(a)
    #ddprint(f"p {p} q {q}")


### FIXED CODE ###

printn = lambda x: print(x,end='')
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
DBG = True # and False
BIG = 10**18
R = 10**9 + 7

def ddprint(x):
  if DBG:
    print(x)

def foo(i):
    print(i,flush=True)
    s = ins()
    a[i] = h[s]
    if h[s]==1:
        exit()

h = {'Vacant':1, 'Male':2, 'Female':3}
n = inn()
a = [0]*(n+1)
foo(0)
a[n] = a[0]
p = 0
q = n
cnt = 1
while q>p+1:
    r = (p+q)//2
    foo(r)
    cnt += 1
    if cnt >= 20:
        exit()
    if a[r]==a[p] and (r-p)%2==1 or a[r]!=a[p] and (r-p)%2==0:
        q = r
    else:
        p = r
        #ddprint(a)
    #ddprint(f"p {p} q {q}")
print("err")
### BUGGY CODE ###

import copy

n=int(input())
a=list(map(int,input().split()))

c=0
a_uniq=list(set(a))

for i in a_uniq:
  c+=a.count(i)*(a.count(i)-1)/2

for i in range(0,n):
  print('{:.0f}'.format(c-a.count(a[i])+1))


### FIXED CODE ###

import copy

n=int(input())
a=list(map(int,input().split()))

c=0

a_uniq=[0]*(n+1)

for i in a:
  a_uniq[i]+=1

for i in a_uniq:
  c+=sum(range(1,i))
#a_uniq=list(set(a))
#for i in a_uniq:
#  c+=sum(range(1, a.count(i)))

for i in a:
  print('{:.0f}'.format(c-a_uniq[i]+1))
### BUGGY CODE ###

import numpy as np
import heapq
import sys
sys.setrecursionlimit(10**6)

H,W = map(int,input().split())
INF = 10**18
q = []

d = np.full((H,W),INF,dtype=np.int64) # '#'からの距離

for i in range(H):
  txt = input()
  for j,c in enumerate(txt):
    if c == '#':
      d[i,j] = 0
      heapq.heappush(q,(0,i,j))

while q:
  dv,x,y = heapq.heappop(q)
  for dx,dy in [(0,1),(0,-1),(1,0),(-1,0)]:
    xx = x+dx
    yy = y+dy
    if xx == -1 or xx == H:
      continue
    if yy == -1 or yy == W:
      continue
    if d[xx,yy] >= dv+1:
      d[xx,yy] = dv+1
      heapq.heappush(q,(dv+1,xx,yy))

ans = d.max()
print(ans)

### FIXED CODE ###

import sys
sys.setrecursionlimit(10**6)
input = sys.stdin.readline

H,W = map(int,input().split())
INF = 10**18
q = []

visited = [[True]*(W+2)]
visited += [[True] + [x == '#' for x in input().rstrip()] + [True] for _ in range(H)]
visited.append([True]*(W+2))
  
for i in range(1,H+1):
  for j in range(1,W+1):
    if visited[i][j]:
      q.append((i,j))

moves = [(0,1),(0,-1),(1,0),(-1,0)]

ans = -1
while q:
  qq = []
  ans += 1
  for x,y in q:
    if not visited[x-1][y]:
      visited[x-1][y] = True
      qq.append((x-1,y))
    if not visited[x+1][y]:
      visited[x+1][y] = True
      qq.append((x+1,y))
    if not visited[x][y-1]:
      visited[x][y-1] = True
      qq.append((x,y-1))
    if not visited[x][y+1]:
      visited[x][y+1] = True
      qq.append((x,y+1))
  q = qq
  
print(ans)
### BUGGY CODE ###

from collections import deque

H, W = map(int, input().split())
sy, sx = map(lambda x: int(x)-1, input().split())
gy, gx = map(lambda x: int(x)-1, input().split())
maze = [input() for _ in range(H)]

INF = float("INF")
cnt = [[INF]*W for _ in range(H)]

q = deque()
q.append([sy, sx])
cnt[sy][sx] = 0
move = [[1, 0], [-1, 0], [0, 1], [0, -1]]

while q:
    y, x = q.popleft()
    for dy, dx in move:
        ny = y + dy
        nx = x + dx
        if ny < 0 or ny > H-1 or nx < 0 or nx > W-1:
            continue
        if maze[ny][nx] == "." and cnt[ny][nx] > cnt[y][x]:
            cnt[ny][nx] = cnt[y][x]
            q.appendleft([ny, nx])
        for i in range(-2, 2+1):
            for j in range(-2, 2+1):
                wy = y + i
                wx = x + j
                if wy < 0 or wy > H-1 or wx < 0 or wx > W-1:
                    continue
                if maze[wy][wx] == "." and cnt[wy][wx] > cnt[y][x]:
                    cnt[wy][wx] = cnt[y][x] + 1
                    q.append([wy, wx])

ans = -1 if cnt[gy][gx] == INF else cnt[gy][gx]
print(ans)

### FIXED CODE ###

from collections import deque

H, W = map(int, input().split())
sy, sx = map(lambda x: int(x)-1, input().split())
gy, gx = map(lambda x: int(x)-1, input().split())
maze = [input() for _ in range(H)]

INF = float("INF")
cnt = [[INF]*W for _ in range(H)]

q = deque()
q.append([sy, sx])
cnt[sy][sx] = 0
move = [[1, 0], [-1, 0], [0, 1], [0, -1]]

while q:
    y, x = q.popleft()
    for dy, dx in move:
        ny = y + dy
        nx = x + dx
        if ny < 0 or ny > H-1 or nx < 0 or nx > W-1:
            continue
        if maze[ny][nx] == "." and cnt[ny][nx] > cnt[y][x]:
            cnt[ny][nx] = cnt[y][x]
            q.appendleft([ny, nx])
        for i in range(-2, 2+1):
            for j in range(-2, 2+1):
                wy = y + i
                wx = x + j
                if wy < 0 or wy > H-1 or wx < 0 or wx > W-1:
                    continue
                if maze[wy][wx] == "." and cnt[wy][wx] > cnt[y][x] + 1:
                    cnt[wy][wx] = cnt[y][x] + 1
                    q.append([wy, wx])

ans = cnt[gy][gx] if cnt[gy][gx] != INF else -1
print(ans)
### BUGGY CODE ###

n=int(input())
l=list(map(int,input().split()))
l.sort()
ans=0
for i in range(n):
  for j in range(i+1,n):
    kmax=n
    kmin=j
    while True:
      k=(kmax+kmin)//2
      if l[i]+l[j]>l[k]:
        ans=ans+k-kmin
        kmin=k
      else:
        kmax=k
      if kmax-kmin==1:
        break
print(ans)

### FIXED CODE ###

n=int(input())
l=list(map(int,input().split()))
l.sort()
ans=0
for i in range(n):
  for j in range(i+1,n):
    kmax=n
    kmin=j
    while True:
      k=(kmax+kmin)//2
      if l[i]+l[j]>l[k]:
        ans=ans+k-kmin
        kmin=k
      else:
        kmax=k
      if kmax-kmin==1:
        break
print(ans)
### BUGGY CODE ###

n=int(input())
x=input()
chk=0
for i,j in enumerate(x[::-1]):
    if j=="1":
        chk+=2**i
c={}
d={}
ans=[]
for i,j in enumerate(x[::-1]):
    if j=="1":
        t=chk-2**i
    else:
        t=chk+2**i
    s=t
    cnt=0
    while t:
        if t not in c:
            pc=bin(t)[2:].count("1")
            c[t]=pc
        else:
            pc=c[t]
        t%=pc
        cnt+=1
        if t in d:
            cnt+=d[t]
            break
    if s not in d:
        d[s]=cnt
    ans.append(cnt)
for i in ans[::-1]:
    print(i)

### FIXED CODE ###

n=int(input())
x=input()
chk0=chk1=chk2=0
b=x.count("1")
if b==1 and x=="1":
    print(0)
    exit()
elif b==1:
    for i in range(n):
        if i==n-1: print(2)
        elif x[i]=="0": print(1)
        else: print(0)
    exit()
for i,j in enumerate(x[::-1]):
    if j=="1":
        chk1+=pow(2,i,b+1)
        if b>1: chk2+=pow(2,i,b-1)
        else: chk2=0
l=[]
for i,j in enumerate(x[::-1]):
    if b: a1=pow(2,i,b+1)
    else: a1=1
    if b>1: a2=pow(2,i,b-1)
    else: a2=1
    if j=="0":
        t=chk1+a1
    else:
        if b>1: t=chk2+b-1-a2
        else: t=0
    ans,f=0,1
    while t:
        if f:
            if j=="0": t%=(b+1)
            else: t%=(b-1)
            f=0
        else:
            t%=bin(t).count("1")
        ans+=1
    l.append(ans)
for i in l[::-1]:
    print(i)
### BUGGY CODE ###

import sys
from collections import deque
stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

n, m = na()
dic = {}
li = []
for i in range(m):
    p, y = na()
    li.append([p,y])
    if p not in dic.keys():
        dic[p] = [y]
    else:
        dic[p].append(y)
for v in dic.values():
    v.sort()
for p, y in li:
    i = dic[p].index(y)
    shi = str(p)
    num = str(i + 1)
    print(shi.zfill(6) + num.zfill(6))


### FIXED CODE ###

import sys
from collections import deque
stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

n, m = na()
buf = [None] * m
cnt = {k: [] for k in range(n + 1)}
for i in range(m):
    p, y = na()
    cnt[p].append((y, i))
for p, l in cnt.items():
    if not l:
        continue
    l.sort()
    for j, (y, i) in enumerate(l):
        buf[i] = '{:06d}{:06d}'.format(p, j + 1)

print('\n'.join(buf))
### BUGGY CODE ###

import sys
input = sys.stdin.readline

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

dp = [float('inf')] * n

dp[0] = 0

for i in range(1, n):
    for j in range(1, k + 1):
        if i - j < 0:
            continue
        dp[i] = min(dp[i], dp[i - j] + abs(h[i] - h[i - j]))

print(dp[n - 1])


### FIXED CODE ###

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

dp = [float('inf')] * n

dp[0] = 0

for i in range(1, n):
    for j in range(1, k+1):
        if i - j < 0:
            continue
        dp[i] = min(dp[i], dp[i-j] + abs(h[i] - h[i-j]))

print(dp[n-1])
### BUGGY CODE ###


#a = int(input())
#b, c = map(int, input().split())
#l = list(map(int, input().split()))


n = int(input())
s=['']*n
st=[]
for i in range(0,n):
  s[i]=input()
  if not s[i] in st:
    st.append(s[i])

maxc=0
anss=[]
for i in range(0,len(st)):
  cc=s.count(st[i])
  if cc>maxc:
    maxc=cc
    anss=[st[i]]
  elif cc==maxc:
    anss.append(st[i])

anss.sort()
print("\n".join(anss))


### FIXED CODE ###

# -*- coding: utf-8 -*-
# 整数の入力
#a = int(input())
# スペース区切りの整数の入力
#b, c = map(int, input().split())
# 文字列の入力
#s = input()
# 出力
#print("{} {}".format(a+b+c, s))

from collections import Counter

n = int(input())
s=[input() for i in range(n)]
l=Counter(s)
m=0
for i in l.values():
  m=max(m,i)
ans=[]
for k,v in l.items():
  if v==m:
    ans.append(k)
ans.sort()
print(*ans,sep='\n')
### BUGGY CODE ###

n,k=map(int,input().split())
a=list(map(int,input().split()))
b=[]
p=1
for i in range(n):
    p=p*a[i]

    if i>=k-1:
        b.append(p)
        p=p//a[i-k+1]

for i in range(1,len(b)):
    if b[i]>b[i-1]:
        print('Yes')
    else:
        print('No')


### FIXED CODE ###

import sys
input=sys.stdin.readline


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

for i in range(k,n):

    if a[i]>a[i-k]:

        print('Yes')
    else:
        print('No')
### BUGGY CODE ###

S = input()
Q = int(input())
T = [input() for i in range(Q)]

count = True

for i in range(Q):
  t = T[i]
  if(int(t[0]) == 1):
    count = not count
  else:
    if(int(t[2]) == 1):
      if(count):
        S = t[4] + S
      else:
        S = S + t[4]
    else:
      if(count):
        S = S + t[4]
      else:
        S = t[4] + S

if(count):
  print(S)
else:
  print(S[::-1])


### FIXED CODE ###

from collections import deque
S = input()
Q = int(input())
T = [input() for i in range(Q)]

d =deque(S)

count = True

for i in range(Q):
  t = T[i]
  if(int(t[0]) == 1):
    count = not count
  else:
    if(int(t[2]) == 1):
      if(count):
        d.appendleft(t[4])
      else:
        d.append(t[4])
    else:
      if(count):
        d.append(t[4])
      else:
        d.appendleft(t[4])

ans = list(d)

if(count):
  print("".join(ans))
else:
  print("".join(ans[::-1]))
### BUGGY CODE ###

def read_line(*types): return [f(a) for a, f in zip(input().split(), types)]

n, q = read_line(int, int)
s, = read_line(str)

p = []
for i in range(len(s) - 1):
    if s[i:i+2] == 'AC':
        p.append(i)

for i in range(q):
    l, r = read_line(int, int)
    l, r = l - 1, r - 1

    c = 0
    for pp in p:
        if l <= pp and pp + 1 <= r:
            c += 1
    print(c)


### FIXED CODE ###

def read_line(*types): return [f(a) for a, f in zip(input().split(), types)]

n, q = read_line(int, int)
s, = read_line(str)

m = [0 for _ in range(len(s) + 1)]

c = 0
for i in range(len(s)):
    if s[i:i+2] == 'AC':
        c += 1
    m[i + 1] = c

for i in range(q):
    l, r = read_line(int, int)

    if c == 0:
        print(0)
        continue
    print(m[r - 1] - m[l - 1])
### BUGGY CODE ###

n, m = map(int, input().split())
l = list(list(map(int, input().split())) for _ in range(m))
c = []
for i in range(m):
  if l[i][0] == n:
    c.append(l[i][1])
  elif l[i][1] == n:
    c.append(l[i][0])

for i in range(m):
  if l[i][0] == 1:
    if l[i][1] in c:
      print('POSSIBLE')
      exit()
  if l[i][1] == 1:
    if l[i][0] in c:
      print('POSSIBLE')
      exit()
print('IMPOSSIBLE')

### FIXED CODE ###

n, m = map(int, input().split())
c = [[] for _ in range(n+1)]
for i in range(m):
  a, b = map(int, input().split())
  c[a].append(b)
  c[b].append(a)

for i in c[1]:
  if n in c[i]:
    print('POSSIBLE')
    exit()

print('IMPOSSIBLE')