Harryxun/stf_run huggingface dataset:
# C - Typical Stairs

MOD = (10 ** 9) + 7
INF = float('inf')
N, M = map(int, input().split())
A = [int(input()) for _ in range(M)]
dp = [INF] * (N + 1)

def f(i):
    if dp[i] != INF:
        return dp[i]
    else:
        if i in A:
            dp[i] = 0
        elif i < 2:
            dp[i] = 1
        else:
            dp[i] = (f(i - 1) + f(i - 2)) % MOD
        return dp[i]

print(f(N))


### FIXED CODE ###

# C - Typical Stairs

MOD = (10 ** 9) + 7
N, M = map(int, input().split())
A = [False] * (N + 1)
for _ in range(M):
    A[int(input())] = True
dp = [0] * (N + 1)
dp[0] = 1
if A[1] == False:
    dp[1] = 1

for i in range(2, N + 1):
    if A[i] == True:
        dp[i] = 0
    else:
        dp[i] = (dp[i - 1] + dp[i - 2]) % MOD

print(dp[N])
n, k = map(int, input().split())
h = sorted([int(input()) for _ in range(n)])
print(min(h[k + i - 1]-h[i] for i in range(n - k + 1)))


### FIXED CODE ###

print("Christmas" + " Eve" * (25 - int(input())))
s=input()
k=int(input())
if k<=len(s):
  if len(set(s[:k]))==1 and s[0]=="1":
    print(1)
    exit(0)
print(s[1])

### FIXED CODE ###

s=input()
k=int(input())
if k<=len(s):
  if len(set(s[:k]))==1 and s[0]=="1":
    print(1)
    exit(0)
ans="1"
for c in s:
  if c!="1":
    ans=c
    break
print(ans)
n = input()
lst = list(map(int,input().split()))
ans = 0
for i in range (n - 2):
  for j in range (i + 1, n - 1):
    for k in range (j + 1, n):
      lst2 = [lst[i], lst[j], lst[k]]
      lst3 = sorted(lst2)
      if(lst3[2] < lst3[1] + lst3[0]):
        ans = ans + 1
print(ans)

### FIXED CODE ###

n = int(input())
lst = list(map(int,input().split()))
ans = 0
for i in range (n - 2):
  for j in range (i + 1, n - 1):
    for k in range (j + 1, n):
      lst2 = [lst[i], lst[j], lst[k]]
      if (lst2[0] != lst2[1] and lst2[0] != lst2[2] and lst2[1] != lst2[2]):
        if (lst2[0] < lst2[1] + lst2[2] and lst2[1] < lst2[0] + lst2[2] and lst2[2] < lst2[0] + lst2[1]):
          ans = ans + 1
print(ans)
import sys


def input():
    return sys.stdin.readline()[:-1]

# N = int(input())
# A = [int(x) for x in input().split()]
# a, b, c = map(int, input().split())
# name1 = str(input())
# alph = {"A": 1, "B": 2, "C": 3, "D": 4, "E": 5}
# b = list(map(lambda x: math.ceil(x/10)*10, a))


n = int(input())
ans = 0
for _ in range(n):
    x, u == map(str, input().split())
    if u == "JPY":
        ans += int(x)
    else:
        ans += int(x)*380000.0
print(ans)


### FIXED CODE ###

import sys


def input():
    return sys.stdin.readline()[:-1]

# N = int(input())
# A = [int(x) for x in input().split()]
# a, b, c = map(int, input().split())
# name1 = str(input())
# alph = {"A": 1, "B": 2, "C": 3, "D": 4, "E": 5}
# b = list(map(lambda x: math.ceil(x/10)*10, a))


N = int(input())

sum = 0
for _ in range(N):
    x, u = input().split()
    if u == 'JPY':
        sum += float(x)
    else:
        sum += float(x) * 380000.0

print(sum)
x, y = [int(i) for i in input().split()]

if x < y:
    a = x
    x = y
    y = a

for i in range(int(x%y/2)):
    if (x%y)% (i+1) == 0 and y%(i+1) == 0:
        kouyakusu = i+1

print(kouyakusu)

### FIXED CODE ###

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

if x < y:
    a = x
    x = y
    y = a

def kouyakusu(x,y):
    yakusu = x % y
    if yakusu == 0:
        print(y)
        return y
    else:
        kouyakusu(y,yakusu)

max_kouyakusu = kouyakusu(x,y)
import math
K = int(input())
A = [int(_) for _ in input().split()]
l = r = 2
'''
if x children form groups consisting of y children each
 then z children are left
=> z=y*(x//y)
=> y*(math.ceil(z/y))<=x<y*(math.floor(z/y)+1)
'''
#necessary conditions
for a in A[::-1]:
    l = a * math.ceil(l / a)
    r = a * (math.floor(r / a) + 1) - 1
#sufficient conditions
for x in [l, r]:
    for a in A:
        x = a * (x // a)
    if x != 2:
        print(-1)
        exit()
print(l, r)


### FIXED CODE ###

N, A, B = [int(_) for _ in input().split()]
if (B - A) % 2:
    print('Borys')
else:
    print('Alice')
A,P = map(int,input.split())

P += 3*A
print(P//2)

### FIXED CODE ###

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

P += 3*A
print(P//2)
print('{}'.fotmat(int(input())//3))


### FIXED CODE ###

print('{}'.format(int(input())//3))
while True:
    n=raw_input()
    m=input()
    if n in "0":break
    S,L=set(),[]
    for i in range(m):
        a,b=map(int,raw_input().split())
        if a==1:
            S.add(b)
        elif b==1:
            S.add(a)
        else:
            L.append((a,b))
    for i in S:
        for s in L:
            if i in s:
                S=S.union(s)
    print len(S)

### FIXED CODE ###

while True:
    n=raw_input()
    if n in "0":break
    try:
        m=input()
    except SyntaxError:
        break
    S,L=set(),[]
    for i in range(m):
        a,b=map(int,raw_input().split())
        if a==1:
            S.add(b)
        elif b==1:
            S.add(a)
        else:
            L.append((a,b))
    for i in S:
        for s in L:
            if i in s:
                S=S.union(s)
    print len(S)
import sys
input = sys.stdin.buffer.readline
 
def main():
    t,b,c,d = map(int,input().split())
    MOD = 10**9+7
    N = c+d+5
    fac = [0 for _ in range(N+1)]
    fac[0],fac[1] = 1,1
 
    for i in range(2,N+1):
        fac[i] = (fac[i-1]*i)%MOD
        
    def comb(x,y):
        return (fac[x+y]*pow(fac[x],MOD-2,MOD)*pow(fac[y],MOD-2,MOD))%MOD
 
    print((comb(c+1,d+1)-comb(c+1,b)-comb(d+1,t)+comb(t,b))%MOD)
    
if _name_ == "_main_":
    main()
#print the result
#calling the main function

### FIXED CODE ###

import sys
input = sys.stdin.buffer.readline
 
def main():
    a,b,p,d = map(int,input().split())
    MOD = 10**9+7
    N = p+d+5
    fac = [0 for _ in range(N+1)]
    fac[0],fac[1] = 1,1
 
    for i in range(2,N+1):
        fac[i] = (fac[i-1]*i)%MOD
        
    def comb(x,y):
        return (fac[x+y]*pow(fac[x],MOD-2,MOD)*pow(fac[y],MOD-2,MOD))%MOD
 
    print((comb(p+1,d+1)-comb(p+1,b)-comb(d+1,a)+comb(a,b))%MOD)
    
if __name__ == "__main__":
    main()
#!/usr/bin/python
# -*- coding: utf-8 -*-

import sys

# x: 2 -> 0
def res_ans(sum, num_list, x, num, k):
  if x==0:
    if sum==k:
      print num_list[0] + " " + num_list[1] + " " + num_list[2]
    return
  for i in range(num):
    num_list.append(i)
    sum += i
    res_ans(sum, num_list, x-1, i)
    num_list.pop()
    sum -= i

# 1 ~ n から３つ選んでkにする
while(1):
  n_k = str(raw_input()).split(" ")  

  n = n_k[0]
  k = n_k[1]
  num_list = []
  sum = 0
  if n == 0 and k == 0:
    sys.exit()
  for i in range(n):
    res_ans(sum, num_list, 2, n, k)
  
sys.exit()

### FIXED CODE ###

while True:
  n, x = map(int, raw_input().split())
  if n + x == 0: break
  ans = 0
  for i in range(1, n+1):
    tmp_ans = []
    tmp_ans.append(i)
    for j in range(1, n+1):
      if j not in tmp_ans and i < j: 
        tmp_ans.append(j)
        for h in range(1, n+1):
          if h not in tmp_ans and j < h: 
            tmp_ans.append(h)
            if sum(tmp_ans) == x: ans+= 1
            tmp_ans.remove(h)
        tmp_ans.remove(j)
    tmp_ans.remove(i)
  
  print ans
import sys

sys.setrecursionlimit(3000)
n, k = map(int, input().split())
pos = [int(i) for i in input().split()]
score = [int(i) for i in input().split()]
if max(score) <= 0:
  print(max(score))
else:
  pos = [0] + pos
  score = [0] + score
  max_point = -10 ** 11
  s_l = [[0]]
  nei = {}
  dic = {}
  loop = 0
  for i in range(1, n + 1):
    f_pos = i
    #print('f_pos',f_pos)
    if f_pos not in nei:
      points = [0]
      count = 0
      loop += 1
      while True:
        n_pos = pos[f_pos]
        points.append(points[-1] + score[n_pos])
        count += 1
        nei[f_pos] = [count, loop]
        if n_pos in nei:
          dic[loop] = count
          break
        f_pos = n_pos
      #print(nei)
      s_l.append(points)
      count = 1
    else:
      loop = nei[f_pos][1]
      count = nei[f_pos][0]
      points = s_l[loop]
    #print(points)
    #print(count)
    loop_num = dic[loop]
    s = points[count - 1]
    m = points[loop_num] - s
    a = k // loop_num
    b = k % loop_num
    if points[loop_num] > 0:
      point = points[loop_num] * a
      if point > max_point and a != 0:
        max_point = point
    else:
      point = 0
      if a > 0:
        b = loop_num
    #print(point)
    if b > 0:
      t_max = -10 ** 11
      if loop_num - count + 1 >= b:
        for j in range(b):
          t = points[j + count] - s
          #print(t)
          if t > t_max:
            t_max = t
      else:
        for j in range(count, loop_num + 1):
          t = points[j] - s
          #print(t)
          if t > t_max:
            t_max = t
        for j in range(1, b - loop_num + count):
          t = points[j] + m
          #print(t)
          if t > t_max:
            t_max = t
      point += t_max
    #print(point)
    if point > max_point:
      max_point = point
  print(max_point)


### FIXED CODE ###

n, k = map(int, input().split())
positions = [int(i) for i in input().split()]
scores = [int(i) for i in input().split()]
if max(scores) <= 0:
  print(max(scores))
else:
  positions = [0] + positions
  scores = [0] + scores
  max_point = -pow(10, 9)
  #print(max_point)
  for i in range(1, n + 1):
    s = []
    f_pos = positions[i]
    score = scores[f_pos]
    s.append(score)
    while f_pos != i:
      f_pos = positions[f_pos]
      score += scores[f_pos]
      s.append(score)
    loop = len(s)
    if loop >= k:
      point = max(s[:k])
    elif s[-1] <= 0:
      point = max(s)
    else:
      loop_c = k // loop
      r = k % loop
      point1 = s[-1] * loop_c
      if r != 0:
        point1 += max(s[:r])
      point2 = s[-1] * (loop_c - 1)
      point2 += max(0, max(s))
      point = max(point1, point2)
    max_point = max(max_point, point)
  print(max_point)
a=[]
b=1000
n,t=map(int,input().split(" "))
for _ in range(n+1):
    a.append(tuple(map(int,input().split(" "))))
for i in range(n+1):
    if t>=a[i][1]:
        if b>a[i][0]:
            b=a[i][0]
if b !=1000:
    print(b)
else:
    print("TLE")

### FIXED CODE ###

a=[]
b=1001
n,t=map(int,input().split(" "))
for _ in range(n):
    a.append(tuple(map(int,input().split(" "))))
for i in range(n):
    if t>=a[i][1]:
        if b>a[i][0]:
            b=a[i][0]
if b !=1001:
    print(b)
else:
    print("TLE")
from itertools import *
*x,=map(int,input().split())
K=int(input())
for i in product(range(K), repeat=K):
    a = x.copy()
    for j in i:
        a[j] *= 2
        if a[0] < a[1] and a[1] < a[2]: 
            print('Yes')
            exit()
else:
    print('No')

### FIXED CODE ###

from itertools import * 
*x,=map(int,input().split())
K=int(input())
c = combinations_with_replacement(range(3), K)
a=x.copy()
ans=0
for i in c:
    a=x.copy()
    for j in i:
        a[j] = a[j] * 2
        if a[0] < a[1] and a[1] < a[2]: 
            ans=1
if ans==1: 
    print('Yes')
else:
    print('No')
a = X / 500
b = X % 500
c = b / 5
    
print(a * 1000 + c * 5)

### FIXED CODE ###

X = int(input())

a = int(X / 500)
b = X % 500
c = int(b / 5)
print(a * 1000 + c * 5)
import numpy as np

n,k = map(int,input().split())
p_list = np.fromstring(input(), np.int64, sep=' ')

Cumulative_sum = np.zeros(n+1, np.int64)
Cumulative_sum[1:] = p_list.cumsum()

length_k_sum_list = Cumulative_sum[k:] - Cumulative_sum[0:-k]

ans = (length_k_sum.max() + k) / 2

print(ans)


### FIXED CODE ###

import sys
import numpy as np

val = np.fromstring(sys.stdin.buffer.read(), np.int64, sep=' ')
n,k = val[:2]
p_list = val[2:]

S = np.zeros(n+1, np.int64)
S[1:] = p_list.cumsum()

KS = S[k:] - S[0:-k]
print((KS.max()+k)/2)
n,m = list(map(int, input().split()))
a=list(map(int, input().split()))
a.sorted()
d=[a[i+1]-a[i] for i in range(n-1)]
d.sorted()
print(sum(d[:m-n]) if m>n else 0)

### FIXED CODE ###

n,m = list(map(int, input().split()))
a=list(map(int, input().split()))
a.sort()
d=[a[i+1]-a[i] for i in range(m-1)]
d.sort()
print(sum(d[:m-n]) if m>n else 0)
left, right = map(int, input().split())
imod = []
jmod = []

for i in range(left, right):
    imod.append(i % 2019)

for i in range(imod.index(min(imod))+1, len(imod)):
    jmod.append(imod[i])

print((min(imod) + min(jmod)) % 2019)


### FIXED CODE ###

left, right = map(int, input().split())
mod = []
if right - left > 2019:
    print(0)
    exit()
else:
    for i in range(left, right):
        for j in range(left+1, right+1):
            mod.append(i*j%2019)
print(min(mod))
a,b,c,d=map(int,input())
if a<=c<=b:
  if b<d:
    print(b-c)
  else:
    print(d-c):
elif c<=a<=d:
  if b<d:
    print(b-a)
  else:
    print(d-a):  
else:
  print(0)

### FIXED CODE ###

a,b,c,d=map(int,input().split())
if a<=c<=b:
  if b<d:
    print(b-c)
  else:
    print(d-c)
elif c<=a<=d:
  if b<d:
    print(b-a)
  else:
    print(d-a)
else:
  print(0)
k = int(input())
x = int(input())

if k*500 > x:
    print("Yes")
else:
    print("No")

### FIXED CODE ###

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

if k*500 >= x:
    print("Yes")
else:
    print("No")
s,t = map(str,input());print(t+s)

### FIXED CODE ###

s,t = map(str,input().split());print(t+s)
n,q=map(int,input().split())

tree = [[] for _ in range(n)]
ope = [0]*n
opef=[False]*n
ret=[0]*n

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

def counter(target,num):
    global ret
    global ope
    global opef
    ret[target]+=num
    if not tree[target]:
        return
    for i in tree[target]:
        tmp=0
        if opef[i]==False:
            tmp=ope[i]
            opef[i]=True
        counter(i,num+tmp)

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

for i in range(n):
    if opef[i]==False:
        opef[i]=True
        counter(i,ope[i])

print(*ret)

### FIXED CODE ###

n,q = map(int,input().split())
rl = [0] * n
al = [0] * n
for i in range(n-1):
    a,b = map(int,input().split())
    rl[b-1] = a -1
for j in range(q):
    p,x = map(int,input().split())
    al[p-1] += x
for k in range(1,n):
    al[k] += al[rl[k]]
print(*al)
import queue


h,w=map(int,input().split())

m=[input() for i in range(w)]

q=queue.Queue()


cnt=[[100000000 for i in range(h)] for j in range(w)]

if m[0][0]=="#":
    cnt[0][0]=1
else:
    cnt[0][0]=0

q.put([1,1])

c=[1,1]#[w,h]
while c!=[w,h]:
    c=q.get()
    if c[0]+1<=w:
        q.put([c[0]+1,c[1]])
        if m[c[0]][c[1]-1]=="#":
            cnt[c[0]][c[1]-1]=min(cnt[c[0]][c[1]-1],cnt[c[0]-1][c[1]-1]+1)
        else:
            cnt[c[0]][c[1]-1]=min(cnt[c[0]][c[1]-1],cnt[c[0]-1][c[1]-1])
    if c[1]+1<=h:
        q.put([c[0],c[1]+1])
        if m[c[0]-1][c[1]]=="#":
            cnt[c[0]-1][c[1]]=min(cnt[c[0]-1][c[1]],cnt[c[0]-1][c[1]-1]+1)
        else:
            cnt[c[0]-1][c[1]]=min(cnt[c[0]-1][c[1]],cnt[c[0]-1][c[1]-1])

print(cnt[w-1][h-1])

### FIXED CODE ###

h,w=map(int,input().split())

m=[input() for i in range(h)]


cnt=[[1000000 for i in range(w)] for j in range(h)]

if m[0][0]=="#":
    cnt[0][0]=1
else:
    cnt[0][0]=0

for y in range(h):
    for x in range(w):
        if x>0:
            if m[y][x-1]=="." and m[y][x]=="#":
                cnt[y][x]=min(cnt[y][x],cnt[y][x-1]+1)
            else:
                cnt[y][x]=min(cnt[y][x],cnt[y][x-1])
        if y>0:
            if m[y-1][x]=="." and m[y][x]=="#":
                cnt[y][x]=min(cnt[y][x],cnt[y-1][x]+1)
            else:
                cnt[y][x]=min(cnt[y][x],cnt[y-1][x])


print(cnt[h-1][w-1])
if N==M:
  print 'Yes'
else:
  print 'No'

### FIXED CODE ###

a=raw_input()
m=a.split()
N,M=map(int,m)
if N==M:
  print 'Yes'
else:
  print 'No'
n, m = map(int, input().split())
l = [list(map(int, input().split())) for i in range(m)]
ans = [9283749384736]*n

if m == 0:
    print(-1)
    exit()


for i in l:
    if i[0] == 1 and i[1] == 0:
        continue
    if ans[i[0]-1] >= i[1]:
        ans[i[0]-1] = i[1]

for i in range(n):
    if ans[i] == 9283749384736:
        ans[i] = 0

s = int("".join(list(map(str, ans))))
if len(str(s)) == n:
    print(s)
else:
    print(-1)



### FIXED CODE ###

n = int(input())
ans = 0
a = 0
for i in range(1, n+1):
    if ans % 2 == 0:
        a += 1
    ans += 1

print(a)
n,m = map(int, input().split())
an = list(map(int, input().split()))
sum_a = sum(an)
if an - sum_a < 0:
    print(-1)
else:
    print(an-sum_a)

### FIXED CODE ###

n,m = map(int, input().split())
an = list(map(int, input().split()))
sum_a = sum(an)
if n - sum_a < 0:
    print(-1)
else:
    print(n-sum_a)
if __name__ == '__main__':
while True:
    H,W = map(int,input().split())
    if H == W == 0:
        break
    for i in range(1, H):
        if i == 1:
            print("#"*W)
        elif i == H:
            print("#"*W)
        else:
            print("#","."*(W-2),"#")
    print()


### FIXED CODE ###

while True:
    H,W = map(int,input().split())
    
    if H == W == 0:
        break
    
    for i in range(H):
        if i == 0 or i == H-1:
            print('#' * W)
        else:
            print('#','.'*(W-2),'#',sep='')
    print('')
import sys

def load(vtype=int):
    return vtype(input().strip())


def load_list(seplator=" ", vtype=int):
    return [vtype(v) for v in input().strip().split(seplator)]

A, B, M = tuple(load_list())

a = load_list()
b = load_list()

coupon = dict()
for _ in range(M):
    x, y, c = tuple(load_list())
    if (x, y) in coupon:
        coupon[(x,y)] = min(coupon[(x,y)], c)
    else:        
        coupon[(x-1, y-1)] = c 

minv = min(a) + min(b)

for key, value in coupon.items():
    i, j = key
    minv = min(minv, a[i] + b[i] - value)
print(minv)

### FIXED CODE ###

import sys

def load(vtype=int):
    return vtype(input().strip())


def load_list(seplator=" ", vtype=int):
    return [vtype(v) for v in input().strip().split(seplator)]

A, B, M = tuple(load_list())

a = load_list()
b = load_list()

coupon = dict()
for _ in range(0, M):
    x, y, c = tuple(load_list())
    if (x-1, y-1) in coupon:
        coupon[(x-1,y-1)] = max(coupon[(x-1,y-1)], c)
    else:        
        coupon[(x-1,y-1)] = c 

minv = min(a) + min(b)

for key in coupon.keys():
    i, j = key
    minv = min(minv, a[i] + b[j] - coupon[(i, j)])

print(minv)
x = int(input())
result = x **3
print(result

### FIXED CODE ###

x = int(input())
result = x ** 3
print(result)
n, r = map(int,input()split())
if (n >= 10):
  print(r)
else:
  sa = 100*(10 - n)
  print(r + sa)

### FIXED CODE ###

n, r = map(int,input().split())
if (n >= 10):
  print(r)
else:
  sa = 100*(10 - n)
  print(r + sa)
print(int(input())*int(input())//2)

### FIXED CODE ###

A, B, C = map(int, input().split())
print(A*B//2)
if __name__ == "__main__":
	N = int(input())
	List = list(map(int,input().split()))
	ido = 0
	ido_res = []
	i=0
	# print(List)
	for t in range(0,N-1):
		# print("t={}".format(t))
		while List[t+i] >= List[t+i+1]:
			# print(t,i,ido)
			ido += 1
			i += 1
			if t+i+1 > int(N)-1:
				break

		if ido==0:
			ido_res.append(0)
		else:
			ido_res.append(ido)
		t = ido
		ido = 0
		i = 0

	print(max(ido_res))

### FIXED CODE ###

def main():
	# n,k = map(int,input().split())
	n = int(input())
	# s = str(input())
	h = list(map(int,input().split()))
	# l = [list(map(int, input().split())) for _ in range(n)]
	# s = list(s)
	ans = 0
	dp = [0] * n
	if n == 1:
		print(0)
	elif n == 2:
		if h[0] >= h[1]:
			print(1)
		else:
			print(0)
	else:
		if h[0] >= h[1]:
			dp[0] = 1
		for i in range(1,n-1):
			if h[i] >= h[i+1]:
				dp[i] = dp[i-1] + 1
			else:
				dp[i] = 0
		print(max(dp))

	





if __name__ == '__main__':
	main()
#入力した整数が５、７、５であるならばTrueを返す
# int,int,int -> True 
x,y,z = int(input())

def check7(x,y,z):
    if x == 7:
        if y == z and y == 5 :
            print("YES")
        else:
            print("NO")
    elif y == 7:
        if x == z and x == 5:
            print("YES")
        else:
          print("NO")
    elif z == 7:
        if x == y and x == 5:
          print("YES")
        else:
          print("NO")
    else:
      print("NO")


### FIXED CODE ###

# -*- coding: utf-8 -*-

input_list = input().split()

cnt7 = 0
cnt5 = 0

for n in input_list:
    if int(n) == 7:
        cnt7 += 1
    elif int(n) == 5:
        cnt5 += 1
    else:
        continue
if cnt7 == 1 and cnt5 == 2:
    print("YES")
else:
    print("NO")
import collections
n = int(input())
a = list(map(int, input().split()))

c = collections.Counter(a)
v = list(c.values())
k = list(c.keys())

if n % 3 == 0 and v[0] == v[1] == v[2] and k[0] ^ k[1] == k[2]:
  print("Yes")
else:
  print("No")


### FIXED CODE ###

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

c = collections.Counter(a)
k = list(c.keys())
v = list(c.values())

if n % 3 == 0:
  if len(v) == 3:
    if v[0] == v[1] == v[2] and k[0] ^ k[1] == k[2]:
      print("Yes")
    else:
      print("No")
  elif len(v) == 2:
    if (k[0] == 0 and v[0] * 2 == v[1]) or (k[1] == 0 and v[1] * 2 == v[0]):
      print("Yes")
    else:
      print("No")
  elif len(v) == 1:
    if k[0] == 0:
      print("Yes")
    else:
      print("No")
  else:
    print("No")
elif len(v) == 1:
  if k[0] == 0:
    print("Yes")
  else:
    print("No")
else:
  print("No")
n, m=map(int, input().split())
a=[0 for i in range(m)]
b=[0 for i in range(m)]
g=[list() for i in range(1+n)]
#print(g)

root=[i for i in range(m)]
cnt_con=[1 for i in range(m)]

def parent(x):
    return root[x]
def connect(x,y):
    if root[x]==root[y]:
        0
    else:
        root[x]=root[y]
        cnt_con[root[y]]+=cnt_con[root[x]]
    return

for i in range(m):
    a[i], b[i]=map(int, input().split())
    a[i], b[i]=a[i]-1, b[i]-1

tmp=int(n*(n-1)/2)
ans=[0]*m
ans[-1]=tmp
ans[0]=0
#print('a,b=',a,b)
for i in range(m-1,0,-1):
    ans[i]=tmp
    if root[a[i]]==root[b[i]]:
        0
    else:
        tmp-=cnt_con[a[i]]*cnt_con[b[i]]
    connect(a[i],b[i])
    #print('i,tmp',i,tmp,root,cnt_con)
        
    
for i in range(m):
    print(ans[i])

### FIXED CODE ###

import sys
sys.setrecursionlimit(100000)

n, m=map(int, input().split())
a=[0 for i in range(m)]
b=[0 for i in range(m)]
g=[list() for i in range(1+n)]
#print(g)

par=[i for i in range(n)]
cnt_con=[1 for i in range(n)]

def root(x):
    if x==par[x]:
        return x
    else:
        par[x]=root(par[x])
        return par[x]
def connect(x,y):
    #par[x]=root(x)
    #par[y]=root(y)
    if root(x)==root(y):
        0
    else:
        cnt_con[root(y)]+=cnt_con[root(x)]
        par[root(x)]=root(y)      
    return

for i in range(m):
    a[i], b[i]=map(int, input().split())
    a[i], b[i]=a[i]-1, b[i]-1


tmp=int(n*(n-1)/2)
ans=[0]*m
ans[-1]=tmp
#ans[0]=0
#print('a,b=',a,b)
for i in range(m-1,-1,-1):
    ans[i]=tmp
    if root(a[i])==root(b[i]):
        0
    else:
        tmp-=cnt_con[root(a[i])]*cnt_con[root(b[i])]
    connect(a[i],b[i])
    #print('i,tmp',i,(a[i],b[i]),ans[i],tmp,par,cnt_con)
    

    
for i in range(m):
    print(ans[i])
s = raw_input().split()
A = s[0]
B = s[1]
C = s[2]
if A[len(A)]==B[0] && B[len(B)]==C[0]:
    print('YES')
else:
    print('NO')

### FIXED CODE ###

s = input().split()
A = s[0]
B = s[1]
C = s[2]
if A[len(A)-1]==B[0] and B[len(B)-1]==C[0]:
    print('YES')
else:
    print('NO')