Harryxun/stf_run huggingface dataset:
# -*- Coding: utf-8 -*-
INF = 1001001001
n, m = map(int, input().split())

def bfs(sv, to_list):
  dist = [INF for i in range(n)]
  hist = [-1 for i in range(n)]
  q = []
  dist[sv] = 0
  q.append(sv)
  while len(q) > 0:
    v = q[0]
    del q[0]
    for j in to_list[v]:
      if dist[j] != INF:
        continue
      hist[j] = v
      dist[j] = dist[v] + 1
      q.append(j)
  min_cycle = INF
  min_hist = -1
  for i in range(n):
    if i == sv:
      continue
    for j in to[i]:
      if j == sv:
        if min_cycle > dist[j]:
          min_cycle = dist[i]
          min_hist = i
  res = []
  temp_v = min_hist
  if min_cycle < INF:
    while temp_v > -1:
      res.append(temp_v)
      temp_v = hist[temp_v]
  else:
    res = [1 for i in range(n+1)]
  return res
    

to = [[] for i in range(m)]
for i in range(m):
  a, b = map(int, input().split())
  to[a-1].append(b-1)
c = [bfs(i, to) for i in range(n)]
ans = [1 for i in range(n+1)]
for i in range(n):
  if len(ans) > len(c[i]):
    ans = c[i]
if len(ans) == n + 1:
  print(-1)
else:
  print(len(ans))
  for v in ans[::-1]:
    print(v+1)

### FIXED CODE ###

# -*- Coding: utf-8 -*-
INF = 1001001001
n, m = map(int, input().split())

def bfs(sv, to_list):
  dist = [INF for i in range(n)]
  hist = [-1 for i in range(n)]
  q = []
  dist[sv] = 0
  q.append(sv)
  while len(q) > 0:
    v = q[0]
    del q[0]
    for j in to_list[v]:
      if dist[j] != INF:
        continue
      hist[j] = v
      dist[j] = dist[v] + 1
      q.append(j)
  min_cycle = INF
  min_hist = -1
  for i in range(n):
    if i == sv:
      continue
    for j in to[i]:
      if j == sv:
        if min_cycle > dist[j]:
          min_cycle = dist[i]
          min_hist = i
  res = []
  temp_v = min_hist
  if min_cycle < INF:
    while temp_v > -1:
      res.append(temp_v)
      temp_v = hist[temp_v]
  else:
    res = [1 for i in range(n+1)]
  return res
    

to = [[] for i in range(m)]
for i in range(m):
  a, b = map(int, input().split())
  to[a-1].append(b-1)
if len(to) == 0:
  print(-1)
else:  
  c = [bfs(i, to) for i in range(n)]
  ans = [1 for i in range(n+1)]
  for i in range(n):
    if len(ans) > len(c[i]):
      ans = c[i]
  if len(ans) == n + 1:
    print(-1)
  else:
    print(len(ans))
    for v in ans[::-1]:
      print(v+1)
a=[int() for i in range(input().split())]
a.sort()
print(a[2]-a[0])

### FIXED CODE ###

a = [int(i) for i in input().split()]
a.sort()
print(a[2]-a[0])
from math import pi
print(int(input() * 2 * pi)

### FIXED CODE ###

from math import pi
print(int(input()) * 2 * pi)
x=int(input())
y=int(input())
z=int(input())
if x==1:
    print('Hello World')
else:
    print(y+z)


### FIXED CODE ###

if int(input()) == 1:
  print('Hello World')
else:
  print(int(input()) + int(input()))
import copy

H, W = map(int, input().split())
state = []
for i in range(H):
    row_list = list(input())
    state.append(row_list)


def light(row, col, state):
    lighted_count = 0
    col1 = copy.copy(col)
    next = '.'
    while next == '.':
        lighted_count += 1
        col1 += 1
        if col1 >= W:
            break
        next = state[row][col1]
    
    col2 = copy.copy(col)
    next = '.'
    while next == '.':
        lighted_count += 1
        col2 -= 1
        if col2 < 0:
            break
        next = state[row][col2]

    row1 = copy.copy(row)
    next = '.'
    while next == '.':
        lighted_count += 1
        row1 += 1
        if row1 >= H:
            break
        next = state[row1][col]

    row2 = copy.copy(row)
    next = '.'
    while next == '.':
        lighted_count += 1
        row2 -= 1
        if row2 < 0:
            break
        next = state[row2][col]

    lighted_count -= 3
    return lighted_count



def blank_fun(state):
    blank_list = []
    for h in range(H):
        for w in range(W):
            if state[h][w] == '.':
                blank_list.append([h, w])
    return blank_list


blank_list = blank_fun(state)
blank_count = 0
for blank in blank_list:
    row = blank[0]
    col = blank[1]
    blank_count_now = light(row, col, state)

    if blank_count_now > blank_count:
        blank_count = blank_count_now


print(blank_count)


### FIXED CODE ###

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

a1 = a+b
a2 = a+c
a3 = b+c
x = [a1, a2, a3]
print(min(x))
N, Q = map(int, input().split())
T = {}
for i in range(N - 1):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    if a in T:
        T[a].append(b)
    else:
        T[a] = [b]
    if b in T:
        T[b].append(a)
    else:
        T[b] = [a]

d = [0] * N

for i in range(Q):
    p, x = map(int, input().split())
    d[p - 1] += x

def dfs(u, v = -1):
    if u in T:
        for p in T[u]:
            if p != v:
                d[p] += d[u]
                dfs(p, u)

dfs(0)


print(' '.join(map(str, d)))


### FIXED CODE ###

from sys import stdin,setrecursionlimit
input = stdin.readline
setrecursionlimit(1000000) 

N, Q = map(int, input().split())
T = [[] for _ in range(2 * (10 ** 5))]
for _ in range(N - 1):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    T[a].append(b)
    T[b].append(a)

d = [0] * N

for _ in range(Q):
    p, x = map(int, input().split())
    d[p - 1] += x

def dfs(u, v):
    global d
    for p in T[u]:
        if p == v:
            continue
        d[p] += d[u]
        dfs(p, u)

dfs(0, -1)

for v in d:
    print(v)
import sys

mt = sys.stdin.strip().split()
mt = sorted([int(i) for i in mt])
print "\n".join(mt[:3])

### FIXED CODE ###

mt = list()
for i in range(10):
    mt.append(int(raw_input()))

mt = sorted(mt,reverse=True)
for i in range(3):
    print mt[i]
n, l = (int(s) for s in input().strip().split(' '))
    an = []
for a in range(0,l):
    an.append(input().strip().split())

box=[[1,0] for i in range(n)]
box[0][1] = 1
for move in an:
    box[int(move[0])-1][0] -= 1
    box[int(move[1])-1][0]+=1
    if box[int(move[0])-1][1] == 1:
        box[int(move[1])-1][1]= 1
    if box[int(move[0])-1][0]==0:
        box[int(move[0])-1][1]=0
print(str(sum([s[1] for s in box])))

### FIXED CODE ###

n, l = (int(s) for s in input().strip().split(' '))
an = []
for a in range(0,l):
    an.append(input().strip().split())
box=[[1,0] for i in range(n)]
box[0][1] = 1
for move in an:
    box[int(move[0])-1][0] -= 1
    box[int(move[1])-1][0]+=1
    if box[int(move[0])-1][1] == 1:
        box[int(move[1])-1][1]= 1
    if box[int(move[0])-1][0]==0:
        box[int(move[0])-1][1]=0
print(str(sum([s[1] for s in box])))
n = int(input())
mod = 10**9+7
def Fac(x):
  return x*Fac(x-1) if x != 0 else 1
print(Fac(n)%mod)

### FIXED CODE ###

import math
n = int(input())
mod = 10**9+7
print(math.factorial(n)%mod)
#!/usr/bin/env python
H, W = map(int, input().split())
A = [[s for s in input()] for i in range(H)]

l = []
for i in range(H):
        for j in range(W):
            if A[i][j] == '#':
                l.append([i,j])

c = 0
for k in range(H*W):
    c += 1
    for i in range(H):
        for j in range(W):
            if A[i][j] == '#':
                if i >= 1 and [i-1,j] not in l:
                    l.append([i-1,j])
                if j >= 1 and [i,j-1] not in l:
                    l.append([i,j-1])
                if i+1 < H and [i+1,j] not in l:
                    l.append([i+1, j])
                if j+1 < H and [i,j+1] not in l:
                    l.append([i, j+1])
    if len(l) == H*W:
        break
    for x in l:
        A[x[0]][x[1]] = '#'
print(c)         

### FIXED CODE ###

#!/usr/bin/env python
H, W = map(int, input().split())

g = [[True] * (W+2)]
for _ in range(H):
    g.append([True] + [x == '#' for x in input()] + [True])
g.append([True] * (W+2))

l = []
for i in range(1, H+1):
    for j in range(1, W+1):
        if g[i][j]:
            l.append((i, j))

c = 0
while l:
    ll = []
    for i,j in l:
        if not g[i+1][j]:
            g[i+1][j] = True
            ll.append((i+1, j))
        if not g[i-1][j]:
            g[i-1][j] = True
            ll.append((i-1, j))
        if not g[i][j+1]:
            g[i][j+1] = True
            ll.append((i, j+1))
        if not g[i][j-1]:
            g[i][j-1] = True
            ll.append((i, j-1))
    c += 1
    l = ll

print(c-1)
a,b,X=[int(i for i in input().split())]
if x>=a and a+b>=x:
  print('YES')
else:
  print('NO')

### FIXED CODE ###

a,b,x=[int(i) for i in input().split()]
if x>=a and a+b>x:
  print('YES')
else:
  print('NO')
import sys
import numpy as np

read = sys.stdin.read
readline = sys.stdin.readline

N, K, *xyc = map(int, read().split())
x = np.array(xyc[::3], np.float)
y = np.array(xyc[1::3], np.float)
c = np.array(xyc[2::3], np.float)

left = x.min()
right = x.max()


def y_solve(X):
    left_y = -1000
    right_y = 1000

    x_tmp = x - X
    while right_y - left_y > 0.1 ** 7:
        mid1 = (right_y + left_y * 2) / 3
        mid2 = (right_y * 2 + left_y) / 3
        t1 = np.hypot(x_tmp, y - mid1) * c
        t1.sort()
        t2 = np.hypot(x_tmp, y - mid2) * c
        t2.sort()
        time1 = t1[K - 1]
        time2 = t2[K - 1]
        if time1 < time2:
            right_y = mid2
        else:
            left_y = mid1
    return left_y


while right - left > 0.1 ** 7:
    mid1 = (right + left * 2) / 3
    mid2 = (right * 2 + left) / 3

    y_tmp1 = y_solve(mid1)
    t1 = np.hypot(x - mid1, y - y_tmp1) * c
    t1.sort()
    y_tmp2 = y_solve(mid2)
    t2 = np.hypot(x - mid2, y - y_tmp2) * c
    t2.sort()
    time1 = t1[K - 1]
    time2 = t2[K - 1]
    if time1 < time2:
        right = mid2
    else:
        left = mid1

x -= left
y -= y_tmp1

answer = np.hypot(x, y) * c
answer.sort()
print(answer[K - 1])


### FIXED CODE ###

import sys
from itertools import combinations
from math import sqrt

read = sys.stdin.read
readline = sys.stdin.readline


def main():
    N, K, *xyc = map(int, read().split())
    x = xyc[::3]
    y = xyc[1::3]
    xy = list(zip(x, y))
    c = xyc[2::3]
    left = 0
    right = 10 ** 6
    delta = 0.1 ** 7
    while right - left > delta:
        mid = (left + right) / 2
        intersections = []
        r = [(mid / i) ** 2 for i in c]
        for i, j in combinations(range(N), 2):
            x1, y1 = xy[i]
            x2, y2 = xy[j]
            X = x2 - x1
            Y = y2 - y1
            XY = X ** 2 + Y ** 2
            r1 = r[i]
            r2 = r[j]

            a = (XY + r1 - r2) / 2
            b = XY * r1 - a ** 2
            if b < delta:
                continue
            b = sqrt(b)
            xi1 = (a * X + Y * b) / XY + x1
            yi1 = (a * Y - X * b) / XY + y1
            xi2 = (a * X - Y * b) / XY + x1
            yi2 = (a * Y + X * b) / XY + y1
            intersections.append((xi1, yi1))
            intersections.append((xi2, yi2))

        intersections.extend(xy)
        cnt = 0
        for X, Y in intersections:
            tmp = 0
            for (i, j), k in zip(xy, r):
                XY = (X - i) ** 2 + (Y - j) ** 2
                if XY < k + delta:
                    tmp += 1
            cnt = max(tmp, cnt)
            if cnt >= K:
                break
        if cnt >= K:
            right = mid
        else:
            left = mid

    print(right)


if __name__ == '__main__':
    main()
import array
from functools import reduce
from operator import xor

N = int(input())
A = array.array("L", map(int, input().split()))

Q = array.array("L", [0]) * N

array.array((A[n] for n in range(N) if n!=i))

R = reduce(xor, A)
for i in range(N):
    print(R^A[i])


### FIXED CODE ###

import array
from functools import reduce
from operator import xor

N = int(input())
A = array.array("L", map(int, input().split()))

Q = array.array("L", [0]) * N

R = reduce(xor, A)
for i in range(N):
    print(R^A[i])
n = input()
N = str(n)
if "7" in N:
    print(yes)
else:
    print(no)
    

### FIXED CODE ###

n = input()
N = str(n)
if "7" in N:
    print("Yes")
else:
    print("No")
s = input()
list = list(s)

for i in range(len(s) / 2):
  print(list[i])

### FIXED CODE ###

x = input()
a1 = int(x.split()[0])
a2 = int(x.split()[1])
a3 = int(x.split()[2])

sum = a1 + a2 + a3

if sum >= 22:
    print('bust')
else:
    print('win')
import os
import sys
from collections import defaultdict, Counter
from itertools import product, permutations,combinations, accumulate
from operator import itemgetter
from bisect import bisect_left,bisect
from heapq import heappop,heappush,heapify
from math import ceil, floor, sqrt, gcd
from copy import deepcopy

def main():
    d,n = map(int, input().split())
    a_list = []
    ans = 0
    if d == 0:
        for i in range(1,100):
            a_list.append(i)
    elif d == 1:
        for i in range(100, 10000, 100):
            a_list.append(i)
    else:
        for i in range(10000, 1000000, 10000):
            a_list.append(i)

    print(a_list[n-1])
    
if __name__ == '__main__':
    main()

### FIXED CODE ###

d,n = map(int,input().split())
li = []
for i in range(1,102):
    if i != 100:
        li.append(i*100**d)
print(li[n-1])
# 7 7
a, b = [xfor x in input().split()]
print(sorted([a * b, b * a])[-1])

### FIXED CODE ###

a, b = [x for x in input().split()]
print(sorted([a * int(b), b * int(a)])[0])
X,Y=map(int,input().split())

prize=0

if X==1:
    prize+=300000
    if Y==1:
        pprize+=700000
    elif Y==2:
        prize+=200000
    elif Y==3:
        prize+=100000
    else:
        pass
elif X==2:
    prize+=200000
    if Y==1:
        prize+=300000
    elif Y==2:
        prize+=200000
    elif Y==3:
        prize+=100000
    else:
        pass
elif X==3:
    prize+=100000
    if Y==1:
        prize+=300000
    elif Y==2:
        prize+=200000
    elif Y==3:
        prize+=100000
    else:
        pass
else:
    prize+=100000
    if Y==1:
        prize+=300000
    elif Y==2:
        prize+=200000
    elif Y==3:
        prize+=100000
    else:
        pass

print(prize)

### FIXED CODE ###

X,Y=map(int,input().split())

prize=0

if X==1:
    prize+=300000
    if Y==1:
        prize+=700000
    elif Y==2:
        prize+=200000
    elif Y==3:
        prize+=100000
    else:
        pass
elif X==2:
    prize+=200000
    if Y==1:
        prize+=300000
    elif Y==2:
        prize+=200000
    elif Y==3:
        prize+=100000
    else:
        pass
elif X==3:
    prize+=100000
    if Y==1:
        prize+=300000
    elif Y==2:
        prize+=200000
    elif Y==3:
        prize+=100000
    else:
        pass
else:
    if Y==1:
        prize+=300000
    elif Y==2:
        prize+=200000
    elif Y==3:
        prize+=100000
    else:
        pass

print(prize)
mountain, answer = [], []

while(True):
  operation = raw_input().split()
  if operation[0] == 'push':
    mountain.append(operation[1])
  elif operation[0] == 'pop':
    answer. append(mountain[-1])
    mountain.pop()
  elif operation == 'quit':
    break

for a in answer:
  print a 

### FIXED CODE ###

mountain, answer = [], []

while(True):
  operation = raw_input().split()
  if operation[0] == 'push':
    mountain.append(operation[1])
  elif operation[0] == 'pop':
    answer. append(mountain[-1])
    mountain.pop()
  elif operation[0] == 'quit':
    break

for a in answer:
  print a
n = int(input())
l = [list(input().split()) for i,c in range(n)]
sum =0
for i,c in l:
  if c =="JPY":
    sum+=i
  else:
    sum+=i*380000
print(sum)
  

### FIXED CODE ###

n = int(input())
sum =0
for j in range(n):
  i,c = input().split()
  if c =="BTC":
    sum+=float(i)*380000
  else:
    sum+=int(i)
print(sum)
#2分探索
#md/cで交点が定まらない時の対案
n,k = map(int, input().split( ))
m = [tuple(map(int, input().split( ))) for i in range(n)]
#そもそも設定はn枚すべて焼く必要はない
mx = 10**15
mn = 0
from math import sqrt
def solve(x1, y1, r1, x2, y2, r2):
    rr0 = (x2 - x1)**2 + (y2 - y1)**2
    xd = x2 - x1
    yd = y2 - y1
    rr1 = r1**2; rr2 = r2**2
    cv = (rr0 + rr1 - rr2)
    if max(r1,r2,sqrt(rr0))*2>r1+r2+sqrt(rr0):
        return (x1,y1),(x2,y2)
    sv = sqrt(4*rr0*rr1 - cv**2)
    return (
        (x1 + (cv*xd - sv*yd)/(2.*rr0), y1 + (cv*yd + sv*xd)/(2.*rr0)),
        (x1 + (cv*xd + sv*yd)/(2.*rr0), y1 + (cv*yd - sv*xd)/(2.*rr0)),
    )

#flag で breakしてたのが煩雑すぎて追えていなかったらしい
while mx-mn>10**(-6) or mx-mn>10**(-7)*mx:#mx大きい時に安易に設定すると到達しない？
    md = (mx+mn)/2
    cnt = 0
    for i in range(n):##中心選ぶケースが抜けてる
        pi0,pi1 = m[i][0],m[i][1]
        tmp = 0
        for l in range(n):#kはすでに使っている変数
            if m[l][2]*sqrt(((pi0-m[l][0])**2) + ((pi1-m[l][1])**2))<=md+0.000000001
                tmp += 1
        if cnt<tmp:
            cnt = tmp

    for i in range(n):
        for j in range(i+1,n):##range(i)だとi=0で止まって何もしない

            p = solve(m[i][0],m[i][1],md/m[i][2], m[j][0],m[j][1],md/m[j][2])

            for pi in p:
                tmp = 0
                for l in range(n):#kはすでに使っている変数
                    if (((pi[0]-m[l][0])**2) + ((pi[1]-m[l][1])**2))**(1/2)<=md/m[l][2]+0.000000001:##ここで誤差認めなかったせいらしい
                        tmp += 1
                if cnt<tmp:
                    cnt = tmp

    if cnt>=k:
        mx = md
    else:
        mn = md
print(mx)


### FIXED CODE ###

#2分探索
#md/cで交点が定まらない時の対案
n,k = map(int, input().split( ))
m = [tuple(map(int, input().split( ))) for i in range(n)]
#そもそも設定はn枚すべて焼く必要はない
mx = 10**15
mn = 0
from math import sqrt
def solve(x1, y1, r1, x2, y2, r2):
    rr0 = (x2 - x1)**2 + (y2 - y1)**2
    xd = x2 - x1
    yd = y2 - y1
    rr1 = r1**2; rr2 = r2**2
    cv = (rr0 + rr1 - rr2)
    if max(r1,r2,sqrt(rr0))*2>r1+r2+sqrt(rr0):
        return (x1,y1),(x2,y2)
    sv = sqrt(4*rr0*rr1 - cv**2)
    return (
        (x1 + (cv*xd - sv*yd)/(2.*rr0), y1 + (cv*yd + sv*xd)/(2.*rr0)),
        (x1 + (cv*xd + sv*yd)/(2.*rr0), y1 + (cv*yd - sv*xd)/(2.*rr0)),
    )

#flag で breakしてたのが煩雑すぎて追えていなかったらしい
while mx-mn>10**(-6) and mx-mn>10**(-7)*mx:#mx大きい時に安易に設定すると到達しない？
    md = (mx+mn)/2
    cnt = 0
    for i in range(n):##中心選ぶケースが抜けてる
        pi0,pi1 = m[i][0],m[i][1]
        tmp = 0
        for l in range(n):#kはすでに使っている変数
            if m[l][2]*sqrt(((pi0-m[l][0])**2) + ((pi1-m[l][1])**2))<=md+0.000000001:
                tmp += 1
        if cnt<tmp:
            cnt = tmp

    for i in range(n):
        for j in range(i+1,n):##range(i)だとi=0で止まって何もしない

            p = solve(m[i][0],m[i][1],md/m[i][2], m[j][0],m[j][1],md/m[j][2])

            for pi in p:
                tmp = 0
                for l in range(n):#kはすでに使っている変数
                    if (((pi[0]-m[l][0])**2) + ((pi[1]-m[l][1])**2))**(1/2)<=md/m[l][2]+0.000000001:##ここで誤差認めなかったせいらしい
                        tmp += 1
                if cnt<tmp:
                    cnt = tmp

    if cnt>=k:
        mx = md
    else:
        mn = md
print(mx)
A, B, C, X = int(input())
ans = 0
for i in range(0,A+1):
    for j in range(0,B+1):
        for k in range(0,C+1):
            sum = 500 * i + 100 * j + 50 * k
            if sum == X:
                ans += 1

print(ans)

### FIXED CODE ###

A = int(input())
B = int(input())
C = int(input())
X = int(input())
ans = 0
for i in range(0,A+1):
    for j in range(0,B+1):
        for k in range(0,C+1):
            sum = 500 * i + 100 * j + 50 * k
            if sum == X:
                ans += 1

print(ans)
n = input()
if n[-1] in "24579":
  print("hon")
elif n[-1] in "0168":
  print("pon")
elif n[-1] in "3"
  print("bon")


### FIXED CODE ###

n = input()
if n[-1] in "24579":
  print("hon")
elif n[-1] in "0168":
  print("pon")
elif n[-1] in "3":
  print("bon")
a, b, c, d = map(int, input().split())
l = a + b
r = c + d
print("Left" if l > r else "Balanced" if l = r else "Right")

### FIXED CODE ###

a, b, c, d = map(int, input().split())
l, r = a + b, c + d
if r < l:
  print("Left")
elif l < r:
  print("Right")
else:
  print("Balanced")
import heapq
n,m=map(int, input().split())
lst = []
for i in range(n):
  a,b=map(int, input().split())
  lst.append((-b,a))
lst = sorted(lst, key=lambda x:x[1])

now_idx = 0
queue = []
sum_ = 0
for i in range(1,m):
  for j in range(now_idx, n):
    if lst[j][1] <= i:
      heapq.heappush(queue, lst[j])
    else:
      now_idx = j
      break
  sum_ -= heapq.heappop(queue)
print(sum_)

### FIXED CODE ###

import heapq
n,m=map(int, input().split())
lst = []
for i in range(n):
  a,b=map(int, input().split())
  lst.append((-b,a))
lst = sorted(lst, key=lambda x:x[1])

now_idx = 0
queue = []
sum_ = 0
for i in range(1,m+1):
  for j in range(now_idx, n):
    if lst[j][1] <= i:
      heapq.heappush(queue, lst[j])
    else:
      now_idx = j
      break
  else:
    now_idx = n
  if len(queue)>0:
    sum_ -= heapq.heappop(queue)[0]
print(sum_)
N,M = map(int,input().split())

from1 = [False]*N
toN = [False]*N
for i in range(M):
  a,b = map(int,input().split())
  if a ==1 or b ==1:
    from1[max(a,b)-1]=True
  if a == N or b == N:
    toN[a-1 if a!= N else b-1]=True
cnt =0 
for i in range(M):
  cnt+=from1[i]&toN[i]
print("POSSIBLE" if cnt else "IMPOSSIBLE")

### FIXED CODE ###

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

from1 = [False]*max(N,M)
toN = [False]*max(N,M)
for i in range(M):
  a,b = map(int,input().split())
  if a ==1 or b ==1:
    from1[a-1 if a!= 1 else b-1]=True
  if a == N or b == N:
    toN[a-1 if a!= N else b-1]=True
cnt =0 
for i in range(M):
  cnt+=from1[i]&toN[i]
print("POSSIBLE" if cnt else "IMPOSSIBLE")
s=input()

A=s.index('C')
for i in range(A,len(s)):
    if s[i]=='F':
        print('Yes')
        break
else:
    print('No')

### FIXED CODE ###

s=input()

if 'C' in s:
    A=s.index('C')
    for i in range(A,len(s)):
        if s[i]=='F':
            print('Yes')
            break
    else:
        print('No')
else:
    print('No')
import sys
input = sys.stdin.readline

N,M,R = map(int,input().split())
r = list(map(int,input().split()))
S = [[]for i in range(N)]
for i in range(M):
    a,b,c = map(int,input().split())
    S[a-1].append([b-1,c])
    S[b-1].append([a-1,c])
d = [[float('inf')]*N for i in range(N)]
queue = []
for i in range(N):
    queue = [i]
    d[i][i] = 0
    while queue !=[]:
        hoge = [0]*(N+1)
        l = 0
        for q in queue:
            for next,c in S[q]:
                if d[i][next] > d[i][q]+c:
                    hoge[l] = next
                    l += 1
                    d[i][next] = d[i][q]+c
        queue = hoge[:l]
def func(x,l):
    if l == []:
        return 0
    ans = float('inf')
    for i in range(len(l)):
        ans =min(ans,func(l[i],l[:i]+l[i+1:]) + d[x-1][l[i]-1])
    return ans
ans = float('inf')
for i in r:
    ans = min(ans,func(i,r))
print(ans)

### FIXED CODE ###

import sys
input = sys.stdin.readline

N,M,R = map(int,input().split())
r = list(map(int,input().split()))
S = [[]for i in range(N)]
for i in range(M):
    a,b,c = map(int,input().split())
    S[a-1].append([b-1,c])
    S[b-1].append([a-1,c])
d = [[float('inf')]*N for i in range(N)]
queue = []
hoge = [0]*(M)
for i in range(N):
    queue = [i]
    d[i][i] = 0
    while queue !=[]:
        l = 0
        for q in queue:
            for next,c in S[q]:
                if d[i][next] > d[i][q]+c:
                    d[i][next] = d[i][q]+c
                    if not(next in hoge[:l]):
                        hoge[l] = next
                        l += 1
        queue = hoge[:l]
def func(x,l):
    if l == []:
        return 0
    ans = float('inf')
    for i in range(len(l)):
        ans =min(ans,func(l[i],l[:i]+l[i+1:]) + d[x-1][l[i]-1])
    return ans
ans = float('inf')
for i in r:
    ans = min(ans,func(i,r))
print(ans)
import math

def rlE(S: str):
    grouped = groupby(S)
    res = []
    for k, v in grouped:
        res.append((k, (len(list(v)))))
    return res

S = input()
ans = [0 for _ in range(len(S))]
cnt = 0
rS = rlE(S)
rS.append(["", 0])
temp = rS[0][1] - 1

while(cnt < len(rS) - 1):
    ans[temp] = math.ceil(rS[cnt][1] / 2) + rS[cnt + 1][1] - math.ceil(rS[cnt + 1][1] / 2)
    ans[temp + 1] = math.ceil(rS[cnt + 1][1] / 2) + rS[cnt][1] - math.ceil(rS[cnt][1] / 2)
    temp += (rS[cnt + 1][1] + rS[cnt + 2][1])
    cnt += 2
print(*ans)

### FIXED CODE ###

import math
from itertools import groupby

def rlE(S: str):
    grouped = groupby(S)
    res = []
    for k, v in grouped:
        res.append((k, (len(list(v)))))
    return res

S = input()
ans = [0 for _ in range(len(S))]
cnt = 0
rS = rlE(S)
rS.append(["", 0])
temp = rS[0][1] - 1

while(cnt < len(rS) - 1):
    ans[temp] = math.ceil(rS[cnt][1] / 2) + rS[cnt + 1][1] - math.ceil(rS[cnt + 1][1] / 2)
    ans[temp + 1] = math.ceil(rS[cnt + 1][1] / 2) + rS[cnt][1] - math.ceil(rS[cnt][1] / 2)
    temp += (rS[cnt + 1][1] + rS[cnt + 2][1])
    cnt += 2
print(*ans)