Harryxun/stf_run huggingface dataset:
n = input()
digit = n % 10
if digit == "3":
  print ("bon")
elif digit == "0" or digit == "1" or digit == "6" or digit == "8":
  print ("pon")
else:
  print ("hon")


### FIXED CODE ###

ninput = input() #これはstr型
n = int(ninput) #これでint型に直す
digit = n % 10
if digit == 3:
  print('bon')
elif digit == 0 or digit == 1 or digit == 6 or digit == 8:
  print('pon')
else:
  print('hon')
if set(list(input()))==2:
  print('Yes')
else
  print('No')

### FIXED CODE ###

S = input()

if len(set(S)) == 2:
  print('Yes')
else:
  print('No')
import sys
input = sys.stdin.readline

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

# 展望台から行ける展望台の高さを格納しておく
from collections import defaultdict
d = defaultdict(int)
for i in range(M):
  A,B = list(map(int,input().split()))
  A -= 1
  B -= 1
  if d[A] < H[B]:
    d[A] = H[B]:
  if d[B] < H[A]:
    d[B] = H[A]
cnt = 0
for idx,h in enumerate(H):
  if d[idx] == 0 or h < d[idx]:
    cnt += 1
else:
  print(cnt)

### FIXED CODE ###

import sys
input = sys.stdin.readline

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

# 展望台から行ける展望台の高さを格納しておく
from collections import defaultdict
d = defaultdict(int)
for i in range(M):
  A,B = list(map(int,input().split()))
  A -= 1
  B -= 1
  if d[A] < H[B]:
    d[A] = H[B]
  if d[B] < H[A]:
    d[B] = H[A]
cnt = 0
for idx,h in enumerate(H):
  if d[idx] == 0 or h > d[idx]:
    cnt += 1
else:
  print(cnt)
import sympy

N = input()
Y = list(map(int,input().split(' ')))

symbols = []
for i in range(N):
    symbols.append(sympy.Symbol('x' + str(i)))

equation = []
for i in range(N):
    i1 = i
    i2 = i + 1 
    if i2 >= N:
        i2 = 0
    equation.append(0.5*symbols[i1] + 0.5*symbols[i2] - Y[i])

for i in range(N):
    print(str(int(sympy.solve(equation)[symbols[i]])) + " " , end="")
print()

### FIXED CODE ###

# -*- coding: utf-8 -*-
 
N = int(input())
A = list(map(int, input().split()))
s = sum(A)
r = [s - 2 * sum(A[1::2])]

for i in range(N-1):
    r.append(2 * A[i] - r[i])
    
r = map(str, r)
print(" ".join(r))

'''
5
3 8 7 5 5
'''
import math
N = int(input())
result = 0

root = math.ceil(math.sqrt(N))
for i in range(root):
    if N % i  == 0:
        result += N // i  - 1

print(result)

### FIXED CODE ###

import math
N = int(input())
result = 0

root = math.ceil(math.sqrt(N))
for i in range(root):
    if N % (i + 1) == 0 and (i + 1) + 1 < N // (i + 1):
        result += N // (i + 1) - 1

print(result)
r = input()
print '%f %f' % (2*math.pi*r, math.pi*r^2)

### FIXED CODE ###

import math
r = float(input())
print '%f %f' % (math.pi*r*r, 2*math.pi*r)
#input
import numpy as np
N, K = map(int, input().split())
A = np.array(list(map(int, input().split())))

#output
import math
A = np.sort(A)

def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

q = np.full(N, 0, np.int64)
for i in range(N-K+1):
    q[i] = cmb(N-i-1, N-K-i)

r = -q + q[-1::-1]

print((A*r).sum() % (10**9 + 7))

### FIXED CODE ###

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

#output
import math

A.sort()
mod = 10**9+7

n_ = 10**5 + 3
fun = [1]*(n_+1)
for i in range(1,n_+1):
    fun[i] = fun[i-1]*i%mod
rev = [1]*(n_+1)
rev[n_] = pow(fun[n_],mod-2,mod)
for i in range(n_-1,0,-1):
    rev[i] = rev[i+1]*(i+1)%mod
def cmb(n,r):
    if n <= 0 or r < 0 or r > n: return 0
    return fun[n]*rev[r]%mod*rev[n-r]%mod
#これだとTLE!
"""
def cmb(n, r):
    if n < r: return 0
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result
"""

M = 0
m = 0
for i, a in enumerate(A):
    M += cmb(i, K-1) * a
    m += cmb(N-i-1, K-1) * a
    M %= mod
    m %= mod

print((M-m) % mod)
a,b,c,d = input().split()
pirnt("Yes",if a==b==c or b==c==d else "No")

### FIXED CODE ###

abcd = list(input())
print("Yes") if abcd[2]==abcd[3]==abcd[1] or abcd[0]==abcd[1]==abcd[2] else print("No")
n=int(input())
s=input()
if n % 2:
  pirnt("No")
  exit()
  
half=n/2
print("Yes" if s[half:]+s[half:]==s else "No")

### FIXED CODE ###

n = int(input())
s = input()
if n % 2:
    print("No")
    exit()
half = s[0:n // 2]
print("Yes" if s == half + half else "No")
a = input()
d = 'Heisei'
if int(a[0:4]) ==2019:
  if int(a[5:7]) == 4:
    if int(a[8:10]) == 30:
      break
    elif int(a[8:10]) <30:
      d = 'TBD'
    else:
      break
  elif int(a[5:7]) <=3:
    d = 'TBD'
  else:
    break
elif int(a[0:4]) <= 2018:
  d = 'TBD'
else:
  break
print(d)

### FIXED CODE ###

a = input()
d = 'TBD'
if int(a[0:4]) ==2019:
  if int(a[5:7]) == 4:
    if int(a[8:10]) <=30:
      d = 'Heisei'
  elif int(a[5:7]) <=3:
    d = 'Heisei'
elif int(a[0:4]) <= 2018:
  d = 'Heisei'
print(d)
o = list(input())
e = list(input())
if len(o) > len(e):
  e.append("")

for i in range(o):
  print(o[i] + e[i], end='')

### FIXED CODE ###

o, e = [input().rstrip() for i in range(2)]
lst = []
for i in range(len(o)):
    print(o[i], end='')

    if i + 1 > len(e):
        print()
        break
    else:
        print(e[i], end='')
import numpy as np
N = int(input())
A = np.array(list(map(int, input().split())),dtype=np.int64)


A = np.array(list(map(int, input().split())),dtype=np.int64)
ans = np.prod(A)
if ans > 10**18:
    print(-1)
elif ans< 0:
    print(-1)
else:
    print(ans)

### FIXED CODE ###

N = int(input())
A = list(map(int, input().split()))
if 0 in A:
    print(0)
    exit()
lim = 10**18

ans = 1
for i in A:
    ans *= i
    if ans > lim:
        print(-1)
        exit()

else:
    if ans >10**18:
        print(-1)
    else:
        print(ans)
a,b = ma-(int,input().split())
print(a + (b//2))

### FIXED CODE ###

a,b = map(int,input().split())
print(a + (b//2))
a, b, t = map(int, imput().split())
total = 0
for _ in range(a, t+1, a):
    total += b
print(total)

### FIXED CODE ###

a, b, t = list(map(int, input().split()))
print(sum([b for _ in range(a, t+1, a)]))
import math
# a: 時
# b: 分
# 
a, b, h, m = map(int, input().split())


x = ( a**2　+　b**2　−　2 * a * b * math(int(360 / h) * 30) + int(360 / m) * 6 ) ** 0.5
print(x)


### FIXED CODE ###

import math
# a: 時
# b: 分
# 
a, b, h, m = map(int, input().split())

angle_h = h * 30 + m * 0.5
angle_m = m * 6

cos_ = math.cos( math.radians( abs( angle_h - angle_m ) ) )

x = ( a**2 + b**2 - 2*a*b*cos_ ) ** 0.5

print(x)
import sys


input = lambda: sys.stdin.readline()[:-1]
RI = lambda x=int: x(input())
RA = lambda x=int: map(x, input().split())
RSS = lambda: input().split()


def solve():
    ans = []
    for i in s:
        if i == "P":
            ans.append("P")
        else:
            ans.append("D")
    print("".join(ans))
    return



s = RS()
solve()

### FIXED CODE ###

print(input().replace("?", "D"))
import numpypy as np
words = lambda t : list(map(t, input().split()))



h,w = words(int)
wq = [0] * w

grid = []
for i in range(h):
    grid.append(list(input()))

ans = 0
for i in range(h):
    j = 0
    while j < w:
        #print(i,j, grid[i][j])
        if grid[i][j] == '#':
            wq[j] = 0
            j+=1
            continue
        k = 0
        while j+k < w:
            if grid[i][j+k] == '.':
                k += 1
            else:
                break
        #print(i,j,k)
        if k + h > ans:
            for x in range(j,j+k):
                vplus = 0
                if not wq[x] == 0:
                    vplus = wq[x]
                else:
                    for vi in range(i-1,-1,-1):
                        if grid[vi][x] == '#':
                            break
                        else:
                            vplus += 1
                    for vi in range(i+1,h):
                        if grid[vi][x] == '#':
                            break
                        else:
                            vplus += 1
                ans = max(ans, vplus+k)
                wq[x] = vplus
        j += k
print(ans)


### FIXED CODE ###

import numpy as np
words = lambda t : list(map(t, input().split()))
pqr = words(int)

pqr.sort()
print(pqr[0] + pqr[1])
i = 1
while True:
    x = int(input().strip())
    if x == 0:
        break
    else:
        print "Case {} : {}".format(i,x)
        i += 1

### FIXED CODE ###

i = 1
while True:
    x = int(input().strip())
    if x == 0:
        break
    else:
        print ("Case {}: {}".format(i,x))
        i += 1
n = int(input())
list_a = list(map(int, input().split()))

list_a.sort()

counts = []

for i in range(100000):
    if i in list_a:
        counts.append(list_a.count(i))
    else:
        counts.append(0)

q = int(input())
ans = sum(list_a)

for i in range(q):
    b, c = map(int, input().split())

    ans += counts[b] * (c - b)

    counts[c] += counts[b]
    counts[b] = 0

    print(ans)


### FIXED CODE ###

import numpy as np

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

counts = np.zeros(100000, dtype=int)

ans = 0

for i in range(len(list_a)):
    counts[list_a[i]-1] += 1
    ans += list_a[i]

q = int(input())

for i in range(q):
    b, c = map(int, input().split())

    ans += counts[b-1] * (c - b)

    counts[c-1] += counts[b-1]
    counts[b-1] = 0

    print(ans)
N = int(input())
ans = [0] * (N)
for x in range(1, 101):
    for y in range(1, 101):
        for z in range(1, 101):
            n = x ** 2 + y ** 2 + z ** 2 + x * y + y * z + z * x - 1
            if n <= N:
                ans[n] += 1
for i in ans:
    print(i)


### FIXED CODE ###

N = int(input())
ans = [0] * N
for x in range(1, 101):
    for y in range(1, 101):
        for z in range(1, 101):
            n = x ** 2 + y ** 2 + z ** 2 + x * y + y * z + z * x - 1
            if n < N:
                ans[n] += 1
for i in ans:
    print(i)
def judge(a,b,c,d):
  if(abs(a-c)<=d or abs(a-b)<=d and abs(b-c)<=d):
    print("Yes")
   else:
    print("No")

### FIXED CODE ###

a,b,c,d=map(int,input().split())
print("Yes" if abs(a-c)<=d or abs(a-b)<=d and abs(c-b)<=d else "No")
D, G = map(int, input().split())
Ci = [list(map(int, input().split())) for _ in range(D)]


MAX_BIT = (1 << D)
# 各ビットが1のとき全部解く
def calc(patternBit):
    if patternBit >= MAX_BIT:
        return None
    p = patternBit
    score = 0
    ans1 = 0
    use_c = None
    for i, c in enumerate(Ci):
        s = (i + 1) * 100 #1問のスコア
        if p % 2 > 0:
            score += s * c[0] + c[1]
            ans1 += c[0]
        else:
            use_c = c + [s]
        p = p // 2
    if score < G:
        remain = G - score
        add_count = remain // use_c[2]
        if remain % use_c[2] > 0:
            add_count += 1
        if add_count > use_c[0]:
            return calc(patternBit + 1)
        ans1 += add_count
    ans2 = calc(patternBit + 1)
    if ans2 != None:
        return min(ans1, ans2)
    return ans1
    
print(calc(0))    

### FIXED CODE ###

D, G = map(int, input().split())
Ci = [list(map(int, input().split())) for _ in range(D)]


MAX_BIT = (1 << D)
minimum = 1000000000
# 各ビットが1のとき全部解く
for patternBit in range(MAX_BIT):
    if patternBit >= MAX_BIT:
        continue
    p = patternBit
    score = 0
    ans1 = 0
    use_c = None
    for i, c in enumerate(Ci):
        s = (i + 1) * 100 #1問のスコア
        if p % 2 > 0:
            score += s * c[0] + c[1]
            ans1 += c[0]
        else:
            use_c = c + [s]
        p = p // 2
    if score < G:
        remain = G - score
        add_count = remain // use_c[2]
        if remain % use_c[2] > 0:
            add_count += 1
        if add_count > use_c[0]:
            continue
        ans1 += add_count
    minimum = min(minimum, ans1)
    
print(minimum)
_ = int(input())
bef_time = 0
bef_x = 0
bef_y = 0
ans = True

for i in range(_):
    next = input().split()
    next_time = int(next[0])
    next_x = int(next[1])
    next_y = int(next[2])
    time = next_time - bef_time
    range = abs((next_x - bef_x)) + abs(next_y - bef_y))

    if (next_time - bef_time) < range:
        ans = False
        break

    if time % 2 == 0:
       if  range % 2 != 0:
           ans = False
           break
       else:
           if range % 2 == 0:
              ans = False
              break

    bef_time = next_time
    bef_y = next_y
    bef_x = next_x



if ans == True:
    print('YES')
else:
    print('NO')

### FIXED CODE ###

_ = int(input())
bef_time = 0
bef_x = 0
bef_y = 0
ans = True

for i in range(_):
    next = input().split()
    next_time = int(next[0])
    next_x = int(next[1])
    next_y = int(next[2])
    time = next_time - bef_time
    range = abs(next_x - bef_x) + abs(next_y - bef_y)

    if (next_time - bef_time) < range:
        ans = False
        break

    if time % 2 == 0:
       if range % 2 != 0:
          ans = False
          break
    else:
       if range % 2 == 0 or range == 0:
          ans = False
          break

    bef_time = next_time
    bef_y = next_y
    bef_x = next_x



if ans == True:
    print('Yes')
else:
    print('No')
def cross(x, y):
    return (x.conjugate() * y).imag

def area_polygon(points):
    area = 0
    n = len(points)
    for i in range(n):
        area += cross(points[i], points[(i+1)%n])
    return area / 2
    
    
import sys

p = []
for line in sys.stdin:
    if line == "":
        break
    p.append(list(map(float, line.split(','))))

print("{0:06f}".format(area_polygon(p)))

### FIXED CODE ###

def cross(x, y):
    return (x.conjugate() * y).imag

def area_polygon(points):
    area = 0
    n = len(points)
    for i in range(n):
        area += cross(points[i], points[(i+1)%n])
    return area / 2
    
    
import sys

p = []
for line in sys.stdin:
    x, y = map(float, line.split(','))
    p.append(complex(x, y))

print(area_polygon(p))
cin=input().split()
N=int(cin[0])
M=int(cin[1])


result={}
ac=0
wa=0
for i in range(M):
    cin=input().split()
    p=int(cin[0])
    S=str(cin[1])

    log=result.get(p,None)
    if S == "AC" and log != "AC":
        ac+=1
        result[p]="AC"

    if S == "WA" and log != "AC":
        wa+=1

print(f"{ac} {wa}")




### FIXED CODE ###

cin=input().split()
N=int(cin[0])
M=int(cin[1])


result={}
ac=0
was={}
for i in range(M):
    cin=input().split()
    p=int(cin[0])
    S=str(cin[1])

    log=result.get(p,None)
    if S == "AC" and log != "AC":
        ac+=1
        result[p]="AC"

    if S == "WA" and log != "AC":
        was[p]=was.get(p,0)+1

wa=0
for k,v in result.items():
    if v == "AC":
        wa+=was.get(k,0)
print(str(ac)+" "+str(wa))
r, c, n = map(int, input().split())
l = []
for i in range(n):
    x1, y1, x2, y2 = map(int, input().split())
    if (x1 == 0 or x1 == r or y1 == 0 or y1 == c) and (x2 == 0 or x2 == r or y2 == 0 or y2 == c):
        if x1 == 0:
            l.append((y1, i))
        elif y1 == c:
            l.append((c + x1, i))
        elif x1 == r:
            l.append((c * 2 + r - y1, i))
        else:
            l.append((r * 2 + c * 2 - x1, i))
        if x2 == 0:
            l.append((y2, i))
        elif y2 == c:
            l.append((c + x2, i))
        elif x2 == r:
            l.append((c * 2 + r - y2, i))
        else:
            l.append((r * 2 + c * 2 - x2, i))
l.sort()
s = [l[0][1]]
for x, i in l[1:]:
    s.append(0)
    s.append(i)
r = [0] * len(s)
i, j = 0, 0
while i < len(s):
    while i - j >= 0 and i + j < len(s) and s[i - j] == s[i + j]:
        j += 1
    r[i] = j
    k = 1
    while i - k >= 0 and k + r[i - k] < j:
        r[i + k] = r[i - k]
        k += 1
    i += k
    j -= k
for i in range(1, len(s), 2):
    p = r[i]
    if i == p - 1:
        m = (len(s) - p * 2) // 2
        if m == -1 or (m > 0 and r[-m] == m):
            print('YES')
            exit(1)
print('NO')


### FIXED CODE ###

r, c, n = map(int, input().split())
l = []
for i in range(n):
    x1, y1, x2, y2 = map(int, input().split())
    if (x1 == 0 or x1 == r or y1 == 0 or y1 == c) and (x2 == 0 or x2 == r or y2 == 0 or y2 == c):
        if x1 == 0:
            l.append((y1, i))
        elif y1 == c:
            l.append((c + x1, i))
        elif x1 == r:
            l.append((c * 2 + r - y1, i))
        else:
            l.append((r * 2 + c * 2 - x1, i))
        if x2 == 0:
            l.append((y2, i))
        elif y2 == c:
            l.append((c + x2, i))
        elif x2 == r:
            l.append((c * 2 + r - y2, i))
        else:
            l.append((r * 2 + c * 2 - x2, i))
l.sort()
s = []
d = [False] * n
for x, i in l:
    if d[i]:
        if s[-1] != i:
            print('NO')
            exit(0)
        s.pop()
    else:
        s.append(i)
        d[i] = True
print('YES')
S, T = map(str, input().split())
A, B = map(int, input().split())
U = input()

if U = S:
  	A -= 1
else:
  	B -= 1

print(A),
print(B)

### FIXED CODE ###

S, T = map(str, input().split())
A, B = map(int, input().split())
U = input()

if U == S:
  	A -= 1
else:
  	B -= 1

print(A),
print(B)
from math import gcd

a, b = map(int, input().split())
print(int((a * b) / gcd(a, b)))

### FIXED CODE ###

from fractions import gcd
a, b = map(int, input().split())
print(int((a * b) / gcd(a, b)))
counter = 0
ans = 0

for i in range(n+1):
    if sum(A[:i])>k:
        break
    for j in range(m+1):
        if sum(A[:i])+sum(B[:j])<=k:
            ans = max(ans, i+j)
        else:
            break
            
print(ans)

### FIXED CODE ###

import bisect

n,m,k = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

A_cum = [0]
B_cum = [0]

for i in range(n):
  A_cum.append(A_cum[i]+A[i])
  
for i in range(m):
  B_cum.append(B_cum[i]+B[i])

ans = 0  
for i in range(n+1):
  rest = k-A_cum[i]
  if rest<0:
    continue
  
  ans = max(ans, bisect.bisect_right(B_cum, rest)-1+i)
  
print(ans)
s = list(input())
t = list(input())
ans = 0
for i in range (3):
    if S[i] == T[i]:
        ans += 1
print(ans)


### FIXED CODE ###

s = list(input())
t = list(input())
ans = 0
for i in range (3):
    if s[i] == t[i]:
        ans += 1
print(ans)
import fractions
N, M = map(int, input().split())
S = input()
T = input()
if S[0] != T[0]:
    print(-1)
elif N == M and S != T:
    print(-1)
else:
    lcm = (N*M) // fractions.gcd(N, M)
    tmp = lcm // N
    tmp2 = lcm // M
    tmp_s = [""] * lcm
    for i in range(N):
        tmp_s[tmp * i] = S[i]
    for i in range(M):
        if tmp_s[tmp2 * i] != "" and tmp_s[tmp2 * i] != T[i]:
            print(-1)
            exit(0)
    print(lcm)


### FIXED CODE ###

import collections
import fractions
N, M = map(int, input().split())
S = input()
T = input()
lcm = (N*M) // fractions.gcd(N, M)
if S[0] != T[0]:
    print(-1)
elif N == M and S != T:
    print(-1)
else:
    tmp = lcm // N
    tmp2 = lcm // M
    tmp_s = collections.defaultdict(str)
    for i in range(N):
        tmp_s[tmp*i] = S[i]

    for i in range(M):
        if tmp2*i in tmp_s:
            if T[i] != tmp_s[tmp2*i]:
                print(-1)
                exit(0)
    print(lcm)
n = int(input())
if n = 2 or n = 4 or n = 5 or n = 7 or n = 9 :
    print("hon")
elif n = 0 or n = 1 or n = 6 or n = 8 :
    print("pon")
else:
    print("bon")

### FIXED CODE ###

n = input()
if n[-1] == "2" or n[-1] == "4" or n[-1] == "5" or n[-1] == "7" or n[-1] == "9" :
    print("hon")
elif n[-1] == "0" or n[-1] == "1" or n[-1] == "6" or n[-1] == "8" :
    print("pon")
else:
    print("bon")
from itertools import combinations
import numpy as np


n,m = list(map(int, input().split()))
a = []
b = []
for _ in range(m):
    aa, bb = list(map(int, input().split()))
    a.append(aa)
    b.append(bb)

# %%time
def saiki(now, reachable):
#     print(now)
    cand = copy.deepcopy(dic[now])
    cue = []
    cand = dic[now]
    while len(cand) > 0:
        c = cand[0]
        cand.pop(0)
        
#         print(cand)
        if c in reachable:
            pass
        else:
            reachable += [c]
            cand += saiki(c, reachable)
            
    return reachable

def saiki_check(now, reachable, reachable_check_target):
#     print(now)
    cue = []
    cand = copy.deepcopy(dic[now])
    ans = False
    while len(cand) > 0:
        c = cand[0]
        cand.pop(0)
        
#         print(cand)
        if c in reachable:
            pass
        else:
            reachable += [c]
            if c == reachable_check_target:
                ans = True
                break
            out = saiki_check(c, reachable, reachable_check_target)
            cand = cand + out[0]
            ans = out[1]
            if ans:
                break
    return reachable, ans
import copy
anss = [0]
for k_start in range(1, m + 1):
    dic = {}
    for k in range(1, n+1):
        dic[k] = []
    for k in range(k_start, m):
        dic[a[k]] += [b[k]]
        dic[b[k]] += [a[k]]
    cutted = [a[k_start-1], b[k_start-1]]
    
#     print(dic)
    if saiki_check(cutted[0], [cutted[0]], cutted[1])[1]:
#     print(dic)
#     reachable = []
        s = anss[-1]
#         print('a')
    else:
        nodes = list(range(1,n+1))
        rs = []
        while len(nodes) > 0:
            reachable = saiki(nodes[0], [nodes[0]])
#             print(reachable)
            for r in reachable:
                nodes.remove(r)
            rs.append(len(reachable))
    #     print(rs)
        s = 0
        for c in combinations(rs, 2):
            s += c[0] * c[1]
        anss.append(s)
#     aaaaa
    print(s)
#     aaaaa

### FIXED CODE ###

import sys
sys.setrecursionlimit(100000)
input = sys.stdin.readline
 
N, M = map(int, input().split())
X = []
for _ in range(M):
    a, b = map(int, input().split())
    X.append((a-1, b-1))
X = X[::-1]
    
P = [-1] * N
CT = [1] * N
def pr(i):
    if P[i] < 0:
        return i
    t = pr(P[i])
    P[i] = t
    return t
 
ANS = [0] * M
ans = N * (N-1) // 2
ANS[-1] = ans
for m in range(M-1):
    a, b = X[m]
    pa = pr(a)
    pb = pr(b)
    
    if pa != pb:
        ans -= CT[pa] * CT[pb]
        P[pa] = pb
        CT[pb] += CT[pa]
 
    ANS[-m-2] = ans
 
for a in ANS:
    print(a)
import sys
n,m = map(int,input().split())

if abs(n-m) >= 2:
    print(0)
    sys.exit()

if abs(n-m) == 1:
    x = max(a,b)
    for i in range(1,min(n,m)+1):
        x = x*i**2 % (10**9 + 7)

else:
    x = 2
    for i in range(1,n+1):
        x = x*i**2 % (10**9 + 7)
print(x)

### FIXED CODE ###

import sys
n,m = map(int,input().split())

if abs(n-m) >= 2:
    print(0)
    sys.exit()

if abs(n-m) == 1:
    x = max(n,m)
    for i in range(1,min(n,m)+1):
        x = x*i**2 % (10**9 + 7)

else:
    x = 2
    for i in range(1,n+1):
        x = x*i**2 % (10**9 + 7)
print(x)