Harryxun/stf_run huggingface dataset:
#!/usr/bin/env python

def main():
    N, M = map(int, input().split())
    # [AC, WA]
    cnt = [[0, 0] for _ in range(2)]
    for _ in range(M):
        num, status = input().split()
        num = int(num) -1
        if status == "AC":
            if cnt[num][0] == 0:
                cnt[num][0] += 1
        if status == "WA":
            if cnt[num][0] == 0:
                cnt[num][1] += 1

    ac_cnt, wa_cnt = 0, 0
    for i in range(N):
        ac_cnt += cnt[i][0]
        wa_cnt += cnt[i][1]

    print(ac_cnt, wa_cnt, sep=" ")

if __name__ == '__main__':
    main()

### FIXED CODE ###

#!/usr/bin/env python

def main():
    N, M = map(int, input().split())
    # [AC, WA]
    cnt = [[0, 0] for _ in range(N)]
    for _ in range(M):
        num, status = input().split()
        num = int(num) -1
        if status == "AC":
            if cnt[num][0] == 0:
                cnt[num][0] += 1
        if status == "WA":
            if cnt[num][0] == 0:
                cnt[num][1] += 1

    ac_cnt, wa_cnt = 0, 0
    for i in range(N):
        if cnt[i][0] == 1:
            ac_cnt += cnt[i][0]
            wa_cnt += cnt[i][1]

    print(ac_cnt, wa_cnt, sep=" ")

if __name__ == '__main__':
    main()
import dateutil
S = dateutil.parser.parse(input())
base = dateutil.parser.parse('2019/04/30')
if S<=base:
    print("Heisei")
else:
    print("TBD")

### FIXED CODE ###

import datetime
S = input()
dt = datetime.date(*list(map(int, S.split('/'))))
base = datetime.date(2019, 4, 30)
if dt<=base:
    print("Heisei")
else:
    print("TBD")
N,K=map(int,input().split())
A=list(map(int,input().split()))
flag=0
now=0
i=0
count=0
c=[0]*N
r=[0]
c[0]=1
while flag==0:
  now=A[now]-1
  count+=1
  if count==K:
    flag=1
  elif c[now]==1:
    flag=2
  c[now]=1
  r.append(now)
if flag==1:
  print(now+1)
else:
  o=[i for i, x in enumerate(r) if x == now]
  print(A[r[K%(o[1]-o[0])]+o[0]-1])

### FIXED CODE ###

N,K=map(int,input().split())
A=list(map(int,input().split()))
flag=0
now=0
i=0
count=0
c=[0]*N
r=[0]
c[0]=1
while flag==0:
  now=A[now]-1
  count+=1
  if count==K:
    flag=1
  elif c[now]==1:
    flag=2
  c[now]=1
  r.append(now)
if flag==1:
  print(now+1)
else:
  o=[i for i, x in enumerate(r) if x == now]
  print(r[(K-o[0])%(o[1]-o[0])+o[0]]+1)
s = input()
print((s in 'a') and (s in 'b') and (s in 'c') ? 'Yes' : 'No')


### FIXED CODE ###

s = input()
print('Yes' if ('a' in s) and ('b' in s) and ('c' in s) else 'No')
# coding: UTF-8
    import sys
    #sys.setrecursionlimit(n)
    import heapq
    import re
    import bisect
    import random
    import math
    import itertools
    from collections import defaultdict, deque
    from copy import deepcopy
    from decimal import *
     
    n, q = map(int, input().split())
    s = list(input())
     
    ss = ""
    a = [0] * n
    b = [0] * n
    for i in range(n):
        if s[i] == "A":
            ss = s[i]
        elif s[i] == "C":
            ss += s[i]
        if ss == "AC":
            a[i] = a[i - 1] - 1
            b[i] += b[i - 1] + 1
            ss = ""
        else:
            if i > 0:
                a[i] = a[i - 1]
                b[i] = b[i - 1]
     
    for i in range(q):
        x, y = map(int, input().split())
        print(max(0, b[y - 1] + a[x - 1]))

### FIXED CODE ###

# coding: UTF-8
import sys
#sys.setrecursionlimit(n)
import heapq
import re
import bisect
import random
import math
import itertools
from collections import defaultdict, deque
from copy import deepcopy
from decimal import *

n, q = map(int, input().split())
s = list(input())

ss = ""
b = [0] * n
for i in range(n):
    if s[i] == "A":
        ss = s[i]
    elif s[i] == "C":
        ss += s[i]
    else:
        ss = ""
    if ss == "AC":
        b[i] += b[i - 1] + 1
        ss = ""
    else:
        if i > 0:
            b[i] = b[i - 1]
for i in range(q):
    x, y = map(int, input().split())
    print(b[y - 1] - b[x - 1])
H, W, D = map(int, input().split())
A = [list(map(int, input().split())) for _ in range(H)]

d = {}
for y in range(H):
    Ay = A[y]
    for x in range(W):
        d[Ay[x]] = (y, x)

t = [[0] * ((H * W + D - 1) // D) for _ in range(D)]
for i in range(D):
    ti = t[i]
    j = 0
    if i == 0:
        j = 1
    while i + (j + 1) * D <= H * W:
        y1, x1 = d[i + j * D]
        y2, x2 = d[i + (j + 1) * D]
        ti[j + 1] = abs(y1 - y2) + abs(x1 - x2)
        j += 1
    for j in range(len(ti) - 1):
        ti[j + 1] += ti[j]

Q = int(input())
for _ in range(Q):
    L, R = map(int, input().split())
    i = L % D
    print(t[i][(R - i) // D] - t[i][(L - i) // D])


### FIXED CODE ###

H, W, D = map(int, input().split())
A = [list(map(int, input().split())) for _ in range(H)]

d = {}
for y in range(H):
    Ay = A[y]
    for x in range(W):
        d[Ay[x]] = (y, x)

t = [[0] * ((H * W + D - 1) // D + 1) for _ in range(D)]
for i in range(D):
    ti = t[i]
    j = 0
    if i == 0:
        j = 1
    while i + (j + 1) * D <= H * W:
        y1, x1 = d[i + j * D]
        y2, x2 = d[i + (j + 1) * D]
        ti[j + 1] = abs(y1 - y2) + abs(x1 - x2)
        j += 1
    for j in range(len(ti) - 1):
        ti[j + 1] += ti[j]

Q = int(input())
for _ in range(Q):
    L, R = map(int, input().split())
    i = L % D
    print(t[i][(R - i) // D] - t[i][(L - i) // D])
n = int(input())
a = 0
for i in range(len(n)):
    a += n[i]
if a == 1:
    print(10)
else:
    print(a)

### FIXED CODE ###

n = input()
a = 0
for i in range(len(n)):
    a += int(n[i])
if a == 1:
    print(10)
else:
    print(a)
[N,L] = [int(x) for x in input().split()]
A = {}
B = [0]*N
ANS = {}
count = 0
for i,x in enumerate(input().split()):
    i = int(i)
    x = int(x)
    B[i] = x
    if x in A : A[x] += [i]
    else : A[x] = [i]
for i in sorted(A) :
    for j in A[i] :
        for k in range(L) :
            if j + k not in ANS :
                ANS[j+k] = i
                count += 1
    if count + L*0.5 > N : break
        
for i in range(L):
    if i not in ANS : ANS[i] = min(B[:i+1])
for i in range(L,N):
    if i not in ANS : ANS[i] = min(B[i+1-L:ijavascript:void(0)+1])
for i in range(L-1,N-1) : print(ANS[i], end=" ")
print(ANS[N-1])

### FIXED CODE ###

def ascend(a,b):
    mini = min(A[a:a+L])
    ans[a] = mini
    for i in range(a+1,b):
        if A[i+L-1] <= mini : mini = A[i+L-1]
        elif A[i-1] == mini : mini = min(A[i:i+L])
        ans[i] = mini

def descend(a,b):
    mini = min(A[b-1:b+L-1])
    ans[b-1] = mini
    for i in range(b-2,a-1,-1):
        if A[i] <= mini : mini = A[i]
        elif A[i+L] == mini: mini = min(A[i:i+L])
        ans[i] = mini
    
[N,L] = [int(x) for x in input().split()]
A = [int(x) for x in input().split()]
ans = [None]*(N-L+1)
count = 0;
if N > 10 ** 4:
    for i in range(100):
        if A[i+1] > A[i] : count += 1
    if count > 80 : descend(0, N-L+1)
    else : ascend(0,N-L+1)
else :
    ascend(0, N-L+1)
for i in ans[:-1] : print(i, end=" ")
print(ans[-1])
word = list(input())
num = int(input())
p = []
count = 1
for i in range(len(word)-1):
  if word[i] == word[i+1]:
    count += 1
    if i == len(word)-2:
      p.append(count)
  else:
    p.append(count)
    count = 1

point = 0
for i in p:
  point += i // 2
if word[0] == word[-1] and p[-1] % 2 == 1:
  point += 1
  
print(point * num)

### FIXED CODE ###

word = list(input())
num = int(input())
if len(word) == 1:
  print(num//2)
else:
  p = []
  count = 1
  for i in range(len(word)-1):
    if word[i] == word[i+1]:
      count += 1
      if i == len(word)-2:
        p.append(count)
    else:
      p.append(count)
      count = 1

  point = 0
  
  for i in p:
    point += i // 2
  if len(p) == 1:
    print(p[0]*num//2)
  elif word[0] == word[-1]:
    print((p[0] + p[-1])//2 * (num-1) + p[0]//2 + p[-1]//2 + (point - p[0]//2 - p[-1]//2)*num)
  else:
    print(point * num)
N = int(input())
A = list(map(int, input().split()))

ans = N
j = 1
s = A[0] + A[1] if N > 0 else A[0]
x = A[0]
for i, a in enumerate(A):
    x = a
    s = a
    if j == i:
        j += 1
    if j == N:
        break
    for k in range(j-i):
        x = x | A[1 + i + k]
        s += A[1 + i + k]
    while True:
        print(i,j,ans, x, s)
        if j == N:
            break
        if s == x:
            ans += j-i
            j += 1
            if j == N:
                break
            s += A[j]
            x = x | A[j]
        else:
            break

print(ans)




### FIXED CODE ###

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

ans = N
if N == 1:
    print(1)
    sys.exit()
j = 1
s = A[0] + A[1]
x = A[0] ^ A[1]
for i, a in enumerate(A):
    if j == i:
        j += 1
        if j == N:
            break
        x = x ^ A[j]
        s += A[j]

    while True:
        if j == N:
            break
        if s == x:
            ans += j-i
            j += 1
            if j == N:
                break
            s += A[j]
            x = x ^ A[j]
        else:
            s -= a
            x = x ^ a
            break
    if j == N:
        break

print(ans)
# ユークリッドの互除法
def gcd(x, y):
    while y != 0:
        x, y = y, x % y
    return x

# 約数の列挙
def make_divisions(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n // i)
    return divisors

A, B = map(int, input().split())
num = gcd(A, B)

arr = make_divisions(num)
arr.sort()

ans = [arr[0]]
for i in range(1, len(arr)):
    if gcd(ans[i-1], arr[i]) == 1:
        ans.append(arr[i])

print(len(ans))

### FIXED CODE ###

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

A, B = map(int, input().split())

prime_A = set(prime_factorize(A))
prime_B = set(prime_factorize(B))
ans = len(prime_A & prime_B) + 1

print(ans)
import sys
input = lambda: sys.stdin.readline().rstrip()

n, q = map(int, input().split())
y = [[] for _ in range(2*10**5)] # i番目の幼稚園の(-rate, 幼児) #heap
data = [(0, 0)]*n # i番目の(rate, 所属) #list
import heapq
for i in range(n):
    a, b = map(int, input().split())
    data[i] = (a, b - 1)
    heapq.heappush(y[b - 1], (-a, i))
max_rate = [] # (rate, 幼児, 所属) #heap
max_rate_list = [()]*(2*10**5) #list
for i in range(2*10**5):
    if y[i]:
        s, t = heapq.heappop(y[i])
        heapq.heappush(max_rate, (-s, t, i))
        heapq.heappush(y[i], (s, t))
        max_rate_list[i] = (-s, t)
from collections import defaultdict
ng_num = defaultdict(set)
for _ in range(q):
    c, d = map(int, input().split())
    c -= 1
    d -= 1
    a, b = data[c]
    data[c] = (a, d)
    heapq.heappush(y[d], (-a, c))
    ng_num[b].add(c)
    if c in ng_num[d]:
        ng_num[d].discard(c)
    #print(ng_num)
    while y[b]:
        s, t = heapq.heappop(y[b])
        if t not in ng_num[b]:
            heapq.heappush(max_rate, (-s, t, b))
            heapq.heappush(y[b], (s, t))
            max_rate_list[b] = (-s, t)
            break
    while y[d]:
        s, t = heapq.heappop(y[d])
        if t not in ng_num[d]:
            heapq.heappush(max_rate, (-s, t, d))
            heapq.heappush(y[d], (s, t))
            max_rate_list[d] = (-s, t)
            break
    #print(max_rate)
    while max_rate:
        s, t, r = heapq.heappop(max_rate)
        if t not in ng_num[r] and (s, t) == max_rate_list[r]:#heapqの弱点(不要になった要素を楽に抜くことができない)をリストでカバーしている
            print(s)
            heapq.heappush(max_rate, (s, t, r))
            break
#popしてその要素を戻すという操作でキューの利便性は上がるということに注意
#どの情報を持てばいいのかをしっかり考えたい


### FIXED CODE ###

#float型を許すな
#numpyはpythonで
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi,factorial
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def SI(): return input().rstrip()
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7

lis=LI()
for i in range(5):
    if lis[i]==0:
        print(i+1)
w=sorted(input())
total=False
for i in range(0,len(w),2):
    if w[i]!=w[i+1]:
        print("No")
        total=True
        break
if total==False:
    print("Yes")

### FIXED CODE ###

w=sorted(input())
total=False
if len(w)==1:
    total=True
    print("No")
else:
    for i in range(0,len(w),2):
        if w[i]!=w[i+1]:
            print("No")
            total=True
            break
if total==False:
    print("Yes")
n = int(raw_input())

d = [99999 for i in range(n)]
G = [0 for i in range(n)]
M = [[0 for i in range(n)] for j in range(n)]
g = [0 for i in range(n)]
temp_d = [0]

def BFS_visit(s, temp_d):
    if temp_d == 99999:
        temp_d = 0
    if d[s] > temp_d:
        d[s] = temp_d
    temp_d += 1
    for e in range(1, n):
        if M[s][e] == 1 and s != e:
            BFS_visit(e, temp_d)

def BFS():
    s = 0
    BFS_visit(0, d[s])
    for s in range(n):
        if d[s] == 99999:
            d[s] = -1
    for s in range(n):
        print'{0} {1}'.format(s+1, d[s])

for i in range(n):
    G = map(int, raw_input().split())
    for j in range(G[1]):
        M[G[0]-1][G[2+j]-1] = 1
    g[i] = G[1]
BFS()

### FIXED CODE ###

n = int(raw_input())
 
d = [99999 for i in range(n)]
G = [0 for i in range(n)]
M = [[0 for i in range(n)] for j in range(n)]
 
def BFS(s):
    for e in range(n):
        if M[s][e] == 1:
            if d[e] > d[s] + 1:
                d[e] = d[s]+1
                BFS(e)
 
for i in range(n):
    G = map(int, raw_input().split())
    for j in range(G[1]):
        M[G[0]-1][G[2+j]-1] = 1
 
d[0] = 0
for s in range(n):
        BFS(s)
for s in range(n):
    if d[s] == 99999:
        d[s] = -1
for s in range(n):
    print'{0} {1}'.format(s+1, d[s])
import math

n,k=map(int,input().split())
if k%2!=0:
  nums=math.ceil(n/k)
  print(nums*3)
 
else:
  nums1=math.ceil(2*n/k)
  if nums1%2==0:
    a=int(nums1/2)
    b=nums1-a
    print(a**3+b**3)
    
    
  elif nums1%2!=0:
    a=int((num-1)/2)
    b=nums1-a
    print(a**3+b**3)
      
  

### FIXED CODE ###

import math

n,k=map(int,input().split())
if k%2!=0:
    nums=math.floor(n/k)
    print(nums**3)
 
else:
    nums1=math.floor(2*n/k)

    if nums1%2==0:
        a=int(nums1/2)
        b=nums1-a
        print(a**3+b**3)
    
    
    if nums1%2!=0:
        a=int((nums1+1)/2)
        b=nums1-a
        print(a**3+b**3)
#!/usr/bin/env python3
import sys
from math import *
from itertools import *
from collections import *
from functools import *
try:
    from math import gcd
except Exception:
    from fractions import gcd
readInt = lambda: int(sys.stdin.readline())
readIntN = lambda: [int(v) for v in sys.stdin.readline().split(' ')]



def main():
    n = readInt()
    result = 'Hello World'
    if n == 2
        a = readInt()
        b = readInt()
        result = a + b
    print(result)

if __name__ == '__main__':
    main()


### FIXED CODE ###

#!/usr/bin/env python3
import sys
from math import *
from itertools import *
from collections import *
from functools import *
try:
    from math import gcd
except Exception:
    from fractions import gcd
readInt = lambda: int(sys.stdin.readline())
readIntN = lambda: [int(v) for v in sys.stdin.readline().split(' ')]



def main():
    n = readInt()
    result = 'Hello World'
    if n == 2:
        a = readInt()
        b = readInt()
        result = a + b
    print(result)

if __name__ == '__main__':
    main()
N,K = map(int, input().split())
A = [int(a) for a in input().split()]

L = sorted(A)
while True:
    s = set()
    for i in range(len(L)-1):
        s.add(L[i+1]-L[i])
    L = list(s)
    L.sort()
    if L[0] == 1 or len(L) == 1:
        break

if K > max(A):
    ans = "IMPOSSIBLE"
elif K in A or L[0] == 1:
    ans = "POSSIBLE"
else:
    ans = "IMPOSSIBLE"
    for a in A:
        if a-K < 0:
            continue
        if (a-K)%L[0] == 0:
            ans = "POSSIBLE"
            break

print(ans)

### FIXED CODE ###

N,K = map(int, input().split())
A = [int(a) for a in input().split()]

L = sorted(A)
while N > 1:
    s = set()
    for i in range(len(L)-1):
        s.add(L[i+1]-L[i])
    L = list(s)
    L.sort()
    if L[0] == 1 or len(L) == 1:
        break

if K > max(A):
    ans = "IMPOSSIBLE"
elif K in A or L[0] == 1:
    ans = "POSSIBLE"
else:
    ans = "IMPOSSIBLE"
    for a in A:
        if a-K < 0:
            continue
        if (a-K)%L[0] == 0:
            ans = "POSSIBLE"
            break

print(ans)
x, a = list(input())
print('100'[x >= a::2])


### FIXED CODE ###

x, a = map(int, input().split())
print(int('100'[x < a::2]))
N,MA,MB=map(int,input().split())
S=[list(map(int,input().split())) for i in range(N)]

DPLIST=[[10**6 for i in range(401)] for j in range(401)]
DPLIST[0][0]=0

for a,b,c in S:
    for i in range(400,a-1,-1):
        for j in range(400,b-1,-1):
            if DPLIST[i][j]>DPLIST[i-a][j-b]+c:
                DPLIST[i][j]=DPLIST[i-a][j-b]+c
                
ANS=10**6
for k in range(1,400//max(i,j)):
    if DPLIST[MA*k][MB*k]<ANS:
        ANS=DPLIST[MA*k][MB*k]

if ANS==10**6:
    print(-1)
else:
    print(ANS)

### FIXED CODE ###

N,MA,MB=map(int,input().split())
S=[list(map(int,input().split())) for i in range(N)]

DPLIST=[[10**6 for i in range(401)] for j in range(401)]
DPLIST[0][0]=0

for a,b,c in S:
    for i in range(400,a-1,-1):
        for j in range(400,b-1,-1):
            if DPLIST[i][j]>DPLIST[i-a][j-b]+c:
                DPLIST[i][j]=DPLIST[i-a][j-b]+c
                
ANS=10**6
for k in range(1,400//max(MA,MB)):
    if DPLIST[MA*k][MB*k]<ANS:
        ANS=DPLIST[MA*k][MB*k]

if ANS==10**6:
    print(-1)
else:
    print(ANS)
N = int(input())
for h in range(1, 3501):
    for w in range(1, 3501):
        u = 4*h*w-N*w-N*h
        d = N*h*w
        if d % u == 0:
            print(h, w, d//u)
            exit()


### FIXED CODE ###

M = 3501
N = int(input())
for h in range(1, M):
    for w in range(1, M):
        u = 4*h*w-N*w-N*h
        d = N*h*w
        if u <= 0:
            continue
        if d % u == 0:
            print(h, w, d//u)
            exit()
#!/usr/bin/env python3
# Generated by https://github.com/kyuridenamida/atcoder-tools
from typing import *
import collections
import functools as fts
import itertools as its
import math
import sys
import numpy as np

INF = float('inf')


def solve(N: int, x: "List[int]", y: "List[int]"):
    def distance(x1, y1, x2, y2):
        return np.linalg.norm(np.array([x1, y1]) - np.array([x2, y2]))

    l = [[distance(x[i], y[i], x[j], y[j]) if j >
          i else 0 for j in range(N)] for i in range(N - 1)]

    return np.average([sum(l[r[i]][r[i+1]] if r[i] < r[i+1] else l[r[i+1]][r[i]] for i in range(N-1))
                       for r in its.permutations(range(N))])


def main():

    sys.setrecursionlimit(10 ** 6)

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    x = [int()] * (N)  # type: "List[int]"
    y = [int()] * (N)  # type: "List[int]"
    for i in range(N):
        x[i] = int(next(tokens))
        y[i] = int(next(tokens))
    print(f'{solve(N, x, y)}')


if __name__ == '__main__':
    main()


### FIXED CODE ###

#!/usr/bin/env python3
# Generated by https://github.com/kyuridenamida/atcoder-tools
from typing import *
import collections
import functools as fts
import itertools as its
import math
import sys
import numpy as np

INF = float('inf')


def solve(N: int, x: "List[int]", y: "List[int]"):
    def distance(x1, y1, x2, y2):
        return np.linalg.norm(np.array([x1, y1]) - np.array([x2, y2]))

    l = [[distance(x[i], y[i], x[j], y[j]) if j >
          i else 0 for j in range(N)] for i in range(N - 1)]

    return np.average([sum(l[r[i]][r[i+1]] if r[i] < r[i+1] else l[r[i+1]][r[i]] for i in range(N-1))
                       for r in its.permutations(range(N))])


def main():

    sys.setrecursionlimit(10 ** 6)

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    x = [int()] * (N)  # type: "List[int]"
    y = [int()] * (N)  # type: "List[int]"
    for i in range(N):
        x[i] = int(next(tokens))
        y[i] = int(next(tokens))
    print(f'{solve(N, x, y)}')


if __name__ == '__main__':
    main()
from collections import defaultdict
import heapq

 
class Dijkstra():
    def __init__(self):
        self.e = defaultdict(list)
 
    def add(self, u, v, d, directed=False):
        if directed is False:
            self.e[u].append([v, d])
            self.e[v].append([u, d])
        else:
            self.e[u].append([v, d])
 
    def delete(self, u, v):
        self.e[u] = [_ for _ in self.e[u] if _[0] != v]
        self.e[v] = [_ for _ in self.e[v] if _[0] != u]
 
    def Dijkstra_search(self, s):
        d = defaultdict(lambda: float('inf'))
        d[s] = 0
        q = []
        heapq.heappush(q, (0, s))
        v = defaultdict(bool)
        while len(q):
            k, u = heapq.heappop(q)
            if v[u]:
                continue
 
            for uv, ud in self.e[u]:
                if v[uv]:
                    continue
                vd = k + ud
                if d[uv] > vd:
                    d[uv] = vd
                    heapq.heappush(q, (vd, uv))
 
        return d


N, M, S, T = map(int, input().split())
UVAB = [list(map(int, input().split())) for i in range(M)]
graph1 = Dijkstra()
graph2 = Dijkstra()
 
for u, v, a, b in UVAB:
    graph1.add(u, v, a)
    graph2.add(u, v, b)

result_a = graph1.search(S)
result_b = graph2.search(T)
 
ans_list = [float('inf')]
 
for i in range(N, 0, -1):
    cur = result_a[i] + result_b[i]
    if cur > ans_list[-1]:
        cur = ans_list[-1]
    ans_list.append(cur)

for i in range(len(ans_list[1:])):
    print(10**15 - ans_list[-(i+1)])

### FIXED CODE ###

from collections import defaultdict
from heapq import heappop, heappush
import sys
input = sys.stdin.readline


class Dijkstra:
    def __init__(self):
        self.edge = defaultdict(list)

    def add(self, u, v, d):
        self.edge[u].append([v, d])
        self.edge[v].append([u, d])

    def search(self, start):
        distance = defaultdict(lambda: float("inf"))
        distance[start] = 0
        queue = []
        heappush(queue, (0, start))
        seen = set()
        while queue:
            k, u = heappop(queue)
            if u in seen:
                continue
            seen.add(u)

            for v, d in self.edge[u]:
                if v in seen:
                    continue
                new_d = k + d
                if distance[v] > new_d:
                    distance[v] = new_d
                    heappush(queue, (new_d, v))
        return distance


n, m, s, t = map(int, input().split())
uvab = [list(map(int, input().split())) for _ in range(m)]
graph1 = Dijkstra()
graph2 = Dijkstra()

for u, v, a, b in uvab:
    graph1.add(u, v, a)
    graph2.add(u, v, b)

result_a = graph1.search(s)
result_b = graph2.search(t)
ans_list = [float('inf')]

for i in range(n, 0, -1):
    cur = result_a[i] + result_b[i]
    if cur > ans_list[-1]:
        cur = ans_list[-1]
    ans_list.append(cur)

for ans in ans_list[n:0:-1]:
    print(10 ** 15 - ans)