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

from fractions import gcd

def lcm(x, y):
    return (x // gcd(x, y)) * y

MOD = 10 ** 9 + 7  
n = int(input())
A = list(map(int, input().split()))

A.sort(reverse=True)

l = 1
for i in A:
  if l % i != 0:
    l = lcm(l, i)

num = [0] * (10 ** 6 + 1)

ans = 0
for i in A:
  if num[i] == 0:
    v = (l // i) % MOD 
    num[i] = v
  else:
    v = num[i]
  ans = (ans + v) % MOD

print(ans)


### FIXED CODE ###

from fractions import gcd

def lcm(x, y):
  return (x * y) // gcd(x, y)

MOD = 10 ** 9 + 7  
n = int(input())
A = list(map(int, input().split()))

l = 1
for i in A:
  l = lcm(l, i)
l %= MOD

ans = 0
for i in A:
  ans += l * pow(i, MOD - 2, MOD)
  ans %= MOD
print(ans)
### BUGGY CODE ###

##################################################################
def main():
    Input = [input() for i in range(2)]
    N = int(Input[0])
    L = list(map(int,Input[1].split()))
    L.sort()
    ans = 0
    for i1 in range(N-1,1,-1):
        a = L[i1]
        for i2 in range(i1-1,0,-1):
            b = L[i2]
            for i3 in range(i2-1,-1,-1):
                if L[i3]>a-b:
                    ans += 1
                else:
                    break
    print(ans)



if __name__ == "__main__":
    main()


### FIXED CODE ###

import bisect
##################################################################
def main():
    Input = [input() for i in range(2)]
    N = int(Input[0])
    L = list(map(int,Input[1].split()))
    L.sort()
    ans = 0
    for i1 in range(0,N-2):
        a = L[i1]
        for i2 in range(i1+1,N-1):
            b = L[i2]
            ans += bisect.bisect_left(L, a+b) - i2 - 1
    print(ans)



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

R,G,B,N=map(int,input().split())

ans=0
for r in range(3000+1):
    if N < r*R:
        break
    for g in range(3000+1):
        if N < r*R+g*G:
            break
        if (N-r*R-g*G)%B==0:
#            print('({0}-{1}*{2}-{3}*{4})%{5}'.format(N,r,R,g,G,B))
            ans+=1
print(ans)

### FIXED CODE ###

R,G,B,N=map(int,input().split())

ans=0
for r in range(3000+1):
    if N < r*R:
        break
    for g in range(3000+1):
        if N < r*R+g*G:
            break
        if (N-r*R-g*G)%B==0:
#            print('({0}-{1}*{2}-{3}*{4})%{5}'.format(N,r,R,g,G,B))
            ans+=1
print(ans)
### BUGGY CODE ###

N,Q = map(int, input().split())
S = str(input())

before = ''
i = 0
num = 0
data_list = [0]*N
for s in S:
    if before == 'A' and s == 'C':
        num += 1
    before = s
    data_list[i] = num
    i += 1

ans = ''
for q in range(Q):
    r,l = map(int, input().split())
    ans += str(data_list[l-1]-data_list[r-1])+'\n'

print(ans.rstrip())

### FIXED CODE ###

N,Q = map(int, input().split())
S = str(input())

before = ''
i = 0
num = 0
data_list = {}
for s in S:
    if before == 'A' and s == 'C':
        num += 1
    before = s
    data_list[i] = num
    i += 1

ans = ''
for q in range(Q):
    r,l = map(int, input().split())
    ans += str(data_list[l-1]-data_list[r-1])+'\n'

print(ans.rstrip())
### BUGGY CODE ###

import sys
input = sys.stdin.readline
n, m = map(int, input().split())
value = []
weight = []
for i in range(m):
    A, B = map(int, input().split())
    C = list(map(int, input().split()))
    binary = 0
    for c in C:
        binary += 2**(c-1)
    value.append(A)
    weight.append(binary)
    
dp = [float("inf") for _ in range(2**n)]
dp[0] = 0
for s in range(2**n):
    for i in range(m):
        t = s | weight[i]
        cost = dp[s] + value[i]
        dp[t] = min(dp[t], cost)
if dp[2**n-1] == float("inf"):
    print(-1)
else:
    print(dp[2**n-1])

### FIXED CODE ###

#import sys
#input = sys.stdin.readline
 
n, m = map(int, input().split())
value = []
for i in range(m):
    A, B = map(int, input().split())
    c = sum(1<<(ci-1) for ci in map(int, input().split()))
    value.append([A, c])
    
dp = [100100100] * (1<<n)
dp[0] = 0
for s in range(1<<n):
    for i in range(m):
        t = s | value[i][1]
        cost = dp[s] + value[i][0]
        if dp[t] > cost:
            dp[t] = cost
        
if dp[(1<<n)-1] == 100100100:
    print(-1)
else:
    print(dp[(1<<n)-1])
### BUGGY CODE ###

n, m = map(int, input().split())
a = list(map(int, input().split()))
for i in range(n):
    while m > 0:
        tmp = a.index(max(a))
        #print(tmp)
        a[tmp] = a[tmp] // 2
        m -= 1
print(sum(a))

### FIXED CODE ###

import heapq
n, m = map(int, input().split())
A = list(map(int, input().split()))

pq = []
for a in A:
    heapq.heappush(pq, -a)#'-'にすることで最大値を考えることができる！
#print(pq)
for _ in range(m):
    a = (-heapq.heappop(pq)) // 2
    heapq.heappush(pq, -a)
print(-sum(pq))
### BUGGY CODE ###

x = int(input())

def prime(n):
  a = int(n**(1/2))
  for i in range(2,a+1):
    if n%i==0: return False
  return True

while (1):
  if prime(x)==False: x += 1
  else: break
  x += 1
print(x)


### FIXED CODE ###

n = int(input())

import math
def prime(n):
  a = math.ceil(math.sqrt(n))
  for i in range(2,a):
    if n%i==0: return 1
  return 0

while (1):
  if prime(n)==0: 
    print(n)
    exit()
  n+=1
### BUGGY CODE ###

from collections import deque

n = int(input())
commands = [input().split() for _ in range(n)]

l = deque([])
for com in commands:
    if com[0]=='insert':
        l.insert(0, com[1])
    elif com[0]=='delete':
        try:
            l.remove(com[1])
        except:
            pass
    elif com[0]=='deleteFirst':
        l.popleft()
    elif com[0]=='deleteLast':
        l.pop()
s = ' '.join(l)
print(s)


### FIXED CODE ###

from collections import deque

n = int(input())
commands = [input() for _ in range(n)] # splitとかしてると間に合わない

l = deque()
for com in commands:
    if com[0]=='i':
        l.appendleft(com[7:])
    elif com[6]=='F':
        l.popleft()
    elif com[6]=='L':
        l.pop()
    else:
        try:
            l.remove(com[7:])
        except:
            pass

s = ' '.join(l)
print(s)
### BUGGY CODE ###

import numpy as np

N,K,Q = map(int, input().split())
A = []
for i in range(Q):
  tmp = int(input())
  A.append(tmp)

count_A = np.zeros(N)
for i in range(Q):
  count_A[A[i]-1] += 1

point_all = [K]*N
for i in range(N):
  if point_all[i]-(sum(count_A)-count_A[i]) <= 0:
    print('No')
  else:
    print('Yes')
  
               

### FIXED CODE ###

import numpy as np

N,K,Q = map(int, input().split())
A = []
for i in range(Q):
  tmp = int(input())
  A.append(tmp)

count_A = np.zeros(N)
for i in range(Q):
  count_A[A[i]-1] += 1

for i in range(N):
  if K-(Q-count_A[i]) <= 0:
    print('No')
  else:
    print('Yes')
### BUGGY CODE ###

import sys
input = sys.stdin.readline
N = int(input())
A = list(map(int, input().split()))
if N == 1:
  print(1)
  exit(0)
  
mod = int(1e9+7)
#### 
# https://note.nkmk.me/python-gcd-lcm/
from math import gcd
from functools import reduce

def lcm_base(x, y):
    return (x * y) // gcd(x, y)

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)
  
L = lcm_list(A)
ans = 0
for a in A:
  ans += L // a
  ans %= mod
  
print(ans)


### FIXED CODE ###

from itertools import groupby
from collections import Counter

### https://atcoder.jp/contests/abc152/submissions/15835670
def fast_prime_factorization_many(lst):
  # 素因数分解（ロー法、複数）
  from subprocess import Popen, PIPE
  res = Popen(["factor"] + list(map(str, lst)), stdout=PIPE).communicate()[0].split(b"\n")[:-1]
  return [Counter(list(map(int, r.split()[1:]))) for r in res]

def main():
  import sys
  input = sys.stdin.readline
  N = int(input())
  A = list(map(int, input().split()))
  if N == 1:
    print(1)
    exit(0)
  
  mod = int(1e9+7)
  Factors = fast_prime_factorization_many(A)
  #print(Factors)
  ### lcmを求める
  lcm = 1
  max_factor = [0] * (1000010)
  for f in Factors:
    for k,v in f.items():
      v_prev = max_factor[k]
      if v_prev < v:
        for i in range(v-v_prev):
          lcm = lcm * k % mod
        max_factor[k] = v
        
  #print(lcm)
  ans = 0
  for a in A:
    wk =  lcm * pow(a,mod-2,mod)
    #print(wk)
    ans += wk
    ans %= mod
  print(ans)
  exit(0)
  
main()
### BUGGY CODE ###

s = input()
count = 0
a, qa, c, qc = 0, 0, 0, 0
def calc(x, qx, y, qy):
    return ((3*x+qx) * (3*y+qy) * pow(3, qx+qy-2))
#x*y*pow(3,qx+qy)+qx*y*pow(3,qx+qy-1)+x*qy*pow(3,qx+qy-1)+qx*qy*pow(3,qx+qy-2)
for i in range(len(s)):
    if s[i] == 'C':
        c += 1
    elif s[i] == '?':
        qc += 1
    else:
        continue
for i in range(len(s)):
    if s[i] == 'A':
        a += 1
    elif s[i] == 'C':
        c -= 1
    elif s[i] == 'B':
        count += calc(a, qa, c, qc)
    else:
        qc -= 1
        count += calc(a, qa, c, qc)
        qa += 1
print(int(count) % 1000000007)

### FIXED CODE ###

s = input()
count = 0
a, qa, c, qc = 0, 0, 0, 0
def calc(x, qx, y, qy):
    return ((3*x+qx) * (3*y+qy) * pow3q)
#x*y*pow(3,qx+qy)+qx*y*pow(3,qx+qy-1)+x*qy*pow(3,qx+qy-1)+qx*qy*pow(3,qx+qy-2)
for i in range(len(s)):
    if s[i] == 'C':
        c += 1
    elif s[i] == '?':
        qc += 1
    else:
        continue
pow3q = pow(3, qc-3)
for i in range(len(s)):
    if s[i] == 'A':
        a += 1
    elif s[i] == 'C':
        c -= 1
    elif s[i] == 'B':
        count += 3*calc(a, qa, c, qc)
    else:
        qc -= 1
        count += calc(a, qa, c, qc)
        qa += 1
print(int(count) % 1000000007)
### BUGGY CODE ###

import sys

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

res = 0
s = 0
s_list = [[0,0]]
i = 0
while i < N:
    s += A[i]
    inside = True
    j = 0
    while j < len(s_list):
        if s == s_list[j][1]:
            s_list[j][0] += 1
            inside = False
            j = len(s_list) + 1
        j += 1
    if inside:
        s_list.append([0,s])
    i += 1
for s in s_list:
    res += s[0] * (s[0] + 1) / 2.
    
print(int(res))

### FIXED CODE ###

#zero_sum slow
import sys

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


res = 0
s = 0
s_list = {}
s_list.update({0:0})
i = 0
while i < N:
    s += A[i]
    try:
        s_temp = s_list[s]
        s_list[s] += 1
        res -= s_temp * (s_temp + 1) / 2.
        res += (s_temp + 1) * (s_temp + 2) / 2.
    except:
        s_list.update({s:0})
    i += 1
    
print(int(res))
### BUGGY CODE ###

alphabet = "abcdefghijklmnopqrstuvwxyz"
a_len = len(alphabet)
table = {c: idx for idx, c in enumerate(alphabet)}

s = input()
k = int(input())

ans = ""
for c in s[:-1]:
    gap = a_len - table[c]
    if gap <= k:
        ans += "a"
        k -= gap
    else:
        ans += c

ans += alphabet[(table[s[-1]] + k) % a_len]
print(ans)


### FIXED CODE ###

import sys

sys.setrecursionlimit(10 ** 7)
rl = sys.stdin.readline


def solve():
    s = rl().rstrip()
    K = int(rl())
    
    ans = []
    for si in s:
        if si == 'a':
            ans.append('a')
            continue
        cnt = ord('z') - ord(si) + 1
        if cnt <= K:
            ans.append('a')
            K -= cnt
        else:
            ans.append(si)
    
    ans[-1] = chr(ord('a') + (ord(ans[-1]) - ord('a') + K % 26) % 26)
    print(''.join(ans))


if __name__ == '__main__':
    solve()
### BUGGY CODE ###

from functools import reduce
from operator import add, mul

a = [1, 2, 3, 4] # 適当なリスト

N = int(input()) # 1行, 単数
arg = list(map(int, input().split())) # 1行, 配列

m = reduce(mul, arg)
 
if m - 1000000000000000000 > 0:
  print(-1)
else:
  print(m)


### FIXED CODE ###

# import math
# from collections import Counter

# N = int(input()) # 1行, 単数
# arg = list(map(int, input().split())) # 1行, 配列
# D = Counter(arg) # 出現数カウント

# print('Yes')
# print('No')
# print()


N = int(input()) # 1行, 単数

arg = list(map(int, input().split())) # 1行, 配列
m = 1

if 0 in arg:
  print(0)
else:
  for A in arg:
    m = A * m
    if m > 1000000000000000000:
      m = -1
      break;
  print(m)
### BUGGY CODE ###

import sys

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

def main():
    h, w = map(int, read().split())
    s = [list(read()) for _ in range(h)]
    l = [[0] * w for _ in range(h)]
    r = [[0] * w for _ in range(h)]
    u = [[0] * w for _ in range(h)]
    d = [[0] * w for _ in range(h)]
    for i in range(h):
        for j in range(w):
            if s[i][j] == ".":
                l[i][j] = l[i][j - 1] + 1 if j > 0 else 1
                u[i][j] = u[i - 1][j] + 1 if i > 0 else 1
            if s[h - 1 - i][w - 1 - j] == ".":
                r[h - 1 - i][w - 1 - j] = r[h - 1 - i][w - j] + 1 if j > 0 else 1
                d[h - 1 - i][w - 1 - j] = d[h - i][w - 1 - j] + 1 if i > 0 else 1
    ans = 0
    for i in range(h):
        for j in range(w):
            ans = max(l[i][j] + r[i][j] + u[i][j] + d[i][j] - 3, ans)
    print(ans)

if __name__ == '__main__':
    main()

### FIXED CODE ###

import sys

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

def main():
    h, w = map(int, read().split())
    s = [list(read()) for _ in range(h)]
    row = [[0 for _ in range(w)] for _ in range(h)]
    col = [[0 for _ in range(w)] for _ in range(h)]
    for i in range(h):
        c = 0
        for j in range(w):
            if s[i][j] == "#":
                for k in range(j - c, j):
                    row[i][k] = c
                c = 0
            else:
                c += 1
        for k in range(w - c, w):
            row[i][k] = c
    for i in range(w):
        c = 0
        for j in range(h):
            if s[j][i] == "#":
                for k in range(j - c, j):
                    col[k][i] = c
                c = 0
            else:
                c += 1
        for k in range(h - c, h):
            col[k][i] = c
    ans = 0
    for i in range(h):
        for j in range(w):
            ans = max(row[i][j] + col[i][j], ans)
    print(ans - 1)

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

(x,y) = [int(i) for i in input().rstrip().split(' ')]

while True:
 if x == 0 and y == 0:
  break
 print('{0} {1}'.format(x,y))

### FIXED CODE ###

while True:
 (x,y) = [int(i) for i in input().rstrip().split(' ')]
 if x == y  == 0:
  break
 if(x < y):
  print('{0} {1}'.format(x,y))
 else:
  print('{0} {1}'.format(y,x))
### BUGGY CODE ###

n = int(input())
s = input()
rgb = s.count('R') * s.count('G') * s.count('B')
cnt = 0
for i in range(n):
    for j in range(i + 1, n):
        k = 2*j - i
        if j < k < n and len({s[i], s[j], s[k]}) == 3:
            cnt += 1
print(rgb - cnt)

### FIXED CODE ###

n = int(input())
s = input()
cnt = s.count('R') * s.count('G') * s.count('B')
for i in range(n):
    for j in range(i + 1, n):
        k = 2*j - i
        if j < k < n and len({s[i], s[j], s[k]}) == 3:
            cnt -= 1
print(cnt)
### BUGGY CODE ###

import math
n, a, b = map(int, input().split())
d = []
for i in range(n):
    d.append(input())
# [d1, d2, d3, ..., dN]
h = [int(m) for m in d]#int型に直す
#print(x)

low = 0
high = math.ceil(max(h)/b)
# t は中央番目の数
t = (low + high) // 2

# 探索の下限のlowが上限のhighになるまで探索
# lowがhighに達すると数は見つからなかっTrueたということ
X = 0
Y = 0
s = 0
while high - low >= 0:
    for j in range(n):
        X += max(0, math.ceil((h[j] - t * b) / (a - b)))
        #Y += max(0, math.ceil((h[j] - (t - 1) * b) / (a - b)))
    if X == t:
        print(t)
        exit()
    elif X < t:
        high = t - 1
        """for j in range(n):
            Y += max(0, math.ceil((h[j] - (t - 1) * b) / (a - b)))"""
    elif X > t:
        low = t + 1
    s = t
    t = (low + high) // 2
    X = 0
    Y = 0
for j in range(n):
            Y += max(0, math.ceil((h[j] - s * b) / (a - b)))
if Y <= s:
  print(s)
else:
  print(s + 1)


### FIXED CODE ###

import math
n, a, b = map(int, input().split())
d = []
for i in range(n):
    d.append(input())
# [d1, d2, d3, ..., dN]
h = [int(m) for m in d]#int型に直す
#print(x)

low = 0
high = math.ceil(max(h)/b)
# t は中央番目の数
t = (low + high) // 2

# 探索の下限のlowが上限のhighになるまで探索
# lowがhighに達すると数は見つからなかっTrueたということ
X = 0
Y = 0
s = 0
while high - low >= 0:
    for j in range(n):
        X += max(0, math.ceil((h[j] - t * b) / (a - b)))
        #Y += max(0, math.ceil((h[j] - (t - 1) * b) / (a - b)))
    if X == t:
        print(t)
        exit()
    elif X < t:
        high = t - 1
        """for j in range(n):
            Y += max(0, math.ceil((h[j] - (t - 1) * b) / (a - b)))"""
    elif X > t:
        low = t + 1
    s = t
    t = (low + high) // 2
    X = 0
    Y = 0
for j in range(n):
  if math.ceil((h[j] - s * b) / (a - b)) > 0:
            Y += math.ceil((h[j] - s * b) / (a - b))
if Y <= s:
  print(s)
else:
  print(s + 1)
### BUGGY CODE ###

X, Y, Z, K = map(int, input().split())
candy = [[],[],[]]
for i in range(3):
    temp = list(map(int, input().split()))
    candy[i] = temp

for i in range(3):
    candy[i] = sorted(candy[i], reverse=True)

output = []
for i in range(X):
    for j in range(Y):
        for k in range(Z):
            output.append(candy[0][i] + candy[1][j] + candy[2][k])
output = sorted(output, reverse=True)
for i in range(K):
    print(output[i])

### FIXED CODE ###

import heapq
X, Y, Z, K = map(int, input().split())
candy = [[],[],[]]
for i in range(3):
    temp = list(map(int, input().split()))
    candy[i] = temp

for i in range(3):
    candy[i] = sorted(candy[i], reverse=True)
i, j, k = 0, 0, 0
heap = [(-(candy[0][i] + candy[1][j] + candy[2][k]), i, j, k)]
cnt = 0
visit = {(i, j, k)}
while cnt < K:
    s, ii, jj, kk = heapq.heappop(heap)
    print(-s)
    cnt += 1
    if ii < len(candy[0]) - 1 and (ii+1, jj, kk) not in visit:
        heapq.heappush(heap, (-(candy[0][ii + 1] + candy[1][jj] + candy[2][kk]), ii + 1, jj, kk))
        visit.add((ii+1, jj, kk))
    if jj < len(candy[1]) - 1 and (ii, jj+1, kk) not in visit:
        heapq.heappush(heap, (-(candy[0][ii] + candy[1][jj + 1] + candy[2][kk]), ii, jj + 1, kk))
        visit.add((ii, jj+1, kk))
    if kk < len(candy[2]) - 1 and (ii, jj, kk+1) not in visit:
        heapq.heappush(heap, (-(candy[0][ii] + candy[1][jj] + candy[2][kk + 1]), ii, jj, kk + 1))
        visit.add((ii, jj, kk+1))
### BUGGY CODE ###


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

MAX = 10**10 + 10

# Ai+Ajを列挙して大きいほうからM番目となるスコアSを求める
# その後S以上となるスコアを加算して合計値を求める

from bisect import bisect_left

def judge(x,key):
    # スコアx以上となるのがkey個以上あるか？
    
    num = 0
    
    for i in range(N):
        eidx = bisect_left(A,x-A[i])
        num += N-eidx
    
    if num >= key:
        return True
    else: 
        return False


def meguru(key):
    ok = -1
    ng = MAX
    
    while (abs(ok-ng)>1):
        mid = (ok+ng)//2
        if judge(mid,key):
            ok = mid
        else:
            ng = mid
    return ok


D = meguru(M)
ans = 0

ruisekiwa = [0]*(N+1)
for i in range(N):
    ruisekiwa[i+1] = ruisekiwa[i] + A[i]

num = 0

for i in range(N):
    eidx = bisect_left(A,D+0.5-A[i])
    ans += A[i] * (N-eidx)
    ans += ruisekiwa[N] - ruisekiwa[eidx]
    num += N-eidx

if num<M:
    ans += (M-num)*D

print(ans)
    





### FIXED CODE ###


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

MAX = 10**10 + 10

# Ai+Ajを列挙して大きいほうからM番目となるスコアSを求める
# その後S以上となるスコアを加算して合計値を求める

from bisect import bisect_left

def judge(x,key):
    # スコアx以上となるのがkey個以上あるか？
    
    num = 0
    
    for i in range(N):
        eidx = bisect_left(A,x-A[i])
        num += N-eidx
    
    if num >= key:
        return True
    else: 
        return False


def meguru(key):
    ok = -1
    ng = MAX
    
    while (abs(ok-ng)>1):
        mid = (ok+ng)//2
        if judge(mid,key):
            ok = mid
        else:
            ng = mid
    return ok


D = meguru(M)
ans = 0

ruisekiwa = [0]*(N+1)
for i in range(N):
    ruisekiwa[i+1] = ruisekiwa[i] + A[i]

num = 0

for i in range(N):
    eidx = bisect_left(A,D+0.5-A[i])
    ans += A[i] * (N-eidx)
    ans += ruisekiwa[N] - ruisekiwa[eidx]
    num += N-eidx

if num<M:
    ans += (M-num)*D

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

x = int(input())
if not x == 0:
  for i in range(10000):
    for j in range(-10000,10000):
      if i**5 - j**5 == x:
        a = i
        b = j
    
print(str(a)+" "+str(b))

### FIXED CODE ###

x = int(input())
a = 0
b = 0
if not x == 0:
  for i in range(1000):
    for j in range(-100,1000):
      if i**5 - j**5 == x:
        a = i
        b = j
      if a != 0 or b != 0:
        break
    if a != 0 or b != 0:
        break
    
print(str(a)+" "+str(b))
### BUGGY CODE ###

n = int(input())
pos = [0] + [int(i) for i in input().split()] + [0]

for l in range(n):
    cost = 0
    tmp = pos.copy()
    tmp.pop(l+1)
    for i in range(n):
        cost += abs(tmp[i+1] - tmp[i])
    print(cost)

### FIXED CODE ###

n = int(input())
pos = [0] + [int(i) for i in input().split()] + [0]

s = 0
for i in range(n+1):
    s += abs(pos[i+1] - pos[i])

for i in range(1, n+1):
    cost = s + abs(pos[i+1] - pos[i-1]) - abs(pos[i] - pos[i-1]) - abs(pos[i+1] - pos[i])
    print(cost)
### BUGGY CODE ###

n = int(input())
a = [int(input()) for i in range(n)]
l = a
for i in range(n):
    m = a.pop(i)
    print(max(a))
    a.insert(i, m)

### FIXED CODE ###

n = int(input())
a = [int(input()) for i in range(n)]
MAX = max(a)
se = list(reversed(sorted(a)))[1]
for i in range(n):
    if a[i] == MAX:
        print(se)
    else:
        print(MAX)
### BUGGY CODE ###

N=int(input())
L=[int(i) for i in input().split()]
L=sorted(L)
ans=0
for i in range(N-2):
    for j in range(i+1,N-1):
        for k in range(j+1,N):
            if L[i]+L[j]>L[k]:
                ans+=1
            else:
                break
print(ans)

### FIXED CODE ###


N=int(input())
L=[int(i) for i in input().split()]
L=sorted(L)
ans=0
import bisect

for i in range(N-2):
    for j in range(i+1,N-1):
        insert_index = bisect.bisect_left(L,L[i]+L[j])
        ans+=insert_index-j-1
        
print(ans)
### BUGGY CODE ###

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

S = M / N
S = int(S)
#print(S)
for i in range(S, -1, -1):
    if M / i >= N:
        if M % i == 0:
            ans = i
            break


print(ans)


### FIXED CODE ###

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

S = M / N
S = int(S)
#print(S)
import math
if N == 1:
    ans = M
else:
    not_sosu = -1
    for i in range(2, int(math.sqrt(M)) + 1):
        if M % i == 0:
            not_sosu = 1
            if M / i >= N and M % i == 0:
                ans = max(ans, i)
            j = M // i
            if M / j >= N and M % j == 0:
                ans = max(ans, j)
            #print(i)
    if not_sosu == -1:
        ans = 1


if N == 1:
    ans = M

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

n = int(input())
l = list(map(int, input().split()))
L_num = [0] * (10 ** 3 + 1)
ans = 0
for i in l:
    L_num[i] += 1
for i in range(n):
    for j in range(i + 1, n):
        L_num[l[i]] -= 1
        L_num[l[j]] -= 1
        start = abs(l[i] - l[j]) + 1
        end = l[i] + l[j]
        ans += sum(L_num[start:end])
        L_num[l[i]] += 1
        L_num[l[j]] += 1
print(int(ans / 3))

### FIXED CODE ###

from bisect import bisect_left
n = int(input())
l = list(map(int, input().split()))
l.sort()
ans = 0
for i in range(n - 2):
    for j in range(i + 1, n - 1):
        ans += bisect_left(l, l[i] + l[j]) - j - 1
print(ans)
### BUGGY CODE ###

def f():
    n,m = map(int,input().split(" "))
    s = []
    w = [[] for i in range(n+2)]
    for i in range(m):
        a,b = map(int,input().split(" "))
        
        if a==1:
            s.append(b)
        if b==1:
            s.append(a)
        w[a].append(b)
        w[b].append(a)
    for i in range(m+1):
        if i in s and n in w[i]:
            print("POSSIBLE")
            return 0
    print("IMPOSSIBLE")
    return 0
f()

### FIXED CODE ###

def f():
    n,m = map(int,input().split(" "))
    s = []
    w = [[] for i in range(n+2)]
    for i in range(m):
        a,b = map(int,input().split(" "))
        
        if a==1:
            s.append(b)
        if b==1:
            s.append(a)
        w[a].append(b)
        w[b].append(a)
    for i in s:
        if n in w[i]:
            print("POSSIBLE")
            return 0
    print("IMPOSSIBLE")
    return 0
f()